@rpamis/comet 0.4.0-beta.17 → 0.4.0-beta.18

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 (371) hide show
  1. package/README.md +49 -24
  2. package/assets/manifest.json +2 -1
  3. package/assets/skills/comet/scripts/comet-archive.mjs +128 -128
  4. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +78 -78
  5. package/assets/skills/comet/scripts/comet-guard.mjs +144 -144
  6. package/assets/skills/comet/scripts/comet-handoff.mjs +109 -109
  7. package/assets/skills/comet/scripts/comet-hook-guard.mjs +130 -130
  8. package/assets/skills/comet/scripts/comet-hook-router.mjs +115 -115
  9. package/assets/skills/comet/scripts/comet-resume-probe.mjs +85 -85
  10. package/assets/skills/comet/scripts/comet-runtime.mjs +188 -187
  11. package/assets/skills/comet/scripts/comet-state.mjs +117 -117
  12. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +71 -71
  13. package/assets/skills/comet-build/SKILL.md +15 -56
  14. package/assets/skills/comet-classic/SKILL.md +14 -8
  15. package/assets/skills/comet-classic/reference/comet-yaml-fields.md +1 -1
  16. package/assets/skills/comet-classic/reference/scripts.md +3 -1
  17. package/assets/skills/comet-classic/reference/workspace.md +23 -0
  18. package/assets/skills/comet-native/SKILL.md +13 -10
  19. package/assets/skills/comet-native/reference/artifacts.md +3 -2
  20. package/assets/skills/comet-native/reference/commands.md +1 -1
  21. package/assets/skills/comet-native/reference/recovery.md +1 -1
  22. package/assets/skills/comet-native/reference/workspace.md +4 -4
  23. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +97 -97
  24. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +146 -146
  25. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +100 -100
  26. package/assets/skills/comet-native/scripts/comet-native-init.mjs +85 -85
  27. package/assets/skills/comet-native/scripts/comet-native-new.mjs +115 -115
  28. package/assets/skills/comet-native/scripts/comet-native-next.mjs +118 -118
  29. package/assets/skills/comet-native/scripts/comet-native-root.mjs +107 -107
  30. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +154 -154
  31. package/assets/skills/comet-native/scripts/comet-native-select.mjs +133 -133
  32. package/assets/skills/comet-native/scripts/comet-native-show.mjs +109 -109
  33. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +87 -87
  34. package/assets/skills/comet-native/scripts/comet-native-status.mjs +109 -109
  35. package/assets/skills/comet-open/SKILL.md +24 -5
  36. package/assets/skills-zh/comet-build/SKILL.md +15 -56
  37. package/assets/skills-zh/comet-classic/SKILL.md +14 -8
  38. package/assets/skills-zh/comet-classic/reference/comet-yaml-fields.md +1 -1
  39. package/assets/skills-zh/comet-classic/reference/scripts.md +3 -1
  40. package/assets/skills-zh/comet-classic/reference/workspace.md +23 -0
  41. package/assets/skills-zh/comet-native/SKILL.md +13 -10
  42. package/assets/skills-zh/comet-native/reference/artifacts.md +3 -2
  43. package/assets/skills-zh/comet-native/reference/commands.md +1 -1
  44. package/assets/skills-zh/comet-native/reference/recovery.md +1 -1
  45. package/assets/skills-zh/comet-native/reference/workspace.md +4 -4
  46. package/assets/skills-zh/comet-open/SKILL.md +24 -5
  47. package/dist/app/cli/index.js +20 -1
  48. package/dist/app/cli/index.js.map +1 -1
  49. package/dist/app/commands/classic.d.ts.map +1 -1
  50. package/dist/app/commands/classic.js +2 -0
  51. package/dist/app/commands/classic.js.map +1 -1
  52. package/dist/app/commands/eval.d.ts +9 -2
  53. package/dist/app/commands/eval.d.ts.map +1 -1
  54. package/dist/app/commands/eval.js +293 -48
  55. package/dist/app/commands/eval.js.map +1 -1
  56. package/dist/app/commands/init.d.ts.map +1 -1
  57. package/dist/app/commands/init.js +2 -1
  58. package/dist/app/commands/init.js.map +1 -1
  59. package/dist/app/commands/update.d.ts.map +1 -1
  60. package/dist/app/commands/update.js +4 -1
  61. package/dist/app/commands/update.js.map +1 -1
  62. package/dist/domains/comet-classic/classic-cli.d.ts +1 -1
  63. package/dist/domains/comet-classic/classic-cli.d.ts.map +1 -1
  64. package/dist/domains/comet-classic/classic-cli.js +3 -0
  65. package/dist/domains/comet-classic/classic-cli.js.map +1 -1
  66. package/dist/domains/comet-classic/classic-current-change.d.ts.map +1 -1
  67. package/dist/domains/comet-classic/classic-current-change.js +29 -3
  68. package/dist/domains/comet-classic/classic-current-change.js.map +1 -1
  69. package/dist/domains/comet-classic/classic-guard.js +2 -2
  70. package/dist/domains/comet-classic/classic-guard.js.map +1 -1
  71. package/dist/domains/comet-classic/classic-hook-guard.d.ts.map +1 -1
  72. package/dist/domains/comet-classic/classic-hook-guard.js +14 -1
  73. package/dist/domains/comet-classic/classic-hook-guard.js.map +1 -1
  74. package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
  75. package/dist/domains/comet-classic/classic-state-command.js +31 -8
  76. package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
  77. package/dist/domains/comet-classic/classic-workspace-command.d.ts +3 -0
  78. package/dist/domains/comet-classic/classic-workspace-command.d.ts.map +1 -0
  79. package/dist/domains/comet-classic/classic-workspace-command.js +45 -0
  80. package/dist/domains/comet-classic/classic-workspace-command.js.map +1 -0
  81. package/dist/domains/comet-classic/classic-workspace.d.ts +38 -0
  82. package/dist/domains/comet-classic/classic-workspace.d.ts.map +1 -0
  83. package/dist/domains/comet-classic/classic-workspace.js +315 -0
  84. package/dist/domains/comet-classic/classic-workspace.js.map +1 -0
  85. package/dist/domains/comet-entry/hook-adapter.d.ts.map +1 -1
  86. package/dist/domains/comet-entry/hook-adapter.js +1 -0
  87. package/dist/domains/comet-entry/hook-adapter.js.map +1 -1
  88. package/dist/domains/comet-entry/hook-router-entry.d.ts +2 -0
  89. package/dist/domains/comet-entry/hook-router-entry.d.ts.map +1 -1
  90. package/dist/domains/comet-entry/hook-router-entry.js +21 -1
  91. package/dist/domains/comet-entry/hook-router-entry.js.map +1 -1
  92. package/dist/domains/comet-entry/init-workflow.d.ts.map +1 -1
  93. package/dist/domains/comet-entry/init-workflow.js +13 -5
  94. package/dist/domains/comet-entry/init-workflow.js.map +1 -1
  95. package/dist/domains/comet-native/index.d.ts +1 -0
  96. package/dist/domains/comet-native/index.d.ts.map +1 -1
  97. package/dist/domains/comet-native/index.js +1 -0
  98. package/dist/domains/comet-native/index.js.map +1 -1
  99. package/dist/domains/comet-native/native-children.d.ts +49 -0
  100. package/dist/domains/comet-native/native-children.d.ts.map +1 -0
  101. package/dist/domains/comet-native/native-children.js +388 -0
  102. package/dist/domains/comet-native/native-children.js.map +1 -0
  103. package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
  104. package/dist/domains/comet-native/native-cli-help.js +3 -3
  105. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  106. package/dist/domains/comet-native/native-doctor-command.d.ts.map +1 -1
  107. package/dist/domains/comet-native/native-doctor-command.js +10 -5
  108. package/dist/domains/comet-native/native-doctor-command.js.map +1 -1
  109. package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
  110. package/dist/domains/comet-native/native-hook-guard.js +41 -2
  111. package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
  112. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  113. package/dist/domains/comet-native/native-next-command.js +85 -5
  114. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  115. package/dist/domains/comet-native/native-portable-continuation.d.ts +3 -2
  116. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  117. package/dist/domains/comet-native/native-portable-continuation.js +63 -1
  118. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  119. package/dist/domains/comet-native/native-portable-runtime.d.ts +5 -0
  120. package/dist/domains/comet-native/native-portable-runtime.d.ts.map +1 -1
  121. package/dist/domains/comet-native/native-portable-runtime.js +110 -4
  122. package/dist/domains/comet-native/native-portable-runtime.js.map +1 -1
  123. package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
  124. package/dist/domains/comet-native/native-portable-state.js +13 -0
  125. package/dist/domains/comet-native/native-portable-state.js.map +1 -1
  126. package/dist/domains/comet-native/native-portable-status.d.ts +3 -0
  127. package/dist/domains/comet-native/native-portable-status.d.ts.map +1 -1
  128. package/dist/domains/comet-native/native-portable-status.js +9 -1
  129. package/dist/domains/comet-native/native-portable-status.js.map +1 -1
  130. package/dist/domains/comet-native/native-portable-types.d.ts +1 -0
  131. package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
  132. package/dist/domains/comet-native/native-portable-types.js.map +1 -1
  133. package/dist/domains/comet-native/native-show-command.d.ts.map +1 -1
  134. package/dist/domains/comet-native/native-show-command.js +2 -1
  135. package/dist/domains/comet-native/native-show-command.js.map +1 -1
  136. package/dist/domains/comet-native/native-workspace-preparation.d.ts.map +1 -1
  137. package/dist/domains/comet-native/native-workspace-preparation.js +192 -133
  138. package/dist/domains/comet-native/native-workspace-preparation.js.map +1 -1
  139. package/dist/domains/dashboard/collector.d.ts +1 -1
  140. package/dist/domains/dashboard/collector.d.ts.map +1 -1
  141. package/dist/domains/dashboard/collector.js +102 -87
  142. package/dist/domains/dashboard/collector.js.map +1 -1
  143. package/dist/domains/dashboard/native-adapter.d.ts +20 -0
  144. package/dist/domains/dashboard/native-adapter.d.ts.map +1 -1
  145. package/dist/domains/dashboard/native-adapter.js +11 -0
  146. package/dist/domains/dashboard/native-adapter.js.map +1 -1
  147. package/dist/domains/dashboard/native-collector.d.ts +1 -0
  148. package/dist/domains/dashboard/native-collector.d.ts.map +1 -1
  149. package/dist/domains/dashboard/native-collector.js +304 -55
  150. package/dist/domains/dashboard/native-collector.js.map +1 -1
  151. package/dist/domains/dashboard/native-legacy-adapter.d.ts +12 -5
  152. package/dist/domains/dashboard/native-legacy-adapter.d.ts.map +1 -1
  153. package/dist/domains/dashboard/native-legacy-adapter.js +12 -0
  154. package/dist/domains/dashboard/native-legacy-adapter.js.map +1 -1
  155. package/dist/domains/dashboard/server.d.ts.map +1 -1
  156. package/dist/domains/dashboard/server.js +5 -3
  157. package/dist/domains/dashboard/server.js.map +1 -1
  158. package/dist/domains/dashboard/types.d.ts +5 -0
  159. package/dist/domains/dashboard/types.d.ts.map +1 -1
  160. package/dist/domains/dashboard/web/assets/abnfDiagram-N423BO3Z-B5cFR6hS.js +1 -0
  161. package/dist/domains/dashboard/web/assets/arc-CVQDtMsu.js +1 -0
  162. package/dist/domains/dashboard/web/assets/architectureDiagram-T3A2C74G-C0v0kULK.js +36 -0
  163. package/dist/domains/dashboard/web/assets/blockDiagram-VBNYF7ZC-DpHLuxu4.js +132 -0
  164. package/dist/domains/dashboard/web/assets/{c4Diagram-AAUBKEIU-BL17BIb8.js → c4Diagram-5PPSVZJV-BHnFxUs1.js} +1 -1
  165. package/dist/domains/dashboard/web/assets/channel-eM0x3m1G.js +1 -0
  166. package/dist/domains/dashboard/web/assets/{chunk-ND2GUHAM-XWLMOyd4.js → chunk-2GRJ4B5K-CGC9gh5n.js} +1 -1
  167. package/dist/domains/dashboard/web/assets/{chunk-QZHKN3VN-4drjXzHQ.js → chunk-2Q5K7J3B-l4puLU_O.js} +1 -1
  168. package/dist/domains/dashboard/web/assets/chunk-5RXB4S5H-ls9jQHZc.js +231 -0
  169. package/dist/domains/dashboard/web/assets/{chunk-FMBD7UC4-CQXqBSqQ.js → chunk-5VM5RSS4-BVavmTEq.js} +1 -1
  170. package/dist/domains/dashboard/web/assets/chunk-6Q2QTUOP-Dungt2g9.js +88 -0
  171. package/dist/domains/dashboard/web/assets/{chunk-727SXJPM-pMreYMW7.js → chunk-GF5L2VYU-BidXO_ZP.js} +5 -5
  172. package/dist/domains/dashboard/web/assets/{chunk-4BX2VUAB-vQyyh3eG.js → chunk-JWPE2WC7-57L5Up5X.js} +1 -1
  173. package/dist/domains/dashboard/web/assets/{chunk-2J33WTMH-B_DDS2IK.js → chunk-KBJHAD2P-C5u5vbwr.js} +1 -1
  174. package/dist/domains/dashboard/web/assets/chunk-RYQCIY6F-CvLz21I2.js +1 -0
  175. package/dist/domains/dashboard/web/assets/{chunk-55IACEB6-Cug8J1Qa.js → chunk-XXDRQBXY-D5nJpckG.js} +1 -1
  176. package/dist/domains/dashboard/web/assets/classDiagram-JCYQIIEL-CEFhao2K.js +1 -0
  177. package/dist/domains/dashboard/web/assets/classDiagram-v2-OCEON4UE-CEFhao2K.js +1 -0
  178. package/dist/domains/dashboard/web/assets/{cose-bilkent-S5V4N54A-IQKP-hgj.js → cose-bilkent-JH36ORCC-Dp0JAGyE.js} +1 -1
  179. package/dist/domains/dashboard/web/assets/{cynefin-VYW2F7L2-CvvRO4J2.js → cynefin-VYW2F7L2-EjC54l1g.js} +2 -2
  180. package/dist/domains/dashboard/web/assets/cynefinDiagram-MW4NZA55-CpYrW3w3.js +62 -0
  181. package/dist/domains/dashboard/web/assets/dagre-VZM6K2ZE-h5K39rCk.js +4 -0
  182. package/dist/domains/dashboard/web/assets/{demo-CeIDHUFJ.js → demo-BfLsKrIL.js} +26 -5
  183. package/dist/domains/dashboard/web/assets/diagram-7IWD3JNH-CKQj9O4H.js +30 -0
  184. package/dist/domains/dashboard/web/assets/{diagram-KO2AKTUF-CN_LYqvT.js → diagram-B4RE2ZJO-DXRIYcnW.js} +3 -3
  185. package/dist/domains/dashboard/web/assets/diagram-LBJQPF4R-wWutQYmv.js +24 -0
  186. package/dist/domains/dashboard/web/assets/diagram-Q27KOJAE-EgXLJQYi.js +24 -0
  187. package/dist/domains/dashboard/web/assets/diagram-UB23O5K3-CsQRXDQZ.js +41 -0
  188. package/dist/domains/dashboard/web/assets/ebnfDiagram-BXEA7PRR-gm328Eho.js +1 -0
  189. package/dist/domains/dashboard/web/assets/erDiagram-JOGREHBK-BbbMVUx_.js +85 -0
  190. package/dist/domains/dashboard/web/assets/flowDiagram-UKHOOZJN-1Y7scCns.js +156 -0
  191. package/dist/domains/dashboard/web/assets/ganttDiagram-PKOTCBZU-BAoBqczv.js +292 -0
  192. package/dist/domains/dashboard/web/assets/{gitGraphDiagram-PVQCEYII-CaWEk3PM.js → gitGraphDiagram-DS77QQ5N-CMUAyEzl.js} +3 -3
  193. package/dist/domains/dashboard/web/assets/{graph--OzhPTMs.js → graph-DOmOIIwC.js} +1 -1
  194. package/dist/domains/dashboard/web/assets/{index-BNyOfAhu.js → index-CCApJ0Yr.js} +1 -1
  195. package/dist/domains/dashboard/web/assets/index-DWdm_XBi.js +257 -0
  196. package/dist/domains/dashboard/web/assets/{index-BFwKBVTJ.css → index-DhhbseFJ.css} +1 -1
  197. package/dist/domains/dashboard/web/assets/{infoDiagram-5YYISTIA-BK07mNG0.js → infoDiagram-6WML65LV-BaCdtYYC.js} +1 -1
  198. package/dist/domains/dashboard/web/assets/{ishikawaDiagram-YF4QCWOH-mWnmaWfZ.js → ishikawaDiagram-WSZJBQD7-DQQlNnjU.js} +4 -4
  199. package/dist/domains/dashboard/web/assets/{journeyDiagram-JHISSGLW-BPy-P7xx.js → journeyDiagram-NVQOT4AX-DW9wUMqn.js} +1 -1
  200. package/dist/domains/dashboard/web/assets/{kanban-definition-UN3LZRKU-3Jq9c_lo.js → kanban-definition-27J2QSJJ-C_ITaZ0q.js} +7 -7
  201. package/dist/domains/dashboard/web/assets/layout-D-LzfAck.js +1 -0
  202. package/dist/domains/dashboard/web/assets/{linear-kQyEW-4G.js → linear-DXOo6ZRT.js} +1 -1
  203. package/dist/domains/dashboard/web/assets/map-DxJ2ADlA.js +1 -0
  204. package/dist/domains/dashboard/web/assets/mermaid.core-ol-0NI97.js +306 -0
  205. package/dist/domains/dashboard/web/assets/{mindmap-definition-RKZ34NQL-CyyurUpv.js → mindmap-definition-FAOFIHXS-CHF_HOLV.js} +1 -1
  206. package/dist/domains/dashboard/web/assets/pegDiagram-VL7TDLO6-wQEvkNF8.js +1 -0
  207. package/dist/domains/dashboard/web/assets/pieDiagram-7S7Q4E2Y-C3H3kiIP.js +39 -0
  208. package/dist/domains/dashboard/web/assets/purify.es-Cz4mVeUR.js +3 -0
  209. package/dist/domains/dashboard/web/assets/{quadrantDiagram-W4KKPZXB-CpayUMjH.js → quadrantDiagram-CIZ2JOQS-S0FdVzJb.js} +4 -4
  210. package/dist/domains/dashboard/web/assets/railroadDiagram-AXF67PYL-DCDXDaVg.js +1 -0
  211. package/dist/domains/dashboard/web/assets/{requirementDiagram-4Y6WPE33-Bi8YpfnA.js → requirementDiagram-LRYGKXZP-BW8J4gO_.js} +1 -1
  212. package/dist/domains/dashboard/web/assets/sankeyDiagram-W5VNT64P-DQQBmLoy.js +40 -0
  213. package/dist/domains/dashboard/web/assets/sequenceDiagram-SI44F4Z6-2tDcli0Y.js +162 -0
  214. package/dist/domains/dashboard/web/assets/sizeCapture-X5ZJPWSS-4sEZLBKb.js +1 -0
  215. package/dist/domains/dashboard/web/assets/stateDiagram-OKZ733FA-OgPb8pyR.js +1 -0
  216. package/dist/domains/dashboard/web/assets/stateDiagram-v2-UEYNNEHI-CiDNPr4P.js +1 -0
  217. package/dist/domains/dashboard/web/assets/swimlanes-SLNWSIFB-DR7lwtxd.js +2 -0
  218. package/dist/domains/dashboard/web/assets/swimlanesDiagram-ULZ7WXOC-DggHFP9q.js +8 -0
  219. package/dist/domains/dashboard/web/assets/{timeline-definition-PNZ67QCA-aHrrtV-b.js → timeline-definition-Z64GVDOM-DNIJVlQV.js} +4 -4
  220. package/dist/domains/dashboard/web/assets/vennDiagram-T6HMQDX7-CClhw4QZ.js +34 -0
  221. package/dist/domains/dashboard/web/assets/{wardleyDiagram-YWT4CUSO-RVQbcySh.js → wardleyDiagram-T6FBY63Y-DzR3aFPS.js} +3 -3
  222. package/dist/domains/dashboard/web/assets/xychartDiagram-ELKLHX3M-DZhq0ZRj.js +7 -0
  223. package/dist/domains/dashboard/web/index.html +2 -2
  224. package/dist/domains/dashboard/workspace.d.ts +24 -0
  225. package/dist/domains/dashboard/workspace.d.ts.map +1 -0
  226. package/dist/domains/dashboard/workspace.js +87 -0
  227. package/dist/domains/dashboard/workspace.js.map +1 -0
  228. package/dist/domains/eval/index.d.ts +3 -0
  229. package/dist/domains/eval/index.d.ts.map +1 -1
  230. package/dist/domains/eval/index.js +3 -0
  231. package/dist/domains/eval/index.js.map +1 -1
  232. package/dist/domains/eval/standalone-context.d.ts +19 -0
  233. package/dist/domains/eval/standalone-context.d.ts.map +1 -0
  234. package/dist/domains/eval/standalone-context.js +107 -0
  235. package/dist/domains/eval/standalone-context.js.map +1 -0
  236. package/dist/domains/eval/standalone-static-collect.d.ts +22 -0
  237. package/dist/domains/eval/standalone-static-collect.d.ts.map +1 -0
  238. package/dist/domains/eval/standalone-static-collect.js +779 -0
  239. package/dist/domains/eval/standalone-static-collect.js.map +1 -0
  240. package/dist/domains/eval/user-environment.d.ts +6 -0
  241. package/dist/domains/eval/user-environment.d.ts.map +1 -0
  242. package/dist/domains/eval/user-environment.js +73 -0
  243. package/dist/domains/eval/user-environment.js.map +1 -0
  244. package/dist/domains/integrations/openspec.d.ts +1 -1
  245. package/dist/domains/integrations/openspec.d.ts.map +1 -1
  246. package/dist/domains/integrations/openspec.js +110 -26
  247. package/dist/domains/integrations/openspec.js.map +1 -1
  248. package/dist/domains/integrations/superpowers.d.ts +5 -1
  249. package/dist/domains/integrations/superpowers.d.ts.map +1 -1
  250. package/dist/domains/integrations/superpowers.js +21 -2
  251. package/dist/domains/integrations/superpowers.js.map +1 -1
  252. package/dist/domains/skill/platform-install.d.ts +1 -1
  253. package/dist/domains/skill/platform-install.js +1 -1
  254. package/dist/domains/skill/project-instructions.d.ts.map +1 -1
  255. package/dist/domains/skill/project-instructions.js +5 -3
  256. package/dist/domains/skill/project-instructions.js.map +1 -1
  257. package/dist/domains/workflow-contract/hook-write-policy.d.ts +9 -0
  258. package/dist/domains/workflow-contract/hook-write-policy.d.ts.map +1 -0
  259. package/dist/domains/workflow-contract/hook-write-policy.js +52 -0
  260. package/dist/domains/workflow-contract/hook-write-policy.js.map +1 -0
  261. package/dist/domains/workflow-contract/index.d.ts +2 -0
  262. package/dist/domains/workflow-contract/index.d.ts.map +1 -1
  263. package/dist/domains/workflow-contract/index.js +1 -0
  264. package/dist/domains/workflow-contract/index.js.map +1 -1
  265. package/dist/domains/workflow-contract/project-config.d.ts +2 -2
  266. package/dist/domains/workflow-contract/project-config.d.ts.map +1 -1
  267. package/dist/domains/workflow-contract/project-config.js +42 -2
  268. package/dist/domains/workflow-contract/project-config.js.map +1 -1
  269. package/dist/domains/workflow-contract/protected-project-path.d.ts +13 -0
  270. package/dist/domains/workflow-contract/protected-project-path.d.ts.map +1 -1
  271. package/dist/domains/workflow-contract/protected-project-path.js +83 -0
  272. package/dist/domains/workflow-contract/protected-project-path.js.map +1 -1
  273. package/dist/domains/workflow-contract/types.d.ts +4 -0
  274. package/dist/domains/workflow-contract/types.d.ts.map +1 -1
  275. package/dist/platform/install/platforms.d.ts.map +1 -1
  276. package/dist/platform/install/platforms.js +13 -2
  277. package/dist/platform/install/platforms.js.map +1 -1
  278. package/dist/platform/paths/git-worktree.d.ts +7 -1
  279. package/dist/platform/paths/git-worktree.d.ts.map +1 -1
  280. package/dist/platform/paths/git-worktree.js +28 -7
  281. package/dist/platform/paths/git-worktree.js.map +1 -1
  282. package/eval/.env.example +115 -0
  283. package/eval/README.md +237 -14
  284. package/eval/langfuse/.env.example +9 -0
  285. package/eval/langfuse/tests/conftest.py +146 -0
  286. package/eval/langfuse/tests/tasks/test_tasks.py +109 -0
  287. package/eval/langfuse/tests/test_adapter.py +272 -0
  288. package/eval/langsmith/.env.example +16 -0
  289. package/eval/langsmith/tests/conftest.py +10 -1
  290. package/eval/local/tasks/comet-classic-layout-lifecycle/environment/current-comet-package.json +4 -2
  291. package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/environment/current-comet-package.json +2 -2
  292. package/eval/local/tests/conftest.py +701 -80
  293. package/eval/local/tests/scaffold/fixtures/custom-agent/adapter.yaml +19 -0
  294. package/eval/local/tests/scaffold/test_agents.py +76 -0
  295. package/eval/local/tests/scaffold/test_aligned_comparison.py +70 -0
  296. package/eval/local/tests/scaffold/test_auto_tasks.py +350 -0
  297. package/eval/local/tests/scaffold/test_conftest_helpers.py +267 -18
  298. package/eval/local/tests/scaffold/test_custom_agents.py +174 -0
  299. package/eval/local/tests/scaffold/test_eval_context.py +217 -0
  300. package/eval/local/tests/scaffold/test_execution.py +364 -0
  301. package/eval/local/tests/scaffold/test_inline_tasks.py +56 -0
  302. package/eval/local/tests/scaffold/test_langfuse_trajectory.py +263 -0
  303. package/eval/local/tests/scaffold/test_langsmith_conftest.py +63 -0
  304. package/eval/local/tests/scaffold/test_logging.py +162 -0
  305. package/eval/local/tests/scaffold/test_manifest_tasks.py +76 -0
  306. package/eval/local/tests/scaffold/test_manifests.py +396 -0
  307. package/eval/local/tests/scaffold/test_native_aligned_eval.py +17 -0
  308. package/eval/local/tests/scaffold/test_profiles.py +64 -6
  309. package/eval/local/tests/scaffold/test_task_resolution.py +212 -0
  310. package/eval/local/tests/scaffold/test_utils.py +480 -4
  311. package/eval/local/tests/tasks/test_tasks.py +216 -14
  312. package/eval/pyproject.toml +5 -0
  313. package/eval/scaffold/__init__.py +6 -0
  314. package/eval/scaffold/docker/agent-overlay.Dockerfile +41 -0
  315. package/eval/scaffold/python/__init__.py +128 -20
  316. package/eval/scaffold/python/agents.py +239 -0
  317. package/eval/scaffold/python/aligned_comparison.py +156 -27
  318. package/eval/scaffold/python/auto_tasks.py +700 -0
  319. package/eval/scaffold/python/custom_agents.py +172 -0
  320. package/eval/scaffold/python/eval_context.py +236 -0
  321. package/eval/scaffold/python/eval_schema.py +135 -0
  322. package/eval/scaffold/python/execution.py +544 -0
  323. package/eval/scaffold/python/generated_task_cache.py +230 -0
  324. package/eval/scaffold/python/generic_llm_judge.py +41 -14
  325. package/eval/scaffold/python/inline_tasks.py +118 -0
  326. package/eval/scaffold/python/judge_config.py +158 -37
  327. package/eval/scaffold/python/langfuse_adapter.py +1023 -0
  328. package/eval/scaffold/python/llm_judge.py +68 -11
  329. package/eval/scaffold/python/logging.py +157 -17
  330. package/eval/scaffold/python/manifest_tasks.py +69 -0
  331. package/eval/scaffold/python/manifests.py +443 -22
  332. package/eval/scaffold/python/paths.py +11 -1
  333. package/eval/scaffold/python/task_resolution.py +176 -0
  334. package/eval/scaffold/python/tasks.py +17 -4
  335. package/eval/scaffold/python/utils.py +167 -11
  336. package/eval/scaffold/python/validation/core.py +48 -2
  337. package/eval/scaffold/python/validation/generic_rubric.py +9 -0
  338. package/eval/scaffold/python/validation/native_workflow.py +6 -1
  339. package/eval/scaffold/python/validation/rubric.py +16 -1
  340. package/eval/scaffold/shell/agent-runtime-config.sh +88 -0
  341. package/eval/scaffold/shell/docker.sh +534 -33
  342. package/eval/scaffold/shell/run-agent-runtime.sh +49 -0
  343. package/eval/scaffold/shell/run-claude-loop.sh +153 -14
  344. package/eval/schemas/comet.eval/v1alpha1.schema.json +244 -0
  345. package/package.json +8 -3
  346. package/dist/domains/dashboard/web/assets/arc-CkuYweSh.js +0 -1
  347. package/dist/domains/dashboard/web/assets/architectureDiagram-3BPJPVTR--tTGrKam.js +0 -36
  348. package/dist/domains/dashboard/web/assets/blockDiagram-GPEHLZMM-DLKYOixs.js +0 -132
  349. package/dist/domains/dashboard/web/assets/channel-Cg__FSMr.js +0 -1
  350. package/dist/domains/dashboard/web/assets/chunk-AQP2D5EJ-BUkV_rb7.js +0 -231
  351. package/dist/domains/dashboard/web/assets/classDiagram-4FO5ZUOK-CsC-pvu9.js +0 -1
  352. package/dist/domains/dashboard/web/assets/classDiagram-v2-Q7XG4LA2-CsC-pvu9.js +0 -1
  353. package/dist/domains/dashboard/web/assets/dagre-BM42HDAG-DeOQo7bP.js +0 -4
  354. package/dist/domains/dashboard/web/assets/diagram-2AECGRRQ-IQd_jQwB.js +0 -43
  355. package/dist/domains/dashboard/web/assets/diagram-5GNKFQAL-Dllkdt0m.js +0 -10
  356. package/dist/domains/dashboard/web/assets/diagram-LMA3HP47-DK36WkNN.js +0 -24
  357. package/dist/domains/dashboard/web/assets/diagram-OG6HWLK6-iqUnMYEh.js +0 -24
  358. package/dist/domains/dashboard/web/assets/erDiagram-TEJ5UH35-Bc64lzy8.js +0 -85
  359. package/dist/domains/dashboard/web/assets/flowDiagram-I6XJVG4X-UfOqef9j.js +0 -162
  360. package/dist/domains/dashboard/web/assets/ganttDiagram-6RSMTGT7-D-u6Aauc.js +0 -292
  361. package/dist/domains/dashboard/web/assets/index-COZ_03uK.js +0 -257
  362. package/dist/domains/dashboard/web/assets/layout-SsrduOYp.js +0 -1
  363. package/dist/domains/dashboard/web/assets/mermaid.core-COBBjtVH.js +0 -301
  364. package/dist/domains/dashboard/web/assets/pieDiagram-4H26LBE5-CJro_XKk.js +0 -30
  365. package/dist/domains/dashboard/web/assets/purify.es-VaSPOPhr.js +0 -3
  366. package/dist/domains/dashboard/web/assets/sankeyDiagram-5OEKKPKP-Wx60WwHe.js +0 -40
  367. package/dist/domains/dashboard/web/assets/sequenceDiagram-3UESZ5HK-BiMsRFbc.js +0 -162
  368. package/dist/domains/dashboard/web/assets/stateDiagram-AJRCARHV-BrURMY0R.js +0 -1
  369. package/dist/domains/dashboard/web/assets/stateDiagram-v2-BHNVJYJU-BpEE-yEg.js +0 -1
  370. package/dist/domains/dashboard/web/assets/vennDiagram-CIIHVFJN-DGB16bvR.js +0 -34
  371. package/dist/domains/dashboard/web/assets/xychartDiagram-2RQKCTM6-DMzzwDVX.js +0 -7
@@ -1,77 +1,77 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var Hd=Object.create;var ls=Object.defineProperty;var Dd=Object.getOwnPropertyDescriptor;var Bd=Object.getOwnPropertyNames;var Ld=Object.getPrototypeOf,Md=Object.prototype.hasOwnProperty;var Ii=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var g=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(i){throw e=0,i}};var Fd=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Bd(e))!Md.call(t,n)&&n!==i&&ls(t,n,{get:()=>e[n],enumerable:!(r=Dd(e,n))||r.enumerable});return t};var ji=(t,e,i)=>(i=t!=null?Hd(Ld(t)):{},Fd(e||!t||!t.__esModule?ls(i,"default",{value:t,enumerable:!0}):i,t));var P=g(H=>{"use strict";var Tn=Symbol.for("yaml.alias"),ps=Symbol.for("yaml.document"),Di=Symbol.for("yaml.map"),ms=Symbol.for("yaml.pair"),In=Symbol.for("yaml.scalar"),Bi=Symbol.for("yaml.seq"),Se=Symbol.for("yaml.node.type"),af=t=>!!t&&typeof t=="object"&&t[Se]===Tn,of=t=>!!t&&typeof t=="object"&&t[Se]===ps,sf=t=>!!t&&typeof t=="object"&&t[Se]===Di,cf=t=>!!t&&typeof t=="object"&&t[Se]===ms,vs=t=>!!t&&typeof t=="object"&&t[Se]===In,lf=t=>!!t&&typeof t=="object"&&t[Se]===Bi;function gs(t){if(t&&typeof t=="object")switch(t[Se]){case Di:case Bi:return!0}return!1}function uf(t){if(t&&typeof t=="object")switch(t[Se]){case Tn:case Di:case In:case Bi:return!0}return!1}var df=t=>(vs(t)||gs(t))&&!!t.anchor;H.ALIAS=Tn;H.DOC=ps;H.MAP=Di;H.NODE_TYPE=Se;H.PAIR=ms;H.SCALAR=In;H.SEQ=Bi;H.hasAnchor=df;H.isAlias=af;H.isCollection=gs;H.isDocument=of;H.isMap=sf;H.isNode=uf;H.isPair=cf;H.isScalar=vs;H.isSeq=lf});var It=g(jn=>{"use strict";var O=P(),q=Symbol("break visit"),ws=Symbol("skip children"),fe=Symbol("remove node");function Li(t,e){let i=ys(e);O.isDocument(t)?ot(null,t.contents,i,Object.freeze([t]))===fe&&(t.contents=null):ot(null,t,i,Object.freeze([]))}Li.BREAK=q;Li.SKIP=ws;Li.REMOVE=fe;function ot(t,e,i,r){let n=Ns(t,e,i,r);if(O.isNode(n)||O.isPair(n))return bs(t,r,n),ot(t,n,i,r);if(typeof n!="symbol"){if(O.isCollection(e)){r=Object.freeze(r.concat(e));for(let a=0;a<e.items.length;++a){let o=ot(a,e.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===q)return q;o===fe&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){r=Object.freeze(r.concat(e));let a=ot("key",e.key,i,r);if(a===q)return q;a===fe&&(e.key=null);let o=ot("value",e.value,i,r);if(o===q)return q;o===fe&&(e.value=null)}}return n}async function Mi(t,e){let i=ys(e);O.isDocument(t)?await st(null,t.contents,i,Object.freeze([t]))===fe&&(t.contents=null):await st(null,t,i,Object.freeze([]))}Mi.BREAK=q;Mi.SKIP=ws;Mi.REMOVE=fe;async function st(t,e,i,r){let n=await Ns(t,e,i,r);if(O.isNode(n)||O.isPair(n))return bs(t,r,n),st(t,n,i,r);if(typeof n!="symbol"){if(O.isCollection(e)){r=Object.freeze(r.concat(e));for(let a=0;a<e.items.length;++a){let o=await st(a,e.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===q)return q;o===fe&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){r=Object.freeze(r.concat(e));let a=await st("key",e.key,i,r);if(a===q)return q;a===fe&&(e.key=null);let o=await st("value",e.value,i,r);if(o===q)return q;o===fe&&(e.value=null)}}return n}function ys(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 Ns(t,e,i,r){if(typeof i=="function")return i(t,e,r);if(O.isMap(e))return i.Map?.(t,e,r);if(O.isSeq(e))return i.Seq?.(t,e,r);if(O.isPair(e))return i.Pair?.(t,e,r);if(O.isScalar(e))return i.Scalar?.(t,e,r);if(O.isAlias(e))return i.Alias?.(t,e,r)}function bs(t,e,i){let r=e[e.length-1];if(O.isCollection(r))r.items[t]=i;else if(O.isPair(r))t==="key"?r.key=i:r.value=i;else if(O.isDocument(r))r.contents=i;else{let n=O.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}jn.visit=Li;jn.visitAsync=Mi});var $n=g(Ss=>{"use strict";var ks=P(),ff=It(),hf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},pf=t=>t.replace(/[!,[\]{}]/g,e=>hf[e]),jt=class t{constructor(e,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,i)}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,i){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2&&(i(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[a,o]=r;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return i(0,"%YAML directive should contain exactly one part"),!1;let[a]=r;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return i(6,`Unsupported YAML version ${a}`,o),!1}}default:return i(0,`Unknown directive ${n}`,!0),!1}}tagName(e,i){if(e==="!")return"!";if(e[0]!=="!")return i(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(i(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&i("Verbatim tags must end with a >"),o)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||i(`The ${e} tag has no suffix`);let a=this.tags[r];if(a)try{return a+decodeURIComponent(n)}catch(o){return i(String(o)),null}return r==="!"?e:(i(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[i,r]of Object.entries(this.tags))if(e.startsWith(r))return i+pf(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&ks.isNode(e.contents)){let a={};ff.visit(e.contents,(o,s)=>{ks.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of r)a==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(o)))&&i.push(`%TAG ${a} ${o}`);return i.join(`
5
- `)}};jt.defaultYaml={explicit:!1,version:"1.2"};jt.defaultTags={"!!":"tag:yaml.org,2002:"};Ss.Directives=jt});var Fi=g($t=>{"use strict";var Es=P(),mf=It();function vf(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(i)}return!0}function Ps(t){let e=new Set;return mf.visit(t,{Value(i,r){r.anchor&&e.add(r.anchor)}}),e}function xs(t,e){for(let i=1;;++i){let r=`${t}${i}`;if(!e.has(r))return r}}function gf(t,e){let i=[],r=new Map,n=null;return{onAnchor:a=>{i.push(a),n??(n=Ps(t));let o=xs(e,n);return n.add(o),o},setAnchors:()=>{for(let a of i){let o=r.get(a);if(typeof o=="object"&&o.anchor&&(Es.isScalar(o.node)||Es.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:r}}$t.anchorIsValid=vf;$t.anchorNames=Ps;$t.createNodeAnchors=gf;$t.findNewAnchor=xs});var On=g(Rs=>{"use strict";function Ot(t,e,i,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let n=0,a=r.length;n<a;++n){let o=r[n],s=Ot(t,r,String(n),o);s===void 0?delete r[n]:s!==o&&(r[n]=s)}else if(r instanceof Map)for(let n of Array.from(r.keys())){let a=r.get(n),o=Ot(t,r,n,a);o===void 0?r.delete(n):o!==a&&r.set(n,o)}else if(r instanceof Set)for(let n of Array.from(r)){let a=Ot(t,r,n,n);a===void 0?r.delete(n):a!==n&&(r.delete(n),r.add(a))}else for(let[n,a]of Object.entries(r)){let o=Ot(t,r,n,a);o===void 0?delete r[n]:o!==a&&(r[n]=o)}return t.call(e,i,r)}Rs.applyReviver=Ot});var _e=g(As=>{"use strict";var wf=P();function Cs(t,e,i){if(Array.isArray(t))return t.map((r,n)=>Cs(r,String(n),i));if(t&&typeof t.toJSON=="function"){if(!i||!wf.hasAnchor(t))return t.toJSON(e,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(t,r),i.onCreate=a=>{r.res=a,delete i.onCreate};let n=t.toJSON(e,i);return i.onCreate&&i.onCreate(n),n}return typeof t=="bigint"&&!i?.keep?Number(t):t}As.toJS=Cs});var Vi=g(Ts=>{"use strict";var yf=On(),_s=P(),Nf=_e(),Hn=class{constructor(e){Object.defineProperty(this,_s.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:i,maxAliasCount:r,onAnchor:n,reviver:a}={}){if(!_s.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=Nf.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?yf.applyReviver(a,{"":s},"",s):s}};Ts.NodeBase=Hn});var Ht=g(Is=>{"use strict";var bf=Fi(),kf=It(),ct=P(),Sf=Vi(),Ef=_e(),Dn=class extends Sf.NodeBase{constructor(e){super(ct.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],kf.visit(e,{Node:(a,o)=>{(ct.isAlias(o)||ct.hasAnchor(o))&&r.push(o)}}),i&&(i.aliasResolveCache=r));let n;for(let a of r){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,i){if(!i)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:a}=i,o=this.resolve(n,i);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=r.get(o);if(s||(Ef.toJS(o,null,i),s=r.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=qi(n,o,r)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,i,r){let n=`*${this.source}`;if(e){if(bf.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 qi(t,e,i){if(ct.isAlias(e)){let r=e.resolve(t),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(ct.isCollection(e)){let r=0;for(let n of e.items){let a=qi(t,n,i);a>r&&(r=a)}return r}else if(ct.isPair(e)){let r=qi(t,e.key,i),n=qi(t,e.value,i);return Math.max(r,n)}return 1}Is.Alias=Dn});var I=g(Bn=>{"use strict";var Pf=P(),xf=Vi(),Rf=_e(),Cf=t=>!t||typeof t!="function"&&typeof t!="object",Te=class extends xf.NodeBase{constructor(e){super(Pf.SCALAR),this.value=e}toJSON(e,i){return i?.keep?this.value:Rf.toJS(this.value,e,i)}toString(){return String(this.value)}};Te.BLOCK_FOLDED="BLOCK_FOLDED";Te.BLOCK_LITERAL="BLOCK_LITERAL";Te.PLAIN="PLAIN";Te.QUOTE_DOUBLE="QUOTE_DOUBLE";Te.QUOTE_SINGLE="QUOTE_SINGLE";Bn.Scalar=Te;Bn.isScalarValue=Cf});var Dt=g($s=>{"use strict";var Af=Ht(),Je=P(),js=I(),_f="tag:yaml.org,2002:";function Tf(t,e,i){if(e){let r=i.filter(a=>a.tag===e),n=r.find(a=>!a.format)??r[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return i.find(r=>r.identify?.(t)&&!r.format)}function If(t,e,i){if(Je.isDocument(t)&&(t=t.contents),Je.isNode(t))return t;if(Je.isPair(t)){let d=i.schema[Je.MAP].createNode?.(i.schema,null,i);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=i,c;if(r&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new Af.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=_f+e.slice(2));let l=Tf(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new js.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?o[Je.MAP]:Symbol.iterator in Object(t)?o[Je.SEQ]:o[Je.MAP]}a&&(a(l),delete i.onTagObj);let f=l?.createNode?l.createNode(i.schema,t,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,t,i):new js.Scalar(t);return e?f.tag=e:l.default||(f.tag=l.tag),c&&(c.node=f),f}$s.createNode=If});var zi=g(Wi=>{"use strict";var jf=Dt(),he=P(),$f=Vi();function Ln(t,e,i){let r=i;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]=r,r=o}else r=new Map([[a,r]])}return jf.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Os=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Mn=class extends $f.NodeBase{constructor(e,i){super(e),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(e){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(i.schema=e),i.items=i.items.map(r=>he.isNode(r)||he.isPair(r)?r.clone(e):r),this.range&&(i.range=this.range.slice()),i}addIn(e,i){if(Os(e))this.add(i);else{let[r,...n]=e,a=this.get(r,!0);if(he.isCollection(a))a.addIn(n,i);else if(a===void 0&&this.schema)this.set(r,Ln(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[i,...r]=e;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(he.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(e,i){let[r,...n]=e,a=this.get(r,!0);return n.length===0?!i&&he.isScalar(a)?a.value:a:he.isCollection(a)?a.getIn(n,i):void 0}hasAllNullValues(e){return this.items.every(i=>{if(!he.isPair(i))return!1;let r=i.value;return r==null||e&&he.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[i,...r]=e;if(r.length===0)return this.has(i);let n=this.get(i,!0);return he.isCollection(n)?n.hasIn(r):!1}setIn(e,i){let[r,...n]=e;if(n.length===0)this.set(r,i);else{let a=this.get(r,!0);if(he.isCollection(a))a.setIn(n,i);else if(a===void 0&&this.schema)this.set(r,Ln(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};Wi.Collection=Mn;Wi.collectionFromPath=Ln;Wi.isEmptyPath=Os});var Bt=g(Ji=>{"use strict";var Of=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Fn(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Hf=(t,e,i)=>t.endsWith(`
6
- `)?Fn(i,e):i.includes(`
4
+ var Ld=Object.create;var us=Object.defineProperty;var Md=Object.getOwnPropertyDescriptor;var Fd=Object.getOwnPropertyNames;var Vd=Object.getPrototypeOf,qd=Object.prototype.hasOwnProperty;var $i=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var g=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(i){throw e=0,i}};var Wd=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fd(e))!qd.call(t,n)&&n!==i&&us(t,n,{get:()=>e[n],enumerable:!(r=Md(e,n))||r.enumerable});return t};var jt=(t,e,i)=>(i=t!=null?Ld(Vd(t)):{},Wd(e||!t||!t.__esModule?us(i,"default",{value:t,enumerable:!0}):i,t));var P=g(H=>{"use strict";var jn=Symbol.for("yaml.alias"),ms=Symbol.for("yaml.document"),Bi=Symbol.for("yaml.map"),vs=Symbol.for("yaml.pair"),$n=Symbol.for("yaml.scalar"),Li=Symbol.for("yaml.seq"),Se=Symbol.for("yaml.node.type"),cf=t=>!!t&&typeof t=="object"&&t[Se]===jn,lf=t=>!!t&&typeof t=="object"&&t[Se]===ms,uf=t=>!!t&&typeof t=="object"&&t[Se]===Bi,df=t=>!!t&&typeof t=="object"&&t[Se]===vs,gs=t=>!!t&&typeof t=="object"&&t[Se]===$n,ff=t=>!!t&&typeof t=="object"&&t[Se]===Li;function ws(t){if(t&&typeof t=="object")switch(t[Se]){case Bi:case Li:return!0}return!1}function hf(t){if(t&&typeof t=="object")switch(t[Se]){case jn:case Bi:case $n:case Li:return!0}return!1}var pf=t=>(gs(t)||ws(t))&&!!t.anchor;H.ALIAS=jn;H.DOC=ms;H.MAP=Bi;H.NODE_TYPE=Se;H.PAIR=vs;H.SCALAR=$n;H.SEQ=Li;H.hasAnchor=pf;H.isAlias=cf;H.isCollection=ws;H.isDocument=lf;H.isMap=uf;H.isNode=hf;H.isPair=df;H.isScalar=gs;H.isSeq=ff});var Ht=g(On=>{"use strict";var O=P(),q=Symbol("break visit"),ys=Symbol("skip children"),fe=Symbol("remove node");function Mi(t,e){let i=Ns(e);O.isDocument(t)?st(null,t.contents,i,Object.freeze([t]))===fe&&(t.contents=null):st(null,t,i,Object.freeze([]))}Mi.BREAK=q;Mi.SKIP=ys;Mi.REMOVE=fe;function st(t,e,i,r){let n=bs(t,e,i,r);if(O.isNode(n)||O.isPair(n))return ks(t,r,n),st(t,n,i,r);if(typeof n!="symbol"){if(O.isCollection(e)){r=Object.freeze(r.concat(e));for(let a=0;a<e.items.length;++a){let o=st(a,e.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===q)return q;o===fe&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){r=Object.freeze(r.concat(e));let a=st("key",e.key,i,r);if(a===q)return q;a===fe&&(e.key=null);let o=st("value",e.value,i,r);if(o===q)return q;o===fe&&(e.value=null)}}return n}async function Fi(t,e){let i=Ns(e);O.isDocument(t)?await ct(null,t.contents,i,Object.freeze([t]))===fe&&(t.contents=null):await ct(null,t,i,Object.freeze([]))}Fi.BREAK=q;Fi.SKIP=ys;Fi.REMOVE=fe;async function ct(t,e,i,r){let n=await bs(t,e,i,r);if(O.isNode(n)||O.isPair(n))return ks(t,r,n),ct(t,n,i,r);if(typeof n!="symbol"){if(O.isCollection(e)){r=Object.freeze(r.concat(e));for(let a=0;a<e.items.length;++a){let o=await ct(a,e.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===q)return q;o===fe&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){r=Object.freeze(r.concat(e));let a=await ct("key",e.key,i,r);if(a===q)return q;a===fe&&(e.key=null);let o=await ct("value",e.value,i,r);if(o===q)return q;o===fe&&(e.value=null)}}return n}function Ns(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 bs(t,e,i,r){if(typeof i=="function")return i(t,e,r);if(O.isMap(e))return i.Map?.(t,e,r);if(O.isSeq(e))return i.Seq?.(t,e,r);if(O.isPair(e))return i.Pair?.(t,e,r);if(O.isScalar(e))return i.Scalar?.(t,e,r);if(O.isAlias(e))return i.Alias?.(t,e,r)}function ks(t,e,i){let r=e[e.length-1];if(O.isCollection(r))r.items[t]=i;else if(O.isPair(r))t==="key"?r.key=i:r.value=i;else if(O.isDocument(r))r.contents=i;else{let n=O.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}On.visit=Mi;On.visitAsync=Fi});var Hn=g(Es=>{"use strict";var Ss=P(),mf=Ht(),vf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},gf=t=>t.replace(/[!,[\]{}]/g,e=>vf[e]),Dt=class t{constructor(e,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,i)}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,i){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2&&(i(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[a,o]=r;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return i(0,"%YAML directive should contain exactly one part"),!1;let[a]=r;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return i(6,`Unsupported YAML version ${a}`,o),!1}}default:return i(0,`Unknown directive ${n}`,!0),!1}}tagName(e,i){if(e==="!")return"!";if(e[0]!=="!")return i(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(i(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&i("Verbatim tags must end with a >"),o)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||i(`The ${e} tag has no suffix`);let a=this.tags[r];if(a)try{return a+decodeURIComponent(n)}catch(o){return i(String(o)),null}return r==="!"?e:(i(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[i,r]of Object.entries(this.tags))if(e.startsWith(r))return i+gf(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&Ss.isNode(e.contents)){let a={};mf.visit(e.contents,(o,s)=>{Ss.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of r)a==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(o)))&&i.push(`%TAG ${a} ${o}`);return i.join(`
5
+ `)}};Dt.defaultYaml={explicit:!1,version:"1.2"};Dt.defaultTags={"!!":"tag:yaml.org,2002:"};Es.Directives=Dt});var Vi=g(Bt=>{"use strict";var Ps=P(),wf=Ht();function yf(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(i)}return!0}function xs(t){let e=new Set;return wf.visit(t,{Value(i,r){r.anchor&&e.add(r.anchor)}}),e}function Cs(t,e){for(let i=1;;++i){let r=`${t}${i}`;if(!e.has(r))return r}}function Nf(t,e){let i=[],r=new Map,n=null;return{onAnchor:a=>{i.push(a),n??(n=xs(t));let o=Cs(e,n);return n.add(o),o},setAnchors:()=>{for(let a of i){let o=r.get(a);if(typeof o=="object"&&o.anchor&&(Ps.isScalar(o.node)||Ps.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:r}}Bt.anchorIsValid=yf;Bt.anchorNames=xs;Bt.createNodeAnchors=Nf;Bt.findNewAnchor=Cs});var Dn=g(Rs=>{"use strict";function Lt(t,e,i,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let n=0,a=r.length;n<a;++n){let o=r[n],s=Lt(t,r,String(n),o);s===void 0?delete r[n]:s!==o&&(r[n]=s)}else if(r instanceof Map)for(let n of Array.from(r.keys())){let a=r.get(n),o=Lt(t,r,n,a);o===void 0?r.delete(n):o!==a&&r.set(n,o)}else if(r instanceof Set)for(let n of Array.from(r)){let a=Lt(t,r,n,n);a===void 0?r.delete(n):a!==n&&(r.delete(n),r.add(a))}else for(let[n,a]of Object.entries(r)){let o=Lt(t,r,n,a);o===void 0?delete r[n]:o!==a&&(r[n]=o)}return t.call(e,i,r)}Rs.applyReviver=Lt});var Ie=g(_s=>{"use strict";var bf=P();function As(t,e,i){if(Array.isArray(t))return t.map((r,n)=>As(r,String(n),i));if(t&&typeof t.toJSON=="function"){if(!i||!bf.hasAnchor(t))return t.toJSON(e,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(t,r),i.onCreate=a=>{r.res=a,delete i.onCreate};let n=t.toJSON(e,i);return i.onCreate&&i.onCreate(n),n}return typeof t=="bigint"&&!i?.keep?Number(t):t}_s.toJS=As});var qi=g(Is=>{"use strict";var kf=Dn(),Ts=P(),Sf=Ie(),Bn=class{constructor(e){Object.defineProperty(this,Ts.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:i,maxAliasCount:r,onAnchor:n,reviver:a}={}){if(!Ts.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=Sf.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?kf.applyReviver(a,{"":s},"",s):s}};Is.NodeBase=Bn});var Mt=g(js=>{"use strict";var Ef=Vi(),Pf=Ht(),lt=P(),xf=qi(),Cf=Ie(),Ln=class extends xf.NodeBase{constructor(e){super(lt.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],Pf.visit(e,{Node:(a,o)=>{(lt.isAlias(o)||lt.hasAnchor(o))&&r.push(o)}}),i&&(i.aliasResolveCache=r));let n;for(let a of r){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,i){if(!i)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:a}=i,o=this.resolve(n,i);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=r.get(o);if(s||(Cf.toJS(o,null,i),s=r.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=Wi(n,o,r)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,i,r){let n=`*${this.source}`;if(e){if(Ef.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 Wi(t,e,i){if(lt.isAlias(e)){let r=e.resolve(t),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(lt.isCollection(e)){let r=0;for(let n of e.items){let a=Wi(t,n,i);a>r&&(r=a)}return r}else if(lt.isPair(e)){let r=Wi(t,e.key,i),n=Wi(t,e.value,i);return Math.max(r,n)}return 1}js.Alias=Ln});var I=g(Mn=>{"use strict";var Rf=P(),Af=qi(),_f=Ie(),Tf=t=>!t||typeof t!="function"&&typeof t!="object",je=class extends Af.NodeBase{constructor(e){super(Rf.SCALAR),this.value=e}toJSON(e,i){return i?.keep?this.value:_f.toJS(this.value,e,i)}toString(){return String(this.value)}};je.BLOCK_FOLDED="BLOCK_FOLDED";je.BLOCK_LITERAL="BLOCK_LITERAL";je.PLAIN="PLAIN";je.QUOTE_DOUBLE="QUOTE_DOUBLE";je.QUOTE_SINGLE="QUOTE_SINGLE";Mn.Scalar=je;Mn.isScalarValue=Tf});var Ft=g(Os=>{"use strict";var If=Mt(),Je=P(),$s=I(),jf="tag:yaml.org,2002:";function $f(t,e,i){if(e){let r=i.filter(a=>a.tag===e),n=r.find(a=>!a.format)??r[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return i.find(r=>r.identify?.(t)&&!r.format)}function Of(t,e,i){if(Je.isDocument(t)&&(t=t.contents),Je.isNode(t))return t;if(Je.isPair(t)){let d=i.schema[Je.MAP].createNode?.(i.schema,null,i);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=i,c;if(r&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new If.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=jf+e.slice(2));let l=$f(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new $s.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?o[Je.MAP]:Symbol.iterator in Object(t)?o[Je.SEQ]:o[Je.MAP]}a&&(a(l),delete i.onTagObj);let f=l?.createNode?l.createNode(i.schema,t,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,t,i):new $s.Scalar(t);return e?f.tag=e:l.default||(f.tag=l.tag),c&&(c.node=f),f}Os.createNode=Of});var Ji=g(zi=>{"use strict";var Hf=Ft(),he=P(),Df=qi();function Fn(t,e,i){let r=i;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]=r,r=o}else r=new Map([[a,r]])}return Hf.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Hs=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Vn=class extends Df.NodeBase{constructor(e,i){super(e),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(e){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(i.schema=e),i.items=i.items.map(r=>he.isNode(r)||he.isPair(r)?r.clone(e):r),this.range&&(i.range=this.range.slice()),i}addIn(e,i){if(Hs(e))this.add(i);else{let[r,...n]=e,a=this.get(r,!0);if(he.isCollection(a))a.addIn(n,i);else if(a===void 0&&this.schema)this.set(r,Fn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[i,...r]=e;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(he.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(e,i){let[r,...n]=e,a=this.get(r,!0);return n.length===0?!i&&he.isScalar(a)?a.value:a:he.isCollection(a)?a.getIn(n,i):void 0}hasAllNullValues(e){return this.items.every(i=>{if(!he.isPair(i))return!1;let r=i.value;return r==null||e&&he.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[i,...r]=e;if(r.length===0)return this.has(i);let n=this.get(i,!0);return he.isCollection(n)?n.hasIn(r):!1}setIn(e,i){let[r,...n]=e;if(n.length===0)this.set(r,i);else{let a=this.get(r,!0);if(he.isCollection(a))a.setIn(n,i);else if(a===void 0&&this.schema)this.set(r,Fn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};zi.Collection=Vn;zi.collectionFromPath=Fn;zi.isEmptyPath=Hs});var Vt=g(Gi=>{"use strict";var Bf=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function qn(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Lf=(t,e,i)=>t.endsWith(`
6
+ `)?qn(i,e):i.includes(`
7
7
  `)?`
8
- `+Fn(i,e):(t.endsWith(" ")?"":" ")+i;Ji.indentComment=Fn;Ji.lineComment=Hf;Ji.stringifyComment=Of});var Ds=g(Lt=>{"use strict";var Df="flow",Vn="block",Gi="quoted";function Bf(t,e,i="flow",{indentAtStart:r,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=[],f={},d=n-e.length;typeof r=="number"&&(r>n-Math.max(2,a)?l.push(0):d=n-r);let u,p,v=!1,h=-1,m=-1,w=-1;i===Vn&&(h=Hs(t,h,e.length),h!==-1&&(d=h+c));for(let b;b=t[h+=1];){if(i===Gi&&b==="\\"){switch(m=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}w=h}if(b===`
9
- `)i===Vn&&(h=Hs(t,h,e.length)),d=h+e.length+c,u=void 0;else{if(b===" "&&p&&p!==" "&&p!==`
8
+ `+qn(i,e):(t.endsWith(" ")?"":" ")+i;Gi.indentComment=qn;Gi.lineComment=Lf;Gi.stringifyComment=Bf});var Bs=g(qt=>{"use strict";var Mf="flow",Wn="block",Ui="quoted";function Ff(t,e,i="flow",{indentAtStart:r,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=[],f={},d=n-e.length;typeof r=="number"&&(r>n-Math.max(2,a)?l.push(0):d=n-r);let u,p,v=!1,h=-1,m=-1,w=-1;i===Wn&&(h=Ds(t,h,e.length),h!==-1&&(d=h+c));for(let b;b=t[h+=1];){if(i===Ui&&b==="\\"){switch(m=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}w=h}if(b===`
9
+ `)i===Wn&&(h=Ds(t,h,e.length)),d=h+e.length+c,u=void 0;else{if(b===" "&&p&&p!==" "&&p!==`
10
10
  `&&p!==" "){let k=t[h+1];k&&k!==" "&&k!==`
11
- `&&k!==" "&&(u=h)}if(h>=d)if(u)l.push(u),d=u+c,u=void 0;else if(i===Gi){for(;p===" "||p===" ";)p=b,b=t[h+=1],v=!0;let k=h>w+1?h-2:m-1;if(f[k])return t;l.push(k),f[k]=!0,d=k+c,u=void 0}else v=!0}p=b}if(v&&s&&s(),l.length===0)return t;o&&o();let y=t.slice(0,l[0]);for(let b=0;b<l.length;++b){let k=l[b],S=l[b+1]||t.length;k===0?y=`
12
- ${e}${t.slice(0,S)}`:(i===Gi&&f[k]&&(y+=`${t[k]}\\`),y+=`
13
- ${e}${t.slice(k+1,S)}`)}return y}function Hs(t,e,i){let r=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+i)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
- `);r=e,n=e+1,a=t[n]}return r}Lt.FOLD_BLOCK=Vn;Lt.FOLD_FLOW=Df;Lt.FOLD_QUOTED=Gi;Lt.foldFlowLines=Bf});var Ft=g(Bs=>{"use strict";var ne=I(),Ie=Ds(),Ki=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Yi=t=>/^(%|---|\.\.\.)/m.test(t);function Lf(t,e,i){if(!e||e<0)return!1;let r=e-i,n=t.length;if(n<=r)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
- `){if(a-o>r)return!0;if(o=a+1,n-o<=r)return!1}return!0}function Mt(t,e){let i=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(Yi(t)?" ":""),o="",s=0;for(let c=0,l=i[c];l;l=i[++c])if(l===" "&&i[c+1]==="\\"&&i[c+2]==="n"&&(o+=i.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(i[c+1]){case"u":{o+=i.slice(s,c);let f=i.substr(c+2,4);switch(f){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:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=i.substr(c,6)}c+=5,s=c+1}break;case"n":if(r||i[c+2]==='"'||i.length<n)c+=1;else{for(o+=i.slice(s,c)+`
11
+ `&&k!==" "&&(u=h)}if(h>=d)if(u)l.push(u),d=u+c,u=void 0;else if(i===Ui){for(;p===" "||p===" ";)p=b,b=t[h+=1],v=!0;let k=h>w+1?h-2:m-1;if(f[k])return t;l.push(k),f[k]=!0,d=k+c,u=void 0}else v=!0}p=b}if(v&&s&&s(),l.length===0)return t;o&&o();let y=t.slice(0,l[0]);for(let b=0;b<l.length;++b){let k=l[b],S=l[b+1]||t.length;k===0?y=`
12
+ ${e}${t.slice(0,S)}`:(i===Ui&&f[k]&&(y+=`${t[k]}\\`),y+=`
13
+ ${e}${t.slice(k+1,S)}`)}return y}function Ds(t,e,i){let r=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+i)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
+ `);r=e,n=e+1,a=t[n]}return r}qt.FOLD_BLOCK=Wn;qt.FOLD_FLOW=Mf;qt.FOLD_QUOTED=Ui;qt.foldFlowLines=Ff});var zt=g(Ls=>{"use strict";var ne=I(),$e=Bs(),Yi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Xi=t=>/^(%|---|\.\.\.)/m.test(t);function Vf(t,e,i){if(!e||e<0)return!1;let r=e-i,n=t.length;if(n<=r)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
+ `){if(a-o>r)return!0;if(o=a+1,n-o<=r)return!1}return!0}function Wt(t,e){let i=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(Xi(t)?" ":""),o="",s=0;for(let c=0,l=i[c];l;l=i[++c])if(l===" "&&i[c+1]==="\\"&&i[c+2]==="n"&&(o+=i.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(i[c+1]){case"u":{o+=i.slice(s,c);let f=i.substr(c+2,4);switch(f){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:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=i.substr(c,6)}c+=5,s=c+1}break;case"n":if(r||i[c+2]==='"'||i.length<n)c+=1;else{for(o+=i.slice(s,c)+`
16
16
 
17
17
  `;i[c+2]==="\\"&&i[c+3]==="n"&&i[c+4]!=='"';)o+=`
18
- `,c+=2;o+=a,i[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+i.slice(s):i,r?o:Ie.foldFlowLines(o,a,Ie.FOLD_QUOTED,Ki(e,!1))}function qn(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(t))return Mt(t,e);let i=e.indent||(Yi(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${i}`)+"'";return e.implicitKey?r:Ie.foldFlowLines(r,i,Ie.FOLD_FLOW,Ki(e,!1))}function lt(t,e){let{singleQuote:i}=e.options,r;if(i===!1)r=Mt;else{let n=t.includes('"'),a=t.includes("'");n&&!a?r=qn:a&&!n?r=Mt:r=i?qn:Mt}return r(t,e)}var Wn;try{Wn=new RegExp(`(^|(?<!
18
+ `,c+=2;o+=a,i[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+i.slice(s):i,r?o:$e.foldFlowLines(o,a,$e.FOLD_QUOTED,Yi(e,!1))}function zn(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(t))return Wt(t,e);let i=e.indent||(Xi(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${i}`)+"'";return e.implicitKey?r:$e.foldFlowLines(r,i,$e.FOLD_FLOW,Yi(e,!1))}function ut(t,e){let{singleQuote:i}=e.options,r;if(i===!1)r=Wt;else{let n=t.includes('"'),a=t.includes("'");n&&!a?r=zn:a&&!n?r=Wt:r=i?zn:Wt}return r(t,e)}var Jn;try{Jn=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{Wn=/\n+(?!\n|$)/g}function Ui({comment:t,type:e,value:i},r,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(i))return lt(i,r);let l=r.indent||(r.forceBlockIndent||Yi(i)?" ":""),f=o==="literal"?!0:o==="folded"||e===ne.Scalar.BLOCK_FOLDED?!1:e===ne.Scalar.BLOCK_LITERAL?!0:!Lf(i,c,l.length);if(!i)return f?`|
23
+ |$)`,"g")}catch{Jn=/\n+(?!\n|$)/g}function Ki({comment:t,type:e,value:i},r,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(i))return ut(i,r);let l=r.indent||(r.forceBlockIndent||Xi(i)?" ":""),f=o==="literal"?!0:o==="folded"||e===ne.Scalar.BLOCK_FOLDED?!1:e===ne.Scalar.BLOCK_LITERAL?!0:!Vf(i,c,l.length);if(!i)return f?`|
24
24
  `:`>
25
25
  `;let d,u;for(u=i.length;u>0;--u){let S=i[u-1];if(S!==`
26
26
  `&&S!==" "&&S!==" ")break}let p=i.substring(u),v=p.indexOf(`
27
27
  `);v===-1?d="-":i===p||v!==p.length-1?(d="+",a&&a()):d="",p&&(i=i.slice(0,-p.length),p[p.length-1]===`
28
- `&&(p=p.slice(0,-1)),p=p.replace(Wn,`$&${l}`));let h=!1,m,w=-1;for(m=0;m<i.length;++m){let S=i[m];if(S===" ")h=!0;else if(S===`
28
+ `&&(p=p.slice(0,-1)),p=p.replace(Jn,`$&${l}`));let h=!1,m,w=-1;for(m=0;m<i.length;++m){let S=i[m];if(S===" ")h=!0;else if(S===`
29
29
  `)w=m;else break}let y=i.substring(0,w<m?w+1:m);y&&(i=i.substring(y.length),y=y.replace(/\n+/g,`$&${l}`));let k=(h?l?"2":"1":"")+d;if(t&&(k+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let S=i.replace(/\n+/g,`
30
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,C=Ki(r,!0);o!=="folded"&&e!==ne.Scalar.BLOCK_FOLDED&&(C.onOverflow=()=>{E=!0});let N=Ie.foldFlowLines(`${y}${S}${p}`,l,Ie.FOLD_BLOCK,C);if(!E)return`>${k}
30
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,R=Yi(r,!0);o!=="folded"&&e!==ne.Scalar.BLOCK_FOLDED&&(R.onOverflow=()=>{E=!0});let N=$e.foldFlowLines(`${y}${S}${p}`,l,$e.FOLD_BLOCK,R);if(!E)return`>${k}
31
31
  ${l}${N}`}return i=i.replace(/\n+/g,`$&${l}`),`|${k}
32
- ${l}${y}${i}${p}`}function Mf(t,e,i,r){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:f}=e;if(s&&a.includes(`
33
- `)||f&&/[[\]{},]/.test(a))return lt(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||f||!a.includes(`
34
- `)?lt(a,e):Ui(t,e,i,r);if(!s&&!f&&n!==ne.Scalar.PLAIN&&a.includes(`
35
- `))return Ui(t,e,i,r);if(Yi(a)){if(c==="")return e.forceBlockIndent=!0,Ui(t,e,i,r);if(s&&c===l)return lt(a,e)}let d=a.replace(/\n+/g,`$&
36
- ${c}`);if(o){let u=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:v}=e.doc.schema;if(v.some(u)||p?.some(u))return lt(a,e)}return s?d:Ie.foldFlowLines(d,c,Ie.FOLD_FLOW,Ki(e,!1))}function Ff(t,e,i,r){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==ne.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=ne.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case ne.Scalar.BLOCK_FOLDED:case ne.Scalar.BLOCK_LITERAL:return n||a?lt(o.value,e):Ui(o,e,i,r);case ne.Scalar.QUOTE_DOUBLE:return Mt(o.value,e);case ne.Scalar.QUOTE_SINGLE:return qn(o.value,e);case ne.Scalar.PLAIN:return Mf(o,e,i,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:f,defaultStringType:d}=e.options,u=n&&f||d;if(l=c(u),l===null)throw new Error(`Unsupported default string type ${u}`)}return l}Bs.stringifyString=Ff});var Vt=g(zn=>{"use strict";var Vf=Fi(),je=P(),qf=Bt(),Wf=Ft();function zf(t,e){let i=Object.assign({blockQuote:!0,commentString:qf.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),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function Jf(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 i,r;if(je.isScalar(e)){r=e.value;let n=t.filter(a=>a.identify?.(r));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}i=n.find(a=>a.format===e.format)??n.find(a=>!a.format)}else r=e,i=t.find(n=>n.nodeClass&&r instanceof n.nodeClass);if(!i){let n=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${n} value`)}return i}function Gf(t,e,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],a=(je.isScalar(t)||je.isCollection(t))&&t.anchor;a&&Vf.anchorIsValid(a)&&(i.add(a),n.push(`&${a}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(r.directives.tagString(o)),n.join(" ")}function Uf(t,e,i,r){if(je.isPair(t))return t.toString(e,i,r);if(je.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=je.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Jf(e.doc.schema.tags,a));let o=Gf(a,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,e,i,r):je.isScalar(a)?Wf.stringifyString(a,e,i,r):a.toString(e,i,r);return o?je.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${e.indent}${s}`:s}zn.createStringifyContext=zf;zn.stringify=Uf});var Vs=g(Fs=>{"use strict";var Ee=P(),Ls=I(),Ms=Vt(),qt=Bt();function Kf({key:t,value:e},i,r,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:d}}=i,u=Ee.isNode(t)&&t.comment||null;if(d){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(Ee.isCollection(t)||!Ee.isNode(t)&&typeof t=="object"){let C="With simple keys, collection cannot be used as a key value";throw new Error(C)}}let p=!d&&(!t||u&&e==null&&!i.inFlow||Ee.isCollection(t)||(Ee.isScalar(t)?t.type===Ls.Scalar.BLOCK_FOLDED||t.type===Ls.Scalar.BLOCK_LITERAL:typeof t=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let v=!1,h=!1,m=Ms.stringify(t,i,()=>v=!0,()=>h=!0);if(!p&&!i.inFlow&&m.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(i.inFlow){if(a||e==null)return v&&r&&r(),m===""?"?":p?`? ${m}`:m}else if(a&&!d||e==null&&p)return m=`? ${m}`,u&&!v?m+=qt.lineComment(m,i.indent,l(u)):h&&n&&n(),m;v&&(u=null),p?(u&&(m+=qt.lineComment(m,i.indent,l(u))),m=`? ${m}
38
- ${s}:`):(m=`${m}:`,u&&(m+=qt.lineComment(m,i.indent,l(u))));let w,y,b;Ee.isNode(e)?(w=!!e.spaceBefore,y=e.commentBefore,b=e.comment):(w=!1,y=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),i.implicitKey=!1,!p&&!u&&Ee.isScalar(e)&&(i.indentAtStart=m.length+1),h=!1,!f&&c.length>=2&&!i.inFlow&&!p&&Ee.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(i.indent=i.indent.substring(2));let k=!1,S=Ms.stringify(e,i,()=>k=!0,()=>h=!0),E=" ";if(u||w||y){if(E=w?`
39
- `:"",y){let C=l(y);E+=`
40
- ${qt.indentComment(C,i.indent)}`}S===""&&!i.inFlow?E===`
32
+ ${l}${y}${i}${p}`}function qf(t,e,i,r){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:f}=e;if(s&&a.includes(`
33
+ `)||f&&/[[\]{},]/.test(a))return ut(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||f||!a.includes(`
34
+ `)?ut(a,e):Ki(t,e,i,r);if(!s&&!f&&n!==ne.Scalar.PLAIN&&a.includes(`
35
+ `))return Ki(t,e,i,r);if(Xi(a)){if(c==="")return e.forceBlockIndent=!0,Ki(t,e,i,r);if(s&&c===l)return ut(a,e)}let d=a.replace(/\n+/g,`$&
36
+ ${c}`);if(o){let u=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:v}=e.doc.schema;if(v.some(u)||p?.some(u))return ut(a,e)}return s?d:$e.foldFlowLines(d,c,$e.FOLD_FLOW,Yi(e,!1))}function Wf(t,e,i,r){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==ne.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=ne.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case ne.Scalar.BLOCK_FOLDED:case ne.Scalar.BLOCK_LITERAL:return n||a?ut(o.value,e):Ki(o,e,i,r);case ne.Scalar.QUOTE_DOUBLE:return Wt(o.value,e);case ne.Scalar.QUOTE_SINGLE:return zn(o.value,e);case ne.Scalar.PLAIN:return qf(o,e,i,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:f,defaultStringType:d}=e.options,u=n&&f||d;if(l=c(u),l===null)throw new Error(`Unsupported default string type ${u}`)}return l}Ls.stringifyString=Wf});var Jt=g(Gn=>{"use strict";var zf=Vi(),Oe=P(),Jf=Vt(),Gf=zt();function Uf(t,e){let i=Object.assign({blockQuote:!0,commentString:Jf.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),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function Kf(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 i,r;if(Oe.isScalar(e)){r=e.value;let n=t.filter(a=>a.identify?.(r));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}i=n.find(a=>a.format===e.format)??n.find(a=>!a.format)}else r=e,i=t.find(n=>n.nodeClass&&r instanceof n.nodeClass);if(!i){let n=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${n} value`)}return i}function Yf(t,e,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],a=(Oe.isScalar(t)||Oe.isCollection(t))&&t.anchor;a&&zf.anchorIsValid(a)&&(i.add(a),n.push(`&${a}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(r.directives.tagString(o)),n.join(" ")}function Xf(t,e,i,r){if(Oe.isPair(t))return t.toString(e,i,r);if(Oe.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=Oe.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Kf(e.doc.schema.tags,a));let o=Yf(a,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,e,i,r):Oe.isScalar(a)?Gf.stringifyString(a,e,i,r):a.toString(e,i,r);return o?Oe.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${e.indent}${s}`:s}Gn.createStringifyContext=Uf;Gn.stringify=Xf});var qs=g(Vs=>{"use strict";var Ee=P(),Ms=I(),Fs=Jt(),Gt=Vt();function Qf({key:t,value:e},i,r,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:d}}=i,u=Ee.isNode(t)&&t.comment||null;if(d){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(Ee.isCollection(t)||!Ee.isNode(t)&&typeof t=="object"){let R="With simple keys, collection cannot be used as a key value";throw new Error(R)}}let p=!d&&(!t||u&&e==null&&!i.inFlow||Ee.isCollection(t)||(Ee.isScalar(t)?t.type===Ms.Scalar.BLOCK_FOLDED||t.type===Ms.Scalar.BLOCK_LITERAL:typeof t=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let v=!1,h=!1,m=Fs.stringify(t,i,()=>v=!0,()=>h=!0);if(!p&&!i.inFlow&&m.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(i.inFlow){if(a||e==null)return v&&r&&r(),m===""?"?":p?`? ${m}`:m}else if(a&&!d||e==null&&p)return m=`? ${m}`,u&&!v?m+=Gt.lineComment(m,i.indent,l(u)):h&&n&&n(),m;v&&(u=null),p?(u&&(m+=Gt.lineComment(m,i.indent,l(u))),m=`? ${m}
38
+ ${s}:`):(m=`${m}:`,u&&(m+=Gt.lineComment(m,i.indent,l(u))));let w,y,b;Ee.isNode(e)?(w=!!e.spaceBefore,y=e.commentBefore,b=e.comment):(w=!1,y=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),i.implicitKey=!1,!p&&!u&&Ee.isScalar(e)&&(i.indentAtStart=m.length+1),h=!1,!f&&c.length>=2&&!i.inFlow&&!p&&Ee.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(i.indent=i.indent.substring(2));let k=!1,S=Fs.stringify(e,i,()=>k=!0,()=>h=!0),E=" ";if(u||w||y){if(E=w?`
39
+ `:"",y){let R=l(y);E+=`
40
+ ${Gt.indentComment(R,i.indent)}`}S===""&&!i.inFlow?E===`
41
41
  `&&b&&(E=`
42
42
 
43
43
  `):E+=`
44
- ${i.indent}`}else if(!p&&Ee.isCollection(e)){let C=S[0],N=S.indexOf(`
45
- `),j=N!==-1,Ce=i.inFlow??e.flow??e.items.length===0;if(j||!Ce){let at=!1;if(j&&(C==="&"||C==="!")){let $=S.indexOf(" ");C==="&"&&$!==-1&&$<N&&S[$+1]==="!"&&($=S.indexOf(" ",$+1)),($===-1||N<$)&&(at=!0)}at||(E=`
44
+ ${i.indent}`}else if(!p&&Ee.isCollection(e)){let R=S[0],N=S.indexOf(`
45
+ `),j=N!==-1,_e=i.inFlow??e.flow??e.items.length===0;if(j||!_e){let ot=!1;if(j&&(R==="&"||R==="!")){let $=S.indexOf(" ");R==="&"&&$!==-1&&$<N&&S[$+1]==="!"&&($=S.indexOf(" ",$+1)),($===-1||N<$)&&(ot=!0)}ot||(E=`
46
46
  ${i.indent}`)}}else(S===""||S[0]===`
47
- `)&&(E="");return m+=E+S,i.inFlow?k&&r&&r():b&&!k?m+=qt.lineComment(m,i.indent,l(b)):h&&n&&n(),m}Fs.stringifyPair=Kf});var Gn=g(Jn=>{"use strict";var qs=Ii("process");function Yf(t,...e){t==="debug"&&console.log(...e)}function Xf(t,e){(t==="debug"||t==="warn")&&(typeof qs.emitWarning=="function"?qs.emitWarning(e):console.warn(e))}Jn.debug=Yf;Jn.warn=Xf});var tr=g(er=>{"use strict";var Zi=P(),Ws=I(),Xi="<<",Qi={identify:t=>t===Xi||typeof t=="symbol"&&t.description===Xi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ws.Scalar(Symbol(Xi)),{addToJSMap:zs}),stringify:()=>Xi},Qf=(t,e)=>(Qi.identify(e)||Zi.isScalar(e)&&(!e.type||e.type===Ws.Scalar.PLAIN)&&Qi.identify(e.value))&&t?.doc.schema.tags.some(i=>i.tag===Qi.tag&&i.default);function zs(t,e,i){let r=Js(t,i);if(Zi.isSeq(r))for(let n of r.items)Un(t,e,n);else if(Array.isArray(r))for(let n of r)Un(t,e,n);else Un(t,e,r)}function Un(t,e,i){let r=Js(t,i);if(!Zi.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.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 Js(t,e){return t&&Zi.isAlias(e)?e.resolve(t.doc,t):e}er.addMergeToJSMap=zs;er.isMergeKey=Qf;er.merge=Qi});var Yn=g(Ks=>{"use strict";var Zf=Gn(),Gs=tr(),eh=Vt(),Us=P(),Kn=_e();function th(t,e,{key:i,value:r}){if(Us.isNode(i)&&i.addToJSMap)i.addToJSMap(t,e,r);else if(Gs.isMergeKey(t,i))Gs.addMergeToJSMap(t,e,r);else{let n=Kn.toJS(i,"",t);if(e instanceof Map)e.set(n,Kn.toJS(r,n,t));else if(e instanceof Set)e.add(n);else{let a=ih(i,n,t),o=Kn.toJS(r,a,t);a in e?Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[a]=o}}return e}function ih(t,e,i){if(e===null)return"";if(typeof e!="object")return String(e);if(Us.isNode(t)&&i?.doc){let r=eh.createStringifyContext(i.doc,{});r.anchors=new Set;for(let a of i.anchors.keys())r.anchors.add(a.anchor);r.inFlow=!0,r.inStringifyKey=!0;let n=t.toString(r);if(!i.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Zf.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return n}return JSON.stringify(e)}Ks.addPairToJSMap=th});var $e=g(Xn=>{"use strict";var Ys=Dt(),rh=Vs(),nh=Yn(),ir=P();function ah(t,e,i){let r=Ys.createNode(t,void 0,i),n=Ys.createNode(e,void 0,i);return new rr(r,n)}var rr=class t{constructor(e,i=null){Object.defineProperty(this,ir.NODE_TYPE,{value:ir.PAIR}),this.key=e,this.value=i}clone(e){let{key:i,value:r}=this;return ir.isNode(i)&&(i=i.clone(e)),ir.isNode(r)&&(r=r.clone(e)),new t(i,r)}toJSON(e,i){let r=i?.mapAsMap?new Map:{};return nh.addPairToJSMap(i,r,this)}toString(e,i,r){return e?.doc?rh.stringifyPair(this,e,i,r):JSON.stringify(this)}};Xn.Pair=rr;Xn.createPair=ah});var Qn=g(Qs=>{"use strict";var Ge=P(),Xs=Vt(),nr=Bt();function oh(t,e,i){return(e.inFlow??t.flow?ch:sh)(t,e,i)}function sh({comment:t,items:e},i,{blockItemPrefix:r,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=i,f=Object.assign({},i,{indent:a,type:null}),d=!1,u=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(Ge.isNode(h))!d&&h.spaceBefore&&u.push(""),ar(i,u,h.commentBefore,d),h.comment&&(m=h.comment);else if(Ge.isPair(h)){let y=Ge.isNode(h.key)?h.key:null;y&&(!d&&y.spaceBefore&&u.push(""),ar(i,u,y.commentBefore,d))}d=!1;let w=Xs.stringify(h,f,()=>m=null,()=>d=!0);m&&(w+=nr.lineComment(w,a,l(m))),d&&m&&(d=!1),u.push(r+w)}let p;if(u.length===0)p=n.start+n.end;else{p=u[0];for(let v=1;v<u.length;++v){let h=u[v];p+=h?`
47
+ `)&&(E="");return m+=E+S,i.inFlow?k&&r&&r():b&&!k?m+=Gt.lineComment(m,i.indent,l(b)):h&&n&&n(),m}Vs.stringifyPair=Qf});var Kn=g(Un=>{"use strict";var Ws=$i("process");function Zf(t,...e){t==="debug"&&console.log(...e)}function eh(t,e){(t==="debug"||t==="warn")&&(typeof Ws.emitWarning=="function"?Ws.emitWarning(e):console.warn(e))}Un.debug=Zf;Un.warn=eh});var ir=g(tr=>{"use strict";var er=P(),zs=I(),Qi="<<",Zi={identify:t=>t===Qi||typeof t=="symbol"&&t.description===Qi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new zs.Scalar(Symbol(Qi)),{addToJSMap:Js}),stringify:()=>Qi},th=(t,e)=>(Zi.identify(e)||er.isScalar(e)&&(!e.type||e.type===zs.Scalar.PLAIN)&&Zi.identify(e.value))&&t?.doc.schema.tags.some(i=>i.tag===Zi.tag&&i.default);function Js(t,e,i){let r=Gs(t,i);if(er.isSeq(r))for(let n of r.items)Yn(t,e,n);else if(Array.isArray(r))for(let n of r)Yn(t,e,n);else Yn(t,e,r)}function Yn(t,e,i){let r=Gs(t,i);if(!er.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.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 Gs(t,e){return t&&er.isAlias(e)?e.resolve(t.doc,t):e}tr.addMergeToJSMap=Js;tr.isMergeKey=th;tr.merge=Zi});var Qn=g(Ys=>{"use strict";var ih=Kn(),Us=ir(),rh=Jt(),Ks=P(),Xn=Ie();function nh(t,e,{key:i,value:r}){if(Ks.isNode(i)&&i.addToJSMap)i.addToJSMap(t,e,r);else if(Us.isMergeKey(t,i))Us.addMergeToJSMap(t,e,r);else{let n=Xn.toJS(i,"",t);if(e instanceof Map)e.set(n,Xn.toJS(r,n,t));else if(e instanceof Set)e.add(n);else{let a=ah(i,n,t),o=Xn.toJS(r,a,t);a in e?Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[a]=o}}return e}function ah(t,e,i){if(e===null)return"";if(typeof e!="object")return String(e);if(Ks.isNode(t)&&i?.doc){let r=rh.createStringifyContext(i.doc,{});r.anchors=new Set;for(let a of i.anchors.keys())r.anchors.add(a.anchor);r.inFlow=!0,r.inStringifyKey=!0;let n=t.toString(r);if(!i.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),ih.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return n}return JSON.stringify(e)}Ys.addPairToJSMap=nh});var He=g(Zn=>{"use strict";var Xs=Ft(),oh=qs(),sh=Qn(),rr=P();function ch(t,e,i){let r=Xs.createNode(t,void 0,i),n=Xs.createNode(e,void 0,i);return new nr(r,n)}var nr=class t{constructor(e,i=null){Object.defineProperty(this,rr.NODE_TYPE,{value:rr.PAIR}),this.key=e,this.value=i}clone(e){let{key:i,value:r}=this;return rr.isNode(i)&&(i=i.clone(e)),rr.isNode(r)&&(r=r.clone(e)),new t(i,r)}toJSON(e,i){let r=i?.mapAsMap?new Map:{};return sh.addPairToJSMap(i,r,this)}toString(e,i,r){return e?.doc?oh.stringifyPair(this,e,i,r):JSON.stringify(this)}};Zn.Pair=nr;Zn.createPair=ch});var ea=g(Zs=>{"use strict";var Ge=P(),Qs=Jt(),ar=Vt();function lh(t,e,i){return(e.inFlow??t.flow?dh:uh)(t,e,i)}function uh({comment:t,items:e},i,{blockItemPrefix:r,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=i,f=Object.assign({},i,{indent:a,type:null}),d=!1,u=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(Ge.isNode(h))!d&&h.spaceBefore&&u.push(""),or(i,u,h.commentBefore,d),h.comment&&(m=h.comment);else if(Ge.isPair(h)){let y=Ge.isNode(h.key)?h.key:null;y&&(!d&&y.spaceBefore&&u.push(""),or(i,u,y.commentBefore,d))}d=!1;let w=Qs.stringify(h,f,()=>m=null,()=>d=!0);m&&(w+=ar.lineComment(w,a,l(m))),d&&m&&(d=!1),u.push(r+w)}let p;if(u.length===0)p=n.start+n.end;else{p=u[0];for(let v=1;v<u.length;++v){let h=u[v];p+=h?`
48
48
  ${c}${h}`:`
49
49
  `}}return t?(p+=`
50
- `+nr.indentComment(l(t),c),s&&s()):d&&o&&o(),p}function ch({items:t},e,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;r+=a;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,f=0,d=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(Ge.isNode(h))h.spaceBefore&&d.push(""),ar(e,d,h.commentBefore,!1),h.comment&&(m=h.comment);else if(Ge.isPair(h)){let y=Ge.isNode(h.key)?h.key:null;y&&(y.spaceBefore&&d.push(""),ar(e,d,y.commentBefore,!1),y.comment&&(l=!0));let b=Ge.isNode(h.value)?h.value:null;b?(b.comment&&(m=b.comment),b.commentBefore&&(l=!0)):h.value==null&&y?.comment&&(m=y.comment)}m&&(l=!0);let w=Xs.stringify(h,c,()=>m=null);l||(l=d.length>f||w.includes(`
51
- `)),v<t.length-1?w+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=d.reduce((y,b)=>y+b.length+2,2)+(w.length+2)>e.options.lineWidth)),l&&(w+=",")),m&&(w+=nr.lineComment(w,r,s(m))),d.push(w),f=d.length}let{start:u,end:p}=i;if(d.length===0)return u+p;if(!l){let v=d.reduce((h,m)=>h+m.length+2,2);l=e.options.lineWidth>0&&v>e.options.lineWidth}if(l){let v=u;for(let h of d)v+=h?`
50
+ `+ar.indentComment(l(t),c),s&&s()):d&&o&&o(),p}function dh({items:t},e,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;r+=a;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,f=0,d=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(Ge.isNode(h))h.spaceBefore&&d.push(""),or(e,d,h.commentBefore,!1),h.comment&&(m=h.comment);else if(Ge.isPair(h)){let y=Ge.isNode(h.key)?h.key:null;y&&(y.spaceBefore&&d.push(""),or(e,d,y.commentBefore,!1),y.comment&&(l=!0));let b=Ge.isNode(h.value)?h.value:null;b?(b.comment&&(m=b.comment),b.commentBefore&&(l=!0)):h.value==null&&y?.comment&&(m=y.comment)}m&&(l=!0);let w=Qs.stringify(h,c,()=>m=null);l||(l=d.length>f||w.includes(`
51
+ `)),v<t.length-1?w+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=d.reduce((y,b)=>y+b.length+2,2)+(w.length+2)>e.options.lineWidth)),l&&(w+=",")),m&&(w+=ar.lineComment(w,r,s(m))),d.push(w),f=d.length}let{start:u,end:p}=i;if(d.length===0)return u+p;if(!l){let v=d.reduce((h,m)=>h+m.length+2,2);l=e.options.lineWidth>0&&v>e.options.lineWidth}if(l){let v=u;for(let h of d)v+=h?`
52
52
  ${a}${n}${h}`:`
53
53
  `;return`${v}
54
- ${n}${p}`}else return`${u}${o}${d.join(" ")}${o}${p}`}function ar({indent:t,options:{commentString:e}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let a=nr.indentComment(e(r),t);i.push(a.trimStart())}}Qs.stringifyCollection=oh});var He=g(ea=>{"use strict";var lh=Qn(),uh=Yn(),dh=zi(),Oe=P(),or=$e(),fh=I();function Wt(t,e){let i=Oe.isScalar(e)?e.value:e;for(let r of t)if(Oe.isPair(r)&&(r.key===e||r.key===i||Oe.isScalar(r.key)&&r.key.value===i))return r}var Zn=class extends dh.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Oe.MAP,e),this.items=[]}static from(e,i,r){let{keepUndefined:n,replacer:a}=r,o=new this(e),s=(c,l)=>{if(typeof a=="function")l=a.call(i,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(or.createPair(c,l,r))};if(i instanceof Map)for(let[c,l]of i)s(c,l);else if(i&&typeof i=="object")for(let c of Object.keys(i))s(c,i[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,i){let r;Oe.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new or.Pair(e,e?.value):r=new or.Pair(e.key,e.value);let n=Wt(this.items,r.key),a=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);Oe.isScalar(n.value)&&fh.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(a){let o=this.items.findIndex(s=>a(r,s)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let i=Wt(this.items,e);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(e,i){let n=Wt(this.items,e)?.value;return(!i&&Oe.isScalar(n)?n.value:n)??void 0}has(e){return!!Wt(this.items,e)}set(e,i){this.add(new or.Pair(e,i),!0)}toJSON(e,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let a of this.items)uh.addPairToJSMap(i,n,a);return n}toString(e,i,r){if(!e)return JSON.stringify(this);for(let n of this.items)if(!Oe.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})),lh.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:i})}};ea.YAMLMap=Zn;ea.findPair=Wt});var ut=g(ec=>{"use strict";var hh=P(),Zs=He(),ph={collection:"map",default:!0,nodeClass:Zs.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return hh.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,i)=>Zs.YAMLMap.from(t,e,i)};ec.map=ph});var De=g(tc=>{"use strict";var mh=Dt(),vh=Qn(),gh=zi(),cr=P(),wh=I(),yh=_e(),ta=class extends gh.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(cr.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let i=sr(e);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(e,i){let r=sr(e);if(typeof r!="number")return;let n=this.items[r];return!i&&cr.isScalar(n)?n.value:n}has(e){let i=sr(e);return typeof i=="number"&&i<this.items.length}set(e,i){let r=sr(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[r];cr.isScalar(n)&&wh.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(e,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let a of this.items)r.push(yh.toJS(a,String(n++),i));return r}toString(e,i,r){return e?vh.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(e,i,r){let{replacer:n}=r,a=new this(e);if(i&&Symbol.iterator in Object(i)){let o=0;for(let s of i){if(typeof n=="function"){let c=i instanceof Set?s:String(o++);s=n.call(i,c,s)}a.items.push(mh.createNode(s,void 0,r))}}return a}};function sr(t){let e=cr.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}tc.YAMLSeq=ta});var dt=g(rc=>{"use strict";var Nh=P(),ic=De(),bh={collection:"seq",default:!0,nodeClass:ic.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Nh.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,i)=>ic.YAMLSeq.from(t,e,i)};rc.seq=bh});var zt=g(nc=>{"use strict";var kh=Ft(),Sh={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,i,r){return e=Object.assign({actualString:!0},e),kh.stringifyString(t,e,i,r)}};nc.string=Sh});var lr=g(sc=>{"use strict";var ac=I(),oc={identify:t=>t==null,createNode:()=>new ac.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ac.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&oc.test.test(t)?t:e.options.nullStr};sc.nullTag=oc});var ia=g(lc=>{"use strict";var Eh=I(),cc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Eh.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},i){if(t&&cc.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?i.options.trueStr:i.options.falseStr}};lc.boolTag=cc});var ft=g(uc=>{"use strict";function Ph({format:t,minFractionDigits:e,tag:i,value:r}){if(typeof r=="bigint")return String(r);let n=typeof r=="number"?r:Number(r);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!i||i==="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}uc.stringifyNumber=Ph});var na=g(ur=>{"use strict";var xh=I(),ra=ft(),Rh={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:ra.stringifyNumber},Ch={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():ra.stringifyNumber(t)}},Ah={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 xh.Scalar(parseFloat(t)),i=t.indexOf(".");return i!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-i-1),e},stringify:ra.stringifyNumber};ur.float=Ah;ur.floatExp=Ch;ur.floatNaN=Rh});var oa=g(fr=>{"use strict";var dc=ft(),dr=t=>typeof t=="bigint"||Number.isInteger(t),aa=(t,e,i,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),i);function fc(t,e,i){let{value:r}=t;return dr(r)&&r>=0?i+r.toString(e):dc.stringifyNumber(t)}var _h={identify:t=>dr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,i)=>aa(t,2,8,i),stringify:t=>fc(t,8,"0o")},Th={identify:dr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,i)=>aa(t,0,10,i),stringify:dc.stringifyNumber},Ih={identify:t=>dr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,i)=>aa(t,2,16,i),stringify:t=>fc(t,16,"0x")};fr.int=Th;fr.intHex=Ih;fr.intOct=_h});var pc=g(hc=>{"use strict";var jh=ut(),$h=lr(),Oh=dt(),Hh=zt(),Dh=ia(),sa=na(),ca=oa(),Bh=[jh.map,Oh.seq,Hh.string,$h.nullTag,Dh.boolTag,ca.intOct,ca.int,ca.intHex,sa.floatNaN,sa.floatExp,sa.float];hc.schema=Bh});var gc=g(vc=>{"use strict";var Lh=I(),Mh=ut(),Fh=dt();function mc(t){return typeof t=="bigint"||Number.isInteger(t)}var hr=({value:t})=>JSON.stringify(t),Vh=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:hr},{identify:t=>t==null,createNode:()=>new Lh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:hr},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:hr},{identify:mc,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:i})=>i?BigInt(t):parseInt(t,10),stringify:({value:t})=>mc(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:hr}],qh={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Wh=[Mh.map,Fh.seq].concat(Vh,qh);vc.schema=Wh});var ua=g(wc=>{"use strict";var Jt=Ii("buffer"),la=I(),zh=Ft(),Jh={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Jt.Buffer=="function")return Jt.Buffer.from(t,"base64");if(typeof atob=="function"){let i=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(i.length);for(let n=0;n<i.length;++n)r[n]=i.charCodeAt(n);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:i},r,n,a){if(!i)return"";let o=i,s;if(typeof Jt.Buffer=="function")s=o instanceof Jt.Buffer?o.toString("base64"):Jt.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=la.Scalar.BLOCK_LITERAL),e!==la.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(s.length/c),f=new Array(l);for(let d=0,u=0;d<l;++d,u+=c)f[d]=s.substr(u,c);s=f.join(e===la.Scalar.BLOCK_LITERAL?`
55
- `:" ")}return zh.stringifyString({comment:t,type:e,value:s},r,n,a)}};wc.binary=Jh});var vr=g(mr=>{"use strict";var pr=P(),da=$e(),Gh=I(),Uh=De();function yc(t,e){if(pr.isSeq(t))for(let i=0;i<t.items.length;++i){let r=t.items[i];if(!pr.isPair(r)){if(pr.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let n=r.items[0]||new da.Pair(new Gh.Scalar(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
54
+ ${n}${p}`}else return`${u}${o}${d.join(" ")}${o}${p}`}function or({indent:t,options:{commentString:e}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let a=ar.indentComment(e(r),t);i.push(a.trimStart())}}Zs.stringifyCollection=lh});var Be=g(ia=>{"use strict";var fh=ea(),hh=Qn(),ph=Ji(),De=P(),sr=He(),mh=I();function Ut(t,e){let i=De.isScalar(e)?e.value:e;for(let r of t)if(De.isPair(r)&&(r.key===e||r.key===i||De.isScalar(r.key)&&r.key.value===i))return r}var ta=class extends ph.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(De.MAP,e),this.items=[]}static from(e,i,r){let{keepUndefined:n,replacer:a}=r,o=new this(e),s=(c,l)=>{if(typeof a=="function")l=a.call(i,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(sr.createPair(c,l,r))};if(i instanceof Map)for(let[c,l]of i)s(c,l);else if(i&&typeof i=="object")for(let c of Object.keys(i))s(c,i[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,i){let r;De.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new sr.Pair(e,e?.value):r=new sr.Pair(e.key,e.value);let n=Ut(this.items,r.key),a=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);De.isScalar(n.value)&&mh.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(a){let o=this.items.findIndex(s=>a(r,s)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let i=Ut(this.items,e);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(e,i){let n=Ut(this.items,e)?.value;return(!i&&De.isScalar(n)?n.value:n)??void 0}has(e){return!!Ut(this.items,e)}set(e,i){this.add(new sr.Pair(e,i),!0)}toJSON(e,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let a of this.items)hh.addPairToJSMap(i,n,a);return n}toString(e,i,r){if(!e)return JSON.stringify(this);for(let n of this.items)if(!De.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})),fh.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:i})}};ia.YAMLMap=ta;ia.findPair=Ut});var dt=g(tc=>{"use strict";var vh=P(),ec=Be(),gh={collection:"map",default:!0,nodeClass:ec.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return vh.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,i)=>ec.YAMLMap.from(t,e,i)};tc.map=gh});var Le=g(ic=>{"use strict";var wh=Ft(),yh=ea(),Nh=Ji(),lr=P(),bh=I(),kh=Ie(),ra=class extends Nh.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(lr.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let i=cr(e);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(e,i){let r=cr(e);if(typeof r!="number")return;let n=this.items[r];return!i&&lr.isScalar(n)?n.value:n}has(e){let i=cr(e);return typeof i=="number"&&i<this.items.length}set(e,i){let r=cr(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[r];lr.isScalar(n)&&bh.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(e,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let a of this.items)r.push(kh.toJS(a,String(n++),i));return r}toString(e,i,r){return e?yh.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(e,i,r){let{replacer:n}=r,a=new this(e);if(i&&Symbol.iterator in Object(i)){let o=0;for(let s of i){if(typeof n=="function"){let c=i instanceof Set?s:String(o++);s=n.call(i,c,s)}a.items.push(wh.createNode(s,void 0,r))}}return a}};function cr(t){let e=lr.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}ic.YAMLSeq=ra});var ft=g(nc=>{"use strict";var Sh=P(),rc=Le(),Eh={collection:"seq",default:!0,nodeClass:rc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Sh.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,i)=>rc.YAMLSeq.from(t,e,i)};nc.seq=Eh});var Kt=g(ac=>{"use strict";var Ph=zt(),xh={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,i,r){return e=Object.assign({actualString:!0},e),Ph.stringifyString(t,e,i,r)}};ac.string=xh});var ur=g(cc=>{"use strict";var oc=I(),sc={identify:t=>t==null,createNode:()=>new oc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new oc.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&sc.test.test(t)?t:e.options.nullStr};cc.nullTag=sc});var na=g(uc=>{"use strict";var Ch=I(),lc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Ch.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},i){if(t&&lc.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?i.options.trueStr:i.options.falseStr}};uc.boolTag=lc});var ht=g(dc=>{"use strict";function Rh({format:t,minFractionDigits:e,tag:i,value:r}){if(typeof r=="bigint")return String(r);let n=typeof r=="number"?r:Number(r);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!i||i==="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}dc.stringifyNumber=Rh});var oa=g(dr=>{"use strict";var Ah=I(),aa=ht(),_h={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:aa.stringifyNumber},Th={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():aa.stringifyNumber(t)}},Ih={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 Ah.Scalar(parseFloat(t)),i=t.indexOf(".");return i!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-i-1),e},stringify:aa.stringifyNumber};dr.float=Ih;dr.floatExp=Th;dr.floatNaN=_h});var ca=g(hr=>{"use strict";var fc=ht(),fr=t=>typeof t=="bigint"||Number.isInteger(t),sa=(t,e,i,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),i);function hc(t,e,i){let{value:r}=t;return fr(r)&&r>=0?i+r.toString(e):fc.stringifyNumber(t)}var jh={identify:t=>fr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,i)=>sa(t,2,8,i),stringify:t=>hc(t,8,"0o")},$h={identify:fr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,i)=>sa(t,0,10,i),stringify:fc.stringifyNumber},Oh={identify:t=>fr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,i)=>sa(t,2,16,i),stringify:t=>hc(t,16,"0x")};hr.int=$h;hr.intHex=Oh;hr.intOct=jh});var mc=g(pc=>{"use strict";var Hh=dt(),Dh=ur(),Bh=ft(),Lh=Kt(),Mh=na(),la=oa(),ua=ca(),Fh=[Hh.map,Bh.seq,Lh.string,Dh.nullTag,Mh.boolTag,ua.intOct,ua.int,ua.intHex,la.floatNaN,la.floatExp,la.float];pc.schema=Fh});var wc=g(gc=>{"use strict";var Vh=I(),qh=dt(),Wh=ft();function vc(t){return typeof t=="bigint"||Number.isInteger(t)}var pr=({value:t})=>JSON.stringify(t),zh=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:pr},{identify:t=>t==null,createNode:()=>new Vh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:pr},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:pr},{identify:vc,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:i})=>i?BigInt(t):parseInt(t,10),stringify:({value:t})=>vc(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:pr}],Jh={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Gh=[qh.map,Wh.seq].concat(zh,Jh);gc.schema=Gh});var fa=g(yc=>{"use strict";var Yt=$i("buffer"),da=I(),Uh=zt(),Kh={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Yt.Buffer=="function")return Yt.Buffer.from(t,"base64");if(typeof atob=="function"){let i=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(i.length);for(let n=0;n<i.length;++n)r[n]=i.charCodeAt(n);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:i},r,n,a){if(!i)return"";let o=i,s;if(typeof Yt.Buffer=="function")s=o instanceof Yt.Buffer?o.toString("base64"):Yt.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=da.Scalar.BLOCK_LITERAL),e!==da.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(s.length/c),f=new Array(l);for(let d=0,u=0;d<l;++d,u+=c)f[d]=s.substr(u,c);s=f.join(e===da.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return Uh.stringifyString({comment:t,type:e,value:s},r,n,a)}};yc.binary=Kh});var gr=g(vr=>{"use strict";var mr=P(),ha=He(),Yh=I(),Xh=Le();function Nc(t,e){if(mr.isSeq(t))for(let i=0;i<t.items.length;++i){let r=t.items[i];if(!mr.isPair(r)){if(mr.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let n=r.items[0]||new ha.Pair(new Yh.Scalar(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
56
56
  ${n.key.commentBefore}`:r.commentBefore),r.comment){let a=n.value??n.key;a.comment=a.comment?`${r.comment}
57
- ${a.comment}`:r.comment}r=n}t.items[i]=pr.isPair(r)?r:new da.Pair(r)}}else e("Expected a sequence for this tag");return t}function Nc(t,e,i){let{replacer:r}=i,n=new Uh.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 r=="function"&&(o=r.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(da.createPair(s,c,i))}return n}var Kh={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:yc,createNode:Nc};mr.createPairs=Nc;mr.pairs=Kh;mr.resolvePairs=yc});var pa=g(ha=>{"use strict";var bc=P(),fa=_e(),Gt=He(),Yh=De(),kc=vr(),Ue=class t extends Yh.YAMLSeq{constructor(){super(),this.add=Gt.YAMLMap.prototype.add.bind(this),this.delete=Gt.YAMLMap.prototype.delete.bind(this),this.get=Gt.YAMLMap.prototype.get.bind(this),this.has=Gt.YAMLMap.prototype.has.bind(this),this.set=Gt.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,i){if(!i)return super.toJSON(e);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let a,o;if(bc.isPair(n)?(a=fa.toJS(n.key,"",i),o=fa.toJS(n.value,a,i)):a=fa.toJS(n,"",i),r.has(a))throw new Error("Ordered maps must not include duplicate keys");r.set(a,o)}return r}static from(e,i,r){let n=kc.createPairs(e,i,r),a=new this;return a.items=n.items,a}};Ue.tag="tag:yaml.org,2002:omap";var Xh={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ue,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let i=kc.resolvePairs(t,e),r=[];for(let{key:n}of i.items)bc.isScalar(n)&&(r.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new Ue,i)},createNode:(t,e,i)=>Ue.from(t,e,i)};ha.YAMLOMap=Ue;ha.omap=Xh});var Rc=g(ma=>{"use strict";var Sc=I();function Ec({value:t,source:e},i){return e&&(t?Pc:xc).test.test(e)?e:t?i.options.trueStr:i.options.falseStr}var Pc={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 Sc.Scalar(!0),stringify:Ec},xc={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 Sc.Scalar(!1),stringify:Ec};ma.falseTag=xc;ma.trueTag=Pc});var Cc=g(gr=>{"use strict";var Qh=I(),va=ft(),Zh={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:va.stringifyNumber},ep={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():va.stringifyNumber(t)}},tp={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 Qh.Scalar(parseFloat(t.replace(/_/g,""))),i=t.indexOf(".");if(i!==-1){let r=t.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:va.stringifyNumber};gr.float=tp;gr.floatExp=ep;gr.floatNaN=Zh});var _c=g(Kt=>{"use strict";var Ac=ft(),Ut=t=>typeof t=="bigint"||Number.isInteger(t);function wr(t,e,i,{intAsBigInt:r}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(i){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,i);return n==="-"?-1*a:a}function ga(t,e,i){let{value:r}=t;if(Ut(r)){let n=r.toString(e);return r<0?"-"+i+n.substr(1):i+n}return Ac.stringifyNumber(t)}var ip={identify:Ut,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,i)=>wr(t,2,2,i),stringify:t=>ga(t,2,"0b")},rp={identify:Ut,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,i)=>wr(t,1,8,i),stringify:t=>ga(t,8,"0")},np={identify:Ut,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,i)=>wr(t,0,10,i),stringify:Ac.stringifyNumber},ap={identify:Ut,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,i)=>wr(t,2,16,i),stringify:t=>ga(t,16,"0x")};Kt.int=np;Kt.intBin=ip;Kt.intHex=ap;Kt.intOct=rp});var ya=g(wa=>{"use strict";var br=P(),yr=$e(),Nr=He(),Ke=class t extends Nr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let i;br.isPair(e)?i=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?i=new yr.Pair(e.key,null):i=new yr.Pair(e,null),Nr.findPair(this.items,i.key)||this.items.push(i)}get(e,i){let r=Nr.findPair(this.items,e);return!i&&br.isPair(r)?br.isScalar(r.key)?r.key.value:r.key:r}set(e,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=Nr.findPair(this.items,e);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new yr.Pair(e))}toJSON(e,i){return super.toJSON(e,i,Set)}toString(e,i,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(e,i,r){let{replacer:n}=r,a=new this(e);if(i&&Symbol.iterator in Object(i))for(let o of i)typeof n=="function"&&(o=n.call(i,o,o)),a.items.push(yr.createPair(o,null,r));return a}};Ke.tag="tag:yaml.org,2002:set";var op={collection:"map",identify:t=>t instanceof Set,nodeClass:Ke,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,i)=>Ke.from(t,e,i),resolve(t,e){if(br.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Ke,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};wa.YAMLSet=Ke;wa.set=op});var ba=g(kr=>{"use strict";var sp=ft();function Na(t,e){let i=t[0],r=i==="-"||i==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=r.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return i==="-"?n(-1)*a:a}function Tc(t){let{value:e}=t,i=o=>o;if(typeof e=="bigint")i=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return sp.stringifyNumber(t);let r="";e<0&&(r="-",e*=i(-1));let n=i(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))),r+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var cp={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:i})=>Na(t,i),stringify:Tc},lp={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=>Na(t,!1),stringify:Tc},Ic={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(Ic.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-1,n,a||0,o||0,s||0,c),f=e[8];if(f&&f!=="Z"){let d=Na(f,!1);Math.abs(d)<30&&(d*=60),l-=6e4*d}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};kr.floatTime=lp;kr.intTime=cp;kr.timestamp=Ic});var Oc=g($c=>{"use strict";var up=ut(),dp=lr(),fp=dt(),hp=zt(),pp=ua(),jc=Rc(),ka=Cc(),Sr=_c(),mp=tr(),vp=pa(),gp=vr(),wp=ya(),Sa=ba(),yp=[up.map,fp.seq,hp.string,dp.nullTag,jc.trueTag,jc.falseTag,Sr.intBin,Sr.intOct,Sr.int,Sr.intHex,ka.floatNaN,ka.floatExp,ka.float,pp.binary,mp.merge,vp.omap,gp.pairs,wp.set,Sa.intTime,Sa.floatTime,Sa.timestamp];$c.schema=yp});var zc=g(xa=>{"use strict";var Lc=ut(),Np=lr(),Mc=dt(),bp=zt(),kp=ia(),Ea=na(),Pa=oa(),Sp=pc(),Ep=gc(),Fc=ua(),Yt=tr(),Vc=pa(),qc=vr(),Hc=Oc(),Wc=ya(),Er=ba(),Dc=new Map([["core",Sp.schema],["failsafe",[Lc.map,Mc.seq,bp.string]],["json",Ep.schema],["yaml11",Hc.schema],["yaml-1.1",Hc.schema]]),Bc={binary:Fc.binary,bool:kp.boolTag,float:Ea.float,floatExp:Ea.floatExp,floatNaN:Ea.floatNaN,floatTime:Er.floatTime,int:Pa.int,intHex:Pa.intHex,intOct:Pa.intOct,intTime:Er.intTime,map:Lc.map,merge:Yt.merge,null:Np.nullTag,omap:Vc.omap,pairs:qc.pairs,seq:Mc.seq,set:Wc.set,timestamp:Er.timestamp},Pp={"tag:yaml.org,2002:binary":Fc.binary,"tag:yaml.org,2002:merge":Yt.merge,"tag:yaml.org,2002:omap":Vc.omap,"tag:yaml.org,2002:pairs":qc.pairs,"tag:yaml.org,2002:set":Wc.set,"tag:yaml.org,2002:timestamp":Er.timestamp};function xp(t,e,i){let r=Dc.get(e);if(r&&!t)return i&&!r.includes(Yt.merge)?r.concat(Yt.merge):r.slice();let n=r;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Dc.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 i&&(n=n.concat(Yt.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Bc[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Bc).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}xa.coreKnownTags=Pp;xa.getTags=xp});var Aa=g(Jc=>{"use strict";var Ra=P(),Rp=ut(),Cp=dt(),Ap=zt(),Pr=zc(),_p=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Ca=class t{constructor({compat:e,customTags:i,merge:r,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Pr.getTags(e,"compat"):e?Pr.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Pr.coreKnownTags:{},this.tags=Pr.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,Ra.MAP,{value:Rp.map}),Object.defineProperty(this,Ra.SCALAR,{value:Ap.string}),Object.defineProperty(this,Ra.SEQ,{value:Cp.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?_p:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Jc.Schema=Ca});var Uc=g(Gc=>{"use strict";var Tp=P(),_a=Vt(),Xt=Bt();function Ip(t,e){let i=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(i.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&i.push("---");let n=_a.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){i.length!==1&&i.unshift("");let c=a(t.commentBefore);i.unshift(Xt.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(Tp.isNode(t.contents)){if(t.contents.spaceBefore&&r&&i.push(""),t.contents.commentBefore){let f=a(t.contents.commentBefore);i.push(Xt.indentComment(f,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=_a.stringify(t.contents,n,()=>s=null,c);s&&(l+=Xt.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(_a.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
- `)?(i.push("..."),i.push(Xt.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&i[i.length-1]!==""&&i.push(""),i.push(Xt.indentComment(a(c),"")))}return i.join(`
57
+ ${a.comment}`:r.comment}r=n}t.items[i]=mr.isPair(r)?r:new ha.Pair(r)}}else e("Expected a sequence for this tag");return t}function bc(t,e,i){let{replacer:r}=i,n=new Xh.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 r=="function"&&(o=r.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(ha.createPair(s,c,i))}return n}var Qh={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Nc,createNode:bc};vr.createPairs=bc;vr.pairs=Qh;vr.resolvePairs=Nc});var va=g(ma=>{"use strict";var kc=P(),pa=Ie(),Xt=Be(),Zh=Le(),Sc=gr(),Ue=class t extends Zh.YAMLSeq{constructor(){super(),this.add=Xt.YAMLMap.prototype.add.bind(this),this.delete=Xt.YAMLMap.prototype.delete.bind(this),this.get=Xt.YAMLMap.prototype.get.bind(this),this.has=Xt.YAMLMap.prototype.has.bind(this),this.set=Xt.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,i){if(!i)return super.toJSON(e);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let a,o;if(kc.isPair(n)?(a=pa.toJS(n.key,"",i),o=pa.toJS(n.value,a,i)):a=pa.toJS(n,"",i),r.has(a))throw new Error("Ordered maps must not include duplicate keys");r.set(a,o)}return r}static from(e,i,r){let n=Sc.createPairs(e,i,r),a=new this;return a.items=n.items,a}};Ue.tag="tag:yaml.org,2002:omap";var ep={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ue,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let i=Sc.resolvePairs(t,e),r=[];for(let{key:n}of i.items)kc.isScalar(n)&&(r.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new Ue,i)},createNode:(t,e,i)=>Ue.from(t,e,i)};ma.YAMLOMap=Ue;ma.omap=ep});var Rc=g(ga=>{"use strict";var Ec=I();function Pc({value:t,source:e},i){return e&&(t?xc:Cc).test.test(e)?e:t?i.options.trueStr:i.options.falseStr}var xc={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 Ec.Scalar(!0),stringify:Pc},Cc={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 Ec.Scalar(!1),stringify:Pc};ga.falseTag=Cc;ga.trueTag=xc});var Ac=g(wr=>{"use strict";var tp=I(),wa=ht(),ip={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:wa.stringifyNumber},rp={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():wa.stringifyNumber(t)}},np={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 tp.Scalar(parseFloat(t.replace(/_/g,""))),i=t.indexOf(".");if(i!==-1){let r=t.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:wa.stringifyNumber};wr.float=np;wr.floatExp=rp;wr.floatNaN=ip});var Tc=g(Zt=>{"use strict";var _c=ht(),Qt=t=>typeof t=="bigint"||Number.isInteger(t);function yr(t,e,i,{intAsBigInt:r}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(i){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,i);return n==="-"?-1*a:a}function ya(t,e,i){let{value:r}=t;if(Qt(r)){let n=r.toString(e);return r<0?"-"+i+n.substr(1):i+n}return _c.stringifyNumber(t)}var ap={identify:Qt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,i)=>yr(t,2,2,i),stringify:t=>ya(t,2,"0b")},op={identify:Qt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,i)=>yr(t,1,8,i),stringify:t=>ya(t,8,"0")},sp={identify:Qt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,i)=>yr(t,0,10,i),stringify:_c.stringifyNumber},cp={identify:Qt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,i)=>yr(t,2,16,i),stringify:t=>ya(t,16,"0x")};Zt.int=sp;Zt.intBin=ap;Zt.intHex=cp;Zt.intOct=op});var ba=g(Na=>{"use strict";var kr=P(),Nr=He(),br=Be(),Ke=class t extends br.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let i;kr.isPair(e)?i=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?i=new Nr.Pair(e.key,null):i=new Nr.Pair(e,null),br.findPair(this.items,i.key)||this.items.push(i)}get(e,i){let r=br.findPair(this.items,e);return!i&&kr.isPair(r)?kr.isScalar(r.key)?r.key.value:r.key:r}set(e,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=br.findPair(this.items,e);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new Nr.Pair(e))}toJSON(e,i){return super.toJSON(e,i,Set)}toString(e,i,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(e,i,r){let{replacer:n}=r,a=new this(e);if(i&&Symbol.iterator in Object(i))for(let o of i)typeof n=="function"&&(o=n.call(i,o,o)),a.items.push(Nr.createPair(o,null,r));return a}};Ke.tag="tag:yaml.org,2002:set";var lp={collection:"map",identify:t=>t instanceof Set,nodeClass:Ke,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,i)=>Ke.from(t,e,i),resolve(t,e){if(kr.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Ke,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Na.YAMLSet=Ke;Na.set=lp});var Sa=g(Sr=>{"use strict";var up=ht();function ka(t,e){let i=t[0],r=i==="-"||i==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=r.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return i==="-"?n(-1)*a:a}function Ic(t){let{value:e}=t,i=o=>o;if(typeof e=="bigint")i=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return up.stringifyNumber(t);let r="";e<0&&(r="-",e*=i(-1));let n=i(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))),r+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var dp={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:i})=>ka(t,i),stringify:Ic},fp={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=>ka(t,!1),stringify:Ic},jc={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(jc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-1,n,a||0,o||0,s||0,c),f=e[8];if(f&&f!=="Z"){let d=ka(f,!1);Math.abs(d)<30&&(d*=60),l-=6e4*d}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Sr.floatTime=fp;Sr.intTime=dp;Sr.timestamp=jc});var Hc=g(Oc=>{"use strict";var hp=dt(),pp=ur(),mp=ft(),vp=Kt(),gp=fa(),$c=Rc(),Ea=Ac(),Er=Tc(),wp=ir(),yp=va(),Np=gr(),bp=ba(),Pa=Sa(),kp=[hp.map,mp.seq,vp.string,pp.nullTag,$c.trueTag,$c.falseTag,Er.intBin,Er.intOct,Er.int,Er.intHex,Ea.floatNaN,Ea.floatExp,Ea.float,gp.binary,wp.merge,yp.omap,Np.pairs,bp.set,Pa.intTime,Pa.floatTime,Pa.timestamp];Oc.schema=kp});var Jc=g(Ra=>{"use strict";var Mc=dt(),Sp=ur(),Fc=ft(),Ep=Kt(),Pp=na(),xa=oa(),Ca=ca(),xp=mc(),Cp=wc(),Vc=fa(),ei=ir(),qc=va(),Wc=gr(),Dc=Hc(),zc=ba(),Pr=Sa(),Bc=new Map([["core",xp.schema],["failsafe",[Mc.map,Fc.seq,Ep.string]],["json",Cp.schema],["yaml11",Dc.schema],["yaml-1.1",Dc.schema]]),Lc={binary:Vc.binary,bool:Pp.boolTag,float:xa.float,floatExp:xa.floatExp,floatNaN:xa.floatNaN,floatTime:Pr.floatTime,int:Ca.int,intHex:Ca.intHex,intOct:Ca.intOct,intTime:Pr.intTime,map:Mc.map,merge:ei.merge,null:Sp.nullTag,omap:qc.omap,pairs:Wc.pairs,seq:Fc.seq,set:zc.set,timestamp:Pr.timestamp},Rp={"tag:yaml.org,2002:binary":Vc.binary,"tag:yaml.org,2002:merge":ei.merge,"tag:yaml.org,2002:omap":qc.omap,"tag:yaml.org,2002:pairs":Wc.pairs,"tag:yaml.org,2002:set":zc.set,"tag:yaml.org,2002:timestamp":Pr.timestamp};function Ap(t,e,i){let r=Bc.get(e);if(r&&!t)return i&&!r.includes(ei.merge)?r.concat(ei.merge):r.slice();let n=r;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Bc.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 i&&(n=n.concat(ei.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Lc[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Lc).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}Ra.coreKnownTags=Rp;Ra.getTags=Ap});var Ta=g(Gc=>{"use strict";var Aa=P(),_p=dt(),Tp=ft(),Ip=Kt(),xr=Jc(),jp=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,_a=class t{constructor({compat:e,customTags:i,merge:r,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?xr.getTags(e,"compat"):e?xr.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?xr.coreKnownTags:{},this.tags=xr.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,Aa.MAP,{value:_p.map}),Object.defineProperty(this,Aa.SCALAR,{value:Ip.string}),Object.defineProperty(this,Aa.SEQ,{value:Tp.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?jp:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Gc.Schema=_a});var Kc=g(Uc=>{"use strict";var $p=P(),Ia=Jt(),ti=Vt();function Op(t,e){let i=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(i.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&i.push("---");let n=Ia.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){i.length!==1&&i.unshift("");let c=a(t.commentBefore);i.unshift(ti.indentComment(c,""))}let o=!1,s=null;if(t.contents){if($p.isNode(t.contents)){if(t.contents.spaceBefore&&r&&i.push(""),t.contents.commentBefore){let f=a(t.contents.commentBefore);i.push(ti.indentComment(f,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=Ia.stringify(t.contents,n,()=>s=null,c);s&&(l+=ti.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(Ia.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
+ `)?(i.push("..."),i.push(ti.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&i[i.length-1]!==""&&i.push(""),i.push(ti.indentComment(a(c),"")))}return i.join(`
59
59
  `)+`
60
- `}Gc.stringifyDocument=Ip});var Qt=g(Kc=>{"use strict";var jp=Ht(),ht=zi(),X=P(),$p=$e(),Op=_e(),Hp=Aa(),Dp=Uc(),Ta=Fi(),Bp=On(),Lp=Dt(),Ia=$n(),ja=class t{constructor(e,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,X.NODE_TYPE,{value:X.DOC});let n=null;typeof i=="function"||Array.isArray(i)?n=i:r===void 0&&i&&(r=i,i=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=a;let{version:o}=a;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Ia.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(t.prototype,{[X.NODE_TYPE]:{value:X.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=X.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){pt(this.contents)&&this.contents.add(e)}addIn(e,i){pt(this.contents)&&this.contents.addIn(e,i)}createAlias(e,i){if(!e.anchor){let r=Ta.anchorNames(this);e.anchor=!i||r.has(i)?Ta.findNewAnchor(i||"a",r):i}return new jp.Alias(e.anchor)}createNode(e,i,r){let n;if(typeof i=="function")e=i.call({"":e},"",e),n=i;else if(Array.isArray(i)){let m=y=>typeof y=="number"||y instanceof String||y instanceof Number,w=i.filter(m).map(String);w.length>0&&(i=i.concat(w)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:f}=r??{},{onAnchor:d,setAnchors:u,sourceObjects:p}=Ta.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=Lp.createNode(e,f,v);return s&&X.isCollection(h)&&(h.flow=!0),u(),h}createPair(e,i,r={}){let n=this.createNode(e,null,r),a=this.createNode(i,null,r);return new $p.Pair(n,a)}delete(e){return pt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return ht.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):pt(this.contents)?this.contents.deleteIn(e):!1}get(e,i){return X.isCollection(this.contents)?this.contents.get(e,i):void 0}getIn(e,i){return ht.isEmptyPath(e)?!i&&X.isScalar(this.contents)?this.contents.value:this.contents:X.isCollection(this.contents)?this.contents.getIn(e,i):void 0}has(e){return X.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return ht.isEmptyPath(e)?this.contents!==void 0:X.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,i){this.contents==null?this.contents=ht.collectionFromPath(this.schema,[e],i):pt(this.contents)&&this.contents.set(e,i)}setIn(e,i){ht.isEmptyPath(e)?this.contents=i:this.contents==null?this.contents=ht.collectionFromPath(this.schema,Array.from(e),i):pt(this.contents)&&this.contents.setIn(e,i)}setSchema(e,i={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Ia.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Ia.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=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(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new Hp.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=Op.toJS(this.contents,i??"",s);if(typeof a=="function")for(let{count:l,res:f}of s.anchors.values())a(f,l);return typeof o=="function"?Bp.applyReviver(o,{"":c},"",c):c}toJSON(e,i){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:i})}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 i=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return Dp.stringifyDocument(this,e)}};function pt(t){if(X.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Kc.Document=ja});var ti=g(ei=>{"use strict";var Zt=class extends Error{constructor(e,i,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=i}},$a=class extends Zt{constructor(e,i,r){super("YAMLParseError",e,i,r)}},Oa=class extends Zt{constructor(e,i,r){super("YAMLWarning",e,i,r)}},Mp=(t,e)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>e.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).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)+"…"),r>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);s.length>80&&(s=s.substring(0,79)+`…
60
+ `}Uc.stringifyDocument=Op});var ii=g(Yc=>{"use strict";var Hp=Mt(),pt=Ji(),Q=P(),Dp=He(),Bp=Ie(),Lp=Ta(),Mp=Kc(),ja=Vi(),Fp=Dn(),Vp=Ft(),$a=Hn(),Oa=class t{constructor(e,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Q.NODE_TYPE,{value:Q.DOC});let n=null;typeof i=="function"||Array.isArray(i)?n=i:r===void 0&&i&&(r=i,i=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=a;let{version:o}=a;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new $a.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(t.prototype,{[Q.NODE_TYPE]:{value:Q.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=Q.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){mt(this.contents)&&this.contents.add(e)}addIn(e,i){mt(this.contents)&&this.contents.addIn(e,i)}createAlias(e,i){if(!e.anchor){let r=ja.anchorNames(this);e.anchor=!i||r.has(i)?ja.findNewAnchor(i||"a",r):i}return new Hp.Alias(e.anchor)}createNode(e,i,r){let n;if(typeof i=="function")e=i.call({"":e},"",e),n=i;else if(Array.isArray(i)){let m=y=>typeof y=="number"||y instanceof String||y instanceof Number,w=i.filter(m).map(String);w.length>0&&(i=i.concat(w)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:f}=r??{},{onAnchor:d,setAnchors:u,sourceObjects:p}=ja.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=Vp.createNode(e,f,v);return s&&Q.isCollection(h)&&(h.flow=!0),u(),h}createPair(e,i,r={}){let n=this.createNode(e,null,r),a=this.createNode(i,null,r);return new Dp.Pair(n,a)}delete(e){return mt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return pt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):mt(this.contents)?this.contents.deleteIn(e):!1}get(e,i){return Q.isCollection(this.contents)?this.contents.get(e,i):void 0}getIn(e,i){return pt.isEmptyPath(e)?!i&&Q.isScalar(this.contents)?this.contents.value:this.contents:Q.isCollection(this.contents)?this.contents.getIn(e,i):void 0}has(e){return Q.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return pt.isEmptyPath(e)?this.contents!==void 0:Q.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,i){this.contents==null?this.contents=pt.collectionFromPath(this.schema,[e],i):mt(this.contents)&&this.contents.set(e,i)}setIn(e,i){pt.isEmptyPath(e)?this.contents=i:this.contents==null?this.contents=pt.collectionFromPath(this.schema,Array.from(e),i):mt(this.contents)&&this.contents.setIn(e,i)}setSchema(e,i={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new $a.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new $a.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=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(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new Lp.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=Bp.toJS(this.contents,i??"",s);if(typeof a=="function")for(let{count:l,res:f}of s.anchors.values())a(f,l);return typeof o=="function"?Fp.applyReviver(o,{"":c},"",c):c}toJSON(e,i){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:i})}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 i=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return Mp.stringifyDocument(this,e)}};function mt(t){if(Q.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Yc.Document=Oa});var ai=g(ni=>{"use strict";var ri=class extends Error{constructor(e,i,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=i}},Ha=class extends ri{constructor(e,i,r){super("YAMLParseError",e,i,r)}},Da=class extends ri{constructor(e,i,r){super("YAMLWarning",e,i,r)}},qp=(t,e)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>e.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).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)+"…"),r>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);s.length>80&&(s=s.substring(0,79)+`…
61
61
  `),o=s+o}if(/[^ ]/.test(o)){let s=1,c=i.linePos[1];c?.line===r&&c.col>n&&(s=Math.max(1,Math.min(c.col-n,80-a)));let l=" ".repeat(a)+"^".repeat(s);i.message+=`:
62
62
 
63
63
  ${o}
64
64
  ${l}
65
- `}};ei.YAMLError=Zt;ei.YAMLParseError=$a;ei.YAMLWarning=Oa;ei.prettifyError=Mp});var ii=g(Yc=>{"use strict";function Fp(t,{flow:e,indicator:i,next:r,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,f=s,d="",u="",p=!1,v=!1,h=null,m=null,w=null,y=null,b=null,k=null,S=null;for(let N of t)switch(v&&(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma"&&a(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&N.type!=="comment"&&N.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),N.type){case"space":!e&&(i!=="doc-start"||r?.type!=="flow-collection")&&N.source.includes(" ")&&(h=N),f=!0;break;case"comment":{f||a(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let j=N.source.substring(1)||" ";d?d+=u+j:d=j,u="",l=!1;break}case"newline":l?d?d+=N.source:(!k||i!=="seq-item-ind")&&(c=!0):u+=N.source,l=!0,p=!0,(m||w)&&(y=N),f=!0;break;case"anchor":m&&a(N,"MULTIPLE_ANCHORS","A node can have at most one anchor"),N.source.endsWith(":")&&a(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=N,S??(S=N.offset),l=!1,f=!1,v=!0;break;case"tag":{w&&a(N,"MULTIPLE_TAGS","A node can have at most one tag"),w=N,S??(S=N.offset),l=!1,f=!1,v=!0;break}case i:(m||w)&&a(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`),k&&a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${e??"collection"}`),k=N,l=i==="seq-item-ind"||i==="explicit-key-ind",f=!1;break;case"comma":if(e){b&&a(N,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=N,l=!1,f=!1;break}default:a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),l=!1,f=!1}let E=t[t.length-1],C=E?E.offset+E.source.length:n;return v&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&a(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:k,spaceBefore:c,comment:d,hasNewline:p,anchor:m,tag:w,newlineAfterProp:y,end:C,start:S??C}}Yc.resolveProps=Fp});var xr=g(Xc=>{"use strict";function Ha(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 i of e.start)if(i.type==="newline")return!0;if(e.sep){for(let i of e.sep)if(i.type==="newline")return!0}if(Ha(e.key)||Ha(e.value))return!0}return!1;default:return!0}}Xc.containsNewline=Ha});var Da=g(Qc=>{"use strict";var Vp=xr();function qp(t,e,i){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&Vp.containsNewline(e)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Qc.flowIndentCheck=qp});var Ba=g(el=>{"use strict";var Zc=P();function Wp(t,e,i){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let n=typeof r=="function"?r:(a,o)=>a===o||Zc.isScalar(a)&&Zc.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,i))}el.mapIncludes=Wp});var ol=g(al=>{"use strict";var tl=$e(),zp=He(),il=ii(),Jp=xr(),rl=Da(),Gp=Ba(),nl="All mapping items must start at the same column";function Up({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=a?.nodeClass??zp.YAMLMap,s=new o(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let f of r.items){let{start:d,key:u,sep:p,value:v}=f,h=il.resolveProps(d,{indicator:"explicit-key-ind",next:u??p?.[0],offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0}),m=!h.found;if(m){if(u&&(u.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==r.indent&&n(c,"BAD_INDENT",nl)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
67
- `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Jp.containsNewline(u))&&n(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",nl);i.atKey=!0;let w=h.end,y=u?t(i,u,h,n):e(i,w,d,null,h,n);i.schema.compat&&rl.flowIndentCheck(r.indent,u,n),i.atKey=!1,Gp.mapIncludes(i,s.items,y)&&n(w,"DUPLICATE_KEY","Map keys must be unique");let b=il.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:y.range[2],onError:n,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(c=b.end,b.found){m&&(v?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.options.strict&&h.start<b.found.offset-1024&&n(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=v?t(i,v,b,n):e(i,c,p,null,b,n);i.schema.compat&&rl.flowIndentCheck(r.indent,v,n),c=k.range[2];let S=new tl.Pair(y,k);i.options.keepSourceTokens&&(S.srcToken=f),s.items.push(S)}else{m&&n(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(y.comment?y.comment+=`
68
- `+b.comment:y.comment=b.comment);let k=new tl.Pair(y);i.options.keepSourceTokens&&(k.srcToken=f),s.items.push(k)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}al.resolveBlockMap=Up});var cl=g(sl=>{"use strict";var Kp=De(),Yp=ii(),Xp=Da();function Qp({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=a?.nodeClass??Kp.YAMLSeq,s=new o(i.schema);i.atRoot&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let c=r.offset,l=null;for(let{start:f,value:d}of r.items){let u=Yp.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)d?.type==="block-seq"?n(u.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=u.end,u.comment&&(s.comment=u.comment);continue}let p=d?t(i,d,u,n):e(i,u.end,f,null,u,n);i.schema.compat&&Xp.flowIndentCheck(r.indent,d,n),c=p.range[2],s.items.push(p)}return s.range=[r.offset,c,l??c],s}sl.resolveBlockSeq=Qp});var mt=g(ll=>{"use strict";function Zp(t,e,i,r){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":{i&&!a&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=c),a=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}ll.resolveEnd=Zp});var hl=g(fl=>{"use strict";var em=P(),tm=$e(),ul=He(),im=De(),rm=mt(),dl=ii(),nm=xr(),am=Ba(),La="Block collections are not allowed within flow collections",Ma=t=>t&&(t.type==="block-map"||t.type==="block-seq");function om({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=r.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?ul.YAMLMap:im.YAMLSeq),l=new c(i.schema);l.flow=!0;let f=i.atRoot;f&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let d=r.offset+r.start.source.length;for(let m=0;m<r.items.length;++m){let w=r.items[m],{start:y,key:b,sep:k,value:S}=w,E=dl.resolveProps(y,{flow:s,indicator:"explicit-key-ind",next:b??k?.[0],offset:d,onError:n,parentIndent:r.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!k&&!S){m===0&&E.comma?n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<r.items.length-1&&n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),E.comment&&(l.comment?l.comment+=`
69
- `+E.comment:l.comment=E.comment),d=E.end;continue}!o&&i.options.strict&&nm.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)E.comma&&n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(E.comma||n(E.start,"MISSING_CHAR",`Missing , between ${s} items`),E.comment){let C="";e:for(let N of y)switch(N.type){case"comma":case"space":break;case"comment":C=N.source.substring(1);break e;default:break e}if(C){let N=l.items[l.items.length-1];em.isPair(N)&&(N=N.value??N.key),N.comment?N.comment+=`
70
- `+C:N.comment=C,E.comment=E.comment.substring(C.length+1)}}if(!o&&!k&&!E.found){let C=S?t(i,S,E,n):e(i,E.end,k,null,E,n);l.items.push(C),d=C.range[2],Ma(S)&&n(C.range,"BLOCK_IN_FLOW",La)}else{i.atKey=!0;let C=E.end,N=b?t(i,b,E,n):e(i,C,y,null,E,n);Ma(b)&&n(N.range,"BLOCK_IN_FLOW",La),i.atKey=!1;let j=dl.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:S,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(j.found){if(!o&&!E.found&&i.options.strict){if(k)for(let $ of k){if($===j.found)break;if($.type==="newline"){n($,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<j.found.offset-1024&&n(j.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${s}`):n(j.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let Ce=S?t(i,S,j,n):j.found?e(i,j.end,k,null,j,n):null;Ce?Ma(S)&&n(Ce.range,"BLOCK_IN_FLOW",La):j.comment&&(N.comment?N.comment+=`
71
- `+j.comment:N.comment=j.comment);let at=new tm.Pair(N,Ce);if(i.options.keepSourceTokens&&(at.srcToken=w),o){let $=l;am.mapIncludes(i,$.items,N)&&n(C,"DUPLICATE_KEY","Map keys must be unique"),$.items.push(at)}else{let $=new ul.YAMLMap(i.schema);$.flow=!0,$.items.push(at);let cs=(Ce??N).range;$.range=[N.range[0],cs[1],cs[2]],l.items.push($)}d=Ce?Ce.range[2]:j.end}}let u=o?"}":"]",[p,...v]=r.end,h=d;if(p?.source===u)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),w=f?`${m} must end with a ${u}`:`${m} in block collection must be sufficiently indented and end with a ${u}`;n(d,f?"MISSING_CHAR":"BAD_INDENT",w),p&&p.source.length!==1&&v.unshift(p)}if(v.length>0){let m=rm.resolveEnd(v,h,i.options.strict,n);m.comment&&(l.comment?l.comment+=`
72
- `+m.comment:l.comment=m.comment),l.range=[r.offset,h,m.offset]}else l.range=[r.offset,h,h];return l}fl.resolveFlowCollection=om});var ml=g(pl=>{"use strict";var sm=P(),cm=I(),lm=He(),um=De(),dm=ol(),fm=cl(),hm=hl();function Fa(t,e,i,r,n,a){let o=i.type==="block-map"?dm.resolveBlockMap(t,e,i,r,a):i.type==="block-seq"?fm.resolveBlockSeq(t,e,i,r,a):hm.resolveFlowCollection(t,e,i,r,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function pm(t,e,i,r,n){let a=r.tag,o=a?e.directives.tagName(a.source,u=>n(a,"TAG_RESOLVE_FAILED",u)):null;if(i.type==="block-seq"){let{anchor:u,newlineAfterProp:p}=r,v=u&&a?u.offset>a.offset?u:a:u??a;v&&(!p||p.offset<v.offset)&&n(v,"MISSING_CHAR","Missing newline after block sequence props")}let s=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===lm.YAMLMap.tagName&&s==="map"||o===um.YAMLSeq.tagName&&s==="seq")return Fa(t,e,i,n,o);let c=e.schema.tags.find(u=>u.tag===o&&u.collection===s);if(!c){let u=e.schema.knownTags[o];if(u?.collection===s)e.schema.tags.push(Object.assign({},u,{default:!1})),c=u;else return u?n(a,"BAD_COLLECTION_TYPE",`${u.tag} used for ${s} collection, but expects ${u.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Fa(t,e,i,n,o)}let l=Fa(t,e,i,n,o,c),f=c.resolve?.(l,u=>n(a,"TAG_RESOLVE_FAILED",u),e.options)??l,d=sm.isNode(f)?f:new cm.Scalar(f);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}pl.composeCollection=pm});var qa=g(vl=>{"use strict";var Va=I();function mm(t,e,i){let r=e.offset,n=vm(e,t.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let a=n.mode===">"?Va.Scalar.BLOCK_FOLDED:Va.Scalar.BLOCK_LITERAL,o=e.source?gm(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
65
+ `}};ni.YAMLError=ri;ni.YAMLParseError=Ha;ni.YAMLWarning=Da;ni.prettifyError=qp});var oi=g(Xc=>{"use strict";function Wp(t,{flow:e,indicator:i,next:r,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,f=s,d="",u="",p=!1,v=!1,h=null,m=null,w=null,y=null,b=null,k=null,S=null;for(let N of t)switch(v&&(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma"&&a(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&N.type!=="comment"&&N.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),N.type){case"space":!e&&(i!=="doc-start"||r?.type!=="flow-collection")&&N.source.includes(" ")&&(h=N),f=!0;break;case"comment":{f||a(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let j=N.source.substring(1)||" ";d?d+=u+j:d=j,u="",l=!1;break}case"newline":l?d?d+=N.source:(!k||i!=="seq-item-ind")&&(c=!0):u+=N.source,l=!0,p=!0,(m||w)&&(y=N),f=!0;break;case"anchor":m&&a(N,"MULTIPLE_ANCHORS","A node can have at most one anchor"),N.source.endsWith(":")&&a(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=N,S??(S=N.offset),l=!1,f=!1,v=!0;break;case"tag":{w&&a(N,"MULTIPLE_TAGS","A node can have at most one tag"),w=N,S??(S=N.offset),l=!1,f=!1,v=!0;break}case i:(m||w)&&a(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`),k&&a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${e??"collection"}`),k=N,l=i==="seq-item-ind"||i==="explicit-key-ind",f=!1;break;case"comma":if(e){b&&a(N,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=N,l=!1,f=!1;break}default:a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),l=!1,f=!1}let E=t[t.length-1],R=E?E.offset+E.source.length:n;return v&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&a(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:k,spaceBefore:c,comment:d,hasNewline:p,anchor:m,tag:w,newlineAfterProp:y,end:R,start:S??R}}Xc.resolveProps=Wp});var Cr=g(Qc=>{"use strict";function Ba(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 i of e.start)if(i.type==="newline")return!0;if(e.sep){for(let i of e.sep)if(i.type==="newline")return!0}if(Ba(e.key)||Ba(e.value))return!0}return!1;default:return!0}}Qc.containsNewline=Ba});var La=g(Zc=>{"use strict";var zp=Cr();function Jp(t,e,i){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&zp.containsNewline(e)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Zc.flowIndentCheck=Jp});var Ma=g(tl=>{"use strict";var el=P();function Gp(t,e,i){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let n=typeof r=="function"?r:(a,o)=>a===o||el.isScalar(a)&&el.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,i))}tl.mapIncludes=Gp});var sl=g(ol=>{"use strict";var il=He(),Up=Be(),rl=oi(),Kp=Cr(),nl=La(),Yp=Ma(),al="All mapping items must start at the same column";function Xp({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=a?.nodeClass??Up.YAMLMap,s=new o(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let f of r.items){let{start:d,key:u,sep:p,value:v}=f,h=rl.resolveProps(d,{indicator:"explicit-key-ind",next:u??p?.[0],offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0}),m=!h.found;if(m){if(u&&(u.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==r.indent&&n(c,"BAD_INDENT",al)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Kp.containsNewline(u))&&n(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",al);i.atKey=!0;let w=h.end,y=u?t(i,u,h,n):e(i,w,d,null,h,n);i.schema.compat&&nl.flowIndentCheck(r.indent,u,n),i.atKey=!1,Yp.mapIncludes(i,s.items,y)&&n(w,"DUPLICATE_KEY","Map keys must be unique");let b=rl.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:y.range[2],onError:n,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(c=b.end,b.found){m&&(v?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.options.strict&&h.start<b.found.offset-1024&&n(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=v?t(i,v,b,n):e(i,c,p,null,b,n);i.schema.compat&&nl.flowIndentCheck(r.indent,v,n),c=k.range[2];let S=new il.Pair(y,k);i.options.keepSourceTokens&&(S.srcToken=f),s.items.push(S)}else{m&&n(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(y.comment?y.comment+=`
68
+ `+b.comment:y.comment=b.comment);let k=new il.Pair(y);i.options.keepSourceTokens&&(k.srcToken=f),s.items.push(k)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}ol.resolveBlockMap=Xp});var ll=g(cl=>{"use strict";var Qp=Le(),Zp=oi(),em=La();function tm({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=a?.nodeClass??Qp.YAMLSeq,s=new o(i.schema);i.atRoot&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let c=r.offset,l=null;for(let{start:f,value:d}of r.items){let u=Zp.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)d?.type==="block-seq"?n(u.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=u.end,u.comment&&(s.comment=u.comment);continue}let p=d?t(i,d,u,n):e(i,u.end,f,null,u,n);i.schema.compat&&em.flowIndentCheck(r.indent,d,n),c=p.range[2],s.items.push(p)}return s.range=[r.offset,c,l??c],s}cl.resolveBlockSeq=tm});var vt=g(ul=>{"use strict";function im(t,e,i,r){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":{i&&!a&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=c),a=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}ul.resolveEnd=im});var pl=g(hl=>{"use strict";var rm=P(),nm=He(),dl=Be(),am=Le(),om=vt(),fl=oi(),sm=Cr(),cm=Ma(),Fa="Block collections are not allowed within flow collections",Va=t=>t&&(t.type==="block-map"||t.type==="block-seq");function lm({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=r.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?dl.YAMLMap:am.YAMLSeq),l=new c(i.schema);l.flow=!0;let f=i.atRoot;f&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let d=r.offset+r.start.source.length;for(let m=0;m<r.items.length;++m){let w=r.items[m],{start:y,key:b,sep:k,value:S}=w,E=fl.resolveProps(y,{flow:s,indicator:"explicit-key-ind",next:b??k?.[0],offset:d,onError:n,parentIndent:r.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!k&&!S){m===0&&E.comma?n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<r.items.length-1&&n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),E.comment&&(l.comment?l.comment+=`
69
+ `+E.comment:l.comment=E.comment),d=E.end;continue}!o&&i.options.strict&&sm.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)E.comma&&n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(E.comma||n(E.start,"MISSING_CHAR",`Missing , between ${s} items`),E.comment){let R="";e:for(let N of y)switch(N.type){case"comma":case"space":break;case"comment":R=N.source.substring(1);break e;default:break e}if(R){let N=l.items[l.items.length-1];rm.isPair(N)&&(N=N.value??N.key),N.comment?N.comment+=`
70
+ `+R:N.comment=R,E.comment=E.comment.substring(R.length+1)}}if(!o&&!k&&!E.found){let R=S?t(i,S,E,n):e(i,E.end,k,null,E,n);l.items.push(R),d=R.range[2],Va(S)&&n(R.range,"BLOCK_IN_FLOW",Fa)}else{i.atKey=!0;let R=E.end,N=b?t(i,b,E,n):e(i,R,y,null,E,n);Va(b)&&n(N.range,"BLOCK_IN_FLOW",Fa),i.atKey=!1;let j=fl.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:S,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(j.found){if(!o&&!E.found&&i.options.strict){if(k)for(let $ of k){if($===j.found)break;if($.type==="newline"){n($,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<j.found.offset-1024&&n(j.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${s}`):n(j.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let _e=S?t(i,S,j,n):j.found?e(i,j.end,k,null,j,n):null;_e?Va(S)&&n(_e.range,"BLOCK_IN_FLOW",Fa):j.comment&&(N.comment?N.comment+=`
71
+ `+j.comment:N.comment=j.comment);let ot=new nm.Pair(N,_e);if(i.options.keepSourceTokens&&(ot.srcToken=w),o){let $=l;cm.mapIncludes(i,$.items,N)&&n(R,"DUPLICATE_KEY","Map keys must be unique"),$.items.push(ot)}else{let $=new dl.YAMLMap(i.schema);$.flow=!0,$.items.push(ot);let ls=(_e??N).range;$.range=[N.range[0],ls[1],ls[2]],l.items.push($)}d=_e?_e.range[2]:j.end}}let u=o?"}":"]",[p,...v]=r.end,h=d;if(p?.source===u)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),w=f?`${m} must end with a ${u}`:`${m} in block collection must be sufficiently indented and end with a ${u}`;n(d,f?"MISSING_CHAR":"BAD_INDENT",w),p&&p.source.length!==1&&v.unshift(p)}if(v.length>0){let m=om.resolveEnd(v,h,i.options.strict,n);m.comment&&(l.comment?l.comment+=`
72
+ `+m.comment:l.comment=m.comment),l.range=[r.offset,h,m.offset]}else l.range=[r.offset,h,h];return l}hl.resolveFlowCollection=lm});var vl=g(ml=>{"use strict";var um=P(),dm=I(),fm=Be(),hm=Le(),pm=sl(),mm=ll(),vm=pl();function qa(t,e,i,r,n,a){let o=i.type==="block-map"?pm.resolveBlockMap(t,e,i,r,a):i.type==="block-seq"?mm.resolveBlockSeq(t,e,i,r,a):vm.resolveFlowCollection(t,e,i,r,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function gm(t,e,i,r,n){let a=r.tag,o=a?e.directives.tagName(a.source,u=>n(a,"TAG_RESOLVE_FAILED",u)):null;if(i.type==="block-seq"){let{anchor:u,newlineAfterProp:p}=r,v=u&&a?u.offset>a.offset?u:a:u??a;v&&(!p||p.offset<v.offset)&&n(v,"MISSING_CHAR","Missing newline after block sequence props")}let s=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===fm.YAMLMap.tagName&&s==="map"||o===hm.YAMLSeq.tagName&&s==="seq")return qa(t,e,i,n,o);let c=e.schema.tags.find(u=>u.tag===o&&u.collection===s);if(!c){let u=e.schema.knownTags[o];if(u?.collection===s)e.schema.tags.push(Object.assign({},u,{default:!1})),c=u;else return u?n(a,"BAD_COLLECTION_TYPE",`${u.tag} used for ${s} collection, but expects ${u.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),qa(t,e,i,n,o)}let l=qa(t,e,i,n,o,c),f=c.resolve?.(l,u=>n(a,"TAG_RESOLVE_FAILED",u),e.options)??l,d=um.isNode(f)?f:new dm.Scalar(f);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}ml.composeCollection=gm});var za=g(gl=>{"use strict";var Wa=I();function wm(t,e,i){let r=e.offset,n=ym(e,t.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let a=n.mode===">"?Wa.Scalar.BLOCK_FOLDED:Wa.Scalar.BLOCK_LITERAL,o=e.source?Nm(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
73
  `.repeat(Math.max(1,o.length-1)):"",m=r+n.length;return e.source&&(m+=e.source.length),{value:h,type:a,comment:n.comment,range:[r,m,m]}}let c=e.indent+n.indent,l=e.offset+n.length,f=0;for(let h=0;h<s;++h){let[m,w]=o[h];if(w===""||w==="\r")n.indent===0&&m.length>c&&(c=m.length);else{m.length<c&&i(l+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=m.length),f=h,c===0&&!t.atRoot&&i(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+w.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let d="",u="",p=!1;for(let h=0;h<f;++h)d+=o[h][0].slice(c)+`
74
- `;for(let h=f;h<s;++h){let[m,w]=o[h];l+=m.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&m.length<c){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;i(l-w.length-(y?2:1),"BAD_INDENT",k),m=""}a===Va.Scalar.BLOCK_LITERAL?(d+=u+m.slice(c)+w,u=`
74
+ `;for(let h=f;h<s;++h){let[m,w]=o[h];l+=m.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&m.length<c){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;i(l-w.length-(y?2:1),"BAD_INDENT",k),m=""}a===Wa.Scalar.BLOCK_LITERAL?(d+=u+m.slice(c)+w,u=`
75
75
  `):m.length>c||w[0]===" "?(u===" "?u=`
76
76
  `:!p&&u===`
77
77
  `&&(u=`
@@ -84,80 +84,80 @@ ${l}
84
84
  `+o[h][0].slice(c);d[d.length-1]!==`
85
85
  `&&(d+=`
86
86
  `);break;default:d+=`
87
- `}let v=r+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[r,v,v]}}function vm({offset:t,props:e},i,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],a=n[0],o=0,s="",c=-1;for(let u=1;u<n.length;++u){let p=n[u];if(!s&&(p==="-"||p==="+"))s=p;else{let v=Number(p);!o&&v?o=v:c===-1&&(c=t+u)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,f="",d=n.length;for(let u=1;u<e.length;++u){let p=e[u];switch(p.type){case"space":l=!0;case"newline":d+=p.source.length;break;case"comment":i&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let v=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",v);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:f,length:d}}function gm(t){let e=t.split(/\n( *)/),i=e[0],r=i.match(/^( *)/),a=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}vl.resolveBlockScalar=mm});var za=g(wl=>{"use strict";var Wa=I(),wm=mt();function ym(t,e,i){let{offset:r,type:n,source:a,end:o}=t,s,c,l=(u,p,v)=>i(r+u,p,v);switch(n){case"scalar":s=Wa.Scalar.PLAIN,c=Nm(a,l);break;case"single-quoted-scalar":s=Wa.Scalar.QUOTE_SINGLE,c=bm(a,l);break;case"double-quoted-scalar":s=Wa.Scalar.QUOTE_DOUBLE,c=km(a,l);break;default:return i(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+a.length,r+a.length]}}let f=r+a.length,d=wm.resolveEnd(o,f,e,i);return{value:c,type:s,comment:d.comment,range:[r,f,d.offset]}}function Nm(t,e){let i="";switch(t[0]){case" ":i="a tab character";break;case",":i="flow indicator character ,";break;case"%":i="directive indicator character %";break;case"|":case">":{i=`block scalar indicator ${t[0]}`;break}case"@":case"`":{i=`reserved character ${t[0]}`;break}}return i&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),gl(t)}function bm(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),gl(t.slice(1,-1)).replace(/''/g,"'")}function gl(t){let e,i;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
+ `}let v=r+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[r,v,v]}}function ym({offset:t,props:e},i,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],a=n[0],o=0,s="",c=-1;for(let u=1;u<n.length;++u){let p=n[u];if(!s&&(p==="-"||p==="+"))s=p;else{let v=Number(p);!o&&v?o=v:c===-1&&(c=t+u)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,f="",d=n.length;for(let u=1;u<e.length;++u){let p=e[u];switch(p.type){case"space":l=!0;case"newline":d+=p.source.length;break;case"comment":i&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let v=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",v);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:f,length:d}}function Nm(t){let e=t.split(/\n( *)/),i=e[0],r=i.match(/^( *)/),a=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}gl.resolveBlockScalar=wm});var Ga=g(yl=>{"use strict";var Ja=I(),bm=vt();function km(t,e,i){let{offset:r,type:n,source:a,end:o}=t,s,c,l=(u,p,v)=>i(r+u,p,v);switch(n){case"scalar":s=Ja.Scalar.PLAIN,c=Sm(a,l);break;case"single-quoted-scalar":s=Ja.Scalar.QUOTE_SINGLE,c=Em(a,l);break;case"double-quoted-scalar":s=Ja.Scalar.QUOTE_DOUBLE,c=Pm(a,l);break;default:return i(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+a.length,r+a.length]}}let f=r+a.length,d=bm.resolveEnd(o,f,e,i);return{value:c,type:s,comment:d.comment,range:[r,f,d.offset]}}function Sm(t,e){let i="";switch(t[0]){case" ":i="a tab character";break;case",":i="flow indicator character ,";break;case"%":i="directive indicator character %";break;case"|":case">":{i=`block scalar indicator ${t[0]}`;break}case"@":case"`":{i=`reserved character ${t[0]}`;break}}return i&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),wl(t)}function Em(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),wl(t.slice(1,-1)).replace(/''/g,"'")}function wl(t){let e,i;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
88
88
  `,"sy"),i=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
89
89
  `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let n=r[1],a=" ",o=e.lastIndex;for(i.lastIndex=o;r=i.exec(t);)r[1]===""?a===`
90
90
  `?n+=a:a=`
91
- `:(n+=a+r[1],a=" "),o=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(t),n+a+(r?.[1]??"")}function km(t,e){let i="";for(let r=1;r<t.length-1;++r){let n=t[r];if(!(n==="\r"&&t[r+1]===`
91
+ `:(n+=a+r[1],a=" "),o=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(t),n+a+(r?.[1]??"")}function Pm(t,e){let i="";for(let r=1;r<t.length-1;++r){let n=t[r];if(!(n==="\r"&&t[r+1]===`
92
92
  `))if(n===`
93
- `){let{fold:a,offset:o}=Sm(t,r);i+=a,r=o}else if(n==="\\"){let a=t[++r],o=Em[a];if(o)i+=o;else if(a===`
93
+ `){let{fold:a,offset:o}=xm(t,r);i+=a,r=o}else if(n==="\\"){let a=t[++r],o=Cm[a];if(o)i+=o;else if(a===`
94
94
  `)for(a=t[r+1];a===" "||a===" ";)a=t[++r+1];else if(a==="\r"&&t[r+1]===`
95
- `)for(a=t[++r+1];a===" "||a===" ";)a=t[++r+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;i+=Pm(t,r+1,s,e),r+=s}else{let s=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let a=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
95
+ `)for(a=t[++r+1];a===" "||a===" ";)a=t[++r+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;i+=Rm(t,r+1,s,e),r+=s}else{let s=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let a=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
96
96
  `&&!(o==="\r"&&t[r+2]===`
97
- `)&&(i+=r>a?t.slice(a,r+1):n)}else i+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),i}function Sm(t,e){let i="",r=t[e+1];for(;(r===" "||r===" "||r===`
97
+ `)&&(i+=r>a?t.slice(a,r+1):n)}else i+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),i}function xm(t,e){let i="",r=t[e+1];for(;(r===" "||r===" "||r===`
98
98
  `||r==="\r")&&!(r==="\r"&&t[e+2]!==`
99
99
  `);)r===`
100
100
  `&&(i+=`
101
- `),e+=1,r=t[e+1];return i||(i=" "),{fold:i,offset:e}}var Em={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Pm(t,e,i,r){let n=t.substr(e,i),o=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=t.substr(e-2,i+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}wl.resolveFlowScalar=ym});var bl=g(Nl=>{"use strict";var Ye=P(),yl=I(),xm=qa(),Rm=za();function Cm(t,e,i,r){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?xm.resolveBlockScalar(t,e,r):Rm.resolveFlowScalar(e,t.options.strict,r),c=i?t.directives.tagName(i.source,d=>r(i,"TAG_RESOLVE_FAILED",d)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Ye.SCALAR]:c?l=Am(t.schema,n,c,i,r):e.type==="scalar"?l=_m(t,n,e,r):l=t.schema[Ye.SCALAR];let f;try{let d=l.resolve(n,u=>r(i??e,"TAG_RESOLVE_FAILED",u),t.options);f=Ye.isScalar(d)?d:new yl.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);r(i??e,"TAG_RESOLVE_FAILED",u),f=new yl.Scalar(n)}return f.range=s,f.source=n,a&&(f.type=a),c&&(f.tag=c),l.format&&(f.format=l.format),o&&(f.comment=o),f}function Am(t,e,i,r,n){if(i==="!")return t[Ye.SCALAR];let a=[];for(let s of t.tags)if(!s.collection&&s.tag===i)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[i];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),t[Ye.SCALAR])}function _m({atKey:t,directives:e,schema:i},r,n,a){let o=i.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(r))||i[Ye.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[Ye.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),f=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}Nl.composeScalar=Cm});var Sl=g(kl=>{"use strict";function Tm(t,e,i){if(e){i??(i=e.length);for(let r=i-1;r>=0;--r){let n=e[r];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++r];n?.type==="space";)t+=n.source.length,n=e[++r];break}}return t}kl.emptyScalarPosition=Tm});var xl=g(Ga=>{"use strict";var Im=Ht(),jm=P(),$m=ml(),El=bl(),Om=mt(),Hm=Sl(),Dm={composeNode:Pl,composeEmptyNode:Ja};function Pl(t,e,i,r){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=i,l,f=!0;switch(e.type){case"alias":l=Bm(t,e,r),(s||c)&&r(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=El.composeScalar(t,e,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=$m.composeCollection(Dm,t,e,i,r),s&&(l.anchor=s.source.substring(1))}catch(d){let u=d instanceof Error?d.message:String(d);r(e,"RESOURCE_EXHAUSTION",u)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),f=!1}}return l??(l=Ja(t,e.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!jm.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(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&&f&&(l.srcToken=e),l}function Ja(t,e,i,r,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let f={type:"scalar",offset:Hm.emptyScalarPosition(e,i,r),indent:-1,source:""},d=El.composeScalar(t,f,s,l);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),a&&(d.comment=a,d.range[2]=c),d}function Bm({options:t},{offset:e,source:i,end:r},n){let a=new Im.Alias(i.substring(1));a.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(e+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+i.length,s=Om.resolveEnd(r,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}Ga.composeEmptyNode=Ja;Ga.composeNode=Pl});var Al=g(Cl=>{"use strict";var Lm=Qt(),Rl=xl(),Mm=mt(),Fm=ii();function Vm(t,e,{offset:i,start:r,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new Lm.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=Fm.resolveProps(r,{indicator:"doc-start",next:n??a?.[0],offset:i,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Rl.composeNode(l,n,f,o):Rl.composeEmptyNode(l,f.end,r,null,f,o);let d=c.contents.range[2],u=Mm.resolveEnd(a,d,!1,o);return u.comment&&(c.comment=u.comment),c.range=[i,d,u.offset],c}Cl.composeDoc=Vm});var Ka=g(Il=>{"use strict";var qm=Ii("process"),Wm=$n(),zm=Qt(),ri=ti(),_l=P(),Jm=Al(),Gm=mt();function ni(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:i}=t;return[e,e+(typeof i=="string"?i.length:1)]}function Tl(t){let e="",i=!1,r=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":r?`
101
+ `),e+=1,r=t[e+1];return i||(i=" "),{fold:i,offset:e}}var Cm={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Rm(t,e,i,r){let n=t.substr(e,i),o=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=t.substr(e-2,i+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}yl.resolveFlowScalar=km});var kl=g(bl=>{"use strict";var Ye=P(),Nl=I(),Am=za(),_m=Ga();function Tm(t,e,i,r){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?Am.resolveBlockScalar(t,e,r):_m.resolveFlowScalar(e,t.options.strict,r),c=i?t.directives.tagName(i.source,d=>r(i,"TAG_RESOLVE_FAILED",d)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Ye.SCALAR]:c?l=Im(t.schema,n,c,i,r):e.type==="scalar"?l=jm(t,n,e,r):l=t.schema[Ye.SCALAR];let f;try{let d=l.resolve(n,u=>r(i??e,"TAG_RESOLVE_FAILED",u),t.options);f=Ye.isScalar(d)?d:new Nl.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);r(i??e,"TAG_RESOLVE_FAILED",u),f=new Nl.Scalar(n)}return f.range=s,f.source=n,a&&(f.type=a),c&&(f.tag=c),l.format&&(f.format=l.format),o&&(f.comment=o),f}function Im(t,e,i,r,n){if(i==="!")return t[Ye.SCALAR];let a=[];for(let s of t.tags)if(!s.collection&&s.tag===i)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[i];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),t[Ye.SCALAR])}function jm({atKey:t,directives:e,schema:i},r,n,a){let o=i.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(r))||i[Ye.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[Ye.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),f=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}bl.composeScalar=Tm});var El=g(Sl=>{"use strict";function $m(t,e,i){if(e){i??(i=e.length);for(let r=i-1;r>=0;--r){let n=e[r];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++r];n?.type==="space";)t+=n.source.length,n=e[++r];break}}return t}Sl.emptyScalarPosition=$m});var Cl=g(Ka=>{"use strict";var Om=Mt(),Hm=P(),Dm=vl(),Pl=kl(),Bm=vt(),Lm=El(),Mm={composeNode:xl,composeEmptyNode:Ua};function xl(t,e,i,r){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=i,l,f=!0;switch(e.type){case"alias":l=Fm(t,e,r),(s||c)&&r(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=Pl.composeScalar(t,e,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Dm.composeCollection(Mm,t,e,i,r),s&&(l.anchor=s.source.substring(1))}catch(d){let u=d instanceof Error?d.message:String(d);r(e,"RESOURCE_EXHAUSTION",u)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),f=!1}}return l??(l=Ua(t,e.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!Hm.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(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&&f&&(l.srcToken=e),l}function Ua(t,e,i,r,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let f={type:"scalar",offset:Lm.emptyScalarPosition(e,i,r),indent:-1,source:""},d=Pl.composeScalar(t,f,s,l);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),a&&(d.comment=a,d.range[2]=c),d}function Fm({options:t},{offset:e,source:i,end:r},n){let a=new Om.Alias(i.substring(1));a.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(e+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+i.length,s=Bm.resolveEnd(r,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}Ka.composeEmptyNode=Ua;Ka.composeNode=xl});var _l=g(Al=>{"use strict";var Vm=ii(),Rl=Cl(),qm=vt(),Wm=oi();function zm(t,e,{offset:i,start:r,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new Vm.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=Wm.resolveProps(r,{indicator:"doc-start",next:n??a?.[0],offset:i,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Rl.composeNode(l,n,f,o):Rl.composeEmptyNode(l,f.end,r,null,f,o);let d=c.contents.range[2],u=qm.resolveEnd(a,d,!1,o);return u.comment&&(c.comment=u.comment),c.range=[i,d,u.offset],c}Al.composeDoc=zm});var Xa=g(jl=>{"use strict";var Jm=$i("process"),Gm=Hn(),Um=ii(),si=ai(),Tl=P(),Km=_l(),Ym=vt();function ci(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:i}=t;return[e,e+(typeof i=="string"?i.length:1)]}function Il(t){let e="",i=!1,r=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":r?`
103
103
 
104
104
  `:`
105
- `)+(a.substring(1)||" "),i=!0,r=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:e,afterEmptyLine:r}}var Ua=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,a)=>{let o=ni(i);a?this.warnings.push(new ri.YAMLWarning(o,r,n)):this.errors.push(new ri.YAMLParseError(o,r,n))},this.directives=new Wm.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,i){let{comment:r,afterEmptyLine:n}=Tl(this.prelude);if(r){let a=e.contents;if(i)e.comment=e.comment?`${e.comment}
106
- ${r}`:r;else if(n||e.directives.docStart||!a)e.commentBefore=r;else if(_l.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];_l.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${r}
105
+ `)+(a.substring(1)||" "),i=!0,r=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:e,afterEmptyLine:r}}var Ya=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,a)=>{let o=ci(i);a?this.warnings.push(new si.YAMLWarning(o,r,n)):this.errors.push(new si.YAMLParseError(o,r,n))},this.directives=new Gm.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,i){let{comment:r,afterEmptyLine:n}=Il(this.prelude);if(r){let a=e.contents;if(i)e.comment=e.comment?`${e.comment}
106
+ ${r}`:r;else if(n||e.directives.docStart||!a)e.commentBefore=r;else if(Tl.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Tl.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${r}
107
107
  ${s}`:r}else{let o=a.commentBefore;a.commentBefore=o?`${r}
108
- ${o}`:r}}if(i){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:Tl(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,i=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(i,r)}*next(e){switch(qm.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(i,r,n)=>{let a=ni(e);a[0]+=i,this.onError(a,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let i=Jm.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(i,!1),this.doc&&(yield this.doc),this.doc=i,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let i=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new ri.YAMLParseError(ni(e),"UNEXPECTED_TOKEN",i);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new ri.YAMLParseError(ni(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=Gm.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),i.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
109
- ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new ri.YAMLParseError(ni(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new zm.Document(void 0,r);this.atDirectives&&this.onError(i,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,i,i],this.decorate(n,!1),yield n}}};Il.Composer=Ua});var Ol=g(Rr=>{"use strict";var Um=qa(),Km=za(),Ym=ti(),jl=Ft();function Xm(t,e=!0,i){if(t){let r=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(i)i(s,a,o);else throw new Ym.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Km.resolveFlowScalar(t,e,r);case"block-scalar":return Um.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function Qm(t,e){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=jl.stringifyString({type:o,value:t},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
108
+ ${o}`:r}}if(i){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:Il(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,i=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(i,r)}*next(e){switch(Jm.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(i,r,n)=>{let a=ci(e);a[0]+=i,this.onError(a,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let i=Km.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(i,!1),this.doc&&(yield this.doc),this.doc=i,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let i=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new si.YAMLParseError(ci(e),"UNEXPECTED_TOKEN",i);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new si.YAMLParseError(ci(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=Ym.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),i.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
109
+ ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new si.YAMLParseError(ci(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new Um.Document(void 0,r);this.atDirectives&&this.onError(i,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,i,i],this.decorate(n,!1),yield n}}};jl.Composer=Ya});var Hl=g(Rr=>{"use strict";var Xm=za(),Qm=Ga(),Zm=ai(),$l=zt();function ev(t,e=!0,i){if(t){let r=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(i)i(s,a,o);else throw new Zm.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Qm.resolveFlowScalar(t,e,r);case"block-scalar":return Xm.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function tv(t,e){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=$l.stringifyString({type:o,value:t},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
110
110
  `}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
111
111
  `),f=s.substring(0,l),d=s.substring(l+1)+`
112
- `,u=[{type:"block-scalar-header",offset:a,indent:r,source:f}];return $l(u,c)||u.push({type:"newline",offset:-1,indent:r,source:`
113
- `}),{type:"block-scalar",offset:a,indent:r,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:r,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:r,source:s,end:c};default:return{type:"scalar",offset:a,indent:r,source:s,end:c}}}function Zm(t,e,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=i,s="indent"in t?t.indent:null;if(r&&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=jl.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">":ev(t,c);break;case'"':Ya(t,c,"double-quoted-scalar");break;case"'":Ya(t,c,"single-quoted-scalar");break;default:Ya(t,c,"scalar")}}function ev(t,e){let i=e.indexOf(`
112
+ `,u=[{type:"block-scalar-header",offset:a,indent:r,source:f}];return Ol(u,c)||u.push({type:"newline",offset:-1,indent:r,source:`
113
+ `}),{type:"block-scalar",offset:a,indent:r,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:r,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:r,source:s,end:c};default:return{type:"scalar",offset:a,indent:r,source:s,end:c}}}function iv(t,e,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=i,s="indent"in t?t.indent:null;if(r&&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=$l.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">":rv(t,c);break;case'"':Qa(t,c,"double-quoted-scalar");break;case"'":Qa(t,c,"single-quoted-scalar");break;default:Qa(t,c,"scalar")}}function rv(t,e){let i=e.indexOf(`
114
114
  `),r=e.substring(0,i),n=e.substring(i+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=r,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:r}];$l(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 $l(t,e){if(e)for(let i of e)switch(i.type){case"space":case"comment":t.push(i);break;case"newline":return t.push(i),!0}return!1}function Ya(t,e,i){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=i,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let a of r)a.offset+=n;delete t.props,Object.assign(t,{type:i,source:e,end:r});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:i,source:e,end:[n]});break}default:{let r="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:i,indent:r,source:e,end:n})}}}Rr.createScalarToken=Qm;Rr.resolveAsScalar=Xm;Rr.setScalarValue=Zm});var Dl=g(Hl=>{"use strict";var tv=t=>"type"in t?Ar(t):Cr(t);function Ar(t){switch(t.type){case"block-scalar":{let e="";for(let i of t.props)e+=Ar(i);return e+t.source}case"block-map":case"block-seq":{let e="";for(let i of t.items)e+=Cr(i);return e}case"flow-collection":{let e=t.start.source;for(let i of t.items)e+=Cr(i);for(let i of t.end)e+=i.source;return e}case"document":{let e=Cr(t);if(t.end)for(let i of t.end)e+=i.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let i of t.end)e+=i.source;return e}}}function Cr({start:t,key:e,sep:i,value:r}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Ar(e)),i)for(let a of i)n+=a.source;return r&&(n+=Ar(r)),n}Hl.stringify=tv});var Fl=g(Ml=>{"use strict";var Xa=Symbol("break visit"),iv=Symbol("skip children"),Bl=Symbol("remove item");function Xe(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Ll(Object.freeze([]),t,e)}Xe.BREAK=Xa;Xe.SKIP=iv;Xe.REMOVE=Bl;Xe.itemAtPath=(t,e)=>{let i=t;for(let[r,n]of e){let a=i?.[r];if(a&&"items"in a)i=a.items[n];else return}return i};Xe.parentCollection=(t,e)=>{let i=Xe.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Ll(t,e,i){let r=i(e,t);if(typeof r=="symbol")return r;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=Ll(Object.freeze(t.concat([[n,o]])),a.items[o],i);if(typeof s=="number")o=s-1;else{if(s===Xa)return Xa;s===Bl&&(a.items.splice(o,1),o-=1)}}typeof r=="function"&&n==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Ml.visit=Xe});var _r=g(W=>{"use strict";var Qa=Ol(),rv=Dl(),nv=Fl(),Za="\uFEFF",eo="",to="",io="",av=t=>!!t&&"items"in t,ov=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function sv(t){switch(t){case Za:return"<BOM>";case eo:return"<DOC>";case to:return"<FLOW_END>";case io:return"<SCALAR>";default:return JSON.stringify(t)}}function cv(t){switch(t){case Za:return"byte-order-mark";case eo:return"doc-mode";case to:return"flow-error-end";case io:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
+ `;if(t.type==="block-scalar"){let a=t.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=r,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:r}];Ol(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 Ol(t,e){if(e)for(let i of e)switch(i.type){case"space":case"comment":t.push(i);break;case"newline":return t.push(i),!0}return!1}function Qa(t,e,i){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=i,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let a of r)a.offset+=n;delete t.props,Object.assign(t,{type:i,source:e,end:r});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:i,source:e,end:[n]});break}default:{let r="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:i,indent:r,source:e,end:n})}}}Rr.createScalarToken=tv;Rr.resolveAsScalar=ev;Rr.setScalarValue=iv});var Bl=g(Dl=>{"use strict";var nv=t=>"type"in t?_r(t):Ar(t);function _r(t){switch(t.type){case"block-scalar":{let e="";for(let i of t.props)e+=_r(i);return e+t.source}case"block-map":case"block-seq":{let e="";for(let i of t.items)e+=Ar(i);return e}case"flow-collection":{let e=t.start.source;for(let i of t.items)e+=Ar(i);for(let i of t.end)e+=i.source;return e}case"document":{let e=Ar(t);if(t.end)for(let i of t.end)e+=i.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let i of t.end)e+=i.source;return e}}}function Ar({start:t,key:e,sep:i,value:r}){let n="";for(let a of t)n+=a.source;if(e&&(n+=_r(e)),i)for(let a of i)n+=a.source;return r&&(n+=_r(r)),n}Dl.stringify=nv});var Vl=g(Fl=>{"use strict";var Za=Symbol("break visit"),av=Symbol("skip children"),Ll=Symbol("remove item");function Xe(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Ml(Object.freeze([]),t,e)}Xe.BREAK=Za;Xe.SKIP=av;Xe.REMOVE=Ll;Xe.itemAtPath=(t,e)=>{let i=t;for(let[r,n]of e){let a=i?.[r];if(a&&"items"in a)i=a.items[n];else return}return i};Xe.parentCollection=(t,e)=>{let i=Xe.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Ml(t,e,i){let r=i(e,t);if(typeof r=="symbol")return r;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=Ml(Object.freeze(t.concat([[n,o]])),a.items[o],i);if(typeof s=="number")o=s-1;else{if(s===Za)return Za;s===Ll&&(a.items.splice(o,1),o-=1)}}typeof r=="function"&&n==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Fl.visit=Xe});var Tr=g(W=>{"use strict";var eo=Hl(),ov=Bl(),sv=Vl(),to="\uFEFF",io="",ro="",no="",cv=t=>!!t&&"items"in t,lv=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function uv(t){switch(t){case to:return"<BOM>";case io:return"<DOC>";case ro:return"<FLOW_END>";case no:return"<SCALAR>";default:return JSON.stringify(t)}}function dv(t){switch(t){case to:return"byte-order-mark";case io:return"doc-mode";case ro:return"flow-error-end";case no:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
118
118
  `:case`\r
119
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}W.createScalarToken=Qa.createScalarToken;W.resolveAsScalar=Qa.resolveAsScalar;W.setScalarValue=Qa.setScalarValue;W.stringify=rv.stringify;W.visit=nv.visit;W.BOM=Za;W.DOCUMENT=eo;W.FLOW_END=to;W.SCALAR=io;W.isCollection=av;W.isScalar=ov;W.prettyToken=sv;W.tokenType=cv});var ao=g(ql=>{"use strict";var ai=_r();function ae(t){switch(t){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var Vl=new Set("0123456789ABCDEFabcdef"),lv=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Tr=new Set(",[]{}"),uv=new Set(` ,[]{}
121
- \r `),ro=t=>!t||uv.has(t),no=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,i=!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=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,i=this.buffer[e];for(;i===" "||i===" ";)i=this.buffer[++e];return!i||i==="#"||i===`
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}W.createScalarToken=eo.createScalarToken;W.resolveAsScalar=eo.resolveAsScalar;W.setScalarValue=eo.setScalarValue;W.stringify=ov.stringify;W.visit=sv.visit;W.BOM=to;W.DOCUMENT=io;W.FLOW_END=ro;W.SCALAR=no;W.isCollection=cv;W.isScalar=lv;W.prettyToken=uv;W.tokenType=dv});var so=g(Wl=>{"use strict";var li=Tr();function ae(t){switch(t){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var ql=new Set("0123456789ABCDEFabcdef"),fv=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ir=new Set(",[]{}"),hv=new Set(` ,[]{}
121
+ \r `),ao=t=>!t||hv.has(t),oo=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,i=!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=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,i=this.buffer[e];for(;i===" "||i===" ";)i=this.buffer[++e];return!i||i==="#"||i===`
122
122
  `?!0:i==="\r"?this.buffer[e+1]===`
123
123
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let i=this.buffer[e];if(this.indentNext>0){let r=0;for(;i===" ";)i=this.buffer[++r+e];if(i==="\r"){let n=this.buffer[r+e+1];if(n===`
124
124
  `||!n&&!this.atEnd)return e+r+1}return i===`
125
125
  `||r>=this.indentNext||!i&&!this.atEnd?e+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&ae(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 i=e.length,r=e.indexOf("#");for(;r!==-1;){let a=e[r-1];if(a===" "||a===" "){i=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let a=e[i-1];if(a===" "||a===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-i),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 i=this.peek(3);if((i==="---"||i==="...")&&ae(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,i==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ae(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ae(i)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(e[i]){case"#":yield*this.pushCount(e.length-i);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(ro),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,i,r=-1;do e=yield*this.pushNewline(),e>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(e+i>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&ae(n[3]))&&!(r===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(ro),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ae(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),i=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;i!==-1&&this.buffer[i+1]==="'";)i=this.buffer.indexOf("'",i+2);else for(;i!==-1;){let a=0;for(;this.buffer[i-1-a]==="\\";)a+=1;if(a%2===0)break;i=this.buffer.indexOf('"',i+1)}let r=this.buffer.substring(0,i),n=r.indexOf(`
126
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===li.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let i=e.length,r=e.indexOf("#");for(;r!==-1;){let a=e[r-1];if(a===" "||a===" "){i=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let a=e[i-1];if(a===" "||a===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-i),yield*this.pushNewline(),"stream"}return yield li.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let i=this.peek(3);if((i==="---"||i==="...")&&ae(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,i==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ae(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ae(i)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(e[i]){case"#":yield*this.pushCount(e.length-i);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(ao),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,i,r=-1;do e=yield*this.pushNewline(),e>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(e+i>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&ae(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield li.FLOW_END,yield*this.parseLineStart();let a=0;for(;n[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(ao),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ae(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),i=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;i!==-1&&this.buffer[i+1]==="'";)i=this.buffer.indexOf("'",i+2);else for(;i!==-1;){let a=0;for(;this.buffer[i-1-a]==="\\";)a+=1;if(a%2===0)break;i=this.buffer.indexOf('"',i+1)}let r=this.buffer.substring(0,i),n=r.indexOf(`
127
127
  `,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=r.indexOf(`
128
128
  `,a)}n!==-1&&(i=n-(r[n-1]==="\r"?2:1))}if(i===-1){if(!this.atEnd)return this.setNext("quoted-scalar");i=this.buffer.length}return yield*this.pushToIndex(i+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let i=this.buffer[++e];if(i==="+")this.blockScalarKeep=!0;else if(i>"0"&&i<="9")this.blockScalarIndent=Number(i)-1;else if(i!=="-")break}return yield*this.pushUntil(i=>ae(i)||i==="#")}*parseBlockScalar(){let e=this.pos-1,i=0,r;e:for(let a=this.pos;r=this.buffer[a];++a)switch(r){case" ":i+=1;break;case`
129
129
  `:e=a,i=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
130
130
  `)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(i>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=i:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(e+1);if(a===-1)break;e=this.buffer.indexOf(`
131
131
  `,a)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(r=this.buffer[n];r===" ";)r=this.buffer[++n];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
132
132
  `;)r=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+i>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,i=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let a=this.buffer[r+1];if(ae(a)||e&&Tr.has(a))break;i=r}else if(ae(n)){let a=this.buffer[r+1];if(n==="\r"&&(a===`
133
+ `&&a>=this.pos&&a+1+i>s)e=a;else break}while(!0);return yield li.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,i=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let a=this.buffer[r+1];if(ae(a)||e&&Ir.has(a))break;i=r}else if(ae(n)){let a=this.buffer[r+1];if(n==="\r"&&(a===`
134
134
  `?(r+=1,n=`
135
- `,a=this.buffer[r+1]):i=r),a==="#"||e&&Tr.has(a))break;if(n===`
136
- `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Tr.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield ai.SCALAR,yield*this.pushToIndex(i+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,i){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(i&&(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(ro),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let i=this.flowLevel>0,r=this.charAt(1);if(ae(r)||i&&Tr.has(r)){i?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,i=this.buffer[e];for(;!ae(i)&&i!==">";)i=this.buffer[++e];return yield*this.pushToIndex(i===">"?e+1:e,!1)}else{let e=this.pos+1,i=this.buffer[e];for(;i;)if(lv.has(i))i=this.buffer[++e];else if(i==="%"&&Vl.has(this.buffer[e+1])&&Vl.has(this.buffer[e+2]))i=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
135
+ `,a=this.buffer[r+1]):i=r),a==="#"||e&&Ir.has(a))break;if(n===`
136
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Ir.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield li.SCALAR,yield*this.pushToIndex(i+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,i){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(i&&(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(ao),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let i=this.flowLevel>0,r=this.charAt(1);if(ae(r)||i&&Ir.has(r)){i?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,i=this.buffer[e];for(;!ae(i)&&i!==">";)i=this.buffer[++e];return yield*this.pushToIndex(i===">"?e+1:e,!1)}else{let e=this.pos+1,i=this.buffer[e];for(;i;)if(fv.has(i))i=this.buffer[++e];else if(i==="%"&&ql.has(this.buffer[e+1])&&ql.has(this.buffer[e+2]))i=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
137
137
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
138
- `?yield*this.pushCount(2):0}*pushSpaces(e){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||e&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(e){let i=this.pos,r=this.buffer[i];for(;!e(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};ql.Lexer=no});var so=g(Wl=>{"use strict";var oo=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let i=0,r=this.lineStarts.length;for(;i<r;){let a=i+r>>1;this.lineStarts[a]<e?i=a+1:r=a}if(this.lineStarts[i]===e)return{line:i+1,col:1};if(i===0)return{line:0,col:e};let n=this.lineStarts[i-1];return{line:i,col:e-n+1}}}};Wl.LineCounter=oo});var lo=g(Kl=>{"use strict";var dv=Ii("process"),zl=_r(),fv=ao();function Be(t,e){for(let i=0;i<t.length;++i)if(t[i].type===e)return!0;return!1}function Jl(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 Ul(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 Ir(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 vt(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 jr(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let i=0;i<e.length;++i)t.push(e[i])}function Gl(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Be(e.start,"explicit-key-ind")&&!Be(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Ul(e.value)?e.value.end?jr(e.value.end,e.sep):e.value.end=e.sep:jr(e.start,e.sep),delete e.sep)}var co=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 fv.Lexer,this.onNewLine=e}*parse(e,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,i))yield*this.next(r);i||(yield*this.end())}*next(e){if(this.source=e,dv.env.LOG_TOKENS&&console.log("|",zl.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let i=zl.tokenType(e);if(i)if(i==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=i,yield*this.step(),i){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 r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,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 i=e??this.stack.pop();if(!i)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield i;else{let r=this.peek(1);switch(i.type==="block-scalar"?i.indent="indent"in r?r.indent:0:i.type==="flow-collection"&&r.type==="document"&&(i.indent=0),i.type==="flow-collection"&&Gl(i),r.type){case"document":r.value=i;break;case"block-scalar":r.props.push(i);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:i,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=i;else{Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];n.value?r.items.push({start:[],value:i}):n.value=i;break}case"flow-collection":{let n=r.items[r.items.length-1];!n||n.value?r.items.push({start:[],key:i,sep:[]}):n.sep?n.value=i:Object.assign(n,{key:i,sep:[]});return}default:yield*this.pop(),yield*this.pop(i)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(i.type==="block-map"||i.type==="block-seq")){let n=i.items[i.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Jl(n.start)===-1&&(i.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<i.indent))&&(r.type==="document"?r.end=n.start:r.items.push({start:n.start}),i.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":{Jl(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 i=this.startBlockValue(e);i?this.stack.push(i):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 i=Ir(this.peek(2)),r=vt(i),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:r,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 i=this.source.indexOf(`
138
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||e&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(e){let i=this.pos,r=this.buffer[i];for(;!e(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};Wl.Lexer=oo});var lo=g(zl=>{"use strict";var co=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let i=0,r=this.lineStarts.length;for(;i<r;){let a=i+r>>1;this.lineStarts[a]<e?i=a+1:r=a}if(this.lineStarts[i]===e)return{line:i+1,col:1};if(i===0)return{line:0,col:e};let n=this.lineStarts[i-1];return{line:i,col:e-n+1}}}};zl.LineCounter=co});var fo=g(Yl=>{"use strict";var pv=$i("process"),Jl=Tr(),mv=so();function Me(t,e){for(let i=0;i<t.length;++i)if(t[i].type===e)return!0;return!1}function Gl(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 Kl(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 jr(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 gt(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 $r(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let i=0;i<e.length;++i)t.push(e[i])}function Ul(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Me(e.start,"explicit-key-ind")&&!Me(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Kl(e.value)?e.value.end?$r(e.value.end,e.sep):e.value.end=e.sep:$r(e.start,e.sep),delete e.sep)}var uo=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 mv.Lexer,this.onNewLine=e}*parse(e,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,i))yield*this.next(r);i||(yield*this.end())}*next(e){if(this.source=e,pv.env.LOG_TOKENS&&console.log("|",Jl.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let i=Jl.tokenType(e);if(i)if(i==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=i,yield*this.step(),i){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 r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,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 i=e??this.stack.pop();if(!i)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield i;else{let r=this.peek(1);switch(i.type==="block-scalar"?i.indent="indent"in r?r.indent:0:i.type==="flow-collection"&&r.type==="document"&&(i.indent=0),i.type==="flow-collection"&&Ul(i),r.type){case"document":r.value=i;break;case"block-scalar":r.props.push(i);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:i,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=i;else{Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];n.value?r.items.push({start:[],value:i}):n.value=i;break}case"flow-collection":{let n=r.items[r.items.length-1];!n||n.value?r.items.push({start:[],key:i,sep:[]}):n.sep?n.value=i:Object.assign(n,{key:i,sep:[]});return}default:yield*this.pop(),yield*this.pop(i)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(i.type==="block-map"||i.type==="block-seq")){let n=i.items[i.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Gl(n.start)===-1&&(i.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<i.indent))&&(r.type==="document"?r.end=n.start:r.items.push({start:n.start}),i.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":{Gl(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 i=this.startBlockValue(e);i?this.stack.push(i):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 i=jr(this.peek(2)),r=gt(i),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:r,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 i=this.source.indexOf(`
139
139
  `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
140
- `,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){jr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&i.sep&&!i.value){let o=[];for(let s=0;s<i.sep.length;++s){let c=i.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=i.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||i.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):n||i.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(i.explicitKey)if(i.sep)if(i.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Be(i.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(Ul(i.key)&&!Be(i.sep,"newline")){let o=vt(i.start),s=i.key,c=i.sep;c.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?i.sep=i.sep.concat(a,this.sourceToken):i.sep.push(this.sourceToken);else if(Be(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let o=vt(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||n?e.items.push({start:a,key:null,sep:[this.sourceToken]}):Be(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{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||i.value?(e.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(o):(Object.assign(i,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!i.explicitKey&&i.sep&&!Be(i.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 r&&e.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){jr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=e.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;i.value||Be(i.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let i=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!i||i.value?e.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!i||i.value?e.items.push({start:[],key:n,sep:[]}):i.sep?this.stack.push(n):Object.assign(i,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=Ir(r),a=vt(n);Gl(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 i=this.source.indexOf(`
140
+ `,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){$r(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&i.sep&&!i.value){let o=[];for(let s=0;s<i.sep.length;++s){let c=i.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=i.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||i.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):n||i.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(i.explicitKey)if(i.sep)if(i.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Me(i.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(Kl(i.key)&&!Me(i.sep,"newline")){let o=gt(i.start),s=i.key,c=i.sep;c.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?i.sep=i.sep.concat(a,this.sourceToken):i.sep.push(this.sourceToken);else if(Me(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let o=gt(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||n?e.items.push({start:a,key:null,sep:[this.sourceToken]}):Me(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{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||i.value?(e.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(o):(Object.assign(i,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!i.explicitKey&&i.sep&&!Me(i.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 r&&e.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){$r(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=e.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;i.value||Me(i.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let i=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!i||i.value?e.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!i||i.value?e.items.push({start:[],key:n,sep:[]}):i.sep?this.stack.push(n):Object.assign(i,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=jr(r),a=gt(n);Ul(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 i=this.source.indexOf(`
141
141
  `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
142
- `,i)+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 i=Ir(e),r=vt(i);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=Ir(e),r=vt(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,i){return this.type!=="comment"||this.indent<=i?!1:e.every(r=>r.type==="newline"||r.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())}}};Kl.Parser=co});var eu=g(si=>{"use strict";var Yl=Ka(),hv=Qt(),oi=ti(),pv=Gn(),mv=P(),vv=so(),Xl=lo();function Ql(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new vv.LineCounter||null,prettyErrors:e}}function gv(t,e={}){let{lineCounter:i,prettyErrors:r}=Ql(e),n=new Xl.Parser(i?.addNewLine),a=new Yl.Composer(e),o=Array.from(a.compose(n.parse(t)));if(r&&i)for(let s of o)s.errors.forEach(oi.prettifyError(t,i)),s.warnings.forEach(oi.prettifyError(t,i));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function Zl(t,e={}){let{lineCounter:i,prettyErrors:r}=Ql(e),n=new Xl.Parser(i?.addNewLine),a=new Yl.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 oi.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(o.errors.forEach(oi.prettifyError(t,i)),o.warnings.forEach(oi.prettifyError(t,i))),o}function wv(t,e,i){let r;typeof e=="function"?r=e:i===void 0&&e&&typeof e=="object"&&(i=e);let n=Zl(t,i);if(!n)return null;if(n.warnings.forEach(a=>pv.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:r},i))}function yv(t,e,i){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:i===void 0&&e&&(i=e),typeof i=="string"&&(i=i.length),typeof i=="number"){let n=Math.round(i);i=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=i??e??{};if(!n)return}return mv.isDocument(t)&&!r?t.toString(i):new hv.Document(t,r,i).toString(i)}si.parse=wv;si.parseAllDocuments=gv;si.parseDocument=Zl;si.stringify=yv});var ci=g(x=>{"use strict";var Nv=Ka(),bv=Qt(),kv=Aa(),uo=ti(),Sv=Ht(),Le=P(),Ev=$e(),Pv=I(),xv=He(),Rv=De(),Cv=_r(),Av=ao(),_v=so(),Tv=lo(),$r=eu(),tu=It();x.Composer=Nv.Composer;x.Document=bv.Document;x.Schema=kv.Schema;x.YAMLError=uo.YAMLError;x.YAMLParseError=uo.YAMLParseError;x.YAMLWarning=uo.YAMLWarning;x.Alias=Sv.Alias;x.isAlias=Le.isAlias;x.isCollection=Le.isCollection;x.isDocument=Le.isDocument;x.isMap=Le.isMap;x.isNode=Le.isNode;x.isPair=Le.isPair;x.isScalar=Le.isScalar;x.isSeq=Le.isSeq;x.Pair=Ev.Pair;x.Scalar=Pv.Scalar;x.YAMLMap=xv.YAMLMap;x.YAMLSeq=Rv.YAMLSeq;x.CST=Cv;x.Lexer=Av.Lexer;x.LineCounter=_v.LineCounter;x.Parser=Tv.Parser;x.parse=$r.parse;x.parseAllDocuments=$r.parseAllDocuments;x.parseDocument=$r.parseDocument;x.stringify=$r.stringify;x.visit=tu.visit;x.visitAsync=tu.visitAsync});function us(t){let e={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[]},i=r=>({kind:r,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...e,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:i("none")};if(t.status==="await-user")return t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...e,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","user-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:i("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...e,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","user-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:i("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...e,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--resolve-verifier-blocker"],requiredInputs:["summary","user-resolution"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:i("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...e,disposition:"await-user",action:"resolve-loop-stop",commandArgs:["comet","native","next",t.name,"--return-to-build","--summary","<summary>"],requiredInputs:["summary","user-decision"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:i("none")}:{...e,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:i("none")};if(t.status==="blocked"){let r=t.blockers.some(({resolution_action:n})=>n==="retry-verifier");return{...e,disposition:"blocked",action:r?"retry-verifier":"none",commandArgs:r?["comet","native","next",t.name,"--retry-verifier","--summary","<summary>"]:null,requiredInputs:r?["summary"]:["repair-runtime"],inputOptions:r?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:i(r?"retry-verifier":"none")}}if(t.phase==="shape")return{...e,disposition:"continue",action:"confirm-shape",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","shared-understanding-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:i("none")};if(t.phase==="build")return{...e,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:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[]}}],runnerAction:i("builder-handoff")};if(t.phase==="verify"){let r=t.loop.next_action==="await-verifier-result";return{...e,disposition:"continue",action:r?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[r?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:r?[{kind:"verifier-response",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}]}},{kind:"verifier-response",response:{kind:"final-result",result:{iteration:t.loop.iteration,attempt:t.loop.attempt,verdict:"<pass|fail|blocked>",acceptance:[{id:"<acceptance-id>",result:"<passed|failed|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:"<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:"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:[]}}],runnerAction:i(r?"await-verifier":"dispatch-verifier")}}return{...e,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:i("none")}}import{randomUUID as _y}from"node:crypto";import{promises as _i}from"node:fs";import Ty from"node:path";import{execFileSync as Vd}from"child_process";import $i from"path";function Rn(t,e){return Vd("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function qd(t,e){let i=$i.normalize(t),r=$i.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function ke(t){try{let e=$i.resolve(Rn(t,["rev-parse","--show-toplevel"])),r=Rn(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=r?$i.resolve(r.slice(9)):e,a=null;try{a=Rn(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!qd(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}import{randomUUID as Wd}from"crypto";import{promises as B}from"fs";import ie from"path";function Ae(t){return t!==0&&t!==0n&&t!=="0"}function G(t,e){return Ae(t.dev)&&Ae(e.dev)&&Ae(t.ino)&&Ae(e.ino)}function A(t,e){let i=Ae(t.dev)&&Ae(e.dev);if(i&&t.dev!==e.dev)return!1;let r=Ae(t.ino)&&Ae(e.ino);return r&&t.ino!==e.ino?!1:i&&r?!0:t.birthtime===e.birthtime}function An(t,e){let i=ie.relative(t,e);return i===""||!ie.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ie.sep}`)}function zd(t,e){return A({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Cn(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return G(i,r)?A(i,r):A(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function ds(t){let e=await B.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 B.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function _t(t){for(let e of t){let i=await B.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!zd(e,i)||await B.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Jd(t,e){let i=ie.resolve(t),r=ie.resolve(e);if(!An(i,r))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await ds(i)],a=ie.relative(i,r).split(ie.sep).filter(Boolean),o=i;for(let s of a){await _t(n),o=ie.join(o,s);try{await B.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await ds(o);if(!An(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await _t(n),n}async function Gd(t){let e;try{e=await B.open(t,"r"),await e.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await e?.close()}}async function Ud(t,e,i={}){let r=ie.dirname(t),n=i.containedRoot?await Jd(i.containedRoot,r):null;n||await B.mkdir(r,{recursive:!0});let a=ie.join(r,`.${ie.basename(t)}.${Wd()}.tmp`),o,s;try{if(await i.beforeTemporaryOpen?.(),o=await B.open(a,"wx"),s=await o.stat(),n){let[c,l]=await Promise.all([B.lstat(a),B.realpath(a)]);if(await _t(n),!c.isFile()||c.isSymbolicLink()||!Cn(s,c)||!An(n[0].realPath,l))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(),!Cn(s,await o.stat()))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await i.beforeCommit?.(),n){await _t(n);let c=await B.lstat(a);if(!c.isFile()||c.isSymbolicLink()||!s||!Cn(c,s))throw new Error("Native atomic write temporary file changed before commit")}i.exclusive?(await B.link(a,t),await B.unlink(a)):await B.rename(a,t),await Gd(r)}catch(c){if(await o?.close(),!n)await B.rm(a,{force:!0});else try{await _t(n),await B.rm(a,{force:!0})}catch{}throw c}}async function de(t,e,i={}){await Ud(t,e,i)}async function K(t,e,i={}){await de(t,JSON.stringify(e,null,2)+`
143
- `,i)}import{createHash as Qd}from"node:crypto";import{promises as re}from"node:fs";import Y from"node:path";import{TextDecoder as Zd}from"node:util";var Kd=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Yd=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Xd(t){return t.toLowerCase().startsWith(".env")}function Tt(t){let i=t.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>Xd(r))?"environment-file":i.some(r=>Yd.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>Kd.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}var Hi=1024*1024;function _n(t,e){let i=Y.relative(t,e);return i===""||!Y.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Y.sep}`)}function ef(t){let e=Y.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})||Y.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 i=t.toLowerCase(),r=Tt(t);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${t}`);return t}function tf(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function rf(t,e){return A({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Oi(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return G(i,r)?A(i,r):A(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function fs(t){let e=await re.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact 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 nf(t,e){let i=Y.resolve(t),r=Y.resolve(e);if(!_n(i,r))throw new Error("Native artifact path is outside its root");let n=[await fs(i)],a=i;for(let o of Y.relative(i,r).split(Y.sep).filter(Boolean)){a=Y.join(a,o);let s=await fs(a);if(!_n(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function hs(t){for(let e of t){let i=await re.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!rf(e,i)||await re.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function V(t){let e=ef(t.ref),i=t.maxBytes===null?null:tf(t.maxBytes??Hi),r=Y.resolve(t.root,...e.split("/")),n=await nf(t.root,Y.dirname(r));await t.hooks?.afterParentChainCaptured?.();let a=await re.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(i!==null&&a.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);let o=await re.realpath(r);if(!_n(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await re.open(r,"r");try{let[c,l,f]=await Promise.all([s.stat(),re.lstat(r),re.realpath(r)]);if(await hs(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||f!==o||!Oi(a,c)||!Oi(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],u=0,p=Buffer.allocUnsafe(i===null?64*1024:Math.min(64*1024,i+1));for(;;){let b=i===null?p.length:i+1-u,k=await s.read(p,0,Math.min(p.length,b),null);if(k.bytesRead===0)break;if(u+=k.bytesRead,i!==null&&u>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);d.push(Buffer.from(p.subarray(0,k.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),re.lstat(r),re.realpath(r)]);if(await hs(n),!h.isFile()||h.isSymbolicLink()||m!==o||!Oi(c,v)||!Oi(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let w=Buffer.concat(d,u),y;try{y=new Zd("utf-8",{fatal:!0}).decode(w)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:b})}return{ref:e,size:u,hash:t.includeHash===!1?null:Qd("sha256").update(w).digest("hex"),text:y}}finally{await s.close()}}var Zo=ji(ci(),1);import Rt from"path";var ho=ji(ci(),1);import Or from"path";var ui=64*1024,Hr=1024,Dr=64,po=5,Iv=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],jv=["**/.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"],$v=[...Iv,...jv].sort((t,e)=>t.localeCompare(e,"en"));var U={include:["**/*"],exclude:[...$v],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function Ov(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim();if(i.length===0||Or.posix.isAbsolute(i)||Or.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function Qe(t){let e=Ov(t,"native.artifact_root");return e.length===0?".":e.join("/")}function ru(t,e="docs"){let i=t??e;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function mo(t,e,i=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim().replaceAll("\\","/");if(r.length===0||Or.posix.isAbsolute(r)||Or.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let n=r.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(!i&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function li(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function nu(t,e,i){let r=t??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function vo(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>Hr)throw new Error(`${e} exceeds ${Hr} characters`);let i=0;for(let r=0;r<t.length;r+=1)t[r]==="?"?i+=1:t[r]==="*"&&(i+=1,t[r+1]==="*"&&(r+=1));if(i>Dr)throw new Error(`${e} contains more than ${Dr} wildcard tokens`);return t}function iu(t,e,i){if(t===void 0)return[...i];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(r=>vo(r,e)))].sort((r,n)=>r.localeCompare(n,"en"))}function fo(t,e,i){let r=t??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function Hv(t){if(t===void 0)return{...U,include:[...U.include],exclude:[...U.exclude]};let e=li(t,"native.snapshot");return{include:iu(e.include,"native.snapshot.include",U.include),exclude:iu(e.exclude,"native.snapshot.exclude",U.exclude),max_files:fo(e.max_files,U.max_files,"native.snapshot.max_files"),max_total_bytes:fo(e.max_total_bytes,U.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:fo(e.max_duration_ms,U.max_duration_ms,"native.snapshot.max_duration_ms")}}function Dv(t){if(t===void 0)return;let e=li(t,"native.pending_root_move"),i=e.id,r=e.from_artifact_root,n=e.to_artifact_root,a=e.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="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=li(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,f=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 f!="string"||!/^[a-f0-9]{64}$/u.test(f))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:f}}return{id:i,fromArtifactRoot:Qe(r),toArtifactRoot:Qe(n),stage:a,...o?{cleanup:o}:{}}}function Bv(t,e={}){let i=li(t,"native"),r=i.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let n=i.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=i.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=i.max_verify_failures??po;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Dv(i.pending_root_move);return{artifact_root:Qe(r),language:nu(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Hv(i.snapshot),...s?{pending_root_move:s}:{}}}function Lv(t){let e=li(t,"classic"),i=e.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="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");return{artifact_layout:ru(e.artifact_layout),language:nu(e.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function Mv(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function Fv(t,e,i,r,n){let a=t.schema!==void 0;if(!(a||t.default_workflow!==void 0||t.workflows!==void 0||!n.allowPartialProject&&t.native!==void 0)||n.allowPartialProject&&!a)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 s=t.workflows??[t.default_workflow];if(!Array.isArray(s)||s.length===0||s.some(l=>l!=="native"&&l!=="classic"))throw new Error("workflows must contain native and/or classic");let c=[...new Set(s)];if(!c.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(c.includes("native")&&!e)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:c,ambient_resume:r,...e?{native:e}:{},...i?{classic:i}:{}}}function di(t,e={}){let i=(0,ho.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let r=i.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=r,a=Mv(n.ambient_resume),o=n.native===void 0?void 0:Bv(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),s=n.classic===void 0?void 0:Lv(n.classic),c=Fv(n,o,s,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:c,ambient_resume:a,...o?{native:o}:{},...s?{classic:s}:{}}}function Br(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:Qe(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:po,snapshot:{...U,include:[...U.include],exclude:[...U.exclude]}}}}import{createHash as qv}from"crypto";import{promises as Fr}from"fs";import Me from"path";import{constants as Lr,promises as Ze}from"fs";var oe=class extends Error{reason;constructor(e,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=e}};function go(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function au(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function fi(t){return{dev:t.dev,ino:t.ino,birthtime:go(t)}}function Mr(t,e){let i=fi(t),r=fi(e);return G(i,r)?A(i,r):A(i,r)&&go(t)===go(e)&&au(t)===au(e)&&t.size===e.size}async function gt(t,e,i={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=i.label??"file",n=i.bigint===!0,a=await Ze.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new oe("not-regular-file",`${r} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new oe("too-large",`${r} exceeds ${e} bytes`);let o=await Ze.realpath(t);await i.verify?.("pre-open",{realPath:o,identity:fi(a)});let s=process.platform==="win32"?Lr.O_RDONLY:Lr.O_RDONLY|Lr.O_NOFOLLOW|Lr.O_NONBLOCK,c;try{c=await Ze.open(t,s)}catch(l){throw l.code==="ELOOP"?new oe("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,f,d]=await Promise.all([c.stat({bigint:n}),Ze.lstat(t,{bigint:n}),Ze.realpath(t)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||d!==o||!Mr(a,l)||!Mr(a,f))throw new oe("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:d,identity:fi(l)}),await i.hooks?.afterOpen?.();let u=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let y=e+1-p,{bytesRead:b}=await c.read(v,0,Math.min(v.length,y),null);if(b===0)break;if(p+=b,p>e)throw new oe("too-large",`${r} exceeds ${e} bytes`);u.push(Buffer.from(v.subarray(0,b)))}await i.hooks?.beforeFinalCheck?.();let[h,m,w]=await Promise.all([c.stat({bigint:n}),Ze.lstat(t,{bigint:n}),Ze.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||w!==o||!Mr(a,h)||!Mr(a,m))throw new oe("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:w,identity:fi(h)}),{bytes:Buffer.concat(u,p),stat:h,realPath:w}}finally{await c.close()}}function Vv(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function wo(t,e){let i=Me.relative(t,e);return i===""||!Me.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Me.sep}`)}async function ou(t,e){let i=Me.resolve(t),r=await Fr.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Fr.realpath(i)}async function su(t,e,i,r){let n=t;for(let a=0;a<i.length;a++){n=Me.join(n,i[a]);let o;try{o=await Fr.lstat(n)}catch(f){if(Vv(f))return{exists:!1,kind:"missing"};throw f}let s=Me.relative(t,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${s}`);let c=a===i.length-1;if(!c&&!o.isDirectory())throw new Error(`${r.label} ancestor ${s} must be a real directory`);if(c&&(r.expected==="file"&&!o.isFile()||r.expected==="directory"&&!o.isDirectory()||r.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await Fr.realpath(n);if(!wo(e,l))throw new Error(`${r.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 wt(t,e,i){let r=mo(e,i.label),n=Me.resolve(t),a=await ou(n,i.label),o=r.split("/"),s=Me.resolve(n,...o);if(!wo(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await su(n,a,o,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function Fe(t,e,i,r){let n=await wt(t,e,{label:r.label,expected:"file"});if(!n.exists){let o=new Error(`${r.label} does not exist`);throw o.code="ENOENT",o}let a=await ou(n.projectRoot,r.label);return gt(n.target,i,{...r,verify:async(o,s)=>{if(!wo(a,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await su(n.projectRoot,a,n.relative.split("/"),{label:r.label,expected:"file"})}})}var hi=".comet/config.yaml";function Wv(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function yo(t,e={}){return(await Vr(t,e)).document}async function zv(t){try{return(await Fe(t,hi,ui,{label:hi})).bytes}catch(e){if(Wv(e))return null;throw e}}function Jv(t){return t?{exists:!0,sha256:qv("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Vr(t,e={}){let i=await zv(t);return{document:i?di(i.toString("utf8"),e):null,identity:Jv(i)}}var Pk=16*1024;import{existsSync as lu,promises as et}from"fs";import R from"path";import Xv from"os";var qr=".comet/config.yaml",Qv=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function ko(t){try{return await et.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Zv(t){try{let e=await et.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Nt(t,e){let i=R.relative(t,e);return i===""||!R.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${R.sep}`)}async function yt(t){let e=[],i=t;for(;!await ko(i);){let n=R.dirname(i);if(n===i)break;e.push(R.basename(i)),i=n}let r=await et.realpath(i);return R.resolve(r,...e.reverse())}async function So(t){try{return(await et.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Wr(t){let e=R.resolve(t);try{(await et.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let i=e,r=R.resolve(Xv.homedir());for(;;){if(!(e===r&&i!==r)){let o=R.join(e,...qr.split("/")),s=e===i||await Zv(o);if(await ko(o)&&s)return e}if(await ko(R.join(e,".git")))return e;let a=R.dirname(e);if(a===e)return i;e=a}}function zr(t){return Qe(t)}async function eg(t,e){let i=zr(e),r=R.resolve(t,...i.split("/")),n=await et.realpath(t),a=await yt(r);if(!Nt(n,a))throw new Error("native.artifact_root resolves outside the project root");return r}async function Jr(t,e){let i=zr(e),r=await eg(t,i),n=R.join(r,"comet");if(await So(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([yt(r),yt(n)]);if(!Nt(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 So(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,f]=await Promise.all([et.realpath(s),yt(c)]);if(!Nt(l,f))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(t,...qr.split("/")),artifactRoot:r,artifactRootRef:i,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 uu(t){if(!Qv.test(t))throw new Error(`Invalid Native change name: ${t}`)}function tt(t,e){uu(e);let i=R.join(t.changesRuntimeDir,e);if(!M(t.changesRuntimeDir,i))throw new Error("Native change Runtime path escaped");return i}function Eo(t,e){uu(e);let i=R.join(t.changesDir,e,"runtime");if(!M(t.changesDir,i))throw new Error("Legacy Native change Runtime path escaped");return i}function pe(t,e){let i=tt(t,e);if(lu(i))return i;let r=Eo(t,e);return lu(r)?r:i}function me(t,e){let i=R.resolve(e);if(M(t.runtimeDir,i))return t.runtimeDir;if(M(t.nativeRoot,i))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function M(t,e){return Nt(R.resolve(t),R.resolve(e))}async function T(t,e){let i=R.resolve(t),r=R.resolve(e);if(!Nt(i,r))throw new Error(`Path is outside the Native root: ${e}`);if(await So(i))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([yt(i),yt(r)]);if(!Nt(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return r}function ig(t="docs",e="en"){return Br(t,e)}async function Ve(t){let e=(await yo(t))?.config??null;return e?.native?e:null}async function Gr(t){let e=await Ve(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function du(t){let e=await Wr(t.startPath),i=await Ve(e);if(!i&&t.allowMissingConfig===!1)throw new Error(`${qr} was not found`);if(i?.native.pending_root_move)throw new Error(`Native root move ${i.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let r=t.explicitArtifactRoot?zr(t.explicitArtifactRoot):void 0;if(i&&r&&r!==i.native.artifact_root)throw new Error(`Configured Native artifact root is ${i.native.artifact_root}; refusing conflicting root ${r}`);let n=i??ig(r??"docs"),a=await Jr(e,n.native.artifact_root);return{config:n,paths:a,configured:i!==null}}import{promises as Tw}from"fs";import Iw from"path";import{AsyncLocalStorage as rg}from"async_hooks";import{randomUUID as pu}from"crypto";import{promises as Q}from"fs";import mu from"os";import F from"path";var fu=16*1024,vu=".coordinator",ng=5e3,hu=new rg,Ur=new Map;function ag(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function og(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let i=t;if(typeof i.id!="string"||i.id.length===0||typeof i.pid!="number"||!Number.isSafeInteger(i.pid)||i.pid<1||typeof i.hostname!="string"||i.hostname.length===0||typeof i.createdAt!="string"||i.createdAt.length===0||typeof i.operation!="string"||i.operation.length===0)throw new Error(`Invalid Native lock metadata: ${e}`);return i}function gu(t){return{device:t.dev.toString(),inode:t.ino.toString(),size:t.size.toString(),birthtimeNs:t.birthtimeNs.toString(),ctimeNs:t.ctimeNs.toString(),mtimeNs:t.mtimeNs.toString()}}function Po(t,e){let i={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},r={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return G(i,r)?A(i,r):A(i,r)&&t.size===e.size}function xo(t,e){return Po(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}async function Pe(t){let e,i;try{let r=await gt(t,fu,{bigint:!0,label:"Native lock"});e=r.bytes,i=r.stat}catch(r){if(r.code==="ENOENT")return null;throw r instanceof oe?r.reason==="too-large"?new Error(`Native lock metadata exceeds ${fu} bytes: ${t}`,{cause:r}):r.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:r}):new Error(`Native lock changed while reading: ${t}`,{cause:r}):r}return{file:t,owner:og(JSON.parse(e.toString("utf8")),t),identity:gu(i)}}async function sg(t){return(await Pe(t))?.owner??null}function wu(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==mu.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=hg(t.owner.pid);return{status:e===!0?"active":e===!1?"stale":"unknown",owner:t.owner,identity:t.identity}}async function cg(t,e){try{await Q.lstat(e);return}catch(i){if(i.code!=="ENOENT")throw i}try{await Q.rename(t,e)}catch(i){if(i.code!=="ENOENT")throw i}}async function Ro(t,e){let i=await Pe(t.file);if(!i)return"missing";if(i.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!xo(i.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await Q.mkdir(e,{recursive:!0});let r=F.join(e,`${F.basename(t.file)}.${t.owner.id}.${pu()}.removed`);try{await Q.rename(t.file,r)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await Pe(r);if(!n||n.owner.id!==t.owner.id||!Po(n.identity,t.identity))throw await cg(r,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await Q.rm(r,{force:!0}),"removed"}function yu(t){return{id:pu(),pid:process.pid,hostname:mu.hostname(),createdAt:new Date().toISOString(),operation:t}}async function Nu(t,e){let i;try{i=await Q.open(t,"wx")}catch(r){if(r.code==="EEXIST"){let n=await sg(t);throw new Error(`Native lock is already held: ${t}${n?` by pid ${n.pid} for ${n.operation}`:""}`,{cause:r})}throw r}try{return await i.writeFile(JSON.stringify(e,null,2)+`
144
- `,"utf8"),await i.sync(),gu(await i.stat({bigint:!0}))}finally{await i.close()}}async function lg(t,e){let i=await T(t.runtimeDir,t.locksDir);await Q.mkdir(i,{recursive:!0});let r=await T(t.runtimeDir,F.join(i,vu));await Q.mkdir(r,{recursive:!0});let n=yu(e),a=F.join(r,`.${n.id}.tmp`),o=F.join(r,`${n.id}.claim`);try{let s=await Nu(a,n);await Q.rename(a,o);let c=await Pe(o);if(!c||!Po(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:i,owner:n,identity:c.identity}}finally{await Q.rm(a,{force:!0})}}async function ug(t){let e=F.dirname(t.file),i=!1,r=F.basename(t.file);for(let n of await Q.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=F.join(e,n.name);if(F.resolve(a)!==F.resolve(t.file))try{let o=await Pe(a),s=wu(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await Ro(o,e);continue}n.name<r&&(i=!0)}catch{n.name<r&&(i=!0)}}return i}async function bu(t){let e=await Pe(t.file);if(e){if(e.owner.id!==t.owner.id||!xo(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await Ro(e,F.dirname(t.file))}}async function dg(t,e){let i=Date.now()+ng;for(;;){let r=await lg(t,e);if(!await ug(r))return r;if(await bu(r),Date.now()>=i)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function fg(t){let e=Ur.get(t)??Promise.resolve(),i,r=new Promise(a=>{i=a}),n=e.then(()=>r);return Ur.set(t,n),await e,()=>{i(),Ur.get(t)===n&&Ur.delete(t)}}async function ku(t,e,i){let r=F.resolve(t.locksDir),n=hu.getStore();if(n?.has(r))return i();let a=await fg(r);try{let o=await dg(t,e),s=new Map(n??[]);return s.set(r,o),await hu.run(s,async()=>{try{return await i()}finally{await bu(o)}})}finally{a()}}async function Kr(t,e,i){return ku(t,`acquire ${e}`,async()=>{let r=await T(t.runtimeDir,t.locksDir);await Q.mkdir(r,{recursive:!0});let n=await T(t.runtimeDir,F.join(r,ag(e))),a=yu(i),o=await Nu(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:r,owner:a,identity:o}})}async function Yr(t){await Pe(t.file)&&await ku({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${F.basename(t.file)}`,async()=>{let e=await Pe(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!xo(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let i=F.join(t.locksDir,vu);await Ro(e,i)})}function hg(t){try{return process.kill(t,0),!0}catch(e){let i=e.code;return i==="ESRCH"?!1:i==="EPERM"?!0:null}}async function Su(t){return wu(await Pe(t))}import Vo from"node:path";import Wg from"node:path";import Pu from"node:path";import{createHash as pg}from"crypto";function se(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function mg(t,e){e.has(t)&&se("cyclic structures are not supported"),e.add(t);try{let i=Object.keys(t);for(let r=0;r<t.length;r+=1)Object.prototype.hasOwnProperty.call(t,r)||se("sparse arrays are not supported");return(i.length!==t.length||i.some((r,n)=>r!==String(n)))&&se("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&se("symbol properties are not supported"),`[${t.map(r=>Co(r,e)).join(",")}]`}finally{e.delete(t)}}function vg(t,e){let i=Object.getPrototypeOf(t);i!==Object.prototype&&i!==null&&se("only plain objects are supported"),e.has(t)&&se("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&se("symbol properties are not supported"),e.add(t);try{let r=Object.getOwnPropertyDescriptors(t);return`{${Object.keys(t).sort().map(o=>{let s=r[o];return(!s||!("value"in s))&&se("accessor properties are not supported"),`${JSON.stringify(o)}:${Co(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function Co(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)||se("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?mg(t,e):vg(t,e);case"bigint":case"function":case"symbol":case"undefined":return se(`${typeof t} values are not supported`)}return se("unsupported value type")}function Ao(t){return Co(t,new Set)}function Z(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 pg("sha256").update(`${t}
145
- ${Ao(e)}`).digest("hex")}var gg="comet.native.acceptance.v1";var nS=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),gi=Object.freeze({maxCriteria:1024});function To(t){let e=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(t);return e?{level:e[1].length,text:e[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function _o(t,e){let i=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(t);if(!i)return e;let r=i[1][0];return e===null?{marker:r,length:i[1].length}:r===e.marker&&i[1].length>=e.length&&i[2].trim().length===0?null:e}function Eu(t){return t.includes("-->")||t.includes("--!>")}function*mi(t){let e=null,i=!1,r=null,n=new Set(["code","pre","script","style","svg","template"]),a=t.replace(/\r\n?/gu,`
142
+ `,i)+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 i=jr(e),r=gt(i);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=jr(e),r=gt(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,i){return this.type!=="comment"||this.indent<=i?!1:e.every(r=>r.type==="newline"||r.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())}}};Yl.Parser=uo});var tu=g(di=>{"use strict";var Xl=Xa(),vv=ii(),ui=ai(),gv=Kn(),wv=P(),yv=lo(),Ql=fo();function Zl(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new yv.LineCounter||null,prettyErrors:e}}function Nv(t,e={}){let{lineCounter:i,prettyErrors:r}=Zl(e),n=new Ql.Parser(i?.addNewLine),a=new Xl.Composer(e),o=Array.from(a.compose(n.parse(t)));if(r&&i)for(let s of o)s.errors.forEach(ui.prettifyError(t,i)),s.warnings.forEach(ui.prettifyError(t,i));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function eu(t,e={}){let{lineCounter:i,prettyErrors:r}=Zl(e),n=new Ql.Parser(i?.addNewLine),a=new Xl.Composer(e),o=null;for(let s of a.compose(n.parse(t),!0,t.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new ui.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(o.errors.forEach(ui.prettifyError(t,i)),o.warnings.forEach(ui.prettifyError(t,i))),o}function bv(t,e,i){let r;typeof e=="function"?r=e:i===void 0&&e&&typeof e=="object"&&(i=e);let n=eu(t,i);if(!n)return null;if(n.warnings.forEach(a=>gv.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:r},i))}function kv(t,e,i){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:i===void 0&&e&&(i=e),typeof i=="string"&&(i=i.length),typeof i=="number"){let n=Math.round(i);i=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=i??e??{};if(!n)return}return wv.isDocument(t)&&!r?t.toString(i):new vv.Document(t,r,i).toString(i)}di.parse=bv;di.parseAllDocuments=Nv;di.parseDocument=eu;di.stringify=kv});var wt=g(x=>{"use strict";var Sv=Xa(),Ev=ii(),Pv=Ta(),ho=ai(),xv=Mt(),Fe=P(),Cv=He(),Rv=I(),Av=Be(),_v=Le(),Tv=Tr(),Iv=so(),jv=lo(),$v=fo(),Or=tu(),iu=Ht();x.Composer=Sv.Composer;x.Document=Ev.Document;x.Schema=Pv.Schema;x.YAMLError=ho.YAMLError;x.YAMLParseError=ho.YAMLParseError;x.YAMLWarning=ho.YAMLWarning;x.Alias=xv.Alias;x.isAlias=Fe.isAlias;x.isCollection=Fe.isCollection;x.isDocument=Fe.isDocument;x.isMap=Fe.isMap;x.isNode=Fe.isNode;x.isPair=Fe.isPair;x.isScalar=Fe.isScalar;x.isSeq=Fe.isSeq;x.Pair=Cv.Pair;x.Scalar=Rv.Scalar;x.YAMLMap=Av.YAMLMap;x.YAMLSeq=_v.YAMLSeq;x.CST=Tv;x.Lexer=Iv.Lexer;x.LineCounter=jv.LineCounter;x.Parser=$v.Parser;x.parse=Or.parse;x.parseAllDocuments=Or.parseAllDocuments;x.parseDocument=Or.parseDocument;x.stringify=Or.stringify;x.visit=iu.visit;x.visitAsync=iu.visitAsync});function ds(t,e){let i={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[]},r=n=>({kind:n,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...i,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:r("none")};if(t.status==="await-user")return t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...i,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","user-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:r("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...i,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","user-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:r("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...i,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--resolve-verifier-blocker"],requiredInputs:["summary","user-resolution"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...i,disposition:"await-user",action:"resolve-loop-stop",commandArgs:["comet","native","next",t.name,"--return-to-build","--summary","<summary>"],requiredInputs:["summary","user-decision"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")}:{...i,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:r("none")};if(t.status==="blocked"){let n=t.blockers.some(({resolution_action:a})=>a==="retry-verifier");return{...i,disposition:"blocked",action:n?"retry-verifier":"none",commandArgs:n?["comet","native","next",t.name,"--retry-verifier","--summary","<summary>"]:null,requiredInputs:n?["summary"]:["repair-runtime"],inputOptions:n?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:r(n?"retry-verifier":"none")}}if(t.phase==="shape")return{...i,disposition:"continue",action:"confirm-shape",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","shared-understanding-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:r("none")};if(t.phase==="build"){if(e){if(!e.confirmed)return{...i,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:r("none")};if(t.loop.stage==="repairing"&&t.verification_result==="fail")return{...i,disposition:"continue",action:"repair",commandArgs:null,requiredInputs:["repair-child"],inputOptions:[],runnerAction:r("none")};if(e.allDone)return{...i,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:r("none")};let n=e.children.some(({status:o})=>o==="blocked"),a=e.children.some(({status:o})=>o==="ready"||o==="active");return{...i,disposition:n&&!a?"blocked":"continue",action:"advance-children",commandArgs:null,requiredInputs:n&&!a?["resolve-child-blocker"]:["ready-children"],inputOptions:[],runnerAction:r("none")}}return{...i,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:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[]}}],runnerAction:r("builder-handoff")}}if(t.phase==="verify"){let n=t.loop.next_action==="await-verifier-result";return{...i,disposition:"continue",action:n?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[n?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:n?[{kind:"verifier-response",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}]}},{kind:"verifier-response",response:{kind:"final-result",result:{iteration:t.loop.iteration,attempt:t.loop.attempt,verdict:"<pass|fail|blocked>",acceptance:[{id:"<acceptance-id>",result:"<passed|failed|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:"<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:"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:[]}}],runnerAction:r(n?"await-verifier":"dispatch-verifier")}}return{...i,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:r("none")}}import{randomUUID as Ly}from"node:crypto";import{promises as Ii}from"node:fs";import My from"node:path";import{execFileSync as zd}from"child_process";import Oi from"path";function An(t,e){return zd("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Jd(t,e){let i=Oi.normalize(t),r=Oi.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function ke(t){try{let e=Oi.resolve(An(t,["rev-parse","--show-toplevel"])),r=An(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=r?Oi.resolve(r.slice(9)):e,a=null;try{a=An(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Jd(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}import{randomUUID as Gd}from"crypto";import{promises as L}from"fs";import ie from"path";function Te(t){return t!==0&&t!==0n&&t!=="0"}function G(t,e){return Te(t.dev)&&Te(e.dev)&&Te(t.ino)&&Te(e.ino)}function A(t,e){let i=Te(t.dev)&&Te(e.dev);if(i&&t.dev!==e.dev)return!1;let r=Te(t.ino)&&Te(e.ino);return r&&t.ino!==e.ino?!1:i&&r?!0:t.birthtime===e.birthtime}function Tn(t,e){let i=ie.relative(t,e);return i===""||!ie.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ie.sep}`)}function Ud(t,e){return A({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function _n(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return G(i,r)?A(i,r):A(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function fs(t){let e=await L.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 L.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function $t(t){for(let e of t){let i=await L.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!Ud(e,i)||await L.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Kd(t,e){let i=ie.resolve(t),r=ie.resolve(e);if(!Tn(i,r))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await fs(i)],a=ie.relative(i,r).split(ie.sep).filter(Boolean),o=i;for(let s of a){await $t(n),o=ie.join(o,s);try{await L.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await fs(o);if(!Tn(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await $t(n),n}async function Yd(t){let e;try{e=await L.open(t,"r"),await e.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await e?.close()}}async function Xd(t,e,i={}){let r=ie.dirname(t),n=i.containedRoot?await Kd(i.containedRoot,r):null;n||await L.mkdir(r,{recursive:!0});let a=ie.join(r,`.${ie.basename(t)}.${Gd()}.tmp`),o,s;try{if(await i.beforeTemporaryOpen?.(),o=await L.open(a,"wx"),s=await o.stat(),n){let[c,l]=await Promise.all([L.lstat(a),L.realpath(a)]);if(await $t(n),!c.isFile()||c.isSymbolicLink()||!_n(s,c)||!Tn(n[0].realPath,l))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(),!_n(s,await o.stat()))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await i.beforeCommit?.(),n){await $t(n);let c=await L.lstat(a);if(!c.isFile()||c.isSymbolicLink()||!s||!_n(c,s))throw new Error("Native atomic write temporary file changed before commit")}i.exclusive?(await L.link(a,t),await L.unlink(a)):await L.rename(a,t),await Yd(r)}catch(c){if(await o?.close(),!n)await L.rm(a,{force:!0});else try{await $t(n),await L.rm(a,{force:!0})}catch{}throw c}}async function de(t,e,i={}){await Xd(t,e,i)}async function Y(t,e,i={}){await de(t,JSON.stringify(e,null,2)+`
143
+ `,i)}import{createHash as tf}from"node:crypto";import{promises as re}from"node:fs";import X from"node:path";import{TextDecoder as rf}from"node:util";var Qd=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Zd=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function ef(t){return t.toLowerCase().startsWith(".env")}function Ot(t){let i=t.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>ef(r))?"environment-file":i.some(r=>Zd.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>Qd.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}var Di=1024*1024;function In(t,e){let i=X.relative(t,e);return i===""||!X.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${X.sep}`)}function nf(t){let e=X.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})||X.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 i=t.toLowerCase(),r=Ot(t);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${t}`);return t}function af(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function of(t,e){return A({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Hi(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return G(i,r)?A(i,r):A(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function hs(t){let e=await re.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact 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 sf(t,e){let i=X.resolve(t),r=X.resolve(e);if(!In(i,r))throw new Error("Native artifact path is outside its root");let n=[await hs(i)],a=i;for(let o of X.relative(i,r).split(X.sep).filter(Boolean)){a=X.join(a,o);let s=await hs(a);if(!In(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function ps(t){for(let e of t){let i=await re.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!of(e,i)||await re.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function M(t){let e=nf(t.ref),i=t.maxBytes===null?null:af(t.maxBytes??Di),r=X.resolve(t.root,...e.split("/")),n=await sf(t.root,X.dirname(r));await t.hooks?.afterParentChainCaptured?.();let a=await re.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(i!==null&&a.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);let o=await re.realpath(r);if(!In(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await re.open(r,"r");try{let[c,l,f]=await Promise.all([s.stat(),re.lstat(r),re.realpath(r)]);if(await ps(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||f!==o||!Hi(a,c)||!Hi(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],u=0,p=Buffer.allocUnsafe(i===null?64*1024:Math.min(64*1024,i+1));for(;;){let b=i===null?p.length:i+1-u,k=await s.read(p,0,Math.min(p.length,b),null);if(k.bytesRead===0)break;if(u+=k.bytesRead,i!==null&&u>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);d.push(Buffer.from(p.subarray(0,k.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),re.lstat(r),re.realpath(r)]);if(await ps(n),!h.isFile()||h.isSymbolicLink()||m!==o||!Hi(c,v)||!Hi(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let w=Buffer.concat(d,u),y;try{y=new rf("utf-8",{fatal:!0}).decode(w)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:b})}return{ref:e,size:u,hash:t.includeHash===!1?null:tf("sha256").update(w).digest("hex"),text:y}}finally{await s.close()}}var es=jt(wt(),1);import _t from"path";var mo=jt(wt(),1);import Hr from"path";var fi=64*1024,Dr=1024,Br=64,vo=5,Ov=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],Hv=["**/.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"],Dv=[...Ov,...Hv].sort((t,e)=>t.localeCompare(e,"en"));var U={include:["**/*"],exclude:[...Dv],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function Bv(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim();if(i.length===0||Hr.posix.isAbsolute(i)||Hr.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function Qe(t){let e=Bv(t,"native.artifact_root");return e.length===0?".":e.join("/")}function nu(t,e="docs"){let i=t??e;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function Lr(t,e,i=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim().replaceAll("\\","/");if(r.length===0||Hr.posix.isAbsolute(r)||Hr.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let n=r.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(!i&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function yt(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function au(t,e,i){let r=t??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function go(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>Dr)throw new Error(`${e} exceeds ${Dr} characters`);let i=0;for(let r=0;r<t.length;r+=1)t[r]==="?"?i+=1:t[r]==="*"&&(i+=1,t[r+1]==="*"&&(r+=1));if(i>Br)throw new Error(`${e} contains more than ${Br} wildcard tokens`);return t}function ru(t,e,i){if(t===void 0)return[...i];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(r=>go(r,e)))].sort((r,n)=>r.localeCompare(n,"en"))}function po(t,e,i){let r=t??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function Lv(t){if(t===void 0)return{...U,include:[...U.include],exclude:[...U.exclude]};let e=yt(t,"native.snapshot");return{include:ru(e.include,"native.snapshot.include",U.include),exclude:ru(e.exclude,"native.snapshot.exclude",U.exclude),max_files:po(e.max_files,U.max_files,"native.snapshot.max_files"),max_total_bytes:po(e.max_total_bytes,U.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:po(e.max_duration_ms,U.max_duration_ms,"native.snapshot.max_duration_ms")}}function Mv(t){if(t===void 0)return;let e=yt(t,"native.pending_root_move"),i=e.id,r=e.from_artifact_root,n=e.to_artifact_root,a=e.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="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=yt(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,f=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 f!="string"||!/^[a-f0-9]{64}$/u.test(f))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:f}}return{id:i,fromArtifactRoot:Qe(r),toArtifactRoot:Qe(n),stage:a,...o?{cleanup:o}:{}}}function Fv(t,e={}){let i=yt(t,"native"),r=i.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let n=i.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=i.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=i.max_verify_failures??vo;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Mv(i.pending_root_move);return{artifact_root:Qe(r),language:au(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Lv(i.snapshot),...s?{pending_root_move:s}:{}}}function Vv(t){let e=yt(t,"classic"),i=e.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="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");return{artifact_layout:nu(e.artifact_layout),language:au(e.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function qv(t){let i=yt(t,"hook").allow_paths??[];if(!Array.isArray(i))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(i.map((r,n)=>Lr(r,`hook.allow_paths[${n}]`)))]}}function Wv(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function zv(t,e,i,r,n,a){let o=t.schema!==void 0;if(!(o||t.default_workflow!==void 0||t.workflows!==void 0||!a.allowPartialProject&&t.native!==void 0)||a.allowPartialProject&&!o)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 c=t.workflows??[t.default_workflow];if(!Array.isArray(c)||c.length===0||c.some(f=>f!=="native"&&f!=="classic"))throw new Error("workflows must contain native and/or classic");let l=[...new Set(c)];if(!l.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(l.includes("native")&&!i)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:l,ambient_resume:n,...e?{hook:e}:{},...i?{native:i}:{},...r?{classic:r}:{}}}function hi(t,e={}){let i=(0,mo.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let r=i.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=r,a=Wv(n.ambient_resume),o=n.hook===void 0?void 0:qv(n.hook),s=n.native===void 0?void 0:Fv(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),c=n.classic===void 0?void 0:Vv(n.classic),l=zv(n,o,s,c,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:l,ambient_resume:a,...o?{hook:o}:{},...s?{native:s}:{},...c?{classic:c}:{}}}function Mr(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:Qe(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:vo,snapshot:{...U,include:[...U.include],exclude:[...U.exclude]}}}}import{createHash as Gv}from"crypto";import{promises as qr}from"fs";import Ve from"path";import{constants as Fr,promises as Ze}from"fs";var oe=class extends Error{reason;constructor(e,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=e}};function wo(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function ou(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function pi(t){return{dev:t.dev,ino:t.ino,birthtime:wo(t)}}function Vr(t,e){let i=pi(t),r=pi(e);return G(i,r)?A(i,r):A(i,r)&&wo(t)===wo(e)&&ou(t)===ou(e)&&t.size===e.size}async function Nt(t,e,i={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=i.label??"file",n=i.bigint===!0,a=await Ze.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new oe("not-regular-file",`${r} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new oe("too-large",`${r} exceeds ${e} bytes`);let o=await Ze.realpath(t);await i.verify?.("pre-open",{realPath:o,identity:pi(a)});let s=process.platform==="win32"?Fr.O_RDONLY:Fr.O_RDONLY|Fr.O_NOFOLLOW|Fr.O_NONBLOCK,c;try{c=await Ze.open(t,s)}catch(l){throw l.code==="ELOOP"?new oe("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,f,d]=await Promise.all([c.stat({bigint:n}),Ze.lstat(t,{bigint:n}),Ze.realpath(t)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||d!==o||!Vr(a,l)||!Vr(a,f))throw new oe("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:d,identity:pi(l)}),await i.hooks?.afterOpen?.();let u=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let y=e+1-p,{bytesRead:b}=await c.read(v,0,Math.min(v.length,y),null);if(b===0)break;if(p+=b,p>e)throw new oe("too-large",`${r} exceeds ${e} bytes`);u.push(Buffer.from(v.subarray(0,b)))}await i.hooks?.beforeFinalCheck?.();let[h,m,w]=await Promise.all([c.stat({bigint:n}),Ze.lstat(t,{bigint:n}),Ze.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||w!==o||!Vr(a,h)||!Vr(a,m))throw new oe("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:w,identity:pi(h)}),{bytes:Buffer.concat(u,p),stat:h,realPath:w}}finally{await c.close()}}function Jv(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function yo(t,e){let i=Ve.relative(t,e);return i===""||!Ve.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Ve.sep}`)}async function su(t,e){let i=Ve.resolve(t),r=await qr.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return qr.realpath(i)}async function cu(t,e,i,r){let n=t;for(let a=0;a<i.length;a++){n=Ve.join(n,i[a]);let o;try{o=await qr.lstat(n)}catch(f){if(Jv(f))return{exists:!1,kind:"missing"};throw f}let s=Ve.relative(t,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${s}`);let c=a===i.length-1;if(!c&&!o.isDirectory())throw new Error(`${r.label} ancestor ${s} must be a real directory`);if(c&&(r.expected==="file"&&!o.isFile()||r.expected==="directory"&&!o.isDirectory()||r.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await qr.realpath(n);if(!yo(e,l))throw new Error(`${r.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 bt(t,e,i){let r=Lr(e,i.label),n=Ve.resolve(t),a=await su(n,i.label),o=r.split("/"),s=Ve.resolve(n,...o);if(!yo(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await cu(n,a,o,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function qe(t,e,i,r){let n=await bt(t,e,{label:r.label,expected:"file"});if(!n.exists){let o=new Error(`${r.label} does not exist`);throw o.code="ENOENT",o}let a=await su(n.projectRoot,r.label);return Nt(n.target,i,{...r,verify:async(o,s)=>{if(!yo(a,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await cu(n.projectRoot,a,n.relative.split("/"),{label:r.label,expected:"file"})}})}var mi=".comet/config.yaml";function Uv(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Wr(t,e={}){return(await zr(t,e)).document}async function Kv(t){try{return(await qe(t,mi,fi,{label:mi})).bytes}catch(e){if(Uv(e))return null;throw e}}function Yv(t){return t?{exists:!0,sha256:Gv("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function zr(t,e={}){let i=await Kv(t);return{document:i?hi(i.toString("utf8"),e):null,identity:Yv(i)}}async function No(t){return(await Wr(t))?.config??null}var $k=16*1024;import{existsSync as uu,promises as et}from"fs";import C from"path";import tg from"os";var Jr=".comet/config.yaml",ig=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function So(t){try{return await et.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function rg(t){try{let e=await et.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function St(t,e){let i=C.relative(t,e);return i===""||!C.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${C.sep}`)}async function kt(t){let e=[],i=t;for(;!await So(i);){let n=C.dirname(i);if(n===i)break;e.push(C.basename(i)),i=n}let r=await et.realpath(i);return C.resolve(r,...e.reverse())}async function Eo(t){try{return(await et.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Gr(t){let e=C.resolve(t);try{(await et.stat(e)).isDirectory()||(e=C.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let i=e,r=C.resolve(tg.homedir());for(;;){if(!(e===r&&i!==r)){let o=C.join(e,...Jr.split("/")),s=e===i||await rg(o);if(await So(o)&&s)return e}if(await So(C.join(e,".git")))return e;let a=C.dirname(e);if(a===e)return i;e=a}}function Ur(t){return Qe(t)}async function ng(t,e){let i=Ur(e),r=C.resolve(t,...i.split("/")),n=await et.realpath(t),a=await kt(r);if(!St(n,a))throw new Error("native.artifact_root resolves outside the project root");return r}async function Et(t,e){let i=Ur(e),r=await ng(t,i),n=C.join(r,"comet");if(await Eo(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([kt(r),kt(n)]);if(!St(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=C.resolve(t),c=C.join(s,".comet","runtime","native");if(await Eo(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,f]=await Promise.all([et.realpath(s),kt(c)]);if(!St(l,f))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:C.join(t,...Jr.split("/")),artifactRoot:r,artifactRootRef:i,nativeRoot:n,specsDir:C.join(n,"specs"),changesDir:C.join(n,"changes"),archiveDir:C.join(n,"archive"),runtimeDir:c,changesRuntimeDir:C.join(c,"changes"),locksDir:C.join(c,"locks"),transactionsDir:C.join(c,"transactions")}}function du(t){if(!ig.test(t))throw new Error(`Invalid Native change name: ${t}`)}function tt(t,e){du(e);let i=C.join(t.changesRuntimeDir,e);if(!F(t.changesRuntimeDir,i))throw new Error("Native change Runtime path escaped");return i}function Po(t,e){du(e);let i=C.join(t.changesDir,e,"runtime");if(!F(t.changesDir,i))throw new Error("Legacy Native change Runtime path escaped");return i}function pe(t,e){let i=tt(t,e);if(uu(i))return i;let r=Po(t,e);return uu(r)?r:i}function me(t,e){let i=C.resolve(e);if(F(t.runtimeDir,i))return t.runtimeDir;if(F(t.nativeRoot,i))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function F(t,e){return St(C.resolve(t),C.resolve(e))}async function T(t,e){let i=C.resolve(t),r=C.resolve(e);if(!St(i,r))throw new Error(`Path is outside the Native root: ${e}`);if(await Eo(i))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([kt(i),kt(r)]);if(!St(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return r}function og(t="docs",e="en"){return Mr(t,e)}async function Pe(t){let e=(await Wr(t))?.config??null;return e?.native?e:null}async function Kr(t){let e=await Pe(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function fu(t){let e=await Gr(t.startPath),i=await Pe(e);if(!i&&t.allowMissingConfig===!1)throw new Error(`${Jr} was not found`);if(i?.native.pending_root_move)throw new Error(`Native root move ${i.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let r=t.explicitArtifactRoot?Ur(t.explicitArtifactRoot):void 0;if(i&&r&&r!==i.native.artifact_root)throw new Error(`Configured Native artifact root is ${i.native.artifact_root}; refusing conflicting root ${r}`);let n=i??og(r??"docs"),a=await Et(e,n.native.artifact_root);return{config:n,paths:a,configured:i!==null}}import{promises as Dw}from"fs";import Bw from"path";import{AsyncLocalStorage as sg}from"async_hooks";import{randomUUID as mu}from"crypto";import{promises as Z}from"fs";import vu from"os";import V from"path";var hu=16*1024,gu=".coordinator",cg=5e3,pu=new sg,Yr=new Map;function lg(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function ug(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let i=t;if(typeof i.id!="string"||i.id.length===0||typeof i.pid!="number"||!Number.isSafeInteger(i.pid)||i.pid<1||typeof i.hostname!="string"||i.hostname.length===0||typeof i.createdAt!="string"||i.createdAt.length===0||typeof i.operation!="string"||i.operation.length===0)throw new Error(`Invalid Native lock metadata: ${e}`);return i}function wu(t){return{device:t.dev.toString(),inode:t.ino.toString(),size:t.size.toString(),birthtimeNs:t.birthtimeNs.toString(),ctimeNs:t.ctimeNs.toString(),mtimeNs:t.mtimeNs.toString()}}function xo(t,e){let i={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},r={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return G(i,r)?A(i,r):A(i,r)&&t.size===e.size}function Co(t,e){return xo(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}async function xe(t){let e,i;try{let r=await Nt(t,hu,{bigint:!0,label:"Native lock"});e=r.bytes,i=r.stat}catch(r){if(r.code==="ENOENT")return null;throw r instanceof oe?r.reason==="too-large"?new Error(`Native lock metadata exceeds ${hu} bytes: ${t}`,{cause:r}):r.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:r}):new Error(`Native lock changed while reading: ${t}`,{cause:r}):r}return{file:t,owner:ug(JSON.parse(e.toString("utf8")),t),identity:wu(i)}}async function dg(t){return(await xe(t))?.owner??null}function yu(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==vu.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=gg(t.owner.pid);return{status:e===!0?"active":e===!1?"stale":"unknown",owner:t.owner,identity:t.identity}}async function fg(t,e){try{await Z.lstat(e);return}catch(i){if(i.code!=="ENOENT")throw i}try{await Z.rename(t,e)}catch(i){if(i.code!=="ENOENT")throw i}}async function Ro(t,e){let i=await xe(t.file);if(!i)return"missing";if(i.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!Co(i.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await Z.mkdir(e,{recursive:!0});let r=V.join(e,`${V.basename(t.file)}.${t.owner.id}.${mu()}.removed`);try{await Z.rename(t.file,r)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await xe(r);if(!n||n.owner.id!==t.owner.id||!xo(n.identity,t.identity))throw await fg(r,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await Z.rm(r,{force:!0}),"removed"}function Nu(t){return{id:mu(),pid:process.pid,hostname:vu.hostname(),createdAt:new Date().toISOString(),operation:t}}async function bu(t,e){let i;try{i=await Z.open(t,"wx")}catch(r){if(r.code==="EEXIST"){let n=await dg(t);throw new Error(`Native lock is already held: ${t}${n?` by pid ${n.pid} for ${n.operation}`:""}`,{cause:r})}throw r}try{return await i.writeFile(JSON.stringify(e,null,2)+`
144
+ `,"utf8"),await i.sync(),wu(await i.stat({bigint:!0}))}finally{await i.close()}}async function hg(t,e){let i=await T(t.runtimeDir,t.locksDir);await Z.mkdir(i,{recursive:!0});let r=await T(t.runtimeDir,V.join(i,gu));await Z.mkdir(r,{recursive:!0});let n=Nu(e),a=V.join(r,`.${n.id}.tmp`),o=V.join(r,`${n.id}.claim`);try{let s=await bu(a,n);await Z.rename(a,o);let c=await xe(o);if(!c||!xo(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:i,owner:n,identity:c.identity}}finally{await Z.rm(a,{force:!0})}}async function pg(t){let e=V.dirname(t.file),i=!1,r=V.basename(t.file);for(let n of await Z.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=V.join(e,n.name);if(V.resolve(a)!==V.resolve(t.file))try{let o=await xe(a),s=yu(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await Ro(o,e);continue}n.name<r&&(i=!0)}catch{n.name<r&&(i=!0)}}return i}async function ku(t){let e=await xe(t.file);if(e){if(e.owner.id!==t.owner.id||!Co(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await Ro(e,V.dirname(t.file))}}async function mg(t,e){let i=Date.now()+cg;for(;;){let r=await hg(t,e);if(!await pg(r))return r;if(await ku(r),Date.now()>=i)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function vg(t){let e=Yr.get(t)??Promise.resolve(),i,r=new Promise(a=>{i=a}),n=e.then(()=>r);return Yr.set(t,n),await e,()=>{i(),Yr.get(t)===n&&Yr.delete(t)}}async function Su(t,e,i){let r=V.resolve(t.locksDir),n=pu.getStore();if(n?.has(r))return i();let a=await vg(r);try{let o=await mg(t,e),s=new Map(n??[]);return s.set(r,o),await pu.run(s,async()=>{try{return await i()}finally{await ku(o)}})}finally{a()}}async function Xr(t,e,i){return Su(t,`acquire ${e}`,async()=>{let r=await T(t.runtimeDir,t.locksDir);await Z.mkdir(r,{recursive:!0});let n=await T(t.runtimeDir,V.join(r,lg(e))),a=Nu(i),o=await bu(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:r,owner:a,identity:o}})}async function Qr(t){await xe(t.file)&&await Su({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${V.basename(t.file)}`,async()=>{let e=await xe(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!Co(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let i=V.join(t.locksDir,gu);await Ro(e,i)})}function gg(t){try{return process.kill(t,0),!0}catch(e){let i=e.code;return i==="ESRCH"?!1:i==="EPERM"?!0:null}}async function Eu(t){return yu(await xe(t))}import qo from"node:path";import Yg from"node:path";import xu from"node:path";import{createHash as wg}from"crypto";function se(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function yg(t,e){e.has(t)&&se("cyclic structures are not supported"),e.add(t);try{let i=Object.keys(t);for(let r=0;r<t.length;r+=1)Object.prototype.hasOwnProperty.call(t,r)||se("sparse arrays are not supported");return(i.length!==t.length||i.some((r,n)=>r!==String(n)))&&se("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&se("symbol properties are not supported"),`[${t.map(r=>Ao(r,e)).join(",")}]`}finally{e.delete(t)}}function Ng(t,e){let i=Object.getPrototypeOf(t);i!==Object.prototype&&i!==null&&se("only plain objects are supported"),e.has(t)&&se("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&se("symbol properties are not supported"),e.add(t);try{let r=Object.getOwnPropertyDescriptors(t);return`{${Object.keys(t).sort().map(o=>{let s=r[o];return(!s||!("value"in s))&&se("accessor properties are not supported"),`${JSON.stringify(o)}:${Ao(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function Ao(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)||se("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?yg(t,e):Ng(t,e);case"bigint":case"function":case"symbol":case"undefined":return se(`${typeof t} values are not supported`)}return se("unsupported value type")}function _o(t){return Ao(t,new Set)}function K(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 wg("sha256").update(`${t}
145
+ ${_o(e)}`).digest("hex")}var bg="comet.native.acceptance.v1";var hS=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),yi=Object.freeze({maxCriteria:1024});function Io(t){let e=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(t);return e?{level:e[1].length,text:e[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function To(t,e){let i=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(t);if(!i)return e;let r=i[1][0];return e===null?{marker:r,length:i[1].length}:r===e.marker&&i[1].length>=e.length&&i[2].trim().length===0?null:e}function Pu(t){return t.includes("-->")||t.includes("--!>")}function*gi(t){let e=null,i=!1,r=null,n=new Set(["code","pre","script","style","svg","template"]),a=t.replace(/\r\n?/gu,`
146
146
  `),o=0,s=0;for(;o<=a.length;){let c=a.indexOf(`
147
- `,o),l=c===-1?a.slice(o):a.slice(o,c);if(yield{line:l,body:e===null&&!i&&r===null,index:s},s+=1,e!==null)e=_o(l,e);else if(i)Eu(l)&&(i=!1);else if(r!==null)new RegExp(`</${r}\\s*>`,"iu").test(l)&&(r=null);else{let d=_o(l,null);if(d!==null)e=d;else{let u=l.trimStart();if(u.startsWith("<!--")&&!Eu(u))i=!0;else{let p=/^<([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/u.exec(u);p&&n.has(p[1].toLowerCase())&&!u.startsWith("</")&&!u.endsWith("/>")&&!new RegExp(`</${p[1]}\\s*>`,"iu").test(u)&&(r=p[1])}}}if(c===-1)break;o=c+1}}function vi(t){return t.normalize("NFC").replace(/\s+/gu," ").trim()}function Io(t,e,i,r=[],n="content-hash"){let a=vi(i),o=e.replaceAll("\\","/").trim(),s=r.map(vi);if(a.length===0)throw new Error(`${t} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${t} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${Z(gg,{kind:t,source:o,context:s,text:a})}`:"",kind:t,source:o,context:s,text:a}}function jo(t,e,i="content-hash"){let r=new Set;for(let n of t){let a=i==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(r.has(a))throw new Error(`${e} contains duplicate acceptance criteria`);r.add(a)}return t}function wg(t){let e=null,i=null,r=0,n=0;for(let{line:a,body:o,index:s}of mi(t)){n=s+1;let c=o?To(a):null;c?.level===1&&(c.text.toLocaleLowerCase("en-US")==="acceptance examples"?(r+=1,r===1&&(e=s+1)):e!==null&&i===null&&(i=s))}if(r===0||e===null)return null;if(r!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:e,end:i??n}}function $o(t,e="brief.md",i=gi.maxCriteria,r="content-hash"){if(!Number.isSafeInteger(i)||i<0)throw new Error("Native brief acceptance budget is invalid");let n=wg(t);if(n===null)return[];let a=null;for(let{line:l,body:f,index:d}of mi(t)){if(d<n.start||d>=n.end)continue;let u=f?/^( {0,3})[-*+][ \t]+/u.exec(l):null;if(u===null)continue;let p=u[1].length;a=a===null?p:Math.min(a,p)}let o=[],s=null,c=()=>{if(s!==null){if(o.length>=i)throw new Error(`Native acceptance exceeds its ${i}-criterion acceptance budget`);o.push(s)}};for(let{line:l,body:f,index:d}of mi(t)){if(d<n.start||d>=n.end)continue;let u=f?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(l):null;u&&u[1].length===a?(c(),s=[u[2]]):s!==null&&s.push(l)}return c(),jo(o.map(l=>Io("brief-example",e,l.join(`
148
- `),[],r)),"Brief",r)}function Oo(t,e="spec.md",i=gi.maxCriteria,r="content-hash"){if(!Number.isSafeInteger(i)||i<0)throw new Error("Native specification acceptance budget is invalid");let n=[],a=[],o=null,s=()=>{if(o!==null){if(n.length>=i)throw new Error(`Native acceptance exceeds its ${i}-criterion acceptance budget`);n.push(Io("spec-scenario",e,[o.title,...o.body].join(`
149
- `),o.context,r)),o=null}};for(let{line:c,body:l}of mi(t)){let f=l?To(c):null,d=f?/^Scenario\s*:\s*(.*)$/iu.exec(f.text):null;if(d){for(s();a.at(-1)&&a.at(-1).level>=f.level;)a.pop();let u=vi(d[1]);if(u.length===0)throw new Error("Scenario title must not be empty");o={level:f.level,title:u,body:[],context:a.map(p=>p.text)}}else if(f){for(o!==null&&f.level<=o.level?s():o!==null&&o.body.push(c);a.at(-1)&&a.at(-1).level>=f.level;)a.pop();a.push(f)}else o!==null&&l&&o.body.push(c)}return s(),jo(n,"Specification",r)}function Ho(t,e="spec.md",i=gi.maxCriteria,r="content-hash"){if(!Number.isSafeInteger(i)||i<0)throw new Error("Native specification acceptance budget is invalid");let n=[],a=[],o=null,s=null,c=()=>{if(s!==null){if(n.length>=i)throw new Error(`Native acceptance exceeds its ${i}-criterion acceptance budget`);n.push(Io("spec-must",e,s.parts.join(" "),s.context,r)),s=null}},l=()=>a.some(f=>/^(?:non-?goals?|非目标)$/iu.test(f.text.trim()));for(let{line:f,body:d}of mi(t)){let u=d?To(f):null;if(u){for(c(),o!==null&&u.level<=o&&(o=null);a.at(-1)&&a.at(-1).level>=u.level;)a.pop();a.push(u),/^Scenario\s*:/iu.test(u.text)&&(o=u.level);continue}let p=f.trim();if(!d||o!==null||l()){c();continue}if(p.length===0||_o(f,null)!==null||p.startsWith("<!--")||p==="-->"||p==="--!>"||/^<\/?[A-Za-z][^>]*>$/u.test(p)||/^<[A-Za-z][^>]*>.*<\/[A-Za-z][^>]*>$/u.test(p)||/^(?:[-*_]\s*){3,}$/u.test(p)||/^\|?(?:\s*:?-{3,}:?\s*\|)+\s*$/u.test(p)){c();continue}let v=/^\s*(?:[-*+]|\d+[.)])[ \t]+(.+)$/u.exec(f);if(v){c(),s={parts:[v[1]],context:a.map(h=>h.text)};continue}if(/^\|.*\|$/u.test(p)){c(),s={parts:[p],context:a.map(h=>h.text)},c();continue}s===null?s={parts:[p],context:a.map(h=>h.text)}:s.parts.push(p)}return c(),jo(n,"Specification mandatory requirements",r)}var yg=/^A[1-9]\d*$/u;function xu(t,e){if(t.length===0||t!==t.trim()||t.includes("\\")||Pu.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||Pu.posix.normalize(t)!==t||t==="."||t.endsWith("/"))throw new Error(`${e} must be a normalized change-relative ref`);return t}function Ng(t,e){return t.localeCompare(e,"en")}function Do(t){let e=xu(t.briefSource??"brief.md","Native brief source"),i=[...t.specs??[]].sort((a,o)=>Ng(a.capability,o.capability));if(new Set(i.map(a=>a.capability)).size!==i.length)throw new Error("Native acceptance sources contain duplicate capabilities");let r=$o(t.briefMarkdown,e,Number.MAX_SAFE_INTEGER,"none").map(({source:a,text:o})=>({source:a,text:o}));for(let a of i){let o=xu(a.source,`Native spec source for ${a.capability}`);r.push(...Oo(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})),...Ho(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})))}let n=new Set;for(let a of r){a.text=vi(a.text);let o=`${a.source}\0${a.text}`;if(n.has(o))throw new Error(`Native acceptance contains a duplicate criterion: ${a.text}`);n.add(o)}if(r.length===0)throw new Error("Native change must define at least one acceptance criterion");return r.map((a,o)=>({id:`A${o+1}`,source:a.source,text:a.text}))}function Ru(t){let e=t.map(({id:i})=>i);if(new Set(e).size!==e.length)throw new Error("Native acceptance IDs must be unique");for(let i=0;i<e.length;i+=1)if(!yg.test(e[i])||e[i]!==`A${i+1}`)throw new Error("Native acceptance IDs must be the contiguous sequence A1..An")}var Zr=ji(ci(),1);import{promises as bg}from"node:fs";var bt="comet.native.v4",wi="comet.native.local-execution.v4";function Bo(){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 kg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Sg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Eg=/^A[1-9][0-9]*$/u,Pg=new Set(["schema","name","language","phase","status","state_version","brief","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),Qr=class extends Error{constructor(i,r){super(`Native state version conflict: expected ${i}, got ${r}`);this.expectedStateVersion=i;this.actualStateVersion=r;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};function z(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function J(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function L(t,e,i){if(typeof t!="string"||!i?.empty&&t.length===0)throw new Error(`${e} must be ${i?.empty?"a string":"a non-empty string"}`);return t}function Lo(t,e){return t===null?null:L(t,e)}function kt(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function _(t,e,i=0){if(!Number.isSafeInteger(t)||t<i)throw new Error(`${e} must be a safe integer greater than or equal to ${i}`);return t}function xg(t,e){return t===null?null:_(t,e,Number.MIN_SAFE_INTEGER)}function D(t,e,i){if(typeof t!="string"||!e.includes(t))throw new Error(`${i} must be one of: ${e.join(", ")}`);return t}function ve(t,e,i){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((r,n)=>i(r,n))}function en(t,e){return ve(t,e,(i,r)=>L(i,`${e}[${r}]`))}function it(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function St(t,e){let i=L(t,e);if(Number.isNaN(Date.parse(i)))throw new Error(`${e} must be an ISO date or timestamp`);return i}function Mo(t,e,i=!1){let r=L(t,e);if(r.includes("\\")||r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").includes("..")||!i&&(r==="."||r.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return r}function ce(t,e){let i=z(t,e);return J(i,new Set(["text","truncated"]),e),{text:L(i.text,`${e}.text`,{empty:!0}),truncated:kt(i.truncated,`${e}.truncated`)}}function Rg(t,e){let i=`Native spec_changes[${e}]`,r=z(t,i);J(r,new Set(["capability","operation","source"]),i);let n=L(r.capability,`${i}.capability`);if(!Sg.test(n))throw new Error(`${i}.capability is invalid`);let a=D(r.operation,["create","modify","remove"],`${i}.operation`),o=r.source===null?null:Mo(r.source,`${i}.source`);if(a==="remove"&&o!==null)throw new Error(`${i} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${i} ${a} requires a source`);return{capability:n,operation:a,source:o}}function Cg(t){let e="Native workspace",i=z(t,e);J(i,new Set(["isolation","change_branch","target_branch","finish"]),e);let r=D(i.isolation,["current","branch","worktree"],`${e}.isolation`),n=Lo(i.change_branch,`${e}.change_branch`),a=Lo(i.target_branch,`${e}.target_branch`),o=i.finish===null?null:D(i.finish,["merge","push","pull-request","keep"],`${e}.finish`);if(r==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(r==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(r!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:r,change_branch:n,target_branch:a,finish:o}}function Ag(t){let e="Native loop",i=z(t,e);J(i,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","execution_failure_count","previous_unresolved_ids","next_action"]),e);let r=en(i.previous_unresolved_ids,`${e}.previous_unresolved_ids`);return it(r,`${e}.previous_unresolved_ids`),{stage:D(i.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:_(i.goal_cycle,`${e}.goal_cycle`,1),iteration:_(i.iteration,`${e}.iteration`),attempt:_(i.attempt,`${e}.attempt`),retry_epoch:_(i.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:_(i.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:_(i.no_progress_count,`${e}.no_progress_count`),execution_failure_count:_(i.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:r,next_action:Lo(i.next_action,`${e}.next_action`)}}function _g(t,e){let i=`Native acceptance[${e}]`,r=z(t,i);J(r,new Set(["id","source","text","result","reason"]),i);let n=L(r.id,`${i}.id`);if(!Eg.test(n))throw new Error(`${i}.id must use A1, A2, ...`);return{id:n,source:Mo(r.source,`${i}.source`),text:L(r.text,`${i}.text`),result:D(r.result,["pending","passed","failed","blocked"],`${i}.result`),reason:r.reason===null?null:ce(r.reason,`${i}.reason`)}}function Tg(t,e){let i=`Native builder_handoff.checks[${e}]`,r=z(t,i);return J(r,new Set(["name","result","note"]),i),{name:ce(r.name,`${i}.name`),result:D(r.result,["passed","failed","not-run"],`${i}.result`),note:r.note===null?null:ce(r.note,`${i}.note`)}}function Ig(t){let e="Native builder_handoff",i=z(t,e);J(i,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","submitted_at"]),e);let r=en(i.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);return it(r,`${e}.addressed_acceptance_ids`),{candidate_id:L(i.candidate_id,`${e}.candidate_id`),identity_provider:L(i.identity_provider,`${e}.identity_provider`),builder_execution_ref:L(i.builder_execution_ref,`${e}.builder_execution_ref`),iteration:_(i.iteration,`${e}.iteration`,1),summary:ce(i.summary,`${e}.summary`),addressed_acceptance_ids:r,checks:ve(i.checks,`${e}.checks`,Tg),checks_truncated:kt(i.checks_truncated,`${e}.checks_truncated`),known_limits:ve(i.known_limits,`${e}.known_limits`,(n,a)=>ce(n,`${e}.known_limits[${a}]`)),known_limits_truncated:kt(i.known_limits_truncated,`${e}.known_limits_truncated`),submitted_at:St(i.submitted_at,`${e}.submitted_at`)}}function jg(t,e){let i=`Native blockers[${e}]`,r=z(t,i);J(r,new Set(["owner","reason","acceptance_ids","resolution_action"]),i);let n=en(r.acceptance_ids,`${i}.acceptance_ids`);return it(n,`${i}.acceptance_ids`),{owner:D(r.owner,["builder","runtime","verifier","user","external"],`${i}.owner`),reason:ce(r.reason,`${i}.reason`),acceptance_ids:n,resolution_action:D(r.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${i}.resolution_action`)}}function $g(t,e){let i=`Native verification.checks[${e}]`,r=z(t,i);return J(r,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),i),{id:L(r.id,`${i}.id`),name:ce(r.name,`${i}.name`),argv_display:ve(r.argv_display,`${i}.argv_display`,(n,a)=>ce(n,`${i}.argv_display[${a}]`)),argv_truncated:kt(r.argv_truncated,`${i}.argv_truncated`),cwd_ref:Mo(r.cwd_ref,`${i}.cwd_ref`,!0),status:D(r.status,["passed","failed","interrupted"],`${i}.status`),exit_code:xg(r.exit_code,`${i}.exit_code`),duration_ms:_(r.duration_ms,`${i}.duration_ms`)}}function Og(t){let e="Native verification",i=z(t,e);J(i,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let r=ve(i.checks,`${e}.checks`,$g);it(r.map(a=>a.id),`${e}.checks IDs`);let n=L(i.identity_provider,`${e}.identity_provider`);return{candidate_id:L(i.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:L(i.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:_(i.iteration,`${e}.iteration`,1),attempt:_(i.attempt,`${e}.attempt`,1),assurance:i.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":D(i.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:D(i.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:r,summary:ce(i.summary,`${e}.summary`),risks:ve(i.risks,`${e}.risks`,(a,o)=>ce(a,`${e}.risks[${o}]`)),risks_truncated:kt(i.risks_truncated,`${e}.risks_truncated`),completed_at:St(i.completed_at,`${e}.completed_at`)}}function Hg(t,e){let i=`Native history[${e}]`,r=z(t,i);J(r,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),i);let n=en(r.unresolved_ids,`${i}.unresolved_ids`);return it(n,`${i}.unresolved_ids`),{goal_cycle:_(r.goal_cycle,`${i}.goal_cycle`,1),iteration:_(r.iteration,`${i}.iteration`),attempt:_(r.attempt,`${i}.attempt`),outcome:D(r.outcome,["pass","fail","blocked","execution-error","recovery"],`${i}.outcome`),unresolved_ids:n,summary:ce(r.summary,`${i}.summary`),completed_at:St(r.completed_at,`${i}.completed_at`)}}function Dg(t){let e="Native history_overflow.outcome_counts",i=z(t,e),r=["pass","fail","blocked","execution-error","recovery"];return J(i,new Set(r),e),{pass:_(i.pass,`${e}.pass`),fail:_(i.fail,`${e}.fail`),blocked:_(i.blocked,`${e}.blocked`),"execution-error":_(i["execution-error"],`${e}.execution-error`),recovery:_(i.recovery,`${e}.recovery`)}}function Bg(t){let e="Native history_overflow",i=z(t,e);J(i,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let r=_(i.dropped_entries,`${e}.dropped_entries`),n=i.first_dropped_at===null?null:St(i.first_dropped_at,`${e}.first_dropped_at`),a=i.last_dropped_at===null?null:St(i.last_dropped_at,`${e}.last_dropped_at`);if(r===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(r>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=Dg(i.outcome_counts);if(Object.values(o).reduce((c,l)=>c+l,0)!==r)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:r,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function Lg(t){let e=new Set(t.acceptance.map(i=>i.id));for(let i of t.loop.previous_unresolved_ids)if(!e.has(i))throw new Error(`Native loop references unknown acceptance ID ${i}`);for(let i of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(i))throw new Error(`Native builder handoff references unknown ID ${i}`);for(let i of t.blockers)for(let r of i.acceptance_ids)if(!e.has(r))throw new Error(`Native blocker references unknown ID ${r}`);if(t.builder_handoff&&!(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.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 r=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(!r&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Mg(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 i=t.status==="await-user"?"await-user":t.status==="blocked"?"blocked":t.status==="done"?"done":null;if(i!==null&&t.loop.stage!==i)throw new Error(`Native status ${t.status} requires loop stage ${i}`);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(r=>r.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(t.verification.checks.some(r=>r.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 Et(t){let e=z(t,"Native portable state");if(J(e,Pg,"Native portable state"),e.schema!==bt)throw new Error(`Native portable state schema must be ${bt}`);let i=L(e.name,"Native state name");if(!kg.test(i))throw new Error("Native state name is invalid");if(e.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let r=ve(e.spec_changes,"Native spec_changes",Rg);it(r.map(s=>s.capability),"Native spec change capabilities");let n=ve(e.acceptance,"Native acceptance",_g);it(n.map(s=>s.id),"Native acceptance IDs");let a=ve(e.history,"Native history",Hg);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:bt,name:i,language:D(e.language,["en","zh-CN"],"Native state language"),phase:D(e.phase,["shape","build","verify","archive"],"Native state phase"),status:D(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:_(e.state_version,"Native state_version",1),brief:"brief.md",spec_changes:r,workspace:Cg(e.workspace),loop:Ag(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Ig(e.builder_handoff),blockers:ve(e.blockers,"Native blockers",jg),verification:e.verification===null?null:Og(e.verification),history:a,history_overflow:Bg(e.history_overflow),verification_result:D(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:D(e.verification_report,["verification.md"],"Native verification_report"),archived:kt(e.archived,"Native archived"),created_at:St(e.created_at,"Native created_at")};return Lg(o),Mg(o),o}function Fg(t,e){let i=(0,Zr.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`${e} is invalid YAML: ${i.errors[0].message}`);return i.toJS({mapAsMap:!1})}async function qe(t){let e=await bg.readFile(t,"utf8");return Et(Fg(e,"Native portable state"))}async function tn(t,e,i={}){let r=Et(e);await de(t,(0,Zr.stringify)(r),i)}var Xr=new Map;async function Vg(t,e){let i=Xr.get(t)??Promise.resolve(),r,n=new Promise(o=>{r=o}),a=i.then(()=>n);Xr.set(t,a),await i;try{return await e()}finally{r(),Xr.get(t)===a&&Xr.delete(t)}}async function Au(t){return Vg(t.file,async()=>{let e=_(t.expectedStateVersion,"Native expected state version",1),i=Et(t.next);if(i.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let r=await qe(t.file);if(r.state_version===i.state_version&&JSON.stringify(r)===JSON.stringify(i))return r;if(r.state_version!==e)throw new Qr(e,r.state_version);return await tn(t.file,i,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await qe(t.file);if(n.state_version!==e)throw new Qr(e,n.state_version)}}),i})}function qg(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function rn(t,e=16384){if(typeof t!="string")throw new Error("Native portable text must be a string");if(qg(e),Buffer.byteLength(t,"utf8")<=e)return{text:t,truncated:!1};let i="",r=0;for(let n of t){let a=Buffer.byteLength(n,"utf8");if(r+a>e)break;i+=n,r+=a}return{text:i,truncated:!0}}var xe="comet.native.v3",ge="comet.native.v2",we="comet.native.v1";var nn="comet.native.portable-migration.v1",zg=new Set(["schema","id","change","fromSchema","status","createdAt"]),Jg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Gg=/^[a-z0-9][a-z0-9-]{7,127}$/u,Ug=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),Kg=new Set([we,ge,xe]);function Yg(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Xg(t,e){let i=t instanceof Date?new Date(t.valueOf()):new Date(t);if(Number.isNaN(i.valueOf()))throw new Error(`${e} must be a valid timestamp`);return i.toISOString()}function Qg(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let i=new Date(t);if(Number.isNaN(i.valueOf())||i.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function Zg(t){return t.schema===we?yi(t):t.schema===ge?Ni(t):bi(t)}function ew(t){return Wg.posix.normalize(t.replaceAll("\\","/"))}function tw(t){return t.spec_changes.map(e=>e.operation==="remove"?{capability:e.capability,operation:"remove",source:null}:{capability:e.capability,operation:e.operation==="replace"?"modify":"create",source:ew(e.source)})}function iw(t){return t==="shape"?"shape":"build"}function rw(t,e){return t==="zh-CN"?e==="shape"?"继续澄清并确认验收项":"重新提交候选实现":e==="shape"?"Continue clarification and confirm acceptance":"Submit a fresh implementation candidate"}function nw(t,e,i){return t==="zh-CN"?`从旧版 ${e} ${i} 状态恢复;旧版 Loop、验证结论和运行记录未继承。`:`Recovered from legacy ${e} ${i} state; prior Loop, verification results, and execution records were not inherited.`}function _u(t){let e=Zg(t.state);Ru(t.acceptance);let i=iw(e.phase),r=i==="shape"?0:1,n=Xg(t.migratedAt??`${e.created_at}T00:00:00.000Z`,"Native portable migration time"),a=t.acceptance.map(o=>({id:o.id,source:o.source,text:o.text,result:"pending",reason:null}));return Et({schema:bt,name:e.name,language:e.language,phase:i,status:"active",state_version:1,brief:"brief.md",spec_changes:tw(e),workspace:t.workspace,loop:{stage:i==="shape"?"shape":"building",goal_cycle:1,iteration:r,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:rw(e.language,i)},acceptance:a,builder_handoff:null,blockers:[],verification:null,history:[{goal_cycle:1,iteration:r,attempt:0,outcome:"recovery",unresolved_ids:a.map(({id:o})=>o),summary:rn(nw(e.language,e.schema,e.phase)),completed_at:n}],history_overflow:Bo(),verification_result:"pending",verification_report:null,archived:!1,created_at:`${e.created_at}T00:00:00.000Z`})}function Fo(t){let e=Yg(t,"Native portable migration transaction"),i=Object.keys(e).filter(r=>!zg.has(r));if(i.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${i.join(", ")}`);if(e.schema!==nn)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!Gg.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!Jg.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!Kg.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!Ug.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:nn,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:Qg(e.createdAt,"Native portable migration transaction createdAt")}}function Tu(t){switch(Fo(t).status){case"prepared":return{action:"commit-portable-yaml",fromStatus:"prepared",nextStatus:"yaml-committed"};case"yaml-committed":return{action:"cleanup-legacy-runtime",fromStatus:"yaml-committed",nextStatus:"legacy-cleanup"};case"legacy-cleanup":return{action:"commit-transaction",fromStatus:"legacy-cleanup",nextStatus:"committed"};case"committed":return{action:"done",fromStatus:"committed",nextStatus:null}}}var Iu="comet.native.archive-transaction.v4",ju="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",aw=new RegExp(`^portable-archive-(${ju})\\.json$`,"u"),ow=new RegExp(`^portable-migration-(${ju})\\.json$`,"u"),sw=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,cw=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,lw=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),uw=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),dw=new Set(["capability","operation","source","content"]),$u=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function Ou(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Hu(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`);if(Object.keys(t).length!==e.size)throw new Error(`${i} fields are invalid`)}function fw(t,e){let i=`Native portable Archive spec_changes[${e}]`,r=Ou(t,i);if(Hu(r,dw,i),typeof r.capability!="string"||!$u.test(r.capability))throw new Error(`${i}.capability is invalid`);if(!["create","modify","remove"].includes(String(r.operation)))throw new Error(`${i}.operation is invalid`);let n=r.operation;if(n==="remove"){if(r.source!==null||r.content!==null)throw new Error(`${i} remove requires source and content null`);return{capability:r.capability,operation:n,source:null,content:null}}if(typeof r.source!="string"||r.source.length===0||r.source.includes("\\")||r.source.startsWith("/")||/^[A-Za-z]:/u.test(r.source)||r.source.split("/").some(a=>a==="."||a===".."))throw new Error(`${i}.${n} source is invalid`);if(typeof r.content!="string")throw new Error(`${i}.${n} content is invalid`);return{capability:r.capability,operation:n,source:r.source,content:r.content}}function hw(t){let e=Ou(t,"Native portable Archive transaction");if(Hu(e,uw,"Native portable Archive transaction"),e.schema!==Iu)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!sw.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!$u.test(e.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(e.start_state_version)||Number(e.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof e.archive_ref!="string"||!cw.test(e.archive_ref)||!e.archive_ref.endsWith(`-${e.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof e.status!="string"||!lw.has(e.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let i=e.spec_changes.map(fw);if(new Set(i.map(({capability:n})=>n)).size!==i.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>i.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof e.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let r=new Date(e.created_at);if(Number.isNaN(r.valueOf())||r.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:Iu,id:e.id,change:e.change,start_state_version:Number(e.start_state_version),archive_ref:e.archive_ref,status:e.status,next_spec_index:Number(e.next_spec_index),spec_changes:i,created_at:e.created_at}}function an(t){let e=aw.exec(t);if(e)return{kind:"archive",change:e[1]};let i=ow.exec(t);return i?{kind:"migration",change:i[1]}:null}function on(t,e){let i=`${e.kind==="archive"?"portable-archive":"portable-migration"}-${e.change}.json`,r=an(i);if(!r||r.kind!==e.kind||r.change!==e.change)throw new Error(`Invalid Native portable transaction change: ${e.change}`);return Vo.join(t.transactionsDir,i)}async function qo(t,e){let i=an(e);if(!i)return null;let r=await V({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(r.text),a=Vo.join(t.transactionsDir,e);if(i.kind==="archive"){let s=hw(n);if(s.change!==i.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:i.change,file:a,journal:s}}let o=Fo(n);if(o.change!==i.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:i.change,file:a,journal:o}}async function Du(t,e){let i=on(t,e);try{return await qo(t,Vo.basename(i))}catch(r){if(r.code==="ENOENT")return null;throw r}}function Bu(t){return t.kind==="archive"||t.journal.status!=="committed"}import Re from"path";import{TextDecoder as bw}from"util";import{createHash as pw}from"node:crypto";import{constants as sn,promises as le}from"node:fs";import ue from"node:path";function ln(t,e){let i=ue.relative(t,e);return i===""||!ue.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ue.sep}`)}function mw(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function vw(t,e){return A({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function gw(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function cn(t,e){return A({...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 Wo(t,e){let i=await le.lstat(t);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await le.realpath(t),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function ww(t,e,i){let r=ue.resolve(t),n=ue.resolve(e);if(!ln(r,n))throw new Error(`${i} is outside its managed root`);let a=[await Wo(r,i)],o=r;for(let s of ue.relative(r,n).split(ue.sep).filter(Boolean)){await rt(a,i),o=ue.join(o,s);let c=await Wo(o,i);if(!ln(a[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${o}`);a.push(c)}return await rt(a,i),a}async function rt(t,e){for(let i of t){let r=await le.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!vw(i,r)||await le.realpath(i.path)!==i.realPath)throw new Error(`${e} parent changed during I/O: ${i.path}`)}}async function yw(t,e,i){let r=[],n=0,a=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let o=e+1-n,{bytesRead:s}=await t.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,n>e)throw new Error(`${i} exceeds ${e} bytes`);r.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(r,n)}async function Pt(t){let e=mw(t.maxBytes),i=ue.resolve(t.file),r=await ww(t.root,ue.dirname(i),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(f=>Wo(ue.resolve(f),t.label)));await t.hooks?.afterParentChainCaptured?.(),await rt(r,t.label);let a=await le.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(a.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let o=gw(a),s=await le.realpath(i);if(!ln(r[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(f=>ln(f.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?sn.O_RDONLY:sn.O_RDONLY|sn.O_NOFOLLOW|sn.O_NONBLOCK,l=await le.open(i,c);try{let f=await l.stat();await t.hooks?.afterOpen?.();let[d,u]=await Promise.all([le.lstat(i),le.realpath(i)]);if(await rt(r,t.label),await rt(n,t.label),!f.isFile()||!d.isFile()||d.isSymbolicLink()||u!==s||!cn(o,f)||!cn(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let p=await yw(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),le.lstat(i),le.realpath(i)]);if(await rt(r,t.label),await rt(n,t.label),!h.isFile()||h.isSymbolicLink()||m!==s||!cn(o,v)||!cn(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:p,hash:pw("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}var kw=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),Sw=new Set(["id","type","source","target","staged","backup"]),Ew=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Pw=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var Fu=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var xw=256*1024,VS=1024*1024,qS=16*1024;var WS=64*1024*1024;var Rw=new bw("utf-8",{fatal:!0});function dn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function fn(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Vu(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function zo(t,e){if(typeof t!="string"||t.length===0||Re.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function un(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function Lu(t,e){if(zo(t,e),t.includes("\\")||t!==Re.posix.normalize(t)||t.split("/").includes(".")||t.endsWith("/")||Buffer.byteLength(t,"utf8")>1024)throw new Error(`${e} must be a normalized Native-relative ref`)}function Cw(t,e){let i=dn(t,`transaction operations[${e}]`);if(fn(i,Sw,`transaction operations[${e}]`),typeof i.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.id))throw new Error(`transaction operations[${e}].id is invalid`);if(i.type!=="write"&&i.type!=="remove"&&i.type!=="move")throw new Error(`transaction operation ${i.id} has an invalid type`);zo(i.target,`transaction operation ${i.id} target`);for(let r of["source","staged","backup"])i[r]!==void 0&&zo(i[r],`transaction operation ${i.id} ${r}`);if(i.type==="write"){if(i.staged===void 0||i.source!==void 0)throw new Error(`write operation ${i.id} requires staged and forbids source`)}else if(i.type==="remove"){if(i.source!==void 0||i.staged!==void 0)throw new Error(`remove operation ${i.id} forbids source and staged`)}else if(i.source===void 0||i.staged!==void 0||i.backup!==void 0)throw new Error(`move operation ${i.id} requires source and forbids staged and backup`);return i}function qu(t){let e=dn(t,"Native Archive transaction journal");if(fn(e,Ew,"Native Archive transaction journal"),e.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native Archive transaction id is invalid");if(e.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof e.status!="string"||!Fu.has(e.status))throw new Error("Native Archive transaction status is invalid");if(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change))throw new Error("Native Archive transaction change name is invalid");if(!Vu(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(un(e.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(e.operations)||e.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let i=e.operations.map((s,c)=>{let l=dn(s,`Archive transaction operations[${c}]`);if(fn(l,Pw,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);Lu(l.target,`Archive transaction operation ${l.id} target`);for(let f of["source","staged","backup"])l[f]!==void 0&&Lu(l[f],`Archive transaction operation ${l.id} ${f}`);if(l.expectedTargetHash!==null&&un(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(un(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);un(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),r=i.map(s=>s.id);if(new Set(r).size!==r.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=i.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${e.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${e.change}$`,"u").test(a[0].target)||i.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of i.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:i}}function Aw(t){let e=dn(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return qu(e);if(fn(e,kw,"Native transaction journal"),e.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native transaction id is invalid");if(e.kind!=="archive"&&e.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof e.status!="string"||!Fu.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!Re.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!Re.isAbsolute(e.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(e.change!==void 0&&(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change)))throw new Error("Native transaction change name is invalid");if(!Vu(e.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(e.operations))throw new Error("Native transaction operations must be an array");let i=e.operations.map(Cw),r=i.map(n=>n.id);if(new Set(r).size!==r.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:e.id,kind:e.kind,status:e.status,projectRoot:e.projectRoot,nativeRoot:e.nativeRoot,...typeof e.change=="string"?{change:e.change}:{},createdAt:e.createdAt,operations:i}}function _w(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return Re.join(t.transactionsDir,e)}function Wu(t,e){let i=_w(t,e);return{directory:i,journal:Re.join(i,"transaction.json"),events:Re.join(i,"events.jsonl"),staged:Re.join(i,"staged"),backups:Re.join(i,"backups")}}async function Go(t,e){let i=Wu(t,e);return await Promise.all(Object.values(i).map(r=>T(t.runtimeDir,r))),i}async function Uo(t,e,i={}){let r=await Go(t,e),n=await Pt({root:t.runtimeDir,file:r.journal,maxBytes:xw,label:`Native transaction journal ${e}`,hooks:i.hooks}),a=JSON.parse(Rw.decode(n.bytes)),o=Aw(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}async function jw(t,e,i){let r;try{r=await Tw.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await Uo(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of r)if(an(n.name))try{let a=await qo(t,n.name);if(!a||i?.kind===a.kind&&i.change===a.change)continue;if(Bu(a))return!0}catch{return!0}return!1}async function $w(t,e){let i=Date.now()+5e3,r=Iw.join(t.locksDir,"root-move.lock");for(;;)try{return await Kr(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Su(r);if(o.status==="missing")continue;if(o.status!=="active"||Date.now()>=i)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function ee(t,e,i,r){let n=await $w(t,e);try{if(await Gr(t.projectRoot),await jw(t,r?.allowedTransactionId,r?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await i()}finally{await Yr(n)}}import{createHash as Ow}from"crypto";function te(t){return Ow("sha256").update(t).digest("hex")}var dE={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024};var fE=8*1024*1024;var hE=64*1024,pE=64*1024;var mE={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},vE={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};var gE=(1n<<256n)-1n;var Vw=ji(ci(),1);var jE=4*1024*1024;var RP=256*1024;var MP={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};import xt from"node:path";var ki=/^[a-f0-9]{64}$/u,Ju=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,zw=16*1024,ix=process.platform;function Jw(t,e){let i=xt.relative(t,e);return xt.isAbsolute(i)||i===".."||i.startsWith(`..${xt.sep}`)?null:i.replaceAll("\\","/")||"."}function Gu(t){return Array.from(t).some(e=>{let i=e.codePointAt(0)??0;return i<=31||i===127})}function Uu(t,e){if(t.length===0||Gu(t)||t.includes("\\")||xt.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let i=xt.posix.normalize(t);if(i!==t||i===".."||i.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return i}function Gw(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 Ko(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||Gu(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function Uw(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Ko(t.changeBranch,"Native workspace change branch"),Ko(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 Kw(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,i=new Set(["provider","baseCommit","targetBranch","targetCommit"]),r=Object.keys(e).filter(n=>!i.has(n));if(r.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${r.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!Ju.test(e.baseCommit)||typeof e.targetCommit!="string"||!Ju.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");Ko(e.targetBranch,"Native workspace Git target branch")}function Yw(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(e).filter(o=>!i.has(o));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.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"||!ki.test(String(e.projectRootId))||!ki.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");Gw(e.capturedAt),Uu(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&&!ki.test(String(e.projectRootPathId))||a&&!ki.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!ki.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&Kw(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(Uw(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 Xw(t,e){return xt.join(pe(t,e),"workspace.json")}function Qw(t,e){let i=Xw(t,e),r=me(t,i),n=Jw(r,i);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:r,ref:Uu(n,"Native workspace file ref")}}async function Zw(t,e){try{let i=Qw(t,e),r=await V({root:i.root,ref:i.ref,maxBytes:zw});return JSON.parse(r.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Si(t,e){let i=await Zw(t,e);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(Yw(i),i)}var Yu=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],iy=new Set(Yu),Xu=new Set([...Yu,"minimum_runtime_version","revision"]),ry=new Set([...Xu,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),ny=new Set(["capability","operation","source","base_hash"]),ay=new Set(["shape","build","verify","archive"]),oy=new Set(["implicit","confirmed"]),sy=new Set(["pending","pass","fail"]),nt="comet-state.yaml",Xo=/^[a-f0-9]{64}$/u,Qu=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,cy=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Qo=class extends Error{constructor(i,r){super(`Native change ${i} uses ${r}; run comet native doctor ${i} --repair before mutating it`);this.change=i;this.schema=r;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},Ct=class extends Error{constructor(i,r){super(i!==xe||r===null?`Unsupported Native change schema ${i} for runtime protocol ${3}`:`Native change ${i} requires runtime protocol ${r}; current protocol is ${3}`);this.schema=i;this.minimumRuntimeVersion=r;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"},hn=class extends Error{constructor(i,r,n){super(`Native change ${i} revision conflict: expected ${r}, actual ${n}`);this.change=i;this.expectedRevision=r;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},Ei=class extends Error{constructor(i,r){super(`Native working directory already contains active change${r.length===1?"":"s"} ${r.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=i;this.activeChanges=r;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},pn=class extends Error{constructor(i,r,n,a,o,s=null,c=null){super(`Native change ${i} baseline is incomplete (${r} omitted entr${r===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=i;this.omittedCount=r;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"},Rx=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
150
- `);function xi(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Zu(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function es(t){if(!Qu.test(t))throw new Error(`Invalid Native change name: ${t}`)}function ly(t){if(!Qu.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function ed(t,e){if(t.length===0||Rt.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function uy(t,e){let i=xi(t,`spec_changes[${e}]`);if(Zu(i,ny,`spec_changes[${e}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(ly(i.capability),i.operation!=="create"&&i.operation!=="replace"&&i.operation!=="remove")throw new Error(`Invalid spec operation for ${i.capability}`);let r=i.source,n=i.base_hash;if(r!==void 0&&typeof r!="string")throw new Error(`Spec source for ${i.capability} must be a string`);if(typeof r=="string"&&ed(r,`Spec source for ${i.capability}`),i.operation==="create"){if(!r)throw new Error(`Create spec ${i.capability} requires source`);if(n!==null)throw new Error(`Create spec ${i.capability} requires null base_hash`)}else if(i.operation==="replace"){if(!r)throw new Error(`Replace spec ${i.capability} requires source`);if(typeof n!="string"||!Xo.test(n))throw new Error(`Replace spec ${i.capability} requires a SHA-256 base_hash`)}else{if(r!==void 0)throw new Error(`Remove spec ${i.capability} forbids source`);if(typeof n!="string"||!Xo.test(n))throw new Error(`Remove spec ${i.capability} requires a SHA-256 base_hash`)}return{capability:i.capability,operation:i.operation,...typeof r=="string"?{source:r}:{},base_hash:n}}function dy(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 ts(t,e){if(Zu(t,e,nt),typeof t.name!="string")throw new Error("Native change name is required");if(es(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"||!ay.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&&!oy.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 i=t.spec_changes.map(uy),r=i.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(r.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(r)].join(", ")}`);if(typeof t.verification_result!="string"||!sy.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"&&ed(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!dy(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:i,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function yi(t){let e=xi(t,nt);if(e.schema!==we)throw new Error(`Expected ${we}`);return{schema:we,...ts(e,iy)}}function Pi(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Yo(t,e,i){if(t===null)return null;let r=typeof t=="string"?cy.exec(t):null;if(!r||r[1]!==i)throw new Error(`${e} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return t}function fy(t){if(t==null)return null;if(typeof t!="string"||!Xo.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function hy(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 Ni(t){let e=xi(t,nt);if(e.schema!==ge)throw new Error(`Expected ${ge}`);if(Pi(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${ge} minimum_runtime_version must be 2`);return{schema:ge,minimum_runtime_version:2,revision:Pi(e.revision,"Native v2 revision"),...ts(e,Xu)}}function bi(t){let e=xi(t,nt);if(e.schema!==xe){if(e.schema===we||e.schema===ge){let o=e.schema===we?yi(e):Ni(e);throw new Qo(o.name,o.schema)}throw new Ct(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let i=Pi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new Ct(e.schema,i);if(i!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let r=Pi(e.revision,"Native revision"),n=ts(e,ry),a=fy(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:xe,minimum_runtime_version:3,revision:r,verification_protocol:hy(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:Yo(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Yo(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Yo(e.partial_allowance,"Native partial_allowance","allowances")}}function py(t){let e=xi(t,nt);if(e.schema===we){let n=yi(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${xe}`}}if(e.schema===ge){let n=Ni(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${xe}`}}if(e.schema!==xe){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 Ct(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let i=Pi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:i,state:null,message:new Ct(e.schema,i).message};let r=bi(e);return{status:"current",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r}}function ye(t,e){es(e);let i=Rt.join(t.changesDir,e);if(!M(t.changesDir,i))throw new Error("Native change path escaped");return i}var my=256*1024;async function vy(t,e=Rt.dirname(t)){let i=Rt.relative(e,t).split(Rt.sep).join("/"),r=await V({root:e,ref:i,maxBytes:my}),n=(0,Zo.parseDocument)(r.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 td(t,e){let i=Rt.join(ye(t,e),nt);await T(t.nativeRoot,i);let r=py(await vy(i,t.nativeRoot));if(r.state&&r.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return r}import{promises as nd}from"node:fs";import bn from"node:path";var Ax=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");import{promises as ky}from"node:fs";import Ci from"node:path";function mn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function vn(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Ne(t,e,i=!1){if(typeof t!="string"||!i&&t.length===0)throw new Error(`${e} must be ${i?"a string":"a non-empty string"}`);return t}function id(t,e){return t===null?null:Ne(t,e)}function wn(t,e,i=0){if(!Number.isSafeInteger(t)||t<i)throw new Error(`${e} must be a safe integer greater than or equal to ${i}`);return t}function Sy(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 Ey(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function gn(t,e,i){if(typeof t!="string"||!e.includes(t))throw new Error(`${i} must be one of: ${e.join(", ")}`);return t}function is(t,e){if(t===null)return null;let i=Ne(t,e);if(Number.isNaN(Date.parse(i)))throw new Error(`${e} must be an ISO timestamp`);return i}function rs(t,e){let i=Ne(t,e);if(!Ci.isAbsolute(i))throw new Error(`${e} must be absolute`);return Ci.resolve(i)}function Py(t,e){let i=`Native local checks[${e}]`,r=mn(t,i);if(vn(r,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),i),!Array.isArray(r.argv)||r.argv.length===0)throw new Error(`${i}.argv must be a non-empty array`);let n=r.argv.map((l,f)=>Ne(l,`${i}.argv[${f}]`,!0)),a=gn(r.status,["planned","running","passed","failed","interrupted"],`${i}.status`),o=is(r.startedAt,`${i}.startedAt`),s=is(r.completedAt,`${i}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${i} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${i} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${i} completed check requires startedAt and completedAt`);let c=wn(r.timeoutMs,`${i}.timeoutMs`);if(c<1)throw new Error(`${i}.timeoutMs must be positive`);return{id:Ne(r.id,`${i}.id`),name:Ne(r.name,`${i}.name`),operationId:Ne(r.operationId,`${i}.operationId`),status:a,repeatable:Ey(r.repeatable,`${i}.repeatable`),timeoutMs:c,executionCount:wn(r.executionCount,`${i}.executionCount`),argv:n,cwd:rs(r.cwd,`${i}.cwd`),exitCode:Sy(r.exitCode,`${i}.exitCode`),startedAt:o,completedAt:s,log:Ne(r.log,`${i}.log`)}}function rd(t){let e="Native local execution state",i=mn(t,e);if(vn(i,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),e),i.schema!==wi)throw new Error(`Native local execution schema must be ${wi}`);let r=mn(i.workspace,"Native local workspace");vn(r,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(i.execution!==null){let o=mn(i.execution,"Native local execution");vn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=is(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Ne(o.operationId,"Native local execution.operationId"),stage:gn(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:gn(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:id(o.executionId,"Native local execution.executionId"),status:gn(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:wn(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(i.checks))throw new Error("Native local checks must be an array");let a=i.checks.map(Py);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:wi,change:Ne(i.change,"Native local change"),basedOnStateVersion:wn(i.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:rs(r.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:rs(r.worktreeRoot,"Native local workspace.worktreeRoot"),branch:id(r.branch,"Native local workspace.branch")},execution:n,checks:a}}function yn(t){return rd({schema:wi,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,workspace:{projectRoot:Ci.resolve(t.projectRoot),worktreeRoot:Ci.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null},execution:null,checks:[]})}async function Nn(t,e,i={}){let r=rd(e);await ky.mkdir(Ci.dirname(t),{recursive:!0}),await K(t,r,i)}var ad=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,xy="comet-state.yaml",Ry="state.json";function od(t,e){if(!ad.test(e))throw new Error(`Invalid Native change name: ${e}`);let i=bn.join(t.changesDir,e);if(!M(t.changesDir,i))throw new Error("Native change path escaped");return i}function ze(t,e){return bn.join(od(t,e),xy)}function ns(t,e){return bn.join(tt(t,e),Ry)}async function Ai(t,e){try{let i=await nd.readFile(ze(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(i)}catch(i){if(i.code==="ENOENT")return!1;throw i}}function Cy(t){return ke(t).currentBranch}async function sd(t,e){return qe(ze(t,e))}async function Ay(t){let e=await Au({file:ze(t.paths,t.previous.name),expectedStateVersion:t.previous.state_version,next:t.next,containedRoot:t.paths.nativeRoot});if(e.verification===null&&e.verification_report===null){let i=bn.join(od(t.paths,e.name),"verification.md");await T(t.paths.nativeRoot,i),await nd.rm(i,{force:!0})}return e}async function cd(t){if(!ad.test(t.capability))throw new Error(`Invalid Native capability: ${t.capability}`);return ee(t.paths,`remove portable spec ${t.capability}`,async()=>{let e=await sd(t.paths,t.name);if(e.archived)throw new Error(`Native change ${e.name} is already archived`);let i=e.spec_changes.filter(({capability:a})=>a!==t.capability),r={...e,phase:"shape",status:"active",state_version:e.state_version+1,spec_changes:[...i,{capability:t.capability,operation:"remove",source:null}].sort((a,o)=>a.capability.localeCompare(o.capability,"en")),acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,history:[],history_overflow:{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}},loop:{stage:"shape",goal_cycle:e.loop.goal_cycle+(e.phase==="shape"?0: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:"confirm-shape"}},n=await Ay({paths:t.paths,previous:e,next:r});return await Nn(ns(t.paths,e.name),yn({portableState:n,projectRoot:t.paths.projectRoot,branch:Cy(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n})}var Iy=["evidence.md","verification.md","repair.md","archive.md","checkpoint.md"];async function jy(t,e){let i=await Du(t,{kind:"migration",change:e});return i?.kind==="migration"?i.journal:null}async function ld(t,e){await _i.mkdir(t.transactionsDir,{recursive:!0}),await K(on(t,{kind:"migration",change:e.change}),e,{containedRoot:t.runtimeDir})}async function ud(t,e){await Promise.all([_i.rm(tt(t,e),{recursive:!0,force:!0}),_i.rm(Eo(t,e),{recursive:!0,force:!0}),...Iy.map(i=>_i.rm(Ty.join(ye(t,e),i),{force:!0}))])}async function dd(t,e){await Nn(ns(t,e.name),yn({portableState:e,projectRoot:t.projectRoot}),{containedRoot:t.runtimeDir})}async function fd(t,e){try{let i=await Si(t,e);if(i?.schema==="comet.native.workspace.v3")return{isolation:i.isolation,change_branch:i.changeBranch,target_branch:i.targetBranch,finish:i.finish}}catch{}return{isolation:"current",change_branch:null,target_branch:null,finish:null}}function hd(t,e){if(e.isolation==="current"&&e.change_branch===null)return;let i=ke(t.projectRoot);if(!i.isGitWorktree)throw new Error("Native legacy migration requires its bound Git branch or worktree");if(i.currentBranch!==e.change_branch)throw new Error(`Native legacy migration expected branch ${e.change_branch??"(missing)"}, current branch is ${i.currentBranch??"(detached)"}`);if(e.isolation==="worktree"&&!i.isSecondaryWorktree)throw new Error("Native legacy migration requires its bound linked worktree")}async function $y(t){let e=ye(t.paths,t.state.name),i=await V({root:e,ref:t.state.brief,maxBytes:null,includeHash:!1}),r=[];for(let n of t.state.spec_changes){if(n.operation==="remove"||!n.source)continue;let a=await V({root:e,ref:n.source,maxBytes:null,includeHash:!1});r.push({capability:n.capability,source:a.ref,markdown:a.text})}try{return Do({briefMarkdown:i.text,specs:r})}catch(n){if(t.state.phase==="shape"&&n.message.includes("at least one acceptance"))return[];throw n}}async function pd(t,e){let i=await td(t,e);if(!i.state)throw new Error(`Native legacy change ${e} is unreadable`);return i.state}async function md(t){return ee(t.paths,`migrate ${t.name} to portable Native`,async()=>{let e=await jy(t.paths,t.name),i=await Ai(t.paths,t.name)?await qe(ze(t.paths,t.name)):null;if(!e&&i)return await ud(t.paths,t.name),await dd(t.paths,i),i;let r=null,n=null;for(e||(r=await pd(t.paths,t.name),n=await fd(t.paths,t.name),hd(t.paths,n),e={schema:nn,id:_y(),change:r.name,fromSchema:r.schema,status:"prepared",createdAt:(t.now??new Date).toISOString()},await ld(t.paths,e));;){let a=Tu(e);if(a.action==="done")break;a.action==="commit-portable-yaml"?i||(r??=await pd(t.paths,t.name),n??=await fd(t.paths,t.name),hd(t.paths,n),i=_u({state:r,acceptance:await $y({paths:t.paths,state:r}),workspace:n,migratedAt:t.now}),await tn(ze(t.paths,t.name),i,{containedRoot:t.paths.nativeRoot})):a.action==="cleanup-legacy-runtime"?await ud(t.paths,t.name):a.action==="commit-transaction"&&(i??=await qe(ze(t.paths,t.name)),await dd(t.paths,i)),e={...e,status:a.nextStatus},await ld(t.paths,e)}return await _i.rm(on(t.paths,{kind:"migration",change:t.name}),{force:!0}),i??qe(ze(t.paths,t.name))},{allowedPortableTransaction:{kind:"migration",change:t.name}})}import ss from"path";var Hy=["Outcome","Scope","Non-goals","Acceptance examples"],kC=[...Hy,"Constraints and invariants","Decisions","Open questions","Verification expectations"];var Dy=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});var vd=1024*1024;var wd="scoped-text-safety",By=1,Ly=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var My="comet.native.checker-policy.v1";var BC=Z(My,{policy:wd,version:By,limits:Ly,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var Fy=["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"],LC=new Set(Fy);var Wy=vd,iA=3*Wy;var yd={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:[]},Jy=te("comet-native-runtime:v3:scope-reopen"),AA=[{skillVersion:"3",skillHash:te("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:te("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:te("comet-native-runtime:v1")}];var bd=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],l_=new Set(bd),Zy=new Set([...bd,"minimum_runtime_version","revision"]),u_=new Set([...Zy,"operation"]),d_=512*1024,eN=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),f_=new Set([...eN,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var v_={maxAcceptanceCriteria:gi.maxCriteria};var b_={maxSpecs:64,maxFileBytes:Hi,maxTotalBytes:4*1024*1024};import{execFile as lN}from"node:child_process";import{promisify as uN}from"node:util";var T_={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var Q_=512*1024;var Ti=class extends Error{recovery;constructor(e,i){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=i}};var bT=64*1024;var kT=3600*1e3;var ST=uN(lN);var kn=class extends Error{details;constructor(e){let i=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(r=>`${r.ref}${r.acceptanceId?`[${r.acceptanceId}]`:""} -> ${r.mismatches.join("; ")}`).join(" | ")}`;super(i),this.name="NativeVerificationReceiptBindingError",this.details=e}};var cI={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var wI=16*1024*1024,yI=256*1024,NI=16*1024;var PI=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var CI=16*1024;var MI=16*1024;var _j=16*1024*1024,Sn=class extends Error{constructor(i,r,n,a){super(`Canonical spec conflict for ${i}: expected ${r??"(missing)"}, actual ${n??"(missing)"}`);this.capability=i;this.expectedHash=r;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},En=class extends Error{constructor(i,r=i.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${i.findingCodes.join(", ")}`){super(r);this.preflight=i;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};var Ij=8*1024*1024;var Pn=class extends Error{constructor(i,r,n){super(i,n);this.preparation=r;this.name="NativeWorkspacePreparationError"}preparation};var Ed=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--help Show help without requiring an initialized project."],os=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",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 remove Record a complete capability removal intent.","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:Ed,output:"Human-readable text by default; use --json for a structured command envelope.",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] [--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.","--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, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","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 remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],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."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries or inspect the exact next Runner action.",options:["--cursor <token> Continue a status-list page.","--details Include acceptance, Spec, workspace, and report details."],output:"A v2 status page or one portable Loop projection with local execution availability and continuation.runnerAction.",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> [--confirmed|--return-to-build|--retry-verifier|--resolve-verifier-blocker]
151
- comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, 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 Shape, a completed skill-coordinated pass, or an explicitly degraded verifier-unavailable fallback before Archive.","--return-to-build Return Verify or Archive to Build after invalidation or user choice.","--retry-verifier Retry a blocked Verifier execution when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," 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."],output:"The portable state, explicit skill-coordinated label, Runtime-owned check results, complete verifierDispatch, bounded request-check response, continuation.runnerAction, and machine-readable continuation.inputOptions. 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','comet native next session-timeout --summary "Implementation changed" --return-to-build','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]
152
- 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 Inspect readiness without rerunning verification.","--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 plus continuation, or the completed Archive transaction and workspace finish result; 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 as(t,e){return`${t}:
147
+ `,o),l=c===-1?a.slice(o):a.slice(o,c);if(yield{line:l,body:e===null&&!i&&r===null,index:s},s+=1,e!==null)e=To(l,e);else if(i)Pu(l)&&(i=!1);else if(r!==null)new RegExp(`</${r}\\s*>`,"iu").test(l)&&(r=null);else{let d=To(l,null);if(d!==null)e=d;else{let u=l.trimStart();if(u.startsWith("<!--")&&!Pu(u))i=!0;else{let p=/^<([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/u.exec(u);p&&n.has(p[1].toLowerCase())&&!u.startsWith("</")&&!u.endsWith("/>")&&!new RegExp(`</${p[1]}\\s*>`,"iu").test(u)&&(r=p[1])}}}if(c===-1)break;o=c+1}}function wi(t){return t.normalize("NFC").replace(/\s+/gu," ").trim()}function jo(t,e,i,r=[],n="content-hash"){let a=wi(i),o=e.replaceAll("\\","/").trim(),s=r.map(wi);if(a.length===0)throw new Error(`${t} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${t} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${K(bg,{kind:t,source:o,context:s,text:a})}`:"",kind:t,source:o,context:s,text:a}}function $o(t,e,i="content-hash"){let r=new Set;for(let n of t){let a=i==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(r.has(a))throw new Error(`${e} contains duplicate acceptance criteria`);r.add(a)}return t}function kg(t){let e=null,i=null,r=0,n=0;for(let{line:a,body:o,index:s}of gi(t)){n=s+1;let c=o?Io(a):null;c?.level===1&&(c.text.toLocaleLowerCase("en-US")==="acceptance examples"?(r+=1,r===1&&(e=s+1)):e!==null&&i===null&&(i=s))}if(r===0||e===null)return null;if(r!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:e,end:i??n}}function Oo(t,e="brief.md",i=yi.maxCriteria,r="content-hash"){if(!Number.isSafeInteger(i)||i<0)throw new Error("Native brief acceptance budget is invalid");let n=kg(t);if(n===null)return[];let a=null;for(let{line:l,body:f,index:d}of gi(t)){if(d<n.start||d>=n.end)continue;let u=f?/^( {0,3})[-*+][ \t]+/u.exec(l):null;if(u===null)continue;let p=u[1].length;a=a===null?p:Math.min(a,p)}let o=[],s=null,c=()=>{if(s!==null){if(o.length>=i)throw new Error(`Native acceptance exceeds its ${i}-criterion acceptance budget`);o.push(s)}};for(let{line:l,body:f,index:d}of gi(t)){if(d<n.start||d>=n.end)continue;let u=f?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(l):null;u&&u[1].length===a?(c(),s=[u[2]]):s!==null&&s.push(l)}return c(),$o(o.map(l=>jo("brief-example",e,l.join(`
148
+ `),[],r)),"Brief",r)}function Ho(t,e="spec.md",i=yi.maxCriteria,r="content-hash"){if(!Number.isSafeInteger(i)||i<0)throw new Error("Native specification acceptance budget is invalid");let n=[],a=[],o=null,s=()=>{if(o!==null){if(n.length>=i)throw new Error(`Native acceptance exceeds its ${i}-criterion acceptance budget`);n.push(jo("spec-scenario",e,[o.title,...o.body].join(`
149
+ `),o.context,r)),o=null}};for(let{line:c,body:l}of gi(t)){let f=l?Io(c):null,d=f?/^Scenario\s*:\s*(.*)$/iu.exec(f.text):null;if(d){for(s();a.at(-1)&&a.at(-1).level>=f.level;)a.pop();let u=wi(d[1]);if(u.length===0)throw new Error("Scenario title must not be empty");o={level:f.level,title:u,body:[],context:a.map(p=>p.text)}}else if(f){for(o!==null&&f.level<=o.level?s():o!==null&&o.body.push(c);a.at(-1)&&a.at(-1).level>=f.level;)a.pop();a.push(f)}else o!==null&&l&&o.body.push(c)}return s(),$o(n,"Specification",r)}function Do(t,e="spec.md",i=yi.maxCriteria,r="content-hash"){if(!Number.isSafeInteger(i)||i<0)throw new Error("Native specification acceptance budget is invalid");let n=[],a=[],o=null,s=null,c=()=>{if(s!==null){if(n.length>=i)throw new Error(`Native acceptance exceeds its ${i}-criterion acceptance budget`);n.push(jo("spec-must",e,s.parts.join(" "),s.context,r)),s=null}},l=()=>a.some(f=>/^(?:non-?goals?|非目标)$/iu.test(f.text.trim()));for(let{line:f,body:d}of gi(t)){let u=d?Io(f):null;if(u){for(c(),o!==null&&u.level<=o&&(o=null);a.at(-1)&&a.at(-1).level>=u.level;)a.pop();a.push(u),/^Scenario\s*:/iu.test(u.text)&&(o=u.level);continue}let p=f.trim();if(!d||o!==null||l()){c();continue}if(p.length===0||To(f,null)!==null||p.startsWith("<!--")||p==="-->"||p==="--!>"||/^<\/?[A-Za-z][^>]*>$/u.test(p)||/^<[A-Za-z][^>]*>.*<\/[A-Za-z][^>]*>$/u.test(p)||/^(?:[-*_]\s*){3,}$/u.test(p)||/^\|?(?:\s*:?-{3,}:?\s*\|)+\s*$/u.test(p)){c();continue}let v=/^\s*(?:[-*+]|\d+[.)])[ \t]+(.+)$/u.exec(f);if(v){c(),s={parts:[v[1]],context:a.map(h=>h.text)};continue}if(/^\|.*\|$/u.test(p)){c(),s={parts:[p],context:a.map(h=>h.text)},c();continue}s===null?s={parts:[p],context:a.map(h=>h.text)}:s.parts.push(p)}return c(),$o(n,"Specification mandatory requirements",r)}var Sg=/^A[1-9]\d*$/u;function Cu(t,e){if(t.length===0||t!==t.trim()||t.includes("\\")||xu.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||xu.posix.normalize(t)!==t||t==="."||t.endsWith("/"))throw new Error(`${e} must be a normalized change-relative ref`);return t}function Eg(t,e){return t.localeCompare(e,"en")}function Bo(t){let e=Cu(t.briefSource??"brief.md","Native brief source"),i=[...t.specs??[]].sort((a,o)=>Eg(a.capability,o.capability));if(new Set(i.map(a=>a.capability)).size!==i.length)throw new Error("Native acceptance sources contain duplicate capabilities");let r=Oo(t.briefMarkdown,e,Number.MAX_SAFE_INTEGER,"none").map(({source:a,text:o})=>({source:a,text:o}));for(let a of i){let o=Cu(a.source,`Native spec source for ${a.capability}`);r.push(...Ho(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})),...Do(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})))}let n=new Set;for(let a of r){a.text=wi(a.text);let o=`${a.source}\0${a.text}`;if(n.has(o))throw new Error(`Native acceptance contains a duplicate criterion: ${a.text}`);n.add(o)}if(r.length===0)throw new Error("Native change must define at least one acceptance criterion");return r.map((a,o)=>({id:`A${o+1}`,source:a.source,text:a.text}))}function Ru(t){let e=t.map(({id:i})=>i);if(new Set(e).size!==e.length)throw new Error("Native acceptance IDs must be unique");for(let i=0;i<e.length;i+=1)if(!Sg.test(e[i])||e[i]!==`A${i+1}`)throw new Error("Native acceptance IDs must be the contiguous sequence A1..An")}var tn=jt(wt(),1);import{promises as Pg}from"node:fs";var Pt="comet.native.v4",Ni="comet.native.local-execution.v4";function Lo(){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 xg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Cg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Rg=/^A[1-9][0-9]*$/u,Ag=/^[a-f0-9]{64}$/u,_g=new Set(["schema","name","language","phase","status","state_version","brief","children_contract_hash","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),en=class extends Error{constructor(i,r){super(`Native state version conflict: expected ${i}, got ${r}`);this.expectedStateVersion=i;this.actualStateVersion=r;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};function z(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function J(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function B(t,e,i){if(typeof t!="string"||!i?.empty&&t.length===0)throw new Error(`${e} must be ${i?.empty?"a string":"a non-empty string"}`);return t}function Mo(t,e){return t===null?null:B(t,e)}function Tg(t,e){let i=B(t,e);if(!Ag.test(i))throw new Error(`${e} must be a SHA-256 hash`);return i}function xt(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function _(t,e,i=0){if(!Number.isSafeInteger(t)||t<i)throw new Error(`${e} must be a safe integer greater than or equal to ${i}`);return t}function Ig(t,e){return t===null?null:_(t,e,Number.MIN_SAFE_INTEGER)}function D(t,e,i){if(typeof t!="string"||!e.includes(t))throw new Error(`${i} must be one of: ${e.join(", ")}`);return t}function ve(t,e,i){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((r,n)=>i(r,n))}function rn(t,e){return ve(t,e,(i,r)=>B(i,`${e}[${r}]`))}function it(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Ct(t,e){let i=B(t,e);if(Number.isNaN(Date.parse(i)))throw new Error(`${e} must be an ISO date or timestamp`);return i}function Fo(t,e,i=!1){let r=B(t,e);if(r.includes("\\")||r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").includes("..")||!i&&(r==="."||r.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return r}function ce(t,e){let i=z(t,e);return J(i,new Set(["text","truncated"]),e),{text:B(i.text,`${e}.text`,{empty:!0}),truncated:xt(i.truncated,`${e}.truncated`)}}function jg(t,e){let i=`Native spec_changes[${e}]`,r=z(t,i);J(r,new Set(["capability","operation","source"]),i);let n=B(r.capability,`${i}.capability`);if(!Cg.test(n))throw new Error(`${i}.capability is invalid`);let a=D(r.operation,["create","modify","remove"],`${i}.operation`),o=r.source===null?null:Fo(r.source,`${i}.source`);if(a==="remove"&&o!==null)throw new Error(`${i} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${i} ${a} requires a source`);return{capability:n,operation:a,source:o}}function $g(t){let e="Native workspace",i=z(t,e);J(i,new Set(["isolation","change_branch","target_branch","finish"]),e);let r=D(i.isolation,["current","branch","worktree"],`${e}.isolation`),n=Mo(i.change_branch,`${e}.change_branch`),a=Mo(i.target_branch,`${e}.target_branch`),o=i.finish===null?null:D(i.finish,["merge","push","pull-request","keep"],`${e}.finish`);if(r==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(r==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(r!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:r,change_branch:n,target_branch:a,finish:o}}function Og(t){let e="Native loop",i=z(t,e);J(i,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","execution_failure_count","previous_unresolved_ids","next_action"]),e);let r=rn(i.previous_unresolved_ids,`${e}.previous_unresolved_ids`);return it(r,`${e}.previous_unresolved_ids`),{stage:D(i.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:_(i.goal_cycle,`${e}.goal_cycle`,1),iteration:_(i.iteration,`${e}.iteration`),attempt:_(i.attempt,`${e}.attempt`),retry_epoch:_(i.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:_(i.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:_(i.no_progress_count,`${e}.no_progress_count`),execution_failure_count:_(i.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:r,next_action:Mo(i.next_action,`${e}.next_action`)}}function Hg(t,e){let i=`Native acceptance[${e}]`,r=z(t,i);J(r,new Set(["id","source","text","result","reason"]),i);let n=B(r.id,`${i}.id`);if(!Rg.test(n))throw new Error(`${i}.id must use A1, A2, ...`);return{id:n,source:Fo(r.source,`${i}.source`),text:B(r.text,`${i}.text`),result:D(r.result,["pending","passed","failed","blocked"],`${i}.result`),reason:r.reason===null?null:ce(r.reason,`${i}.reason`)}}function Dg(t,e){let i=`Native builder_handoff.checks[${e}]`,r=z(t,i);return J(r,new Set(["name","result","note"]),i),{name:ce(r.name,`${i}.name`),result:D(r.result,["passed","failed","not-run"],`${i}.result`),note:r.note===null?null:ce(r.note,`${i}.note`)}}function Bg(t){let e="Native builder_handoff",i=z(t,e);J(i,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","submitted_at"]),e);let r=rn(i.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);return it(r,`${e}.addressed_acceptance_ids`),{candidate_id:B(i.candidate_id,`${e}.candidate_id`),identity_provider:B(i.identity_provider,`${e}.identity_provider`),builder_execution_ref:B(i.builder_execution_ref,`${e}.builder_execution_ref`),iteration:_(i.iteration,`${e}.iteration`,1),summary:ce(i.summary,`${e}.summary`),addressed_acceptance_ids:r,checks:ve(i.checks,`${e}.checks`,Dg),checks_truncated:xt(i.checks_truncated,`${e}.checks_truncated`),known_limits:ve(i.known_limits,`${e}.known_limits`,(n,a)=>ce(n,`${e}.known_limits[${a}]`)),known_limits_truncated:xt(i.known_limits_truncated,`${e}.known_limits_truncated`),submitted_at:Ct(i.submitted_at,`${e}.submitted_at`)}}function Lg(t,e){let i=`Native blockers[${e}]`,r=z(t,i);J(r,new Set(["owner","reason","acceptance_ids","resolution_action"]),i);let n=rn(r.acceptance_ids,`${i}.acceptance_ids`);return it(n,`${i}.acceptance_ids`),{owner:D(r.owner,["builder","runtime","verifier","user","external"],`${i}.owner`),reason:ce(r.reason,`${i}.reason`),acceptance_ids:n,resolution_action:D(r.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${i}.resolution_action`)}}function Mg(t,e){let i=`Native verification.checks[${e}]`,r=z(t,i);return J(r,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),i),{id:B(r.id,`${i}.id`),name:ce(r.name,`${i}.name`),argv_display:ve(r.argv_display,`${i}.argv_display`,(n,a)=>ce(n,`${i}.argv_display[${a}]`)),argv_truncated:xt(r.argv_truncated,`${i}.argv_truncated`),cwd_ref:Fo(r.cwd_ref,`${i}.cwd_ref`,!0),status:D(r.status,["passed","failed","interrupted"],`${i}.status`),exit_code:Ig(r.exit_code,`${i}.exit_code`),duration_ms:_(r.duration_ms,`${i}.duration_ms`)}}function Fg(t){let e="Native verification",i=z(t,e);J(i,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let r=ve(i.checks,`${e}.checks`,Mg);it(r.map(a=>a.id),`${e}.checks IDs`);let n=B(i.identity_provider,`${e}.identity_provider`);return{candidate_id:B(i.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:B(i.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:_(i.iteration,`${e}.iteration`,1),attempt:_(i.attempt,`${e}.attempt`,1),assurance:i.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":D(i.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:D(i.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:r,summary:ce(i.summary,`${e}.summary`),risks:ve(i.risks,`${e}.risks`,(a,o)=>ce(a,`${e}.risks[${o}]`)),risks_truncated:xt(i.risks_truncated,`${e}.risks_truncated`),completed_at:Ct(i.completed_at,`${e}.completed_at`)}}function Vg(t,e){let i=`Native history[${e}]`,r=z(t,i);J(r,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),i);let n=rn(r.unresolved_ids,`${i}.unresolved_ids`);return it(n,`${i}.unresolved_ids`),{goal_cycle:_(r.goal_cycle,`${i}.goal_cycle`,1),iteration:_(r.iteration,`${i}.iteration`),attempt:_(r.attempt,`${i}.attempt`),outcome:D(r.outcome,["pass","fail","blocked","execution-error","recovery"],`${i}.outcome`),unresolved_ids:n,summary:ce(r.summary,`${i}.summary`),completed_at:Ct(r.completed_at,`${i}.completed_at`)}}function qg(t){let e="Native history_overflow.outcome_counts",i=z(t,e),r=["pass","fail","blocked","execution-error","recovery"];return J(i,new Set(r),e),{pass:_(i.pass,`${e}.pass`),fail:_(i.fail,`${e}.fail`),blocked:_(i.blocked,`${e}.blocked`),"execution-error":_(i["execution-error"],`${e}.execution-error`),recovery:_(i.recovery,`${e}.recovery`)}}function Wg(t){let e="Native history_overflow",i=z(t,e);J(i,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let r=_(i.dropped_entries,`${e}.dropped_entries`),n=i.first_dropped_at===null?null:Ct(i.first_dropped_at,`${e}.first_dropped_at`),a=i.last_dropped_at===null?null:Ct(i.last_dropped_at,`${e}.last_dropped_at`);if(r===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(r>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=qg(i.outcome_counts);if(Object.values(o).reduce((c,l)=>c+l,0)!==r)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:r,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function zg(t){let e=new Set(t.acceptance.map(i=>i.id));for(let i of t.loop.previous_unresolved_ids)if(!e.has(i))throw new Error(`Native loop references unknown acceptance ID ${i}`);for(let i of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(i))throw new Error(`Native builder handoff references unknown ID ${i}`);for(let i of t.blockers)for(let r of i.acceptance_ids)if(!e.has(r))throw new Error(`Native blocker references unknown ID ${r}`);if(t.builder_handoff&&!(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.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 r=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(!r&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Jg(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 i=t.status==="await-user"?"await-user":t.status==="blocked"?"blocked":t.status==="done"?"done":null;if(i!==null&&t.loop.stage!==i)throw new Error(`Native status ${t.status} requires loop stage ${i}`);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(r=>r.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(t.verification.checks.some(r=>r.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 rt(t){let e=z(t,"Native portable state");if(J(e,_g,"Native portable state"),e.schema!==Pt)throw new Error(`Native portable state schema must be ${Pt}`);let i=B(e.name,"Native state name");if(!xg.test(i))throw new Error("Native state name is invalid");if(e.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let r=ve(e.spec_changes,"Native spec_changes",jg);it(r.map(s=>s.capability),"Native spec change capabilities");let n=ve(e.acceptance,"Native acceptance",Hg);it(n.map(s=>s.id),"Native acceptance IDs");let a=ve(e.history,"Native history",Vg);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Pt,name:i,language:D(e.language,["en","zh-CN"],"Native state language"),phase:D(e.phase,["shape","build","verify","archive"],"Native state phase"),status:D(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:_(e.state_version,"Native state_version",1),brief:"brief.md",...e.children_contract_hash===void 0?{}:{children_contract_hash:Tg(e.children_contract_hash,"Native children contract hash")},spec_changes:r,workspace:$g(e.workspace),loop:Og(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Bg(e.builder_handoff),blockers:ve(e.blockers,"Native blockers",Lg),verification:e.verification===null?null:Fg(e.verification),history:a,history_overflow:Wg(e.history_overflow),verification_result:D(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:D(e.verification_report,["verification.md"],"Native verification_report"),archived:xt(e.archived,"Native archived"),created_at:Ct(e.created_at,"Native created_at")};return zg(o),Jg(o),o}function Gg(t,e){let i=(0,tn.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`${e} is invalid YAML: ${i.errors[0].message}`);return i.toJS({mapAsMap:!1})}async function Ce(t){let e=await Pg.readFile(t,"utf8");return rt(Gg(e,"Native portable state"))}async function nn(t,e,i={}){let r=rt(e);await de(t,(0,tn.stringify)(r),i)}var Zr=new Map;async function Ug(t,e){let i=Zr.get(t)??Promise.resolve(),r,n=new Promise(o=>{r=o}),a=i.then(()=>n);Zr.set(t,a),await i;try{return await e()}finally{r(),Zr.get(t)===a&&Zr.delete(t)}}async function _u(t){return Ug(t.file,async()=>{let e=_(t.expectedStateVersion,"Native expected state version",1),i=rt(t.next);if(i.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let r=await Ce(t.file);if(r.state_version===i.state_version&&JSON.stringify(r)===JSON.stringify(i))return r;if(r.state_version!==e)throw new en(e,r.state_version);return await nn(t.file,i,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await Ce(t.file);if(n.state_version!==e)throw new en(e,n.state_version)}}),i})}function Kg(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function an(t,e=16384){if(typeof t!="string")throw new Error("Native portable text must be a string");if(Kg(e),Buffer.byteLength(t,"utf8")<=e)return{text:t,truncated:!1};let i="",r=0;for(let n of t){let a=Buffer.byteLength(n,"utf8");if(r+a>e)break;i+=n,r+=a}return{text:i,truncated:!0}}var Re="comet.native.v3",ge="comet.native.v2",we="comet.native.v1";var on="comet.native.portable-migration.v1",Xg=new Set(["schema","id","change","fromSchema","status","createdAt"]),Qg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Zg=/^[a-z0-9][a-z0-9-]{7,127}$/u,ew=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),tw=new Set([we,ge,Re]);function iw(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function rw(t,e){let i=t instanceof Date?new Date(t.valueOf()):new Date(t);if(Number.isNaN(i.valueOf()))throw new Error(`${e} must be a valid timestamp`);return i.toISOString()}function nw(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let i=new Date(t);if(Number.isNaN(i.valueOf())||i.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function aw(t){return t.schema===we?bi(t):t.schema===ge?ki(t):Si(t)}function ow(t){return Yg.posix.normalize(t.replaceAll("\\","/"))}function sw(t){return t.spec_changes.map(e=>e.operation==="remove"?{capability:e.capability,operation:"remove",source:null}:{capability:e.capability,operation:e.operation==="replace"?"modify":"create",source:ow(e.source)})}function cw(t){return t==="shape"?"shape":"build"}function lw(t,e){return t==="zh-CN"?e==="shape"?"继续澄清并确认验收项":"重新提交候选实现":e==="shape"?"Continue clarification and confirm acceptance":"Submit a fresh implementation candidate"}function uw(t,e,i){return t==="zh-CN"?`从旧版 ${e} ${i} 状态恢复;旧版 Loop、验证结论和运行记录未继承。`:`Recovered from legacy ${e} ${i} state; prior Loop, verification results, and execution records were not inherited.`}function Tu(t){let e=aw(t.state);Ru(t.acceptance);let i=cw(e.phase),r=i==="shape"?0:1,n=rw(t.migratedAt??`${e.created_at}T00:00:00.000Z`,"Native portable migration time"),a=t.acceptance.map(o=>({id:o.id,source:o.source,text:o.text,result:"pending",reason:null}));return rt({schema:Pt,name:e.name,language:e.language,phase:i,status:"active",state_version:1,brief:"brief.md",spec_changes:sw(e),workspace:t.workspace,loop:{stage:i==="shape"?"shape":"building",goal_cycle:1,iteration:r,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:lw(e.language,i)},acceptance:a,builder_handoff:null,blockers:[],verification:null,history:[{goal_cycle:1,iteration:r,attempt:0,outcome:"recovery",unresolved_ids:a.map(({id:o})=>o),summary:an(uw(e.language,e.schema,e.phase)),completed_at:n}],history_overflow:Lo(),verification_result:"pending",verification_report:null,archived:!1,created_at:`${e.created_at}T00:00:00.000Z`})}function Vo(t){let e=iw(t,"Native portable migration transaction"),i=Object.keys(e).filter(r=>!Xg.has(r));if(i.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${i.join(", ")}`);if(e.schema!==on)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!Zg.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!Qg.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!tw.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!ew.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:on,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:nw(e.createdAt,"Native portable migration transaction createdAt")}}function Iu(t){switch(Vo(t).status){case"prepared":return{action:"commit-portable-yaml",fromStatus:"prepared",nextStatus:"yaml-committed"};case"yaml-committed":return{action:"cleanup-legacy-runtime",fromStatus:"yaml-committed",nextStatus:"legacy-cleanup"};case"legacy-cleanup":return{action:"commit-transaction",fromStatus:"legacy-cleanup",nextStatus:"committed"};case"committed":return{action:"done",fromStatus:"committed",nextStatus:null}}}var ju="comet.native.archive-transaction.v4",$u="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",dw=new RegExp(`^portable-archive-(${$u})\\.json$`,"u"),fw=new RegExp(`^portable-migration-(${$u})\\.json$`,"u"),hw=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,pw=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,mw=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),vw=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),gw=new Set(["capability","operation","source","content"]),Ou=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function Hu(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Du(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`);if(Object.keys(t).length!==e.size)throw new Error(`${i} fields are invalid`)}function ww(t,e){let i=`Native portable Archive spec_changes[${e}]`,r=Hu(t,i);if(Du(r,gw,i),typeof r.capability!="string"||!Ou.test(r.capability))throw new Error(`${i}.capability is invalid`);if(!["create","modify","remove"].includes(String(r.operation)))throw new Error(`${i}.operation is invalid`);let n=r.operation;if(n==="remove"){if(r.source!==null||r.content!==null)throw new Error(`${i} remove requires source and content null`);return{capability:r.capability,operation:n,source:null,content:null}}if(typeof r.source!="string"||r.source.length===0||r.source.includes("\\")||r.source.startsWith("/")||/^[A-Za-z]:/u.test(r.source)||r.source.split("/").some(a=>a==="."||a===".."))throw new Error(`${i}.${n} source is invalid`);if(typeof r.content!="string")throw new Error(`${i}.${n} content is invalid`);return{capability:r.capability,operation:n,source:r.source,content:r.content}}function yw(t){let e=Hu(t,"Native portable Archive transaction");if(Du(e,vw,"Native portable Archive transaction"),e.schema!==ju)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!hw.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!Ou.test(e.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(e.start_state_version)||Number(e.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof e.archive_ref!="string"||!pw.test(e.archive_ref)||!e.archive_ref.endsWith(`-${e.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof e.status!="string"||!mw.has(e.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let i=e.spec_changes.map(ww);if(new Set(i.map(({capability:n})=>n)).size!==i.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>i.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof e.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let r=new Date(e.created_at);if(Number.isNaN(r.valueOf())||r.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:ju,id:e.id,change:e.change,start_state_version:Number(e.start_state_version),archive_ref:e.archive_ref,status:e.status,next_spec_index:Number(e.next_spec_index),spec_changes:i,created_at:e.created_at}}function sn(t){let e=dw.exec(t);if(e)return{kind:"archive",change:e[1]};let i=fw.exec(t);return i?{kind:"migration",change:i[1]}:null}function cn(t,e){let i=`${e.kind==="archive"?"portable-archive":"portable-migration"}-${e.change}.json`,r=sn(i);if(!r||r.kind!==e.kind||r.change!==e.change)throw new Error(`Invalid Native portable transaction change: ${e.change}`);return qo.join(t.transactionsDir,i)}async function Wo(t,e){let i=sn(e);if(!i)return null;let r=await M({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(r.text),a=qo.join(t.transactionsDir,e);if(i.kind==="archive"){let s=yw(n);if(s.change!==i.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:i.change,file:a,journal:s}}let o=Vo(n);if(o.change!==i.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:i.change,file:a,journal:o}}async function Bu(t,e){let i=cn(t,e);try{return await Wo(t,qo.basename(i))}catch(r){if(r.code==="ENOENT")return null;throw r}}function Lu(t){return t.kind==="archive"||t.journal.status!=="committed"}import Ae from"path";import{TextDecoder as Cw}from"util";import{createHash as Nw}from"node:crypto";import{constants as ln,promises as le}from"node:fs";import ue from"node:path";function dn(t,e){let i=ue.relative(t,e);return i===""||!ue.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ue.sep}`)}function bw(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function kw(t,e){return A({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Sw(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function un(t,e){return A({...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 zo(t,e){let i=await le.lstat(t);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await le.realpath(t),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function Ew(t,e,i){let r=ue.resolve(t),n=ue.resolve(e);if(!dn(r,n))throw new Error(`${i} is outside its managed root`);let a=[await zo(r,i)],o=r;for(let s of ue.relative(r,n).split(ue.sep).filter(Boolean)){await nt(a,i),o=ue.join(o,s);let c=await zo(o,i);if(!dn(a[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${o}`);a.push(c)}return await nt(a,i),a}async function nt(t,e){for(let i of t){let r=await le.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!kw(i,r)||await le.realpath(i.path)!==i.realPath)throw new Error(`${e} parent changed during I/O: ${i.path}`)}}async function Pw(t,e,i){let r=[],n=0,a=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let o=e+1-n,{bytesRead:s}=await t.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,n>e)throw new Error(`${i} exceeds ${e} bytes`);r.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(r,n)}async function Rt(t){let e=bw(t.maxBytes),i=ue.resolve(t.file),r=await Ew(t.root,ue.dirname(i),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(f=>zo(ue.resolve(f),t.label)));await t.hooks?.afterParentChainCaptured?.(),await nt(r,t.label);let a=await le.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(a.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let o=Sw(a),s=await le.realpath(i);if(!dn(r[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(f=>dn(f.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?ln.O_RDONLY:ln.O_RDONLY|ln.O_NOFOLLOW|ln.O_NONBLOCK,l=await le.open(i,c);try{let f=await l.stat();await t.hooks?.afterOpen?.();let[d,u]=await Promise.all([le.lstat(i),le.realpath(i)]);if(await nt(r,t.label),await nt(n,t.label),!f.isFile()||!d.isFile()||d.isSymbolicLink()||u!==s||!un(o,f)||!un(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let p=await Pw(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),le.lstat(i),le.realpath(i)]);if(await nt(r,t.label),await nt(n,t.label),!h.isFile()||h.isSymbolicLink()||m!==s||!un(o,v)||!un(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:p,hash:Nw("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}var Rw=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),Aw=new Set(["id","type","source","target","staged","backup"]),_w=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Tw=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var Vu=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var Iw=256*1024,XS=1024*1024,QS=16*1024;var ZS=64*1024*1024;var jw=new Cw("utf-8",{fatal:!0});function hn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function pn(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function qu(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function Jo(t,e){if(typeof t!="string"||t.length===0||Ae.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function fn(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function Mu(t,e){if(Jo(t,e),t.includes("\\")||t!==Ae.posix.normalize(t)||t.split("/").includes(".")||t.endsWith("/")||Buffer.byteLength(t,"utf8")>1024)throw new Error(`${e} must be a normalized Native-relative ref`)}function $w(t,e){let i=hn(t,`transaction operations[${e}]`);if(pn(i,Aw,`transaction operations[${e}]`),typeof i.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.id))throw new Error(`transaction operations[${e}].id is invalid`);if(i.type!=="write"&&i.type!=="remove"&&i.type!=="move")throw new Error(`transaction operation ${i.id} has an invalid type`);Jo(i.target,`transaction operation ${i.id} target`);for(let r of["source","staged","backup"])i[r]!==void 0&&Jo(i[r],`transaction operation ${i.id} ${r}`);if(i.type==="write"){if(i.staged===void 0||i.source!==void 0)throw new Error(`write operation ${i.id} requires staged and forbids source`)}else if(i.type==="remove"){if(i.source!==void 0||i.staged!==void 0)throw new Error(`remove operation ${i.id} forbids source and staged`)}else if(i.source===void 0||i.staged!==void 0||i.backup!==void 0)throw new Error(`move operation ${i.id} requires source and forbids staged and backup`);return i}function Wu(t){let e=hn(t,"Native Archive transaction journal");if(pn(e,_w,"Native Archive transaction journal"),e.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native Archive transaction id is invalid");if(e.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof e.status!="string"||!Vu.has(e.status))throw new Error("Native Archive transaction status is invalid");if(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change))throw new Error("Native Archive transaction change name is invalid");if(!qu(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(fn(e.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(e.operations)||e.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let i=e.operations.map((s,c)=>{let l=hn(s,`Archive transaction operations[${c}]`);if(pn(l,Tw,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);Mu(l.target,`Archive transaction operation ${l.id} target`);for(let f of["source","staged","backup"])l[f]!==void 0&&Mu(l[f],`Archive transaction operation ${l.id} ${f}`);if(l.expectedTargetHash!==null&&fn(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(fn(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);fn(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),r=i.map(s=>s.id);if(new Set(r).size!==r.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=i.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${e.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${e.change}$`,"u").test(a[0].target)||i.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of i.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:i}}function Ow(t){let e=hn(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return Wu(e);if(pn(e,Rw,"Native transaction journal"),e.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native transaction id is invalid");if(e.kind!=="archive"&&e.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof e.status!="string"||!Vu.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!Ae.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!Ae.isAbsolute(e.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(e.change!==void 0&&(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change)))throw new Error("Native transaction change name is invalid");if(!qu(e.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(e.operations))throw new Error("Native transaction operations must be an array");let i=e.operations.map($w),r=i.map(n=>n.id);if(new Set(r).size!==r.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:e.id,kind:e.kind,status:e.status,projectRoot:e.projectRoot,nativeRoot:e.nativeRoot,...typeof e.change=="string"?{change:e.change}:{},createdAt:e.createdAt,operations:i}}function Hw(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return Ae.join(t.transactionsDir,e)}function zu(t,e){let i=Hw(t,e);return{directory:i,journal:Ae.join(i,"transaction.json"),events:Ae.join(i,"events.jsonl"),staged:Ae.join(i,"staged"),backups:Ae.join(i,"backups")}}async function Uo(t,e){let i=zu(t,e);return await Promise.all(Object.values(i).map(r=>T(t.runtimeDir,r))),i}async function Ko(t,e,i={}){let r=await Uo(t,e),n=await Rt({root:t.runtimeDir,file:r.journal,maxBytes:Iw,label:`Native transaction journal ${e}`,hooks:i.hooks}),a=JSON.parse(jw.decode(n.bytes)),o=Ow(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}async function Lw(t,e,i){let r;try{r=await Dw.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await Ko(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of r)if(sn(n.name))try{let a=await Wo(t,n.name);if(!a||i?.kind===a.kind&&i.change===a.change)continue;if(Lu(a))return!0}catch{return!0}return!1}async function Mw(t,e){let i=Date.now()+5e3,r=Bw.join(t.locksDir,"root-move.lock");for(;;)try{return await Xr(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Eu(r);if(o.status==="missing")continue;if(o.status!=="active"||Date.now()>=i)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function ee(t,e,i,r){let n=await Mw(t,e);try{if(await Kr(t.projectRoot),await Lw(t,r?.allowedTransactionId,r?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await i()}finally{await Qr(n)}}import{createHash as Fw}from"crypto";function te(t){return Fw("sha256").update(t).digest("hex")}var NE={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024};var bE=8*1024*1024;var kE=64*1024,SE=64*1024;var EE={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},PE={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};var xE=(1n<<256n)-1n;var Uw=jt(wt(),1);var VE=4*1024*1024;var Kw=null;function Yw(t,e){let i=t;for(let r of e)i+="\0"+(typeof r=="string"?r:JSON.stringify(r));return i}function Ju(t,e){return(...i)=>{let r=Kw;if(r===null)return e(...i);let n=Yw(`async:${t}`,i),a=r.entries.get(n);if(a)return a.value;let o=e(...i).catch(s=>{throw r.entries.delete(n),s});return r.entries.set(n,{value:o}),o}}var GE=Ju("hookWritePolicy",async t=>(await No(t))?.hook??{allow_paths:[]});var VP=256*1024;var tx={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};import At from"node:path";var Ei=/^[a-f0-9]{64}$/u,Uu=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,Zw=16*1024,gx=process.platform;function ey(t,e){let i=At.relative(t,e);return At.isAbsolute(i)||i===".."||i.startsWith(`..${At.sep}`)?null:i.replaceAll("\\","/")||"."}function Ku(t){return Array.from(t).some(e=>{let i=e.codePointAt(0)??0;return i<=31||i===127})}function Yu(t,e){if(t.length===0||Ku(t)||t.includes("\\")||At.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let i=At.posix.normalize(t);if(i!==t||i===".."||i.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return i}function ty(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 Yo(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||Ku(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function iy(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Yo(t.changeBranch,"Native workspace change branch"),Yo(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 ry(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,i=new Set(["provider","baseCommit","targetBranch","targetCommit"]),r=Object.keys(e).filter(n=>!i.has(n));if(r.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${r.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!Uu.test(e.baseCommit)||typeof e.targetCommit!="string"||!Uu.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");Yo(e.targetBranch,"Native workspace Git target branch")}function ny(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(e).filter(o=>!i.has(o));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.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"||!Ei.test(String(e.projectRootId))||!Ei.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");ty(e.capturedAt),Yu(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&&!Ei.test(String(e.projectRootPathId))||a&&!Ei.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!Ei.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&ry(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(iy(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 ay(t,e){return At.join(pe(t,e),"workspace.json")}function oy(t,e){let i=ay(t,e),r=me(t,i),n=ey(r,i);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:r,ref:Yu(n,"Native workspace file ref")}}async function sy(t,e){try{let i=oy(t,e),r=await M({root:i.root,ref:i.ref,maxBytes:Zw});return JSON.parse(r.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Pi(t,e){let i=await sy(t,e);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(ny(i),i)}var Zu=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],ly=new Set(Zu),ed=new Set([...Zu,"minimum_runtime_version","revision"]),uy=new Set([...ed,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),dy=new Set(["capability","operation","source","base_hash"]),fy=new Set(["shape","build","verify","archive"]),hy=new Set(["implicit","confirmed"]),py=new Set(["pending","pass","fail"]),at="comet-state.yaml",Qo=/^[a-f0-9]{64}$/u,td=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,my=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Zo=class extends Error{constructor(i,r){super(`Native change ${i} uses ${r}; run comet native doctor ${i} --repair before mutating it`);this.change=i;this.schema=r;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},Tt=class extends Error{constructor(i,r){super(i!==Re||r===null?`Unsupported Native change schema ${i} for runtime protocol ${3}`:`Native change ${i} requires runtime protocol ${r}; current protocol is ${3}`);this.schema=i;this.minimumRuntimeVersion=r;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"},mn=class extends Error{constructor(i,r,n){super(`Native change ${i} revision conflict: expected ${r}, actual ${n}`);this.change=i;this.expectedRevision=r;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},xi=class extends Error{constructor(i,r){super(`Native working directory already contains active change${r.length===1?"":"s"} ${r.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=i;this.activeChanges=r;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},vn=class extends Error{constructor(i,r,n,a,o,s=null,c=null){super(`Native change ${i} baseline is incomplete (${r} omitted entr${r===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=i;this.omittedCount=r;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"},Vx=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
150
+ `);function Ri(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function id(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function ts(t){if(!td.test(t))throw new Error(`Invalid Native change name: ${t}`)}function vy(t){if(!td.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function rd(t,e){if(t.length===0||_t.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function gy(t,e){let i=Ri(t,`spec_changes[${e}]`);if(id(i,dy,`spec_changes[${e}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(vy(i.capability),i.operation!=="create"&&i.operation!=="replace"&&i.operation!=="remove")throw new Error(`Invalid spec operation for ${i.capability}`);let r=i.source,n=i.base_hash;if(r!==void 0&&typeof r!="string")throw new Error(`Spec source for ${i.capability} must be a string`);if(typeof r=="string"&&rd(r,`Spec source for ${i.capability}`),i.operation==="create"){if(!r)throw new Error(`Create spec ${i.capability} requires source`);if(n!==null)throw new Error(`Create spec ${i.capability} requires null base_hash`)}else if(i.operation==="replace"){if(!r)throw new Error(`Replace spec ${i.capability} requires source`);if(typeof n!="string"||!Qo.test(n))throw new Error(`Replace spec ${i.capability} requires a SHA-256 base_hash`)}else{if(r!==void 0)throw new Error(`Remove spec ${i.capability} forbids source`);if(typeof n!="string"||!Qo.test(n))throw new Error(`Remove spec ${i.capability} requires a SHA-256 base_hash`)}return{capability:i.capability,operation:i.operation,...typeof r=="string"?{source:r}:{},base_hash:n}}function wy(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 is(t,e){if(id(t,e,at),typeof t.name!="string")throw new Error("Native change name is required");if(ts(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"||!fy.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&&!hy.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 i=t.spec_changes.map(gy),r=i.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(r.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(r)].join(", ")}`);if(typeof t.verification_result!="string"||!py.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"&&rd(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!wy(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:i,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function bi(t){let e=Ri(t,at);if(e.schema!==we)throw new Error(`Expected ${we}`);return{schema:we,...is(e,ly)}}function Ci(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Xo(t,e,i){if(t===null)return null;let r=typeof t=="string"?my.exec(t):null;if(!r||r[1]!==i)throw new Error(`${e} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return t}function yy(t){if(t==null)return null;if(typeof t!="string"||!Qo.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function Ny(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 ki(t){let e=Ri(t,at);if(e.schema!==ge)throw new Error(`Expected ${ge}`);if(Ci(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${ge} minimum_runtime_version must be 2`);return{schema:ge,minimum_runtime_version:2,revision:Ci(e.revision,"Native v2 revision"),...is(e,ed)}}function Si(t){let e=Ri(t,at);if(e.schema!==Re){if(e.schema===we||e.schema===ge){let o=e.schema===we?bi(e):ki(e);throw new Zo(o.name,o.schema)}throw new Tt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let i=Ci(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new Tt(e.schema,i);if(i!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let r=Ci(e.revision,"Native revision"),n=is(e,uy),a=yy(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Re,minimum_runtime_version:3,revision:r,verification_protocol:Ny(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:Xo(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Xo(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Xo(e.partial_allowance,"Native partial_allowance","allowances")}}function by(t){let e=Ri(t,at);if(e.schema===we){let n=bi(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Re}`}}if(e.schema===ge){let n=ki(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Re}`}}if(e.schema!==Re){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 Tt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let i=Ci(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:i,state:null,message:new Tt(e.schema,i).message};let r=Si(e);return{status:"current",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r}}function ye(t,e){ts(e);let i=_t.join(t.changesDir,e);if(!F(t.changesDir,i))throw new Error("Native change path escaped");return i}var ky=256*1024;async function Sy(t,e=_t.dirname(t)){let i=_t.relative(e,t).split(_t.sep).join("/"),r=await M({root:e,ref:i,maxBytes:ky}),n=(0,es.parseDocument)(r.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 nd(t,e){let i=_t.join(ye(t,e),at);await T(t.nativeRoot,i);let r=by(await Sy(i,t.nativeRoot));if(r.state&&r.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return r}import{promises as sd}from"node:fs";import Sn from"node:path";var Py=jt(wt(),1);var Wx=8*1024*1024;var eC=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");import{promises as Ty}from"node:fs";import _i from"node:path";function gn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function wn(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Ne(t,e,i=!1){if(typeof t!="string"||!i&&t.length===0)throw new Error(`${e} must be ${i?"a string":"a non-empty string"}`);return t}function ad(t,e){return t===null?null:Ne(t,e)}function Nn(t,e,i=0){if(!Number.isSafeInteger(t)||t<i)throw new Error(`${e} must be a safe integer greater than or equal to ${i}`);return t}function Iy(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 jy(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function yn(t,e,i){if(typeof t!="string"||!e.includes(t))throw new Error(`${i} must be one of: ${e.join(", ")}`);return t}function rs(t,e){if(t===null)return null;let i=Ne(t,e);if(Number.isNaN(Date.parse(i)))throw new Error(`${e} must be an ISO timestamp`);return i}function ns(t,e){let i=Ne(t,e);if(!_i.isAbsolute(i))throw new Error(`${e} must be absolute`);return _i.resolve(i)}function $y(t,e){let i=`Native local checks[${e}]`,r=gn(t,i);if(wn(r,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),i),!Array.isArray(r.argv)||r.argv.length===0)throw new Error(`${i}.argv must be a non-empty array`);let n=r.argv.map((l,f)=>Ne(l,`${i}.argv[${f}]`,!0)),a=yn(r.status,["planned","running","passed","failed","interrupted"],`${i}.status`),o=rs(r.startedAt,`${i}.startedAt`),s=rs(r.completedAt,`${i}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${i} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${i} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${i} completed check requires startedAt and completedAt`);let c=Nn(r.timeoutMs,`${i}.timeoutMs`);if(c<1)throw new Error(`${i}.timeoutMs must be positive`);return{id:Ne(r.id,`${i}.id`),name:Ne(r.name,`${i}.name`),operationId:Ne(r.operationId,`${i}.operationId`),status:a,repeatable:jy(r.repeatable,`${i}.repeatable`),timeoutMs:c,executionCount:Nn(r.executionCount,`${i}.executionCount`),argv:n,cwd:ns(r.cwd,`${i}.cwd`),exitCode:Iy(r.exitCode,`${i}.exitCode`),startedAt:o,completedAt:s,log:Ne(r.log,`${i}.log`)}}function od(t){let e="Native local execution state",i=gn(t,e);if(wn(i,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),e),i.schema!==Ni)throw new Error(`Native local execution schema must be ${Ni}`);let r=gn(i.workspace,"Native local workspace");wn(r,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(i.execution!==null){let o=gn(i.execution,"Native local execution");wn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=rs(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Ne(o.operationId,"Native local execution.operationId"),stage:yn(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:yn(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:ad(o.executionId,"Native local execution.executionId"),status:yn(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Nn(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(i.checks))throw new Error("Native local checks must be an array");let a=i.checks.map($y);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:Ni,change:Ne(i.change,"Native local change"),basedOnStateVersion:Nn(i.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:ns(r.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:ns(r.worktreeRoot,"Native local workspace.worktreeRoot"),branch:ad(r.branch,"Native local workspace.branch")},execution:n,checks:a}}function bn(t){return od({schema:Ni,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,workspace:{projectRoot:_i.resolve(t.projectRoot),worktreeRoot:_i.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null},execution:null,checks:[]})}async function kn(t,e,i={}){let r=od(e);await Ty.mkdir(_i.dirname(t),{recursive:!0}),await Y(t,r,i)}var cd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Oy="comet-state.yaml",Hy="state.json";function ld(t,e){if(!cd.test(e))throw new Error(`Invalid Native change name: ${e}`);let i=Sn.join(t.changesDir,e);if(!F(t.changesDir,i))throw new Error("Native change path escaped");return i}function ze(t,e){return Sn.join(ld(t,e),Oy)}function as(t,e){return Sn.join(tt(t,e),Hy)}async function Ti(t,e){try{let i=await sd.readFile(ze(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(i)}catch(i){if(i.code==="ENOENT")return!1;throw i}}function Dy(t){return ke(t).currentBranch}async function ud(t,e){return Ce(ze(t,e))}async function By(t){let e=await _u({file:ze(t.paths,t.previous.name),expectedStateVersion:t.previous.state_version,next:t.next,containedRoot:t.paths.nativeRoot});if(e.verification===null&&e.verification_report===null){let i=Sn.join(ld(t.paths,e.name),"verification.md");await T(t.paths.nativeRoot,i),await sd.rm(i,{force:!0})}return e}async function dd(t){if(!cd.test(t.capability))throw new Error(`Invalid Native capability: ${t.capability}`);return ee(t.paths,`remove portable spec ${t.capability}`,async()=>{let e=await ud(t.paths,t.name);if(e.archived)throw new Error(`Native change ${e.name} is already archived`);let i=e.spec_changes.filter(({capability:a})=>a!==t.capability),r={...e,phase:"shape",status:"active",state_version:e.state_version+1,spec_changes:[...i,{capability:t.capability,operation:"remove",source:null}].sort((a,o)=>a.capability.localeCompare(o.capability,"en")),acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,history:[],history_overflow:{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}},loop:{stage:"shape",goal_cycle:e.loop.goal_cycle+(e.phase==="shape"?0: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:"confirm-shape"}};delete r.children_contract_hash;let n=await By({paths:t.paths,previous:e,next:r});return await kn(as(t.paths,e.name),bn({portableState:n,projectRoot:t.paths.projectRoot,branch:Dy(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n})}var Fy=["evidence.md","verification.md","repair.md","archive.md","checkpoint.md"];async function Vy(t,e){let i=await Bu(t,{kind:"migration",change:e});return i?.kind==="migration"?i.journal:null}async function fd(t,e){await Ii.mkdir(t.transactionsDir,{recursive:!0}),await Y(cn(t,{kind:"migration",change:e.change}),e,{containedRoot:t.runtimeDir})}async function hd(t,e){await Promise.all([Ii.rm(tt(t,e),{recursive:!0,force:!0}),Ii.rm(Po(t,e),{recursive:!0,force:!0}),...Fy.map(i=>Ii.rm(My.join(ye(t,e),i),{force:!0}))])}async function pd(t,e){await kn(as(t,e.name),bn({portableState:e,projectRoot:t.projectRoot}),{containedRoot:t.runtimeDir})}async function md(t,e){try{let i=await Pi(t,e);if(i?.schema==="comet.native.workspace.v3")return{isolation:i.isolation,change_branch:i.changeBranch,target_branch:i.targetBranch,finish:i.finish}}catch{}return{isolation:"current",change_branch:null,target_branch:null,finish:null}}function vd(t,e){if(e.isolation==="current"&&e.change_branch===null)return;let i=ke(t.projectRoot);if(!i.isGitWorktree)throw new Error("Native legacy migration requires its bound Git branch or worktree");if(i.currentBranch!==e.change_branch)throw new Error(`Native legacy migration expected branch ${e.change_branch??"(missing)"}, current branch is ${i.currentBranch??"(detached)"}`);if(e.isolation==="worktree"&&!i.isSecondaryWorktree)throw new Error("Native legacy migration requires its bound linked worktree")}async function qy(t){let e=ye(t.paths,t.state.name),i=await M({root:e,ref:t.state.brief,maxBytes:null,includeHash:!1}),r=[];for(let n of t.state.spec_changes){if(n.operation==="remove"||!n.source)continue;let a=await M({root:e,ref:n.source,maxBytes:null,includeHash:!1});r.push({capability:n.capability,source:a.ref,markdown:a.text})}try{return Bo({briefMarkdown:i.text,specs:r})}catch(n){if(t.state.phase==="shape"&&n.message.includes("at least one acceptance"))return[];throw n}}async function gd(t,e){let i=await nd(t,e);if(!i.state)throw new Error(`Native legacy change ${e} is unreadable`);return i.state}async function wd(t){return ee(t.paths,`migrate ${t.name} to portable Native`,async()=>{let e=await Vy(t.paths,t.name),i=await Ti(t.paths,t.name)?await Ce(ze(t.paths,t.name)):null;if(!e&&i)return await hd(t.paths,t.name),await pd(t.paths,i),i;let r=null,n=null;for(e||(r=await gd(t.paths,t.name),n=await md(t.paths,t.name),vd(t.paths,n),e={schema:on,id:Ly(),change:r.name,fromSchema:r.schema,status:"prepared",createdAt:(t.now??new Date).toISOString()},await fd(t.paths,e));;){let a=Iu(e);if(a.action==="done")break;a.action==="commit-portable-yaml"?i||(r??=await gd(t.paths,t.name),n??=await md(t.paths,t.name),vd(t.paths,n),i=Tu({state:r,acceptance:await qy({paths:t.paths,state:r}),workspace:n,migratedAt:t.now}),await nn(ze(t.paths,t.name),i,{containedRoot:t.paths.nativeRoot})):a.action==="cleanup-legacy-runtime"?await hd(t.paths,t.name):a.action==="commit-transaction"&&(i??=await Ce(ze(t.paths,t.name)),await pd(t.paths,i)),e={...e,status:a.nextStatus},await fd(t.paths,e)}return await Ii.rm(cn(t.paths,{kind:"migration",change:t.name}),{force:!0}),i??Ce(ze(t.paths,t.name))},{allowedPortableTransaction:{kind:"migration",change:t.name}})}import cs from"path";var zy=["Outcome","Scope","Non-goals","Acceptance examples"],QR=[...zy,"Constraints and invariants","Decisions","Open questions","Verification expectations"];var Jy=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});var yd=1024*1024;var bd="scoped-text-safety",Gy=1,Uy=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var Ky="comet.native.checker-policy.v1";var pA=K(Ky,{policy:bd,version:Gy,limits:Uy,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var Yy=["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"],mA=new Set(Yy);var Zy=yd,IA=3*Zy;var kd={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:[]},tN=te("comet-native-runtime:v3:scope-reopen"),a_=[{skillVersion:"3",skillHash:te("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:te("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:te("comet-native-runtime:v1")}];var Ed=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],L_=new Set(Ed),cN=new Set([...Ed,"minimum_runtime_version","revision"]),M_=new Set([...cN,"operation"]),F_=512*1024,lN=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),V_=new Set([...lN,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var J_={maxAcceptanceCriteria:yi.maxCriteria};var X_={maxSpecs:64,maxFileBytes:Di,maxTotalBytes:4*1024*1024};import{execFile as wN}from"node:child_process";import{promisify as yN}from"node:util";var sT={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var RT=512*1024;var ji=class extends Error{recovery;constructor(e,i){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=i}};var XT=64*1024;var QT=3600*1e3;var ZT=yN(wN);var En=class extends Error{details;constructor(e){let i=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(r=>`${r.ref}${r.acceptanceId?`[${r.acceptanceId}]`:""} -> ${r.mismatches.join("; ")}`).join(" | ")}`;super(i),this.name="NativeVerificationReceiptBindingError",this.details=e}};var BI={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var UI=16*1024*1024,KI=256*1024,YI=16*1024;var tj=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var nj=16*1024;var vj=16*1024;var o$=16*1024*1024,Pn=class extends Error{constructor(i,r,n,a){super(`Canonical spec conflict for ${i}: expected ${r??"(missing)"}, actual ${n??"(missing)"}`);this.capability=i;this.expectedHash=r;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},xn=class extends Error{constructor(i,r=i.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${i.findingCodes.join(", ")}`){super(r);this.preflight=i;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};var Cn=class extends Error{constructor(i,r,n){super(i,n);this.preparation=r;this.name="NativeWorkspacePreparationError"}preparation};var Cd=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--help Show help without requiring an initialized project."],ss=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",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 remove Record a complete capability removal intent.","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:Cd,output:"Human-readable text by default; use --json for a structured command envelope.",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] [--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.","--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, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","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 remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],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."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},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.","--details Include acceptance, Spec, workspace, and report details."],output:"A v2 status page or one portable Loop projection with local execution availability and continuation.runnerAction; parent changes also expose children 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> [--confirmed|--return-to-build|--retry-verifier|--resolve-verifier-blocker]
151
+ comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, 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 Shape, a completed skill-coordinated pass, or an explicitly degraded verifier-unavailable fallback before Archive.","--return-to-build Return Verify or Archive to Build after invalidation or user choice.","--retry-verifier Retry a blocked Verifier execution when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," 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."],output:"The portable state, explicit skill-coordinated label, Runtime-owned check results, complete verifierDispatch, bounded request-check response, continuation.runnerAction, and machine-readable continuation.inputOptions. 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','comet native next session-timeout --summary "Implementation changed" --return-to-build','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]
152
+ 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 Inspect readiness without rerunning verification.","--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 plus continuation, or the completed Archive transaction and workspace finish result; 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 os(t,e){return`${t}:
153
153
  ${e.map(i=>` ${i}`).join(`
154
- `)}`}function vN(t){let e=t.filter(r=>r!=="--help");if(e.length===0)return"";let i=e.slice(0,2).join(" ");return os[i]||e.length>1&&os[e[0]]?.subcommands?i:e[0]}function gN(t=[]){let e=vN(t),i=os[e];if(!i)throw new Error(`Unknown Native help topic: ${e}`);let r=[`Usage: ${i.usage}`,"",i.purpose];i.subcommands&&r.push("",as("Commands",i.subcommands));let n=e===""?i.options:[...i.options??[],...Ed];return n&&n.length>0&&r.push("",as("Options",n)),r.push("",`Output:
155
- ${i.output}`),i.examples&&r.push("",as("Examples",i.examples)),e===""&&r.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${r.join(`
154
+ `)}`}function PN(t){let e=t.filter(r=>r!=="--help");if(e.length===0)return"";let i=e.slice(0,2).join(" ");return ss[i]||e.length>1&&ss[e[0]]?.subcommands?i:e[0]}function xN(t=[]){let e=PN(t),i=ss[e];if(!i)throw new Error(`Unknown Native help topic: ${e}`);let r=[`Usage: ${i.usage}`,"",i.purpose];i.subcommands&&r.push("",os("Commands",i.subcommands));let n=e===""?i.options:[...i.options??[],...Cd];return n&&n.length>0&&r.push("",os("Options",n)),r.push("",`Output:
155
+ ${i.output}`),i.examples&&r.push("",os("Examples",i.examples)),e===""&&r.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${r.join(`
156
156
  `)}
157
- `}}var wN=gN().usage;var Qj=10*1024*1024,be=class extends Error{};function xd(t,e){let i=t.flatMap((r,n)=>r===e?[n]:[]);if(i.length>1)throw new be(`${e} may only be provided once`);return i.length===0?!1:(t.splice(i[0],1),!0)}function Rd(t,e){let i=t.flatMap((a,o)=>a===e?[o]:[]);if(i.length>1)throw new be(`${e} may only be provided once`);if(i.length===0)return;let r=i[0],n=t[r+1];if(n===void 0||n.startsWith("--"))throw new be(`${e} requires a value`);return t.splice(r,2),n}function Cd(t){if(t.length>0)throw new be(`Unexpected argument: ${t[0]}`)}function xn(t,e){let i=t.shift();if(!i||i.startsWith("--"))throw new be(`${e} is required`);return i}function Pd(t,e){let i=ss.normalize(t),r=ss.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function yN(t){let e=ss.resolve(t),i=ke(process.cwd());if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return e;let r=ke(e);return!r.isGitWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null||!Pd(i.primaryWorktreeRoot,r.primaryWorktreeRoot)||Pd(i.currentWorktreeRoot,r.currentWorktreeRoot)?e:i.currentWorktreeRoot}async function Ad(t){return t?yN(t):Wr(process.cwd())}async function _d(t){let e=await du({startPath:t,allowMissingConfig:!1});return{config:e.config,paths:e.paths}}function Td(t,e,i){return{command:t,exitCode:0,data:e,text:i??JSON.stringify(e,null,2)+`
158
- `}}function Id(t,e){if(e instanceof be)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof Sn)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 En)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof hn)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 Ei)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 Pn)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof pn)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 kn)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof Ti)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let i=e.code;if(i&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(i))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let r=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:r?73:65,error:{code:r?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function jd(t,e){return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
159
- `}:t.error?{exitCode:t.exitCode,stderr:t.error.message}:{exitCode:t.exitCode,stdout:t.text}}async function $d(t,e){let i=xn(t,"spec subcommand");if(i!=="remove")throw new be(`Unknown spec command: ${i}`);let r=xn(t,"change name"),n=xn(t,"capability");Cd(t);let{paths:a}=await _d(e);await Ai(a,r)||await md({paths:a,name:r});let o=await cd({paths:a,name:r,capability:n});return Td("spec remove",{...o,continuation:us(o)},`Marked Native capability ${n} for removal in ${r}
160
- `)}function NN(t){return{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
161
- `}}async function Od(t,e,i=process.argv.slice(2)){let r=i.indexOf("--"),n=r<0?[...i]:i.slice(0,r),a=r<0?[]:i.slice(r),o=n.includes("--json"),s,c;try{xd(n,"--json"),s=Rd(n,"--project-root");let f=[...n,...a],d=await Ad(s);c=await e(f,d)}catch(f){c=Id(t,f)}let l=o?NN(c):jd(c,!1);return l.stdout&&process.stdout.write(l.stdout),l.stderr&&process.stderr.write(l.stderr+(l.stderr.endsWith(`
157
+ `}}var CN=xN().usage;var A$=10*1024*1024,be=class extends Error{};function Ad(t,e){let i=t.flatMap((r,n)=>r===e?[n]:[]);if(i.length>1)throw new be(`${e} may only be provided once`);return i.length===0?!1:(t.splice(i[0],1),!0)}function _d(t,e){let i=t.flatMap((a,o)=>a===e?[o]:[]);if(i.length>1)throw new be(`${e} may only be provided once`);if(i.length===0)return;let r=i[0],n=t[r+1];if(n===void 0||n.startsWith("--"))throw new be(`${e} requires a value`);return t.splice(r,2),n}function Td(t){if(t.length>0)throw new be(`Unexpected argument: ${t[0]}`)}function Rn(t,e){let i=t.shift();if(!i||i.startsWith("--"))throw new be(`${e} is required`);return i}function Rd(t,e){let i=cs.normalize(t),r=cs.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function RN(t){let e=cs.resolve(t),i=ke(process.cwd());if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return e;let r=ke(e);return!r.isGitWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null||!Rd(i.primaryWorktreeRoot,r.primaryWorktreeRoot)||Rd(i.currentWorktreeRoot,r.currentWorktreeRoot)?e:i.currentWorktreeRoot}async function Id(t){return t?RN(t):Gr(process.cwd())}async function jd(t){let e=await fu({startPath:t,allowMissingConfig:!1});return{config:e.config,paths:e.paths}}function $d(t,e,i){return{command:t,exitCode:0,data:e,text:i??JSON.stringify(e,null,2)+`
158
+ `}}function Od(t,e){if(e instanceof be)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof Pn)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 xn)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof mn)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 xi)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 Cn)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof vn)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 En)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof ji)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let i=e.code;if(i&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(i))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let r=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:r?73:65,error:{code:r?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function Hd(t,e){return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
159
+ `}:t.error?{exitCode:t.exitCode,stderr:t.error.message}:{exitCode:t.exitCode,stdout:t.text}}async function Dd(t,e){let i=Rn(t,"spec subcommand");if(i!=="remove")throw new be(`Unknown spec command: ${i}`);let r=Rn(t,"change name"),n=Rn(t,"capability");Td(t);let{paths:a}=await jd(e);await Ti(a,r)||await wd({paths:a,name:r});let o=await dd({paths:a,name:r,capability:n});return $d("spec remove",{...o,continuation:ds(o)},`Marked Native capability ${n} for removal in ${r}
160
+ `)}function AN(t){return{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
161
+ `}}async function Bd(t,e,i=process.argv.slice(2)){let r=i.indexOf("--"),n=r<0?[...i]:i.slice(0,r),a=r<0?[]:i.slice(r),o=n.includes("--json"),s,c;try{Ad(n,"--json"),s=_d(n,"--project-root");let f=[...n,...a],d=await Id(s);c=await e(f,d)}catch(f){c=Od(t,f)}let l=o?AN(c):Hd(c,!1);return l.stdout&&process.stdout.write(l.stdout),l.stderr&&process.stderr.write(l.stderr+(l.stderr.endsWith(`
162
162
  `)?"":`
163
- `)),l.exitCode}process.exitCode=await Od("spec",$d);
163
+ `)),l.exitCode}process.exitCode=await Bd("spec",Dd);