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

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 (446) hide show
  1. package/README.md +66 -26
  2. package/assets/manifest.json +4 -1
  3. package/assets/skills/comet/scripts/comet-archive.mjs +120 -120
  4. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +79 -79
  5. package/assets/skills/comet/scripts/comet-guard.mjs +134 -134
  6. package/assets/skills/comet/scripts/comet-handoff.mjs +106 -106
  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-intent.mjs +6 -6
  10. package/assets/skills/comet/scripts/comet-resume-probe.mjs +78 -78
  11. package/assets/skills/comet/scripts/comet-runtime.mjs +194 -193
  12. package/assets/skills/comet/scripts/comet-state.mjs +117 -117
  13. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +96 -96
  14. package/assets/skills/comet-build/SKILL.md +36 -62
  15. package/assets/skills/comet-classic/SKILL.md +14 -8
  16. package/assets/skills/comet-classic/reference/comet-yaml-fields.md +1 -1
  17. package/assets/skills/comet-classic/reference/scripts.md +3 -1
  18. package/assets/skills/comet-classic/reference/workspace.md +23 -0
  19. package/assets/skills/comet-design/SKILL.md +2 -2
  20. package/assets/skills/comet-native/SKILL.md +18 -15
  21. package/assets/skills/comet-native/reference/artifacts.md +5 -4
  22. package/assets/skills/comet-native/reference/clarification.md +1 -1
  23. package/assets/skills/comet-native/reference/commands.md +4 -4
  24. package/assets/skills/comet-native/reference/recovery.md +1 -1
  25. package/assets/skills/comet-native/reference/workspace.md +4 -4
  26. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +116 -115
  27. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +148 -148
  28. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +100 -100
  29. package/assets/skills/comet-native/scripts/comet-native-init.mjs +118 -118
  30. package/assets/skills/comet-native/scripts/comet-native-new.mjs +118 -118
  31. package/assets/skills/comet-native/scripts/comet-native-next.mjs +121 -121
  32. package/assets/skills/comet-native/scripts/comet-native-root.mjs +108 -108
  33. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +157 -156
  34. package/assets/skills/comet-native/scripts/comet-native-select.mjs +133 -133
  35. package/assets/skills/comet-native/scripts/comet-native-show.mjs +109 -109
  36. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +89 -89
  37. package/assets/skills/comet-native/scripts/comet-native-status.mjs +109 -109
  38. package/assets/skills/comet-open/SKILL.md +24 -5
  39. package/assets/skills/comet-review/SKILL.md +121 -0
  40. package/assets/skills/comet-review/agents/openai.yaml +5 -0
  41. package/assets/skills-zh/comet-build/SKILL.md +36 -62
  42. package/assets/skills-zh/comet-classic/SKILL.md +14 -8
  43. package/assets/skills-zh/comet-classic/reference/comet-yaml-fields.md +1 -1
  44. package/assets/skills-zh/comet-classic/reference/scripts.md +3 -1
  45. package/assets/skills-zh/comet-classic/reference/workspace.md +23 -0
  46. package/assets/skills-zh/comet-design/SKILL.md +2 -2
  47. package/assets/skills-zh/comet-native/SKILL.md +18 -15
  48. package/assets/skills-zh/comet-native/reference/artifacts.md +5 -4
  49. package/assets/skills-zh/comet-native/reference/clarification.md +1 -1
  50. package/assets/skills-zh/comet-native/reference/commands.md +4 -4
  51. package/assets/skills-zh/comet-native/reference/recovery.md +1 -1
  52. package/assets/skills-zh/comet-native/reference/workspace.md +4 -4
  53. package/assets/skills-zh/comet-open/SKILL.md +24 -5
  54. package/assets/skills-zh/comet-review/SKILL.md +121 -0
  55. package/assets/skills-zh/comet-review/agents/openai.yaml +5 -0
  56. package/dist/app/cli/index.js +20 -1
  57. package/dist/app/cli/index.js.map +1 -1
  58. package/dist/app/commands/classic.d.ts.map +1 -1
  59. package/dist/app/commands/classic.js +2 -0
  60. package/dist/app/commands/classic.js.map +1 -1
  61. package/dist/app/commands/eval.d.ts +9 -2
  62. package/dist/app/commands/eval.d.ts.map +1 -1
  63. package/dist/app/commands/eval.js +293 -48
  64. package/dist/app/commands/eval.js.map +1 -1
  65. package/dist/app/commands/init.d.ts.map +1 -1
  66. package/dist/app/commands/init.js +5 -8
  67. package/dist/app/commands/init.js.map +1 -1
  68. package/dist/app/commands/update.d.ts.map +1 -1
  69. package/dist/app/commands/update.js +5 -6
  70. package/dist/app/commands/update.js.map +1 -1
  71. package/dist/domains/comet-classic/classic-cli.d.ts +1 -1
  72. package/dist/domains/comet-classic/classic-cli.d.ts.map +1 -1
  73. package/dist/domains/comet-classic/classic-cli.js +3 -0
  74. package/dist/domains/comet-classic/classic-cli.js.map +1 -1
  75. package/dist/domains/comet-classic/classic-command-context.d.ts +9 -0
  76. package/dist/domains/comet-classic/classic-command-context.d.ts.map +1 -1
  77. package/dist/domains/comet-classic/classic-command-context.js +10 -0
  78. package/dist/domains/comet-classic/classic-command-context.js.map +1 -1
  79. package/dist/domains/comet-classic/classic-current-change.d.ts.map +1 -1
  80. package/dist/domains/comet-classic/classic-current-change.js +29 -3
  81. package/dist/domains/comet-classic/classic-current-change.js.map +1 -1
  82. package/dist/domains/comet-classic/classic-guard.d.ts.map +1 -1
  83. package/dist/domains/comet-classic/classic-guard.js +4 -4
  84. package/dist/domains/comet-classic/classic-guard.js.map +1 -1
  85. package/dist/domains/comet-classic/classic-handoff.d.ts.map +1 -1
  86. package/dist/domains/comet-classic/classic-handoff.js +44 -6
  87. package/dist/domains/comet-classic/classic-handoff.js.map +1 -1
  88. package/dist/domains/comet-classic/classic-hook-guard.d.ts.map +1 -1
  89. package/dist/domains/comet-classic/classic-hook-guard.js +16 -2
  90. package/dist/domains/comet-classic/classic-hook-guard.js.map +1 -1
  91. package/dist/domains/comet-classic/classic-intent-command.d.ts.map +1 -1
  92. package/dist/domains/comet-classic/classic-intent-command.js +2 -1
  93. package/dist/domains/comet-classic/classic-intent-command.js.map +1 -1
  94. package/dist/domains/comet-classic/classic-resume-probe-command.d.ts.map +1 -1
  95. package/dist/domains/comet-classic/classic-resume-probe-command.js +4 -3
  96. package/dist/domains/comet-classic/classic-resume-probe-command.js.map +1 -1
  97. package/dist/domains/comet-classic/classic-runtime-run.d.ts +6 -0
  98. package/dist/domains/comet-classic/classic-runtime-run.d.ts.map +1 -1
  99. package/dist/domains/comet-classic/classic-runtime-run.js +58 -9
  100. package/dist/domains/comet-classic/classic-runtime-run.js.map +1 -1
  101. package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
  102. package/dist/domains/comet-classic/classic-state-command.js +39 -13
  103. package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
  104. package/dist/domains/comet-classic/classic-validate-command.d.ts.map +1 -1
  105. package/dist/domains/comet-classic/classic-validate-command.js +2 -2
  106. package/dist/domains/comet-classic/classic-validate-command.js.map +1 -1
  107. package/dist/domains/comet-classic/classic-workspace-command.d.ts +3 -0
  108. package/dist/domains/comet-classic/classic-workspace-command.d.ts.map +1 -0
  109. package/dist/domains/comet-classic/classic-workspace-command.js +45 -0
  110. package/dist/domains/comet-classic/classic-workspace-command.js.map +1 -0
  111. package/dist/domains/comet-classic/classic-workspace.d.ts +38 -0
  112. package/dist/domains/comet-classic/classic-workspace.d.ts.map +1 -0
  113. package/dist/domains/comet-classic/classic-workspace.js +315 -0
  114. package/dist/domains/comet-classic/classic-workspace.js.map +1 -0
  115. package/dist/domains/comet-entry/hook-adapter.d.ts.map +1 -1
  116. package/dist/domains/comet-entry/hook-adapter.js +5 -1
  117. package/dist/domains/comet-entry/hook-adapter.js.map +1 -1
  118. package/dist/domains/comet-entry/hook-router-entry.d.ts +2 -0
  119. package/dist/domains/comet-entry/hook-router-entry.d.ts.map +1 -1
  120. package/dist/domains/comet-entry/hook-router-entry.js +21 -1
  121. package/dist/domains/comet-entry/hook-router-entry.js.map +1 -1
  122. package/dist/domains/comet-entry/init-workflow.d.ts.map +1 -1
  123. package/dist/domains/comet-entry/init-workflow.js +13 -5
  124. package/dist/domains/comet-entry/init-workflow.js.map +1 -1
  125. package/dist/domains/comet-native/index.d.ts +1 -0
  126. package/dist/domains/comet-native/index.d.ts.map +1 -1
  127. package/dist/domains/comet-native/index.js +1 -0
  128. package/dist/domains/comet-native/index.js.map +1 -1
  129. package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
  130. package/dist/domains/comet-native/native-archive-command.js +2 -0
  131. package/dist/domains/comet-native/native-archive-command.js.map +1 -1
  132. package/dist/domains/comet-native/native-atomic-file.d.ts.map +1 -1
  133. package/dist/domains/comet-native/native-atomic-file.js +17 -10
  134. package/dist/domains/comet-native/native-atomic-file.js.map +1 -1
  135. package/dist/domains/comet-native/native-children.d.ts +65 -0
  136. package/dist/domains/comet-native/native-children.d.ts.map +1 -0
  137. package/dist/domains/comet-native/native-children.js +453 -0
  138. package/dist/domains/comet-native/native-children.js.map +1 -0
  139. package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
  140. package/dist/domains/comet-native/native-cli-help.js +13 -7
  141. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  142. package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
  143. package/dist/domains/comet-native/native-cli-shared.js +18 -5
  144. package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
  145. package/dist/domains/comet-native/native-doctor-command.d.ts.map +1 -1
  146. package/dist/domains/comet-native/native-doctor-command.js +10 -5
  147. package/dist/domains/comet-native/native-doctor-command.js.map +1 -1
  148. package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
  149. package/dist/domains/comet-native/native-hook-guard.js +56 -4
  150. package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
  151. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  152. package/dist/domains/comet-native/native-next-command.js +179 -20
  153. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  154. package/dist/domains/comet-native/native-portable-continuation.d.ts +22 -9
  155. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  156. package/dist/domains/comet-native/native-portable-continuation.js +178 -73
  157. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  158. package/dist/domains/comet-native/native-portable-migration-runtime.d.ts.map +1 -1
  159. package/dist/domains/comet-native/native-portable-migration-runtime.js +9 -4
  160. package/dist/domains/comet-native/native-portable-migration-runtime.js.map +1 -1
  161. package/dist/domains/comet-native/native-portable-runtime.d.ts +19 -1
  162. package/dist/domains/comet-native/native-portable-runtime.d.ts.map +1 -1
  163. package/dist/domains/comet-native/native-portable-runtime.js +168 -4
  164. package/dist/domains/comet-native/native-portable-runtime.js.map +1 -1
  165. package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
  166. package/dist/domains/comet-native/native-portable-state.js +13 -0
  167. package/dist/domains/comet-native/native-portable-state.js.map +1 -1
  168. package/dist/domains/comet-native/native-portable-status.d.ts +3 -0
  169. package/dist/domains/comet-native/native-portable-status.d.ts.map +1 -1
  170. package/dist/domains/comet-native/native-portable-status.js +9 -1
  171. package/dist/domains/comet-native/native-portable-status.js.map +1 -1
  172. package/dist/domains/comet-native/native-portable-types.d.ts +1 -0
  173. package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
  174. package/dist/domains/comet-native/native-portable-types.js.map +1 -1
  175. package/dist/domains/comet-native/native-pull-request-finish.d.ts +35 -0
  176. package/dist/domains/comet-native/native-pull-request-finish.d.ts.map +1 -0
  177. package/dist/domains/comet-native/native-pull-request-finish.js +282 -0
  178. package/dist/domains/comet-native/native-pull-request-finish.js.map +1 -0
  179. package/dist/domains/comet-native/native-show-command.d.ts.map +1 -1
  180. package/dist/domains/comet-native/native-show-command.js +2 -1
  181. package/dist/domains/comet-native/native-show-command.js.map +1 -1
  182. package/dist/domains/comet-native/native-status-discovery.d.ts.map +1 -1
  183. package/dist/domains/comet-native/native-status-discovery.js +24 -6
  184. package/dist/domains/comet-native/native-status-discovery.js.map +1 -1
  185. package/dist/domains/comet-native/native-workspace-finish.d.ts +6 -0
  186. package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -1
  187. package/dist/domains/comet-native/native-workspace-finish.js +86 -35
  188. package/dist/domains/comet-native/native-workspace-finish.js.map +1 -1
  189. package/dist/domains/comet-native/native-workspace-preparation.d.ts.map +1 -1
  190. package/dist/domains/comet-native/native-workspace-preparation.js +192 -133
  191. package/dist/domains/comet-native/native-workspace-preparation.js.map +1 -1
  192. package/dist/domains/dashboard/collector.d.ts +1 -1
  193. package/dist/domains/dashboard/collector.d.ts.map +1 -1
  194. package/dist/domains/dashboard/collector.js +102 -87
  195. package/dist/domains/dashboard/collector.js.map +1 -1
  196. package/dist/domains/dashboard/native-adapter.d.ts +20 -0
  197. package/dist/domains/dashboard/native-adapter.d.ts.map +1 -1
  198. package/dist/domains/dashboard/native-adapter.js +11 -0
  199. package/dist/domains/dashboard/native-adapter.js.map +1 -1
  200. package/dist/domains/dashboard/native-collector.d.ts +1 -0
  201. package/dist/domains/dashboard/native-collector.d.ts.map +1 -1
  202. package/dist/domains/dashboard/native-collector.js +304 -55
  203. package/dist/domains/dashboard/native-collector.js.map +1 -1
  204. package/dist/domains/dashboard/native-legacy-adapter.d.ts +12 -5
  205. package/dist/domains/dashboard/native-legacy-adapter.d.ts.map +1 -1
  206. package/dist/domains/dashboard/native-legacy-adapter.js +12 -0
  207. package/dist/domains/dashboard/native-legacy-adapter.js.map +1 -1
  208. package/dist/domains/dashboard/server.d.ts.map +1 -1
  209. package/dist/domains/dashboard/server.js +5 -3
  210. package/dist/domains/dashboard/server.js.map +1 -1
  211. package/dist/domains/dashboard/types.d.ts +5 -0
  212. package/dist/domains/dashboard/types.d.ts.map +1 -1
  213. package/dist/domains/dashboard/web/assets/abnfDiagram-N423BO3Z-BYya6ofk.js +1 -0
  214. package/dist/domains/dashboard/web/assets/arc-DJbo4TD3.js +1 -0
  215. package/dist/domains/dashboard/web/assets/architectureDiagram-T3A2C74G-D8uZ2IB-.js +36 -0
  216. package/dist/domains/dashboard/web/assets/blockDiagram-VBNYF7ZC-B16BVj-r.js +132 -0
  217. package/dist/domains/dashboard/web/assets/{c4Diagram-AAUBKEIU-BL17BIb8.js → c4Diagram-5PPSVZJV-ayV208_D.js} +1 -1
  218. package/dist/domains/dashboard/web/assets/channel-CEsrvmig.js +1 -0
  219. package/dist/domains/dashboard/web/assets/{chunk-ND2GUHAM-XWLMOyd4.js → chunk-2GRJ4B5K-Bn5o8p3H.js} +1 -1
  220. package/dist/domains/dashboard/web/assets/{chunk-QZHKN3VN-4drjXzHQ.js → chunk-2Q5K7J3B-BnF1SI6B.js} +1 -1
  221. package/dist/domains/dashboard/web/assets/chunk-5RXB4S5H-ETnma053.js +231 -0
  222. package/dist/domains/dashboard/web/assets/{chunk-FMBD7UC4-CQXqBSqQ.js → chunk-5VM5RSS4-Cuvy639H.js} +1 -1
  223. package/dist/domains/dashboard/web/assets/chunk-6Q2QTUOP-DOXBzl73.js +88 -0
  224. package/dist/domains/dashboard/web/assets/{chunk-727SXJPM-pMreYMW7.js → chunk-GF5L2VYU-CfREXlEl.js} +5 -5
  225. package/dist/domains/dashboard/web/assets/{chunk-4BX2VUAB-vQyyh3eG.js → chunk-JWPE2WC7-DWIdpYTb.js} +1 -1
  226. package/dist/domains/dashboard/web/assets/{chunk-2J33WTMH-B_DDS2IK.js → chunk-KBJHAD2P-BnqPcfZB.js} +1 -1
  227. package/dist/domains/dashboard/web/assets/chunk-RYQCIY6F-DdJ00fZz.js +1 -0
  228. package/dist/domains/dashboard/web/assets/{chunk-55IACEB6-Cug8J1Qa.js → chunk-XXDRQBXY-BVDhdJyW.js} +1 -1
  229. package/dist/domains/dashboard/web/assets/classDiagram-JCYQIIEL-CKFe0hg4.js +1 -0
  230. package/dist/domains/dashboard/web/assets/classDiagram-v2-OCEON4UE-CKFe0hg4.js +1 -0
  231. package/dist/domains/dashboard/web/assets/{cose-bilkent-S5V4N54A-IQKP-hgj.js → cose-bilkent-JH36ORCC-C-nglwHC.js} +1 -1
  232. package/dist/domains/dashboard/web/assets/{cynefin-VYW2F7L2-CvvRO4J2.js → cynefin-VYW2F7L2-C8TMmrbP.js} +2 -2
  233. package/dist/domains/dashboard/web/assets/cynefinDiagram-MW4NZA55-C3pnQnjg.js +62 -0
  234. package/dist/domains/dashboard/web/assets/dagre-VZM6K2ZE-DY7UWiPI.js +4 -0
  235. package/dist/domains/dashboard/web/assets/{demo-CeIDHUFJ.js → demo-BfLsKrIL.js} +26 -5
  236. package/dist/domains/dashboard/web/assets/diagram-7IWD3JNH-voTyDkQ5.js +30 -0
  237. package/dist/domains/dashboard/web/assets/{diagram-KO2AKTUF-CN_LYqvT.js → diagram-B4RE2ZJO-B3VkUMck.js} +3 -3
  238. package/dist/domains/dashboard/web/assets/diagram-LBJQPF4R-BdJzPkv8.js +24 -0
  239. package/dist/domains/dashboard/web/assets/diagram-Q27KOJAE-Bsq0anZx.js +24 -0
  240. package/dist/domains/dashboard/web/assets/diagram-UB23O5K3-CBaKRbcu.js +41 -0
  241. package/dist/domains/dashboard/web/assets/ebnfDiagram-BXEA7PRR-Bl9Bm5wa.js +1 -0
  242. package/dist/domains/dashboard/web/assets/erDiagram-JOGREHBK-DjOZzfKI.js +85 -0
  243. package/dist/domains/dashboard/web/assets/flowDiagram-UKHOOZJN-C21e4siK.js +156 -0
  244. package/dist/domains/dashboard/web/assets/ganttDiagram-PKOTCBZU-Bs62uy6-.js +292 -0
  245. package/dist/domains/dashboard/web/assets/{gitGraphDiagram-PVQCEYII-CaWEk3PM.js → gitGraphDiagram-DS77QQ5N-DQY_Ba00.js} +3 -3
  246. package/dist/domains/dashboard/web/assets/{graph--OzhPTMs.js → graph-DOmOIIwC.js} +1 -1
  247. package/dist/domains/dashboard/web/assets/{index-BNyOfAhu.js → index-BLv71GRj.js} +1 -1
  248. package/dist/domains/dashboard/web/assets/index-Be4r99N4.js +257 -0
  249. package/dist/domains/dashboard/web/assets/index-ByVYiA6g.css +1 -0
  250. package/dist/domains/dashboard/web/assets/{infoDiagram-5YYISTIA-BK07mNG0.js → infoDiagram-6WML65LV-CNgNNG9l.js} +1 -1
  251. package/dist/domains/dashboard/web/assets/{ishikawaDiagram-YF4QCWOH-mWnmaWfZ.js → ishikawaDiagram-WSZJBQD7-D9k1fTO1.js} +4 -4
  252. package/dist/domains/dashboard/web/assets/{journeyDiagram-JHISSGLW-BPy-P7xx.js → journeyDiagram-NVQOT4AX-CHijUnPl.js} +1 -1
  253. package/dist/domains/dashboard/web/assets/{kanban-definition-UN3LZRKU-3Jq9c_lo.js → kanban-definition-27J2QSJJ-DfWlntDq.js} +7 -7
  254. package/dist/domains/dashboard/web/assets/layout-D-LzfAck.js +1 -0
  255. package/dist/domains/dashboard/web/assets/{linear-kQyEW-4G.js → linear-o6hemX-z.js} +1 -1
  256. package/dist/domains/dashboard/web/assets/map-DxJ2ADlA.js +1 -0
  257. package/dist/domains/dashboard/web/assets/mermaid.core-B1DoOsPD.js +306 -0
  258. package/dist/domains/dashboard/web/assets/{mindmap-definition-RKZ34NQL-CyyurUpv.js → mindmap-definition-FAOFIHXS-COMQF9Yy.js} +1 -1
  259. package/dist/domains/dashboard/web/assets/pegDiagram-VL7TDLO6-C_21n7Ps.js +1 -0
  260. package/dist/domains/dashboard/web/assets/pieDiagram-7S7Q4E2Y-D3EmoYDY.js +39 -0
  261. package/dist/domains/dashboard/web/assets/purify.es-Cz4mVeUR.js +3 -0
  262. package/dist/domains/dashboard/web/assets/{quadrantDiagram-W4KKPZXB-CpayUMjH.js → quadrantDiagram-CIZ2JOQS-C3fGdiMa.js} +4 -4
  263. package/dist/domains/dashboard/web/assets/railroadDiagram-AXF67PYL-mIsjemD-.js +1 -0
  264. package/dist/domains/dashboard/web/assets/{requirementDiagram-4Y6WPE33-Bi8YpfnA.js → requirementDiagram-LRYGKXZP-D_UMpS5e.js} +1 -1
  265. package/dist/domains/dashboard/web/assets/sankeyDiagram-W5VNT64P-D1MwyMF6.js +40 -0
  266. package/dist/domains/dashboard/web/assets/sequenceDiagram-SI44F4Z6-B8jp1RxX.js +162 -0
  267. package/dist/domains/dashboard/web/assets/sizeCapture-X5ZJPWSS-BKioI1Ql.js +1 -0
  268. package/dist/domains/dashboard/web/assets/stateDiagram-OKZ733FA-B7l8_CDo.js +1 -0
  269. package/dist/domains/dashboard/web/assets/stateDiagram-v2-UEYNNEHI-BIxuwbeV.js +1 -0
  270. package/dist/domains/dashboard/web/assets/swimlanes-SLNWSIFB-951PRLYp.js +2 -0
  271. package/dist/domains/dashboard/web/assets/swimlanesDiagram-ULZ7WXOC-CEo6cGsy.js +8 -0
  272. package/dist/domains/dashboard/web/assets/{timeline-definition-PNZ67QCA-aHrrtV-b.js → timeline-definition-Z64GVDOM-CeyA2KbI.js} +4 -4
  273. package/dist/domains/dashboard/web/assets/vennDiagram-T6HMQDX7-BHe0TZJV.js +34 -0
  274. package/dist/domains/dashboard/web/assets/{wardleyDiagram-YWT4CUSO-RVQbcySh.js → wardleyDiagram-T6FBY63Y-CWqdSzJ-.js} +3 -3
  275. package/dist/domains/dashboard/web/assets/xychartDiagram-ELKLHX3M-DCKiZVPV.js +7 -0
  276. package/dist/domains/dashboard/web/index.html +2 -2
  277. package/dist/domains/dashboard/workspace.d.ts +27 -0
  278. package/dist/domains/dashboard/workspace.d.ts.map +1 -0
  279. package/dist/domains/dashboard/workspace.js +108 -0
  280. package/dist/domains/dashboard/workspace.js.map +1 -0
  281. package/dist/domains/eval/index.d.ts +3 -0
  282. package/dist/domains/eval/index.d.ts.map +1 -1
  283. package/dist/domains/eval/index.js +3 -0
  284. package/dist/domains/eval/index.js.map +1 -1
  285. package/dist/domains/eval/standalone-context.d.ts +19 -0
  286. package/dist/domains/eval/standalone-context.d.ts.map +1 -0
  287. package/dist/domains/eval/standalone-context.js +107 -0
  288. package/dist/domains/eval/standalone-context.js.map +1 -0
  289. package/dist/domains/eval/standalone-static-collect.d.ts +22 -0
  290. package/dist/domains/eval/standalone-static-collect.d.ts.map +1 -0
  291. package/dist/domains/eval/standalone-static-collect.js +779 -0
  292. package/dist/domains/eval/standalone-static-collect.js.map +1 -0
  293. package/dist/domains/eval/user-environment.d.ts +6 -0
  294. package/dist/domains/eval/user-environment.d.ts.map +1 -0
  295. package/dist/domains/eval/user-environment.js +73 -0
  296. package/dist/domains/eval/user-environment.js.map +1 -0
  297. package/dist/domains/integrations/openspec.d.ts +1 -1
  298. package/dist/domains/integrations/openspec.d.ts.map +1 -1
  299. package/dist/domains/integrations/openspec.js +87 -44
  300. package/dist/domains/integrations/openspec.js.map +1 -1
  301. package/dist/domains/integrations/superpowers.d.ts +14 -1
  302. package/dist/domains/integrations/superpowers.d.ts.map +1 -1
  303. package/dist/domains/integrations/superpowers.js +93 -5
  304. package/dist/domains/integrations/superpowers.js.map +1 -1
  305. package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
  306. package/dist/domains/skill/platform-inspect.js +3 -3
  307. package/dist/domains/skill/platform-inspect.js.map +1 -1
  308. package/dist/domains/skill/platform-install.d.ts +4 -2
  309. package/dist/domains/skill/platform-install.d.ts.map +1 -1
  310. package/dist/domains/skill/platform-install.js +16 -10
  311. package/dist/domains/skill/platform-install.js.map +1 -1
  312. package/dist/domains/skill/project-instructions.d.ts.map +1 -1
  313. package/dist/domains/skill/project-instructions.js +11 -3
  314. package/dist/domains/skill/project-instructions.js.map +1 -1
  315. package/dist/domains/skill/uninstall.d.ts.map +1 -1
  316. package/dist/domains/skill/uninstall.js +39 -29
  317. package/dist/domains/skill/uninstall.js.map +1 -1
  318. package/dist/domains/workflow-contract/contained-atomic-write.d.ts.map +1 -1
  319. package/dist/domains/workflow-contract/contained-atomic-write.js +18 -10
  320. package/dist/domains/workflow-contract/contained-atomic-write.js.map +1 -1
  321. package/dist/domains/workflow-contract/hook-write-policy.d.ts +9 -0
  322. package/dist/domains/workflow-contract/hook-write-policy.d.ts.map +1 -0
  323. package/dist/domains/workflow-contract/hook-write-policy.js +52 -0
  324. package/dist/domains/workflow-contract/hook-write-policy.js.map +1 -0
  325. package/dist/domains/workflow-contract/index.d.ts +2 -0
  326. package/dist/domains/workflow-contract/index.d.ts.map +1 -1
  327. package/dist/domains/workflow-contract/index.js +1 -0
  328. package/dist/domains/workflow-contract/index.js.map +1 -1
  329. package/dist/domains/workflow-contract/project-config.d.ts +4 -2
  330. package/dist/domains/workflow-contract/project-config.d.ts.map +1 -1
  331. package/dist/domains/workflow-contract/project-config.js +174 -2
  332. package/dist/domains/workflow-contract/project-config.js.map +1 -1
  333. package/dist/domains/workflow-contract/protected-project-path.d.ts +13 -0
  334. package/dist/domains/workflow-contract/protected-project-path.d.ts.map +1 -1
  335. package/dist/domains/workflow-contract/protected-project-path.js +83 -0
  336. package/dist/domains/workflow-contract/protected-project-path.js.map +1 -1
  337. package/dist/domains/workflow-contract/types.d.ts +13 -0
  338. package/dist/domains/workflow-contract/types.d.ts.map +1 -1
  339. package/dist/platform/fs/strip-bom.d.ts +10 -0
  340. package/dist/platform/fs/strip-bom.d.ts.map +1 -0
  341. package/dist/platform/fs/strip-bom.js +12 -0
  342. package/dist/platform/fs/strip-bom.js.map +1 -0
  343. package/dist/platform/install/platforms.d.ts +11 -0
  344. package/dist/platform/install/platforms.d.ts.map +1 -1
  345. package/dist/platform/install/platforms.js +49 -2
  346. package/dist/platform/install/platforms.js.map +1 -1
  347. package/dist/platform/paths/git-worktree.d.ts +7 -1
  348. package/dist/platform/paths/git-worktree.d.ts.map +1 -1
  349. package/dist/platform/paths/git-worktree.js +28 -7
  350. package/dist/platform/paths/git-worktree.js.map +1 -1
  351. package/dist/platform/process/external-command.d.ts +1 -0
  352. package/dist/platform/process/external-command.d.ts.map +1 -1
  353. package/dist/platform/process/external-command.js +2 -1
  354. package/dist/platform/process/external-command.js.map +1 -1
  355. package/eval/.env.example +115 -0
  356. package/eval/README.md +237 -14
  357. package/eval/langfuse/.env.example +9 -0
  358. package/eval/langfuse/tests/conftest.py +146 -0
  359. package/eval/langfuse/tests/tasks/test_tasks.py +109 -0
  360. package/eval/langfuse/tests/test_adapter.py +272 -0
  361. package/eval/langsmith/.env.example +16 -0
  362. package/eval/langsmith/tests/conftest.py +10 -1
  363. package/eval/local/tasks/comet-classic-layout-lifecycle/environment/current-comet-package.json +4 -2
  364. package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/environment/current-comet-package.json +2 -2
  365. package/eval/local/tests/conftest.py +719 -83
  366. package/eval/local/tests/scaffold/fixtures/custom-agent/adapter.yaml +19 -0
  367. package/eval/local/tests/scaffold/test_agents.py +76 -0
  368. package/eval/local/tests/scaffold/test_aligned_comparison.py +70 -0
  369. package/eval/local/tests/scaffold/test_auto_tasks.py +350 -0
  370. package/eval/local/tests/scaffold/test_conftest_helpers.py +324 -18
  371. package/eval/local/tests/scaffold/test_custom_agents.py +174 -0
  372. package/eval/local/tests/scaffold/test_eval_context.py +217 -0
  373. package/eval/local/tests/scaffold/test_execution.py +364 -0
  374. package/eval/local/tests/scaffold/test_inline_tasks.py +56 -0
  375. package/eval/local/tests/scaffold/test_langfuse_trajectory.py +263 -0
  376. package/eval/local/tests/scaffold/test_langsmith_conftest.py +63 -0
  377. package/eval/local/tests/scaffold/test_logging.py +162 -0
  378. package/eval/local/tests/scaffold/test_manifest_tasks.py +76 -0
  379. package/eval/local/tests/scaffold/test_manifests.py +396 -0
  380. package/eval/local/tests/scaffold/test_native_aligned_eval.py +17 -0
  381. package/eval/local/tests/scaffold/test_profiles.py +64 -6
  382. package/eval/local/tests/scaffold/test_task_resolution.py +212 -0
  383. package/eval/local/tests/scaffold/test_utils.py +480 -4
  384. package/eval/local/tests/tasks/test_tasks.py +216 -14
  385. package/eval/pyproject.toml +5 -0
  386. package/eval/scaffold/__init__.py +6 -0
  387. package/eval/scaffold/docker/agent-overlay.Dockerfile +41 -0
  388. package/eval/scaffold/python/__init__.py +128 -20
  389. package/eval/scaffold/python/agents.py +239 -0
  390. package/eval/scaffold/python/aligned_comparison.py +156 -27
  391. package/eval/scaffold/python/auto_tasks.py +700 -0
  392. package/eval/scaffold/python/custom_agents.py +172 -0
  393. package/eval/scaffold/python/eval_context.py +236 -0
  394. package/eval/scaffold/python/eval_schema.py +135 -0
  395. package/eval/scaffold/python/execution.py +544 -0
  396. package/eval/scaffold/python/generated_task_cache.py +230 -0
  397. package/eval/scaffold/python/generic_llm_judge.py +41 -14
  398. package/eval/scaffold/python/inline_tasks.py +118 -0
  399. package/eval/scaffold/python/judge_config.py +158 -37
  400. package/eval/scaffold/python/langfuse_adapter.py +1023 -0
  401. package/eval/scaffold/python/llm_judge.py +68 -11
  402. package/eval/scaffold/python/logging.py +157 -17
  403. package/eval/scaffold/python/manifest_tasks.py +69 -0
  404. package/eval/scaffold/python/manifests.py +443 -22
  405. package/eval/scaffold/python/paths.py +11 -1
  406. package/eval/scaffold/python/task_resolution.py +176 -0
  407. package/eval/scaffold/python/tasks.py +17 -4
  408. package/eval/scaffold/python/utils.py +167 -11
  409. package/eval/scaffold/python/validation/core.py +48 -2
  410. package/eval/scaffold/python/validation/generic_rubric.py +9 -0
  411. package/eval/scaffold/python/validation/native_workflow.py +6 -1
  412. package/eval/scaffold/python/validation/rubric.py +16 -1
  413. package/eval/scaffold/shell/agent-runtime-config.sh +88 -0
  414. package/eval/scaffold/shell/docker.sh +534 -33
  415. package/eval/scaffold/shell/run-agent-runtime.sh +49 -0
  416. package/eval/scaffold/shell/run-claude-loop.sh +153 -14
  417. package/eval/schemas/comet.eval/v1alpha1.schema.json +244 -0
  418. package/package.json +18 -28
  419. package/dist/domains/dashboard/web/assets/arc-CkuYweSh.js +0 -1
  420. package/dist/domains/dashboard/web/assets/architectureDiagram-3BPJPVTR--tTGrKam.js +0 -36
  421. package/dist/domains/dashboard/web/assets/blockDiagram-GPEHLZMM-DLKYOixs.js +0 -132
  422. package/dist/domains/dashboard/web/assets/channel-Cg__FSMr.js +0 -1
  423. package/dist/domains/dashboard/web/assets/chunk-AQP2D5EJ-BUkV_rb7.js +0 -231
  424. package/dist/domains/dashboard/web/assets/classDiagram-4FO5ZUOK-CsC-pvu9.js +0 -1
  425. package/dist/domains/dashboard/web/assets/classDiagram-v2-Q7XG4LA2-CsC-pvu9.js +0 -1
  426. package/dist/domains/dashboard/web/assets/dagre-BM42HDAG-DeOQo7bP.js +0 -4
  427. package/dist/domains/dashboard/web/assets/diagram-2AECGRRQ-IQd_jQwB.js +0 -43
  428. package/dist/domains/dashboard/web/assets/diagram-5GNKFQAL-Dllkdt0m.js +0 -10
  429. package/dist/domains/dashboard/web/assets/diagram-LMA3HP47-DK36WkNN.js +0 -24
  430. package/dist/domains/dashboard/web/assets/diagram-OG6HWLK6-iqUnMYEh.js +0 -24
  431. package/dist/domains/dashboard/web/assets/erDiagram-TEJ5UH35-Bc64lzy8.js +0 -85
  432. package/dist/domains/dashboard/web/assets/flowDiagram-I6XJVG4X-UfOqef9j.js +0 -162
  433. package/dist/domains/dashboard/web/assets/ganttDiagram-6RSMTGT7-D-u6Aauc.js +0 -292
  434. package/dist/domains/dashboard/web/assets/index-BFwKBVTJ.css +0 -1
  435. package/dist/domains/dashboard/web/assets/index-COZ_03uK.js +0 -257
  436. package/dist/domains/dashboard/web/assets/layout-SsrduOYp.js +0 -1
  437. package/dist/domains/dashboard/web/assets/mermaid.core-COBBjtVH.js +0 -301
  438. package/dist/domains/dashboard/web/assets/pieDiagram-4H26LBE5-CJro_XKk.js +0 -30
  439. package/dist/domains/dashboard/web/assets/purify.es-VaSPOPhr.js +0 -3
  440. package/dist/domains/dashboard/web/assets/sankeyDiagram-5OEKKPKP-Wx60WwHe.js +0 -40
  441. package/dist/domains/dashboard/web/assets/sequenceDiagram-3UESZ5HK-BiMsRFbc.js +0 -162
  442. package/dist/domains/dashboard/web/assets/stateDiagram-AJRCARHV-BrURMY0R.js +0 -1
  443. package/dist/domains/dashboard/web/assets/stateDiagram-v2-BHNVJYJU-BpEE-yEg.js +0 -1
  444. package/dist/domains/dashboard/web/assets/vennDiagram-CIIHVFJN-DGB16bvR.js +0 -34
  445. package/dist/domains/dashboard/web/assets/xychartDiagram-2RQKCTM6-DMzzwDVX.js +0 -7
  446. package/eval/local/tasks/comet-native-interrupted-transition/environment/.comet/config.yaml +0 -6
@@ -1,158 +1,158 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var Ff=Object.create;var nc=Object.defineProperty;var Mf=Object.getOwnPropertyDescriptor;var Vf=Object.getOwnPropertyNames;var qf=Object.getPrototypeOf,Wf=Object.prototype.hasOwnProperty;var dr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var y=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(i){throw t=0,i}};var zf=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Vf(t))!Wf.call(e,n)&&n!==i&&nc(e,n,{get:()=>t[n],enumerable:!(r=Mf(t,n))||r.enumerable});return e};var fr=(e,t,i)=>(i=e!=null?Ff(qf(e)):{},zf(t||!e||!e.__esModule?nc(i,"default",{value:e,enumerable:!0}):i,e));var P=y(M=>{"use strict";var ua=Symbol.for("yaml.alias"),cc=Symbol.for("yaml.document"),mr=Symbol.for("yaml.map"),lc=Symbol.for("yaml.pair"),da=Symbol.for("yaml.scalar"),vr=Symbol.for("yaml.seq"),Ie=Symbol.for("yaml.node.type"),ch=e=>!!e&&typeof e=="object"&&e[Ie]===ua,lh=e=>!!e&&typeof e=="object"&&e[Ie]===cc,uh=e=>!!e&&typeof e=="object"&&e[Ie]===mr,dh=e=>!!e&&typeof e=="object"&&e[Ie]===lc,uc=e=>!!e&&typeof e=="object"&&e[Ie]===da,fh=e=>!!e&&typeof e=="object"&&e[Ie]===vr;function dc(e){if(e&&typeof e=="object")switch(e[Ie]){case mr:case vr:return!0}return!1}function hh(e){if(e&&typeof e=="object")switch(e[Ie]){case ua:case mr:case da:case vr:return!0}return!1}var ph=e=>(uc(e)||dc(e))&&!!e.anchor;M.ALIAS=ua;M.DOC=cc;M.MAP=mr;M.NODE_TYPE=Ie;M.PAIR=lc;M.SCALAR=da;M.SEQ=vr;M.hasAnchor=ph;M.isAlias=ch;M.isCollection=dc;M.isDocument=lh;M.isMap=uh;M.isNode=hh;M.isPair=dh;M.isScalar=uc;M.isSeq=fh});var ri=y(fa=>{"use strict";var H=P(),X=Symbol("break visit"),fc=Symbol("skip children"),ke=Symbol("remove node");function gr(e,t){let i=hc(t);H.isDocument(e)?Et(null,e.contents,i,Object.freeze([e]))===ke&&(e.contents=null):Et(null,e,i,Object.freeze([]))}gr.BREAK=X;gr.SKIP=fc;gr.REMOVE=ke;function Et(e,t,i,r){let n=pc(e,t,i,r);if(H.isNode(n)||H.isPair(n))return mc(e,r,n),Et(e,n,i,r);if(typeof n!="symbol"){if(H.isCollection(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){let o=Et(a,t.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===X)return X;o===ke&&(t.items.splice(a,1),a-=1)}}}else if(H.isPair(t)){r=Object.freeze(r.concat(t));let a=Et("key",t.key,i,r);if(a===X)return X;a===ke&&(t.key=null);let o=Et("value",t.value,i,r);if(o===X)return X;o===ke&&(t.value=null)}}return n}async function wr(e,t){let i=hc(t);H.isDocument(e)?await Pt(null,e.contents,i,Object.freeze([e]))===ke&&(e.contents=null):await Pt(null,e,i,Object.freeze([]))}wr.BREAK=X;wr.SKIP=fc;wr.REMOVE=ke;async function Pt(e,t,i,r){let n=await pc(e,t,i,r);if(H.isNode(n)||H.isPair(n))return mc(e,r,n),Pt(e,n,i,r);if(typeof n!="symbol"){if(H.isCollection(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){let o=await Pt(a,t.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===X)return X;o===ke&&(t.items.splice(a,1),a-=1)}}}else if(H.isPair(t)){r=Object.freeze(r.concat(t));let a=await Pt("key",t.key,i,r);if(a===X)return X;a===ke&&(t.key=null);let o=await Pt("value",t.value,i,r);if(o===X)return X;o===ke&&(t.value=null)}}return n}function hc(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function pc(e,t,i,r){if(typeof i=="function")return i(e,t,r);if(H.isMap(t))return i.Map?.(e,t,r);if(H.isSeq(t))return i.Seq?.(e,t,r);if(H.isPair(t))return i.Pair?.(e,t,r);if(H.isScalar(t))return i.Scalar?.(e,t,r);if(H.isAlias(t))return i.Alias?.(e,t,r)}function mc(e,t,i){let r=t[t.length-1];if(H.isCollection(r))r.items[e]=i;else if(H.isPair(r))e==="key"?r.key=i:r.value=i;else if(H.isDocument(r))r.contents=i;else{let n=H.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}fa.visit=gr;fa.visitAsync=wr});var ha=y(gc=>{"use strict";var vc=P(),mh=ri(),vh={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},gh=e=>e.replace(/[!,[\]{}]/g,t=>vh[t]),ni=class e{constructor(t,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,i)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,i){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let r=t.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(t,i){if(t==="!")return"!";if(t[0]!=="!")return i(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(i(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&i("Verbatim tags must end with a >"),o)}let[,r,n]=t.match(/^(.*!)([^!]*)$/s);n||i(`The ${t} 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==="!"?t:(i(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[i,r]of Object.entries(this.tags))if(t.startsWith(r))return i+gh(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(t&&r.length>0&&vc.isNode(t.contents)){let a={};mh.visit(t.contents,(o,s)=>{vc.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:"||(!t||n.some(s=>s.startsWith(o)))&&i.push(`%TAG ${a} ${o}`);return i.join(`
5
- `)}};ni.defaultYaml={explicit:!1,version:"1.2"};ni.defaultTags={"!!":"tag:yaml.org,2002:"};gc.Directives=ni});var yr=y(ai=>{"use strict";var wc=P(),wh=ri();function yh(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(i)}return!0}function yc(e){let t=new Set;return wh.visit(e,{Value(i,r){r.anchor&&t.add(r.anchor)}}),t}function Nc(e,t){for(let i=1;;++i){let r=`${e}${i}`;if(!t.has(r))return r}}function Nh(e,t){let i=[],r=new Map,n=null;return{onAnchor:a=>{i.push(a),n??(n=yc(e));let o=Nc(t,n);return n.add(o),o},setAnchors:()=>{for(let a of i){let o=r.get(a);if(typeof o=="object"&&o.anchor&&(wc.isScalar(o.node)||wc.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}}ai.anchorIsValid=yh;ai.anchorNames=yc;ai.createNodeAnchors=Nh;ai.findNewAnchor=Nc});var pa=y(bc=>{"use strict";function oi(e,t,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=oi(e,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=oi(e,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=oi(e,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=oi(e,r,n,a);o===void 0?delete r[n]:o!==a&&(r[n]=o)}return e.call(t,i,r)}bc.applyReviver=oi});var Ve=y(Sc=>{"use strict";var bh=P();function kc(e,t,i){if(Array.isArray(e))return e.map((r,n)=>kc(r,String(n),i));if(e&&typeof e.toJSON=="function"){if(!i||!bh.hasAnchor(e))return e.toJSON(t,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(e,r),i.onCreate=a=>{r.res=a,delete i.onCreate};let n=e.toJSON(t,i);return i.onCreate&&i.onCreate(n),n}return typeof e=="bigint"&&!i?.keep?Number(e):e}Sc.toJS=kc});var Nr=y(Pc=>{"use strict";var kh=pa(),Ec=P(),Sh=Ve(),ma=class{constructor(t){Object.defineProperty(this,Ec.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:i,maxAliasCount:r,onAnchor:n,reviver:a}={}){if(!Ec.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=Sh.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?kh.applyReviver(a,{"":s},"",s):s}};Pc.NodeBase=ma});var si=y(xc=>{"use strict";var Eh=yr(),Ph=ri(),xt=P(),xh=Nr(),Rh=Ve(),va=class extends xh.NodeBase{constructor(t){super(xt.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],Ph.visit(t,{Node:(a,o)=>{(xt.isAlias(o)||xt.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(t,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||(Rh.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=br(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(t,i,r){let n=`*${this.source}`;if(t){if(Eh.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${n} `}return n}};function br(e,t,i){if(xt.isAlias(t)){let r=t.resolve(e),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(xt.isCollection(t)){let r=0;for(let n of t.items){let a=br(e,n,i);a>r&&(r=a)}return r}else if(xt.isPair(t)){let r=br(e,t.key,i),n=br(e,t.value,i);return Math.max(r,n)}return 1}xc.Alias=va});var I=y(ga=>{"use strict";var Ch=P(),Ah=Nr(),_h=Ve(),Th=e=>!e||typeof e!="function"&&typeof e!="object",qe=class extends Ah.NodeBase{constructor(t){super(Ch.SCALAR),this.value=t}toJSON(t,i){return i?.keep?this.value:_h.toJS(this.value,t,i)}toString(){return String(this.value)}};qe.BLOCK_FOLDED="BLOCK_FOLDED";qe.BLOCK_LITERAL="BLOCK_LITERAL";qe.PLAIN="PLAIN";qe.QUOTE_DOUBLE="QUOTE_DOUBLE";qe.QUOTE_SINGLE="QUOTE_SINGLE";ga.Scalar=qe;ga.isScalarValue=Th});var ci=y(Cc=>{"use strict";var Ih=si(),nt=P(),Rc=I(),jh="tag:yaml.org,2002:";function $h(e,t,i){if(t){let r=i.filter(a=>a.tag===t),n=r.find(a=>!a.format)??r[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return i.find(r=>r.identify?.(e)&&!r.format)}function Oh(e,t,i){if(nt.isDocument(e)&&(e=e.contents),nt.isNode(e))return e;if(nt.isPair(e)){let f=i.schema[nt.MAP].createNode?.(i.schema,null,i);return f.items.push(e),f}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=i,c;if(r&&e&&typeof e=="object"){if(c=s.get(e),c)return c.anchor??(c.anchor=n(e)),new Ih.Alias(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith("!!")&&(t=jh+t.slice(2));let l=$h(e,t,o.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let f=new Rc.Scalar(e);return c&&(c.node=f),f}l=e instanceof Map?o[nt.MAP]:Symbol.iterator in Object(e)?o[nt.SEQ]:o[nt.MAP]}a&&(a(l),delete i.onTagObj);let d=l?.createNode?l.createNode(i.schema,e,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,e,i):new Rc.Scalar(e);return t?d.tag=t:l.default||(d.tag=l.tag),c&&(c.node=d),d}Cc.createNode=Oh});var Sr=y(kr=>{"use strict";var Hh=ci(),Se=P(),Dh=Nr();function wa(e,t,i){let r=i;for(let n=t.length-1;n>=0;--n){let a=t[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=r,r=o}else r=new Map([[a,r]])}return Hh.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Ac=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,ya=class extends Dh.NodeBase{constructor(t,i){super(t),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(t){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(i.schema=t),i.items=i.items.map(r=>Se.isNode(r)||Se.isPair(r)?r.clone(t):r),this.range&&(i.range=this.range.slice()),i}addIn(t,i){if(Ac(t))this.add(i);else{let[r,...n]=t,a=this.get(r,!0);if(Se.isCollection(a))a.addIn(n,i);else if(a===void 0&&this.schema)this.set(r,wa(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(t){let[i,...r]=t;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(Se.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(t,i){let[r,...n]=t,a=this.get(r,!0);return n.length===0?!i&&Se.isScalar(a)?a.value:a:Se.isCollection(a)?a.getIn(n,i):void 0}hasAllNullValues(t){return this.items.every(i=>{if(!Se.isPair(i))return!1;let r=i.value;return r==null||t&&Se.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){let[i,...r]=t;if(r.length===0)return this.has(i);let n=this.get(i,!0);return Se.isCollection(n)?n.hasIn(r):!1}setIn(t,i){let[r,...n]=t;if(n.length===0)this.set(r,i);else{let a=this.get(r,!0);if(Se.isCollection(a))a.setIn(n,i);else if(a===void 0&&this.schema)this.set(r,wa(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};kr.Collection=ya;kr.collectionFromPath=wa;kr.isEmptyPath=Ac});var li=y(Er=>{"use strict";var Bh=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Na(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Lh=(e,t,i)=>e.endsWith(`
6
- `)?Na(i,t):i.includes(`
4
+ var Sh=Object.create;var kc=Object.defineProperty;var Eh=Object.getOwnPropertyDescriptor;var Ph=Object.getOwnPropertyNames;var xh=Object.getPrototypeOf,Rh=Object.prototype.hasOwnProperty;var wr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var y=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(i){throw t=0,i}};var Ch=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ph(t))!Rh.call(e,n)&&n!==i&&kc(e,n,{get:()=>t[n],enumerable:!(r=Eh(t,n))||r.enumerable});return e};var ai=(e,t,i)=>(i=e!=null?Sh(xh(e)):{},Ch(t||!e||!e.__esModule?kc(i,"default",{value:e,enumerable:!0}):i,e));var P=y(M=>{"use strict";var Ea=Symbol.for("yaml.alias"),Rc=Symbol.for("yaml.document"),br=Symbol.for("yaml.map"),Cc=Symbol.for("yaml.pair"),Pa=Symbol.for("yaml.scalar"),kr=Symbol.for("yaml.seq"),je=Symbol.for("yaml.node.type"),Jh=e=>!!e&&typeof e=="object"&&e[je]===Ea,Gh=e=>!!e&&typeof e=="object"&&e[je]===Rc,Uh=e=>!!e&&typeof e=="object"&&e[je]===br,Kh=e=>!!e&&typeof e=="object"&&e[je]===Cc,Ac=e=>!!e&&typeof e=="object"&&e[je]===Pa,Yh=e=>!!e&&typeof e=="object"&&e[je]===kr;function _c(e){if(e&&typeof e=="object")switch(e[je]){case br:case kr:return!0}return!1}function Xh(e){if(e&&typeof e=="object")switch(e[je]){case Ea:case br:case Pa:case kr:return!0}return!1}var Qh=e=>(Ac(e)||_c(e))&&!!e.anchor;M.ALIAS=Ea;M.DOC=Rc;M.MAP=br;M.NODE_TYPE=je;M.PAIR=Cc;M.SCALAR=Pa;M.SEQ=kr;M.hasAnchor=Qh;M.isAlias=Jh;M.isCollection=_c;M.isDocument=Gh;M.isMap=Uh;M.isNode=Xh;M.isPair=Kh;M.isScalar=Ac;M.isSeq=Yh});var ui=y(xa=>{"use strict";var B=P(),Q=Symbol("break visit"),Tc=Symbol("skip children"),Ee=Symbol("remove node");function Sr(e,t){let i=Ic(t);B.isDocument(e)?_t(null,e.contents,i,Object.freeze([e]))===Ee&&(e.contents=null):_t(null,e,i,Object.freeze([]))}Sr.BREAK=Q;Sr.SKIP=Tc;Sr.REMOVE=Ee;function _t(e,t,i,r){let n=jc(e,t,i,r);if(B.isNode(n)||B.isPair(n))return $c(e,r,n),_t(e,n,i,r);if(typeof n!="symbol"){if(B.isCollection(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){let o=_t(a,t.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===Q)return Q;o===Ee&&(t.items.splice(a,1),a-=1)}}}else if(B.isPair(t)){r=Object.freeze(r.concat(t));let a=_t("key",t.key,i,r);if(a===Q)return Q;a===Ee&&(t.key=null);let o=_t("value",t.value,i,r);if(o===Q)return Q;o===Ee&&(t.value=null)}}return n}async function Er(e,t){let i=Ic(t);B.isDocument(e)?await Tt(null,e.contents,i,Object.freeze([e]))===Ee&&(e.contents=null):await Tt(null,e,i,Object.freeze([]))}Er.BREAK=Q;Er.SKIP=Tc;Er.REMOVE=Ee;async function Tt(e,t,i,r){let n=await jc(e,t,i,r);if(B.isNode(n)||B.isPair(n))return $c(e,r,n),Tt(e,n,i,r);if(typeof n!="symbol"){if(B.isCollection(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){let o=await Tt(a,t.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===Q)return Q;o===Ee&&(t.items.splice(a,1),a-=1)}}}else if(B.isPair(t)){r=Object.freeze(r.concat(t));let a=await Tt("key",t.key,i,r);if(a===Q)return Q;a===Ee&&(t.key=null);let o=await Tt("value",t.value,i,r);if(o===Q)return Q;o===Ee&&(t.value=null)}}return n}function Ic(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function jc(e,t,i,r){if(typeof i=="function")return i(e,t,r);if(B.isMap(t))return i.Map?.(e,t,r);if(B.isSeq(t))return i.Seq?.(e,t,r);if(B.isPair(t))return i.Pair?.(e,t,r);if(B.isScalar(t))return i.Scalar?.(e,t,r);if(B.isAlias(t))return i.Alias?.(e,t,r)}function $c(e,t,i){let r=t[t.length-1];if(B.isCollection(r))r.items[e]=i;else if(B.isPair(r))e==="key"?r.key=i:r.value=i;else if(B.isDocument(r))r.contents=i;else{let n=B.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}xa.visit=Sr;xa.visitAsync=Er});var Ra=y(Hc=>{"use strict";var Oc=P(),Zh=ui(),ep={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},tp=e=>e.replace(/[!,[\]{}]/g,t=>ep[t]),di=class e{constructor(t,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,i)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,i){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let r=t.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(t,i){if(t==="!")return"!";if(t[0]!=="!")return i(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(i(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&i("Verbatim tags must end with a >"),o)}let[,r,n]=t.match(/^(.*!)([^!]*)$/s);n||i(`The ${t} 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==="!"?t:(i(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[i,r]of Object.entries(this.tags))if(t.startsWith(r))return i+tp(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(t&&r.length>0&&Oc.isNode(t.contents)){let a={};Zh.visit(t.contents,(o,s)=>{Oc.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:"||(!t||n.some(s=>s.startsWith(o)))&&i.push(`%TAG ${a} ${o}`);return i.join(`
5
+ `)}};di.defaultYaml={explicit:!1,version:"1.2"};di.defaultTags={"!!":"tag:yaml.org,2002:"};Hc.Directives=di});var Pr=y(fi=>{"use strict";var Dc=P(),ip=ui();function rp(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(i)}return!0}function Bc(e){let t=new Set;return ip.visit(e,{Value(i,r){r.anchor&&t.add(r.anchor)}}),t}function Lc(e,t){for(let i=1;;++i){let r=`${e}${i}`;if(!t.has(r))return r}}function np(e,t){let i=[],r=new Map,n=null;return{onAnchor:a=>{i.push(a),n??(n=Bc(e));let o=Lc(t,n);return n.add(o),o},setAnchors:()=>{for(let a of i){let o=r.get(a);if(typeof o=="object"&&o.anchor&&(Dc.isScalar(o.node)||Dc.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}}fi.anchorIsValid=rp;fi.anchorNames=Bc;fi.createNodeAnchors=np;fi.findNewAnchor=Lc});var Ca=y(qc=>{"use strict";function hi(e,t,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=hi(e,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=hi(e,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=hi(e,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=hi(e,r,n,a);o===void 0?delete r[n]:o!==a&&(r[n]=o)}return e.call(t,i,r)}qc.applyReviver=hi});var ze=y(Mc=>{"use strict";var ap=P();function Fc(e,t,i){if(Array.isArray(e))return e.map((r,n)=>Fc(r,String(n),i));if(e&&typeof e.toJSON=="function"){if(!i||!ap.hasAnchor(e))return e.toJSON(t,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(e,r),i.onCreate=a=>{r.res=a,delete i.onCreate};let n=e.toJSON(t,i);return i.onCreate&&i.onCreate(n),n}return typeof e=="bigint"&&!i?.keep?Number(e):e}Mc.toJS=Fc});var xr=y(Wc=>{"use strict";var op=Ca(),Vc=P(),sp=ze(),Aa=class{constructor(t){Object.defineProperty(this,Vc.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:i,maxAliasCount:r,onAnchor:n,reviver:a}={}){if(!Vc.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=sp.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?op.applyReviver(a,{"":s},"",s):s}};Wc.NodeBase=Aa});var pi=y(zc=>{"use strict";var cp=Pr(),lp=ui(),It=P(),up=xr(),dp=ze(),_a=class extends up.NodeBase{constructor(t){super(It.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],lp.visit(t,{Node:(a,o)=>{(It.isAlias(o)||It.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(t,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||(dp.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=Rr(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(t,i,r){let n=`*${this.source}`;if(t){if(cp.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${n} `}return n}};function Rr(e,t,i){if(It.isAlias(t)){let r=t.resolve(e),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(It.isCollection(t)){let r=0;for(let n of t.items){let a=Rr(e,n,i);a>r&&(r=a)}return r}else if(It.isPair(t)){let r=Rr(e,t.key,i),n=Rr(e,t.value,i);return Math.max(r,n)}return 1}zc.Alias=_a});var $=y(Ta=>{"use strict";var fp=P(),hp=xr(),pp=ze(),mp=e=>!e||typeof e!="function"&&typeof e!="object",Je=class extends hp.NodeBase{constructor(t){super(fp.SCALAR),this.value=t}toJSON(t,i){return i?.keep?this.value:pp.toJS(this.value,t,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";Ta.Scalar=Je;Ta.isScalarValue=mp});var mi=y(Gc=>{"use strict";var vp=pi(),ut=P(),Jc=$(),gp="tag:yaml.org,2002:";function wp(e,t,i){if(t){let r=i.filter(a=>a.tag===t),n=r.find(a=>!a.format)??r[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return i.find(r=>r.identify?.(e)&&!r.format)}function yp(e,t,i){if(ut.isDocument(e)&&(e=e.contents),ut.isNode(e))return e;if(ut.isPair(e)){let f=i.schema[ut.MAP].createNode?.(i.schema,null,i);return f.items.push(e),f}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=i,c;if(r&&e&&typeof e=="object"){if(c=s.get(e),c)return c.anchor??(c.anchor=n(e)),new vp.Alias(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith("!!")&&(t=gp+t.slice(2));let l=wp(e,t,o.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let f=new Jc.Scalar(e);return c&&(c.node=f),f}l=e instanceof Map?o[ut.MAP]:Symbol.iterator in Object(e)?o[ut.SEQ]:o[ut.MAP]}a&&(a(l),delete i.onTagObj);let u=l?.createNode?l.createNode(i.schema,e,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,e,i):new Jc.Scalar(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}Gc.createNode=yp});var Ar=y(Cr=>{"use strict";var Np=mi(),Pe=P(),bp=xr();function Ia(e,t,i){let r=i;for(let n=t.length-1;n>=0;--n){let a=t[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=r,r=o}else r=new Map([[a,r]])}return Np.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Uc=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,ja=class extends bp.NodeBase{constructor(t,i){super(t),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(t){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(i.schema=t),i.items=i.items.map(r=>Pe.isNode(r)||Pe.isPair(r)?r.clone(t):r),this.range&&(i.range=this.range.slice()),i}addIn(t,i){if(Uc(t))this.add(i);else{let[r,...n]=t,a=this.get(r,!0);if(Pe.isCollection(a))a.addIn(n,i);else if(a===void 0&&this.schema)this.set(r,Ia(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(t){let[i,...r]=t;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(Pe.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(t,i){let[r,...n]=t,a=this.get(r,!0);return n.length===0?!i&&Pe.isScalar(a)?a.value:a:Pe.isCollection(a)?a.getIn(n,i):void 0}hasAllNullValues(t){return this.items.every(i=>{if(!Pe.isPair(i))return!1;let r=i.value;return r==null||t&&Pe.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){let[i,...r]=t;if(r.length===0)return this.has(i);let n=this.get(i,!0);return Pe.isCollection(n)?n.hasIn(r):!1}setIn(t,i){let[r,...n]=t;if(n.length===0)this.set(r,i);else{let a=this.get(r,!0);if(Pe.isCollection(a))a.setIn(n,i);else if(a===void 0&&this.schema)this.set(r,Ia(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};Cr.Collection=ja;Cr.collectionFromPath=Ia;Cr.isEmptyPath=Uc});var vi=y(_r=>{"use strict";var kp=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function $a(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Sp=(e,t,i)=>e.endsWith(`
6
+ `)?$a(i,t):i.includes(`
7
7
  `)?`
8
- `+Na(i,t):(e.endsWith(" ")?"":" ")+i;Er.indentComment=Na;Er.lineComment=Lh;Er.stringifyComment=Bh});var Tc=y(ui=>{"use strict";var Fh="flow",ba="block",Pr="quoted";function Mh(e,t,i="flow",{indentAtStart:r,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return e;n<a&&(a=0);let c=Math.max(1+a,1+n-t.length);if(e.length<=c)return e;let l=[],d={},f=n-t.length;typeof r=="number"&&(r>n-Math.max(2,a)?l.push(0):f=n-r);let u,p,v=!1,h=-1,m=-1,g=-1;i===ba&&(h=_c(e,h,t.length),h!==-1&&(f=h+c));for(let w;w=e[h+=1];){if(i===Pr&&w==="\\"){switch(m=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}g=h}if(w===`
9
- `)i===ba&&(h=_c(e,h,t.length)),f=h+t.length+c,u=void 0;else{if(w===" "&&p&&p!==" "&&p!==`
8
+ `+$a(i,t):(e.endsWith(" ")?"":" ")+i;_r.indentComment=$a;_r.lineComment=Sp;_r.stringifyComment=kp});var Yc=y(gi=>{"use strict";var Ep="flow",Oa="block",Tr="quoted";function Pp(e,t,i="flow",{indentAtStart:r,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return e;n<a&&(a=0);let c=Math.max(1+a,1+n-t.length);if(e.length<=c)return e;let l=[],u={},f=n-t.length;typeof r=="number"&&(r>n-Math.max(2,a)?l.push(0):f=n-r);let d,p,v=!1,h=-1,m=-1,g=-1;i===Oa&&(h=Kc(e,h,t.length),h!==-1&&(f=h+c));for(let w;w=e[h+=1];){if(i===Tr&&w==="\\"){switch(m=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}g=h}if(w===`
9
+ `)i===Oa&&(h=Kc(e,h,t.length)),f=h+t.length+c,d=void 0;else{if(w===" "&&p&&p!==" "&&p!==`
10
10
  `&&p!==" "){let k=e[h+1];k&&k!==" "&&k!==`
11
- `&&k!==" "&&(u=h)}if(h>=f)if(u)l.push(u),f=u+c,u=void 0;else if(i===Pr){for(;p===" "||p===" ";)p=w,w=e[h+=1],v=!0;let k=h>g+1?h-2:m-1;if(d[k])return e;l.push(k),d[k]=!0,f=k+c,u=void 0}else v=!0}p=w}if(v&&s&&s(),l.length===0)return e;o&&o();let N=e.slice(0,l[0]);for(let w=0;w<l.length;++w){let k=l[w],S=l[w+1]||e.length;k===0?N=`
12
- ${t}${e.slice(0,S)}`:(i===Pr&&d[k]&&(N+=`${e[k]}\\`),N+=`
13
- ${t}${e.slice(k+1,S)}`)}return N}function _c(e,t,i){let r=t,n=t+1,a=e[n];for(;a===" "||a===" ";)if(t<n+i)a=e[++t];else{do a=e[++t];while(a&&a!==`
14
- `);r=t,n=t+1,a=e[n]}return r}ui.FOLD_BLOCK=ba;ui.FOLD_FLOW=Fh;ui.FOLD_QUOTED=Pr;ui.foldFlowLines=Mh});var fi=y(Ic=>{"use strict";var pe=I(),We=Tc(),Rr=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Cr=e=>/^(%|---|\.\.\.)/m.test(e);function Vh(e,t,i){if(!t||t<0)return!1;let r=t-i,n=e.length;if(n<=r)return!1;for(let a=0,o=0;a<n;++a)if(e[a]===`
15
- `){if(a-o>r)return!0;if(o=a+1,n-o<=r)return!1}return!0}function di(e,t){let i=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=t,n=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(Cr(e)?" ":""),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 d=i.substr(c+2,4);switch(d){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:d.substr(0,2)==="00"?o+="\\x"+d.substr(2):o+=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!==" "&&(d=h)}if(h>=f)if(d)l.push(d),f=d+c,d=void 0;else if(i===Tr){for(;p===" "||p===" ";)p=w,w=e[h+=1],v=!0;let k=h>g+1?h-2:m-1;if(u[k])return e;l.push(k),u[k]=!0,f=k+c,d=void 0}else v=!0}p=w}if(v&&s&&s(),l.length===0)return e;o&&o();let N=e.slice(0,l[0]);for(let w=0;w<l.length;++w){let k=l[w],S=l[w+1]||e.length;k===0?N=`
12
+ ${t}${e.slice(0,S)}`:(i===Tr&&u[k]&&(N+=`${e[k]}\\`),N+=`
13
+ ${t}${e.slice(k+1,S)}`)}return N}function Kc(e,t,i){let r=t,n=t+1,a=e[n];for(;a===" "||a===" ";)if(t<n+i)a=e[++t];else{do a=e[++t];while(a&&a!==`
14
+ `);r=t,n=t+1,a=e[n]}return r}gi.FOLD_BLOCK=Oa;gi.FOLD_FLOW=Ep;gi.FOLD_QUOTED=Tr;gi.foldFlowLines=Pp});var yi=y(Xc=>{"use strict";var me=$(),Ge=Yc(),jr=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),$r=e=>/^(%|---|\.\.\.)/m.test(e);function xp(e,t,i){if(!t||t<0)return!1;let r=t-i,n=e.length;if(n<=r)return!1;for(let a=0,o=0;a<n;++a)if(e[a]===`
15
+ `){if(a-o>r)return!0;if(o=a+1,n-o<=r)return!1}return!0}function wi(e,t){let i=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=t,n=t.options.doubleQuotedMinMultiLineLength,a=t.indent||($r(e)?" ":""),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 u=i.substr(c+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=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:We.foldFlowLines(o,a,We.FOLD_QUOTED,Rr(t,!1))}function ka(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(e))return di(e,t);let i=t.indent||(Cr(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${i}`)+"'";return t.implicitKey?r:We.foldFlowLines(r,i,We.FOLD_FLOW,Rr(t,!1))}function Rt(e,t){let{singleQuote:i}=t.options,r;if(i===!1)r=di;else{let n=e.includes('"'),a=e.includes("'");n&&!a?r=ka:a&&!n?r=di:r=i?ka:di}return r(e,t)}var Sa;try{Sa=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:Ge.foldFlowLines(o,a,Ge.FOLD_QUOTED,jr(t,!1))}function Ha(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(e))return wi(e,t);let i=t.indent||($r(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${i}`)+"'";return t.implicitKey?r:Ge.foldFlowLines(r,i,Ge.FOLD_FLOW,jr(t,!1))}function jt(e,t){let{singleQuote:i}=t.options,r;if(i===!1)r=wi;else{let n=e.includes('"'),a=e.includes("'");n&&!a?r=Ha:a&&!n?r=wi:r=i?Ha:wi}return r(e,t)}var Da;try{Da=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{Sa=/\n+(?!\n|$)/g}function xr({comment:e,type:t,value:i},r,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(i))return Rt(i,r);let l=r.indent||(r.forceBlockIndent||Cr(i)?" ":""),d=o==="literal"?!0:o==="folded"||t===pe.Scalar.BLOCK_FOLDED?!1:t===pe.Scalar.BLOCK_LITERAL?!0:!Vh(i,c,l.length);if(!i)return d?`|
23
+ |$)`,"g")}catch{Da=/\n+(?!\n|$)/g}function Ir({comment:e,type:t,value:i},r,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(i))return jt(i,r);let l=r.indent||(r.forceBlockIndent||$r(i)?" ":""),u=o==="literal"?!0:o==="folded"||t===me.Scalar.BLOCK_FOLDED?!1:t===me.Scalar.BLOCK_LITERAL?!0:!xp(i,c,l.length);if(!i)return u?`|
24
24
  `:`>
25
- `;let f,u;for(u=i.length;u>0;--u){let S=i[u-1];if(S!==`
26
- `&&S!==" "&&S!==" ")break}let p=i.substring(u),v=p.indexOf(`
25
+ `;let f,d;for(d=i.length;d>0;--d){let S=i[d-1];if(S!==`
26
+ `&&S!==" "&&S!==" ")break}let p=i.substring(d),v=p.indexOf(`
27
27
  `);v===-1?f="-":i===p||v!==p.length-1?(f="+",a&&a()):f="",p&&(i=i.slice(0,-p.length),p[p.length-1]===`
28
- `&&(p=p.slice(0,-1)),p=p.replace(Sa,`$&${l}`));let h=!1,m,g=-1;for(m=0;m<i.length;++m){let S=i[m];if(S===" ")h=!0;else if(S===`
29
- `)g=m;else break}let N=i.substring(0,g<m?g+1:m);N&&(i=i.substring(N.length),N=N.replace(/\n+/g,`$&${l}`));let k=(h?l?"2":"1":"")+f;if(e&&(k+=" "+s(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!d){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=Rr(r,!0);o!=="folded"&&t!==pe.Scalar.BLOCK_FOLDED&&(C.onOverflow=()=>{E=!0});let b=We.foldFlowLines(`${N}${S}${p}`,l,We.FOLD_BLOCK,C);if(!E)return`>${k}
28
+ `&&(p=p.slice(0,-1)),p=p.replace(Da,`$&${l}`));let h=!1,m,g=-1;for(m=0;m<i.length;++m){let S=i[m];if(S===" ")h=!0;else if(S===`
29
+ `)g=m;else break}let N=i.substring(0,g<m?g+1:m);N&&(i=i.substring(N.length),N=N.replace(/\n+/g,`$&${l}`));let k=(h?l?"2":"1":"")+f;if(e&&(k+=" "+s(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!u){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=jr(r,!0);o!=="folded"&&t!==me.Scalar.BLOCK_FOLDED&&(C.onOverflow=()=>{E=!0});let b=Ge.foldFlowLines(`${N}${S}${p}`,l,Ge.FOLD_BLOCK,C);if(!E)return`>${k}
31
31
  ${l}${b}`}return i=i.replace(/\n+/g,`$&${l}`),`|${k}
32
- ${l}${N}${i}${p}`}function qh(e,t,i,r){let{type:n,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:d}=t;if(s&&a.includes(`
33
- `)||d&&/[[\]{},]/.test(a))return Rt(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||d||!a.includes(`
34
- `)?Rt(a,t):xr(e,t,i,r);if(!s&&!d&&n!==pe.Scalar.PLAIN&&a.includes(`
35
- `))return xr(e,t,i,r);if(Cr(a)){if(c==="")return t.forceBlockIndent=!0,xr(e,t,i,r);if(s&&c===l)return Rt(a,t)}let f=a.replace(/\n+/g,`$&
36
- ${c}`);if(o){let u=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(f),{compat:p,tags:v}=t.doc.schema;if(v.some(u)||p?.some(u))return Rt(a,t)}return s?f:We.foldFlowLines(f,c,We.FOLD_FLOW,Rr(t,!1))}function Wh(e,t,i,r){let{implicitKey:n,inFlow:a}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==pe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=pe.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case pe.Scalar.BLOCK_FOLDED:case pe.Scalar.BLOCK_LITERAL:return n||a?Rt(o.value,t):xr(o,t,i,r);case pe.Scalar.QUOTE_DOUBLE:return di(o.value,t);case pe.Scalar.QUOTE_SINGLE:return ka(o.value,t);case pe.Scalar.PLAIN:return qh(o,t,i,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:d,defaultStringType:f}=t.options,u=n&&d||f;if(l=c(u),l===null)throw new Error(`Unsupported default string type ${u}`)}return l}Ic.stringifyString=Wh});var hi=y(Ea=>{"use strict";var zh=yr(),ze=P(),Jh=li(),Gh=fi();function Uh(e,t){let i=Object.assign({blockQuote:!0,commentString:Jh.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function Kh(e,t){if(t.tag){let n=e.filter(a=>a.tag===t.tag);if(n.length>0)return n.find(a=>a.format===t.format)??n[0]}let i,r;if(ze.isScalar(t)){r=t.value;let n=e.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===t.format)??n.find(a=>!a.format)}else r=t,i=e.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 Yh(e,t,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],a=(ze.isScalar(e)||ze.isCollection(e))&&e.anchor;a&&zh.anchorIsValid(a)&&(i.add(a),n.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(r.directives.tagString(o)),n.join(" ")}function Xh(e,t,i,r){if(ze.isPair(e))return e.toString(t,i,r);if(ze.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,a=ze.isNode(e)?e:t.doc.createNode(e,{onTagObj:c=>n=c});n??(n=Kh(t.doc.schema.tags,a));let o=Yh(a,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,t,i,r):ze.isScalar(a)?Gh.stringifyString(a,t,i,r):a.toString(t,i,r);return o?ze.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${t.indent}${s}`:s}Ea.createStringifyContext=Uh;Ea.stringify=Xh});var Hc=y(Oc=>{"use strict";var je=P(),jc=I(),$c=hi(),pi=li();function Qh({key:e,value:t},i,r,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:f}}=i,u=je.isNode(e)&&e.comment||null;if(f){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(je.isCollection(e)||!je.isNode(e)&&typeof e=="object"){let C="With simple keys, collection cannot be used as a key value";throw new Error(C)}}let p=!f&&(!e||u&&t==null&&!i.inFlow||je.isCollection(e)||(je.isScalar(e)?e.type===jc.Scalar.BLOCK_FOLDED||e.type===jc.Scalar.BLOCK_LITERAL:typeof e=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!p&&(f||!a),indent:s+c});let v=!1,h=!1,m=$c.stringify(e,i,()=>v=!0,()=>h=!0);if(!p&&!i.inFlow&&m.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(i.inFlow){if(a||t==null)return v&&r&&r(),m===""?"?":p?`? ${m}`:m}else if(a&&!f||t==null&&p)return m=`? ${m}`,u&&!v?m+=pi.lineComment(m,i.indent,l(u)):h&&n&&n(),m;v&&(u=null),p?(u&&(m+=pi.lineComment(m,i.indent,l(u))),m=`? ${m}
38
- ${s}:`):(m=`${m}:`,u&&(m+=pi.lineComment(m,i.indent,l(u))));let g,N,w;je.isNode(t)?(g=!!t.spaceBefore,N=t.commentBefore,w=t.comment):(g=!1,N=null,w=null,t&&typeof t=="object"&&(t=o.createNode(t))),i.implicitKey=!1,!p&&!u&&je.isScalar(t)&&(i.indentAtStart=m.length+1),h=!1,!d&&c.length>=2&&!i.inFlow&&!p&&je.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(i.indent=i.indent.substring(2));let k=!1,S=$c.stringify(t,i,()=>k=!0,()=>h=!0),E=" ";if(u||g||N){if(E=g?`
32
+ ${l}${N}${i}${p}`}function Rp(e,t,i,r){let{type:n,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
33
+ `)||u&&/[[\]{},]/.test(a))return jt(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
34
+ `)?jt(a,t):Ir(e,t,i,r);if(!s&&!u&&n!==me.Scalar.PLAIN&&a.includes(`
35
+ `))return Ir(e,t,i,r);if($r(a)){if(c==="")return t.forceBlockIndent=!0,Ir(e,t,i,r);if(s&&c===l)return jt(a,t)}let f=a.replace(/\n+/g,`$&
36
+ ${c}`);if(o){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(f),{compat:p,tags:v}=t.doc.schema;if(v.some(d)||p?.some(d))return jt(a,t)}return s?f:Ge.foldFlowLines(f,c,Ge.FOLD_FLOW,jr(t,!1))}function Cp(e,t,i,r){let{implicitKey:n,inFlow:a}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==me.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=me.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case me.Scalar.BLOCK_FOLDED:case me.Scalar.BLOCK_LITERAL:return n||a?jt(o.value,t):Ir(o,t,i,r);case me.Scalar.QUOTE_DOUBLE:return wi(o.value,t);case me.Scalar.QUOTE_SINGLE:return Ha(o.value,t);case me.Scalar.PLAIN:return Rp(o,t,i,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:u,defaultStringType:f}=t.options,d=n&&u||f;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}Xc.stringifyString=Cp});var Ni=y(Ba=>{"use strict";var Ap=Pr(),Ue=P(),_p=vi(),Tp=yi();function Ip(e,t){let i=Object.assign({blockQuote:!0,commentString:_p.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function jp(e,t){if(t.tag){let n=e.filter(a=>a.tag===t.tag);if(n.length>0)return n.find(a=>a.format===t.format)??n[0]}let i,r;if(Ue.isScalar(t)){r=t.value;let n=e.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===t.format)??n.find(a=>!a.format)}else r=t,i=e.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 $p(e,t,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],a=(Ue.isScalar(e)||Ue.isCollection(e))&&e.anchor;a&&Ap.anchorIsValid(a)&&(i.add(a),n.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(r.directives.tagString(o)),n.join(" ")}function Op(e,t,i,r){if(Ue.isPair(e))return e.toString(t,i,r);if(Ue.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,a=Ue.isNode(e)?e:t.doc.createNode(e,{onTagObj:c=>n=c});n??(n=jp(t.doc.schema.tags,a));let o=$p(a,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,t,i,r):Ue.isScalar(a)?Tp.stringifyString(a,t,i,r):a.toString(t,i,r);return o?Ue.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${t.indent}${s}`:s}Ba.createStringifyContext=Ip;Ba.stringify=Op});var tl=y(el=>{"use strict";var $e=P(),Qc=$(),Zc=Ni(),bi=vi();function Hp({key:e,value:t},i,r,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:f}}=i,d=$e.isNode(e)&&e.comment||null;if(f){if(d)throw new Error("With simple keys, key nodes cannot have comments");if($e.isCollection(e)||!$e.isNode(e)&&typeof e=="object"){let C="With simple keys, collection cannot be used as a key value";throw new Error(C)}}let p=!f&&(!e||d&&t==null&&!i.inFlow||$e.isCollection(e)||($e.isScalar(e)?e.type===Qc.Scalar.BLOCK_FOLDED||e.type===Qc.Scalar.BLOCK_LITERAL:typeof e=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!p&&(f||!a),indent:s+c});let v=!1,h=!1,m=Zc.stringify(e,i,()=>v=!0,()=>h=!0);if(!p&&!i.inFlow&&m.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(i.inFlow){if(a||t==null)return v&&r&&r(),m===""?"?":p?`? ${m}`:m}else if(a&&!f||t==null&&p)return m=`? ${m}`,d&&!v?m+=bi.lineComment(m,i.indent,l(d)):h&&n&&n(),m;v&&(d=null),p?(d&&(m+=bi.lineComment(m,i.indent,l(d))),m=`? ${m}
38
+ ${s}:`):(m=`${m}:`,d&&(m+=bi.lineComment(m,i.indent,l(d))));let g,N,w;$e.isNode(t)?(g=!!t.spaceBefore,N=t.commentBefore,w=t.comment):(g=!1,N=null,w=null,t&&typeof t=="object"&&(t=o.createNode(t))),i.implicitKey=!1,!p&&!d&&$e.isScalar(t)&&(i.indentAtStart=m.length+1),h=!1,!u&&c.length>=2&&!i.inFlow&&!p&&$e.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(i.indent=i.indent.substring(2));let k=!1,S=Zc.stringify(t,i,()=>k=!0,()=>h=!0),E=" ";if(d||g||N){if(E=g?`
39
39
  `:"",N){let C=l(N);E+=`
40
- ${pi.indentComment(C,i.indent)}`}S===""&&!i.inFlow?E===`
40
+ ${bi.indentComment(C,i.indent)}`}S===""&&!i.inFlow?E===`
41
41
  `&&w&&(E=`
42
42
 
43
43
  `):E+=`
44
- ${i.indent}`}else if(!p&&je.isCollection(t)){let C=S[0],b=S.indexOf(`
45
- `),$=b!==-1,Fe=i.inFlow??t.flow??t.items.length===0;if($||!Fe){let kt=!1;if($&&(C==="&"||C==="!")){let O=S.indexOf(" ");C==="&"&&O!==-1&&O<b&&S[O+1]==="!"&&(O=S.indexOf(" ",O+1)),(O===-1||b<O)&&(kt=!0)}kt||(E=`
44
+ ${i.indent}`}else if(!p&&$e.isCollection(t)){let C=S[0],b=S.indexOf(`
45
+ `),H=b!==-1,Ve=i.inFlow??t.flow??t.items.length===0;if(H||!Ve){let At=!1;if(H&&(C==="&"||C==="!")){let D=S.indexOf(" ");C==="&"&&D!==-1&&D<b&&S[D+1]==="!"&&(D=S.indexOf(" ",D+1)),(D===-1||b<D)&&(At=!0)}At||(E=`
46
46
  ${i.indent}`)}}else(S===""||S[0]===`
47
- `)&&(E="");return m+=E+S,i.inFlow?k&&r&&r():w&&!k?m+=pi.lineComment(m,i.indent,l(w)):h&&n&&n(),m}Oc.stringifyPair=Qh});var xa=y(Pa=>{"use strict";var Dc=dr("process");function Zh(e,...t){e==="debug"&&console.log(...t)}function ep(e,t){(e==="debug"||e==="warn")&&(typeof Dc.emitWarning=="function"?Dc.emitWarning(t):console.warn(t))}Pa.debug=Zh;Pa.warn=ep});var jr=y(Ir=>{"use strict";var Tr=P(),Bc=I(),Ar="<<",_r={identify:e=>e===Ar||typeof e=="symbol"&&e.description===Ar,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Bc.Scalar(Symbol(Ar)),{addToJSMap:Lc}),stringify:()=>Ar},tp=(e,t)=>(_r.identify(t)||Tr.isScalar(t)&&(!t.type||t.type===Bc.Scalar.PLAIN)&&_r.identify(t.value))&&e?.doc.schema.tags.some(i=>i.tag===_r.tag&&i.default);function Lc(e,t,i){let r=Fc(e,i);if(Tr.isSeq(r))for(let n of r.items)Ra(e,t,n);else if(Array.isArray(r))for(let n of r)Ra(e,t,n);else Ra(e,t,r)}function Ra(e,t,i){let r=Fc(e,i);if(!Tr.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.toJSON(null,e,Map);for(let[a,o]of n)t instanceof Map?t.has(a)||t.set(a,o):t instanceof Set?t.add(a):Object.prototype.hasOwnProperty.call(t,a)||Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function Fc(e,t){return e&&Tr.isAlias(t)?t.resolve(e.doc,e):t}Ir.addMergeToJSMap=Lc;Ir.isMergeKey=tp;Ir.merge=_r});var Aa=y(qc=>{"use strict";var ip=xa(),Mc=jr(),rp=hi(),Vc=P(),Ca=Ve();function np(e,t,{key:i,value:r}){if(Vc.isNode(i)&&i.addToJSMap)i.addToJSMap(e,t,r);else if(Mc.isMergeKey(e,i))Mc.addMergeToJSMap(e,t,r);else{let n=Ca.toJS(i,"",e);if(t instanceof Map)t.set(n,Ca.toJS(r,n,e));else if(t instanceof Set)t.add(n);else{let a=ap(i,n,e),o=Ca.toJS(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function ap(e,t,i){if(t===null)return"";if(typeof t!="object")return String(t);if(Vc.isNode(e)&&i?.doc){let r=rp.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=e.toString(r);if(!i.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),ip.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(t)}qc.addPairToJSMap=np});var Je=y(_a=>{"use strict";var Wc=ci(),op=Hc(),sp=Aa(),$r=P();function cp(e,t,i){let r=Wc.createNode(e,void 0,i),n=Wc.createNode(t,void 0,i);return new Or(r,n)}var Or=class e{constructor(t,i=null){Object.defineProperty(this,$r.NODE_TYPE,{value:$r.PAIR}),this.key=t,this.value=i}clone(t){let{key:i,value:r}=this;return $r.isNode(i)&&(i=i.clone(t)),$r.isNode(r)&&(r=r.clone(t)),new e(i,r)}toJSON(t,i){let r=i?.mapAsMap?new Map:{};return sp.addPairToJSMap(i,r,this)}toString(t,i,r){return t?.doc?op.stringifyPair(this,t,i,r):JSON.stringify(this)}};_a.Pair=Or;_a.createPair=cp});var Ta=y(Jc=>{"use strict";var at=P(),zc=hi(),Hr=li();function lp(e,t,i){return(t.inFlow??e.flow?dp:up)(e,t,i)}function up({comment:e,items:t},i,{blockItemPrefix:r,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=i,d=Object.assign({},i,{indent:a,type:null}),f=!1,u=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(at.isNode(h))!f&&h.spaceBefore&&u.push(""),Dr(i,u,h.commentBefore,f),h.comment&&(m=h.comment);else if(at.isPair(h)){let N=at.isNode(h.key)?h.key:null;N&&(!f&&N.spaceBefore&&u.push(""),Dr(i,u,N.commentBefore,f))}f=!1;let g=zc.stringify(h,d,()=>m=null,()=>f=!0);m&&(g+=Hr.lineComment(g,a,l(m))),f&&m&&(f=!1),u.push(r+g)}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():w&&!k?m+=bi.lineComment(m,i.indent,l(w)):h&&n&&n(),m}el.stringifyPair=Hp});var qa=y(La=>{"use strict";var il=wr("process");function Dp(e,...t){e==="debug"&&console.log(...t)}function Bp(e,t){(e==="debug"||e==="warn")&&(typeof il.emitWarning=="function"?il.emitWarning(t):console.warn(t))}La.debug=Dp;La.warn=Bp});var Lr=y(Br=>{"use strict";var Dr=P(),rl=$(),Or="<<",Hr={identify:e=>e===Or||typeof e=="symbol"&&e.description===Or,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new rl.Scalar(Symbol(Or)),{addToJSMap:nl}),stringify:()=>Or},Lp=(e,t)=>(Hr.identify(t)||Dr.isScalar(t)&&(!t.type||t.type===rl.Scalar.PLAIN)&&Hr.identify(t.value))&&e?.doc.schema.tags.some(i=>i.tag===Hr.tag&&i.default);function nl(e,t,i){let r=al(e,i);if(Dr.isSeq(r))for(let n of r.items)Fa(e,t,n);else if(Array.isArray(r))for(let n of r)Fa(e,t,n);else Fa(e,t,r)}function Fa(e,t,i){let r=al(e,i);if(!Dr.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.toJSON(null,e,Map);for(let[a,o]of n)t instanceof Map?t.has(a)||t.set(a,o):t instanceof Set?t.add(a):Object.prototype.hasOwnProperty.call(t,a)||Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function al(e,t){return e&&Dr.isAlias(t)?t.resolve(e.doc,e):t}Br.addMergeToJSMap=nl;Br.isMergeKey=Lp;Br.merge=Hr});var Va=y(cl=>{"use strict";var qp=qa(),ol=Lr(),Fp=Ni(),sl=P(),Ma=ze();function Mp(e,t,{key:i,value:r}){if(sl.isNode(i)&&i.addToJSMap)i.addToJSMap(e,t,r);else if(ol.isMergeKey(e,i))ol.addMergeToJSMap(e,t,r);else{let n=Ma.toJS(i,"",e);if(t instanceof Map)t.set(n,Ma.toJS(r,n,e));else if(t instanceof Set)t.add(n);else{let a=Vp(i,n,e),o=Ma.toJS(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Vp(e,t,i){if(t===null)return"";if(typeof t!="object")return String(t);if(sl.isNode(e)&&i?.doc){let r=Fp.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=e.toString(r);if(!i.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),qp.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(t)}cl.addPairToJSMap=Mp});var Ke=y(Wa=>{"use strict";var ll=mi(),Wp=tl(),zp=Va(),qr=P();function Jp(e,t,i){let r=ll.createNode(e,void 0,i),n=ll.createNode(t,void 0,i);return new Fr(r,n)}var Fr=class e{constructor(t,i=null){Object.defineProperty(this,qr.NODE_TYPE,{value:qr.PAIR}),this.key=t,this.value=i}clone(t){let{key:i,value:r}=this;return qr.isNode(i)&&(i=i.clone(t)),qr.isNode(r)&&(r=r.clone(t)),new e(i,r)}toJSON(t,i){let r=i?.mapAsMap?new Map:{};return zp.addPairToJSMap(i,r,this)}toString(t,i,r){return t?.doc?Wp.stringifyPair(this,t,i,r):JSON.stringify(this)}};Wa.Pair=Fr;Wa.createPair=Jp});var za=y(dl=>{"use strict";var dt=P(),ul=Ni(),Mr=vi();function Gp(e,t,i){return(t.inFlow??e.flow?Kp:Up)(e,t,i)}function Up({comment:e,items:t},i,{blockItemPrefix:r,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=i,u=Object.assign({},i,{indent:a,type:null}),f=!1,d=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(dt.isNode(h))!f&&h.spaceBefore&&d.push(""),Vr(i,d,h.commentBefore,f),h.comment&&(m=h.comment);else if(dt.isPair(h)){let N=dt.isNode(h.key)?h.key:null;N&&(!f&&N.spaceBefore&&d.push(""),Vr(i,d,N.commentBefore,f))}f=!1;let g=ul.stringify(h,u,()=>m=null,()=>f=!0);m&&(g+=Mr.lineComment(g,a,l(m))),f&&m&&(f=!1),d.push(r+g)}let p;if(d.length===0)p=n.start+n.end;else{p=d[0];for(let v=1;v<d.length;++v){let h=d[v];p+=h?`
48
48
  ${c}${h}`:`
49
49
  `}}return e?(p+=`
50
- `+Hr.indentComment(l(e),c),s&&s()):f&&o&&o(),p}function dp({items:e},t,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,d=0,f=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(at.isNode(h))h.spaceBefore&&f.push(""),Dr(t,f,h.commentBefore,!1),h.comment&&(m=h.comment);else if(at.isPair(h)){let N=at.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&f.push(""),Dr(t,f,N.commentBefore,!1),N.comment&&(l=!0));let w=at.isNode(h.value)?h.value:null;w?(w.comment&&(m=w.comment),w.commentBefore&&(l=!0)):h.value==null&&N?.comment&&(m=N.comment)}m&&(l=!0);let g=zc.stringify(h,c,()=>m=null);l||(l=f.length>d||g.includes(`
51
- `)),v<e.length-1?g+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(l||(l=f.reduce((N,w)=>N+w.length+2,2)+(g.length+2)>t.options.lineWidth)),l&&(g+=",")),m&&(g+=Hr.lineComment(g,r,s(m))),f.push(g),d=f.length}let{start:u,end:p}=i;if(f.length===0)return u+p;if(!l){let v=f.reduce((h,m)=>h+m.length+2,2);l=t.options.lineWidth>0&&v>t.options.lineWidth}if(l){let v=u;for(let h of f)v+=h?`
50
+ `+Mr.indentComment(l(e),c),s&&s()):f&&o&&o(),p}function Kp({items:e},t,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,f=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(dt.isNode(h))h.spaceBefore&&f.push(""),Vr(t,f,h.commentBefore,!1),h.comment&&(m=h.comment);else if(dt.isPair(h)){let N=dt.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&f.push(""),Vr(t,f,N.commentBefore,!1),N.comment&&(l=!0));let w=dt.isNode(h.value)?h.value:null;w?(w.comment&&(m=w.comment),w.commentBefore&&(l=!0)):h.value==null&&N?.comment&&(m=N.comment)}m&&(l=!0);let g=ul.stringify(h,c,()=>m=null);l||(l=f.length>u||g.includes(`
51
+ `)),v<e.length-1?g+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(l||(l=f.reduce((N,w)=>N+w.length+2,2)+(g.length+2)>t.options.lineWidth)),l&&(g+=",")),m&&(g+=Mr.lineComment(g,r,s(m))),f.push(g),u=f.length}let{start:d,end:p}=i;if(f.length===0)return d+p;if(!l){let v=f.reduce((h,m)=>h+m.length+2,2);l=t.options.lineWidth>0&&v>t.options.lineWidth}if(l){let v=d;for(let h of f)v+=h?`
52
52
  ${a}${n}${h}`:`
53
53
  `;return`${v}
54
- ${n}${p}`}else return`${u}${o}${f.join(" ")}${o}${p}`}function Dr({indent:e,options:{commentString:t}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let a=Hr.indentComment(t(r),e);i.push(a.trimStart())}}Jc.stringifyCollection=lp});var Ue=y(ja=>{"use strict";var fp=Ta(),hp=Aa(),pp=Sr(),Ge=P(),Br=Je(),mp=I();function mi(e,t){let i=Ge.isScalar(t)?t.value:t;for(let r of e)if(Ge.isPair(r)&&(r.key===t||r.key===i||Ge.isScalar(r.key)&&r.key.value===i))return r}var Ia=class extends pp.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Ge.MAP,t),this.items=[]}static from(t,i,r){let{keepUndefined:n,replacer:a}=r,o=new this(t),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(Br.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 t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,i){let r;Ge.isPair(t)?r=t:!t||typeof t!="object"||!("key"in t)?r=new Br.Pair(t,t?.value):r=new Br.Pair(t.key,t.value);let n=mi(this.items,r.key),a=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);Ge.isScalar(n.value)&&mp.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(t){let i=mi(this.items,t);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(t,i){let n=mi(this.items,t)?.value;return(!i&&Ge.isScalar(n)?n.value:n)??void 0}has(t){return!!mi(this.items,t)}set(t,i){this.add(new Br.Pair(t,i),!0)}toJSON(t,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let a of this.items)hp.addPairToJSMap(i,n,a);return n}toString(t,i,r){if(!t)return JSON.stringify(this);for(let n of this.items)if(!Ge.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),fp.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:r,onComment:i})}};ja.YAMLMap=Ia;ja.findPair=mi});var Ct=y(Uc=>{"use strict";var vp=P(),Gc=Ue(),gp={collection:"map",default:!0,nodeClass:Gc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return vp.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,i)=>Gc.YAMLMap.from(e,t,i)};Uc.map=gp});var Ke=y(Kc=>{"use strict";var wp=ci(),yp=Ta(),Np=Sr(),Fr=P(),bp=I(),kp=Ve(),$a=class extends Np.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Fr.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let i=Lr(t);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(t,i){let r=Lr(t);if(typeof r!="number")return;let n=this.items[r];return!i&&Fr.isScalar(n)?n.value:n}has(t){let i=Lr(t);return typeof i=="number"&&i<this.items.length}set(t,i){let r=Lr(t);if(typeof r!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[r];Fr.isScalar(n)&&bp.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(t,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let a of this.items)r.push(kp.toJS(a,String(n++),i));return r}toString(t,i,r){return t?yp.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(t,i,r){let{replacer:n}=r,a=new this(t);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(wp.createNode(s,void 0,r))}}return a}};function Lr(e){let t=Fr.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}Kc.YAMLSeq=$a});var At=y(Xc=>{"use strict";var Sp=P(),Yc=Ke(),Ep={collection:"seq",default:!0,nodeClass:Yc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return Sp.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,i)=>Yc.YAMLSeq.from(e,t,i)};Xc.seq=Ep});var vi=y(Qc=>{"use strict";var Pp=fi(),xp={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,i,r){return t=Object.assign({actualString:!0},t),Pp.stringifyString(e,t,i,r)}};Qc.string=xp});var Mr=y(tl=>{"use strict";var Zc=I(),el={identify:e=>e==null,createNode:()=>new Zc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Zc.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&el.test.test(e)?e:t.options.nullStr};tl.nullTag=el});var Oa=y(rl=>{"use strict";var Rp=I(),il={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Rp.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},i){if(e&&il.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?i.options.trueStr:i.options.falseStr}};rl.boolTag=il});var _t=y(nl=>{"use strict";function Cp({format:e,minFractionDigits:t,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(!e&&t&&(!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=t-(a.length-o-1);for(;s-- >0;)a+="0"}return a}nl.stringifyNumber=Cp});var Da=y(Vr=>{"use strict";var Ap=I(),Ha=_t(),_p={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ha.stringifyNumber},Tp={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ha.stringifyNumber(e)}},Ip={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new Ap.Scalar(parseFloat(e)),i=e.indexOf(".");return i!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-i-1),t},stringify:Ha.stringifyNumber};Vr.float=Ip;Vr.floatExp=Tp;Vr.floatNaN=_p});var La=y(Wr=>{"use strict";var al=_t(),qr=e=>typeof e=="bigint"||Number.isInteger(e),Ba=(e,t,i,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),i);function ol(e,t,i){let{value:r}=e;return qr(r)&&r>=0?i+r.toString(t):al.stringifyNumber(e)}var jp={identify:e=>qr(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,i)=>Ba(e,2,8,i),stringify:e=>ol(e,8,"0o")},$p={identify:qr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,i)=>Ba(e,0,10,i),stringify:al.stringifyNumber},Op={identify:e=>qr(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,i)=>Ba(e,2,16,i),stringify:e=>ol(e,16,"0x")};Wr.int=$p;Wr.intHex=Op;Wr.intOct=jp});var cl=y(sl=>{"use strict";var Hp=Ct(),Dp=Mr(),Bp=At(),Lp=vi(),Fp=Oa(),Fa=Da(),Ma=La(),Mp=[Hp.map,Bp.seq,Lp.string,Dp.nullTag,Fp.boolTag,Ma.intOct,Ma.int,Ma.intHex,Fa.floatNaN,Fa.floatExp,Fa.float];sl.schema=Mp});var dl=y(ul=>{"use strict";var Vp=I(),qp=Ct(),Wp=At();function ll(e){return typeof e=="bigint"||Number.isInteger(e)}var zr=({value:e})=>JSON.stringify(e),zp=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:zr},{identify:e=>e==null,createNode:()=>new Vp.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:zr},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:zr},{identify:ll,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:i})=>i?BigInt(e):parseInt(e,10),stringify:({value:e})=>ll(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:zr}],Jp={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Gp=[qp.map,Wp.seq].concat(zp,Jp);ul.schema=Gp});var qa=y(fl=>{"use strict";var gi=dr("buffer"),Va=I(),Up=fi(),Kp={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof gi.Buffer=="function")return gi.Buffer.from(e,"base64");if(typeof atob=="function"){let i=atob(e.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 t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:i},r,n,a){if(!i)return"";let o=i,s;if(typeof gi.Buffer=="function")s=o instanceof gi.Buffer?o.toString("base64"):gi.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Va.Scalar.BLOCK_LITERAL),t!==Va.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(s.length/c),d=new Array(l);for(let f=0,u=0;f<l;++f,u+=c)d[f]=s.substr(u,c);s=d.join(t===Va.Scalar.BLOCK_LITERAL?`
55
- `:" ")}return Up.stringifyString({comment:e,type:t,value:s},r,n,a)}};fl.binary=Kp});var Ur=y(Gr=>{"use strict";var Jr=P(),Wa=Je(),Yp=I(),Xp=Ke();function hl(e,t){if(Jr.isSeq(e))for(let i=0;i<e.items.length;++i){let r=e.items[i];if(!Jr.isPair(r)){if(Jr.isMap(r)){r.items.length>1&&t("Each pair must have its own sequence indicator");let n=r.items[0]||new Wa.Pair(new Yp.Scalar(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
54
+ ${n}${p}`}else return`${d}${o}${f.join(" ")}${o}${p}`}function Vr({indent:e,options:{commentString:t}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let a=Mr.indentComment(t(r),e);i.push(a.trimStart())}}dl.stringifyCollection=Gp});var Xe=y(Ga=>{"use strict";var Yp=za(),Xp=Va(),Qp=Ar(),Ye=P(),Wr=Ke(),Zp=$();function ki(e,t){let i=Ye.isScalar(t)?t.value:t;for(let r of e)if(Ye.isPair(r)&&(r.key===t||r.key===i||Ye.isScalar(r.key)&&r.key.value===i))return r}var Ja=class extends Qp.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Ye.MAP,t),this.items=[]}static from(t,i,r){let{keepUndefined:n,replacer:a}=r,o=new this(t),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(Wr.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 t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,i){let r;Ye.isPair(t)?r=t:!t||typeof t!="object"||!("key"in t)?r=new Wr.Pair(t,t?.value):r=new Wr.Pair(t.key,t.value);let n=ki(this.items,r.key),a=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);Ye.isScalar(n.value)&&Zp.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(t){let i=ki(this.items,t);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(t,i){let n=ki(this.items,t)?.value;return(!i&&Ye.isScalar(n)?n.value:n)??void 0}has(t){return!!ki(this.items,t)}set(t,i){this.add(new Wr.Pair(t,i),!0)}toJSON(t,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let a of this.items)Xp.addPairToJSMap(i,n,a);return n}toString(t,i,r){if(!t)return JSON.stringify(this);for(let n of this.items)if(!Ye.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Yp.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:r,onComment:i})}};Ga.YAMLMap=Ja;Ga.findPair=ki});var $t=y(hl=>{"use strict";var em=P(),fl=Xe(),tm={collection:"map",default:!0,nodeClass:fl.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return em.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,i)=>fl.YAMLMap.from(e,t,i)};hl.map=tm});var Qe=y(pl=>{"use strict";var im=mi(),rm=za(),nm=Ar(),Jr=P(),am=$(),om=ze(),Ua=class extends nm.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Jr.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let i=zr(t);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(t,i){let r=zr(t);if(typeof r!="number")return;let n=this.items[r];return!i&&Jr.isScalar(n)?n.value:n}has(t){let i=zr(t);return typeof i=="number"&&i<this.items.length}set(t,i){let r=zr(t);if(typeof r!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[r];Jr.isScalar(n)&&am.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(t,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let a of this.items)r.push(om.toJS(a,String(n++),i));return r}toString(t,i,r){return t?rm.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(t,i,r){let{replacer:n}=r,a=new this(t);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(im.createNode(s,void 0,r))}}return a}};function zr(e){let t=Jr.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}pl.YAMLSeq=Ua});var Ot=y(vl=>{"use strict";var sm=P(),ml=Qe(),cm={collection:"seq",default:!0,nodeClass:ml.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return sm.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,i)=>ml.YAMLSeq.from(e,t,i)};vl.seq=cm});var Si=y(gl=>{"use strict";var lm=yi(),um={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,i,r){return t=Object.assign({actualString:!0},t),lm.stringifyString(e,t,i,r)}};gl.string=um});var Gr=y(Nl=>{"use strict";var wl=$(),yl={identify:e=>e==null,createNode:()=>new wl.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new wl.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&yl.test.test(e)?e:t.options.nullStr};Nl.nullTag=yl});var Ka=y(kl=>{"use strict";var dm=$(),bl={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new dm.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},i){if(e&&bl.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?i.options.trueStr:i.options.falseStr}};kl.boolTag=bl});var Ht=y(Sl=>{"use strict";function fm({format:e,minFractionDigits:t,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(!e&&t&&(!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=t-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Sl.stringifyNumber=fm});var Xa=y(Ur=>{"use strict";var hm=$(),Ya=Ht(),pm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ya.stringifyNumber},mm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ya.stringifyNumber(e)}},vm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new hm.Scalar(parseFloat(e)),i=e.indexOf(".");return i!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-i-1),t},stringify:Ya.stringifyNumber};Ur.float=vm;Ur.floatExp=mm;Ur.floatNaN=pm});var Za=y(Yr=>{"use strict";var El=Ht(),Kr=e=>typeof e=="bigint"||Number.isInteger(e),Qa=(e,t,i,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),i);function Pl(e,t,i){let{value:r}=e;return Kr(r)&&r>=0?i+r.toString(t):El.stringifyNumber(e)}var gm={identify:e=>Kr(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,i)=>Qa(e,2,8,i),stringify:e=>Pl(e,8,"0o")},wm={identify:Kr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,i)=>Qa(e,0,10,i),stringify:El.stringifyNumber},ym={identify:e=>Kr(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,i)=>Qa(e,2,16,i),stringify:e=>Pl(e,16,"0x")};Yr.int=wm;Yr.intHex=ym;Yr.intOct=gm});var Rl=y(xl=>{"use strict";var Nm=$t(),bm=Gr(),km=Ot(),Sm=Si(),Em=Ka(),eo=Xa(),to=Za(),Pm=[Nm.map,km.seq,Sm.string,bm.nullTag,Em.boolTag,to.intOct,to.int,to.intHex,eo.floatNaN,eo.floatExp,eo.float];xl.schema=Pm});var _l=y(Al=>{"use strict";var xm=$(),Rm=$t(),Cm=Ot();function Cl(e){return typeof e=="bigint"||Number.isInteger(e)}var Xr=({value:e})=>JSON.stringify(e),Am=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Xr},{identify:e=>e==null,createNode:()=>new xm.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Xr},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Xr},{identify:Cl,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:i})=>i?BigInt(e):parseInt(e,10),stringify:({value:e})=>Cl(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Xr}],_m={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Tm=[Rm.map,Cm.seq].concat(Am,_m);Al.schema=Tm});var ro=y(Tl=>{"use strict";var Ei=wr("buffer"),io=$(),Im=yi(),jm={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Ei.Buffer=="function")return Ei.Buffer.from(e,"base64");if(typeof atob=="function"){let i=atob(e.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 t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:i},r,n,a){if(!i)return"";let o=i,s;if(typeof Ei.Buffer=="function")s=o instanceof Ei.Buffer?o.toString("base64"):Ei.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=io.Scalar.BLOCK_LITERAL),t!==io.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(s.length/c),u=new Array(l);for(let f=0,d=0;f<l;++f,d+=c)u[f]=s.substr(d,c);s=u.join(t===io.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return Im.stringifyString({comment:e,type:t,value:s},r,n,a)}};Tl.binary=jm});var en=y(Zr=>{"use strict";var Qr=P(),no=Ke(),$m=$(),Om=Qe();function Il(e,t){if(Qr.isSeq(e))for(let i=0;i<e.items.length;++i){let r=e.items[i];if(!Qr.isPair(r)){if(Qr.isMap(r)){r.items.length>1&&t("Each pair must have its own sequence indicator");let n=r.items[0]||new no.Pair(new $m.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}e.items[i]=Jr.isPair(r)?r:new Wa.Pair(r)}}else t("Expected a sequence for this tag");return e}function pl(e,t,i){let{replacer:r}=i,n=new Xp.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let a=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof r=="function"&&(o=r.call(t,String(a++),o));let s,c;if(Array.isArray(o))if(o.length===2)s=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)s=l[0],c=o[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=o;n.items.push(Wa.createPair(s,c,i))}return n}var Qp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:hl,createNode:pl};Gr.createPairs=pl;Gr.pairs=Qp;Gr.resolvePairs=hl});var Ga=y(Ja=>{"use strict";var ml=P(),za=Ve(),wi=Ue(),Zp=Ke(),vl=Ur(),ot=class e extends Zp.YAMLSeq{constructor(){super(),this.add=wi.YAMLMap.prototype.add.bind(this),this.delete=wi.YAMLMap.prototype.delete.bind(this),this.get=wi.YAMLMap.prototype.get.bind(this),this.has=wi.YAMLMap.prototype.has.bind(this),this.set=wi.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,i){if(!i)return super.toJSON(t);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let a,o;if(ml.isPair(n)?(a=za.toJS(n.key,"",i),o=za.toJS(n.value,a,i)):a=za.toJS(n,"",i),r.has(a))throw new Error("Ordered maps must not include duplicate keys");r.set(a,o)}return r}static from(t,i,r){let n=vl.createPairs(t,i,r),a=new this;return a.items=n.items,a}};ot.tag="tag:yaml.org,2002:omap";var em={collection:"seq",identify:e=>e instanceof Map,nodeClass:ot,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let i=vl.resolvePairs(e,t),r=[];for(let{key:n}of i.items)ml.isScalar(n)&&(r.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new ot,i)},createNode:(e,t,i)=>ot.from(e,t,i)};Ja.YAMLOMap=ot;Ja.omap=em});var bl=y(Ua=>{"use strict";var gl=I();function wl({value:e,source:t},i){return t&&(e?yl:Nl).test.test(t)?t:e?i.options.trueStr:i.options.falseStr}var yl={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new gl.Scalar(!0),stringify:wl},Nl={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new gl.Scalar(!1),stringify:wl};Ua.falseTag=Nl;Ua.trueTag=yl});var kl=y(Kr=>{"use strict";var tm=I(),Ka=_t(),im={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ka.stringifyNumber},rm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ka.stringifyNumber(e)}},nm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new tm.Scalar(parseFloat(e.replace(/_/g,""))),i=e.indexOf(".");if(i!==-1){let r=e.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(t.minFractionDigits=r.length)}return t},stringify:Ka.stringifyNumber};Kr.float=nm;Kr.floatExp=rm;Kr.floatNaN=im});var El=y(Ni=>{"use strict";var Sl=_t(),yi=e=>typeof e=="bigint"||Number.isInteger(e);function Yr(e,t,i,{intAsBigInt:r}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),r){switch(i){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let a=parseInt(e,i);return n==="-"?-1*a:a}function Ya(e,t,i){let{value:r}=e;if(yi(r)){let n=r.toString(t);return r<0?"-"+i+n.substr(1):i+n}return Sl.stringifyNumber(e)}var am={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,i)=>Yr(e,2,2,i),stringify:e=>Ya(e,2,"0b")},om={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,i)=>Yr(e,1,8,i),stringify:e=>Ya(e,8,"0")},sm={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,i)=>Yr(e,0,10,i),stringify:Sl.stringifyNumber},cm={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,i)=>Yr(e,2,16,i),stringify:e=>Ya(e,16,"0x")};Ni.int=sm;Ni.intBin=am;Ni.intHex=cm;Ni.intOct=om});var Qa=y(Xa=>{"use strict";var Zr=P(),Xr=Je(),Qr=Ue(),st=class e extends Qr.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let i;Zr.isPair(t)?i=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?i=new Xr.Pair(t.key,null):i=new Xr.Pair(t,null),Qr.findPair(this.items,i.key)||this.items.push(i)}get(t,i){let r=Qr.findPair(this.items,t);return!i&&Zr.isPair(r)?Zr.isScalar(r.key)?r.key.value:r.key:r}set(t,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=Qr.findPair(this.items,t);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new Xr.Pair(t))}toJSON(t,i){return super.toJSON(t,i,Set)}toString(t,i,r){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(t,i,r){let{replacer:n}=r,a=new this(t);if(i&&Symbol.iterator in Object(i))for(let o of i)typeof n=="function"&&(o=n.call(i,o,o)),a.items.push(Xr.createPair(o,null,r));return a}};st.tag="tag:yaml.org,2002:set";var lm={collection:"map",identify:e=>e instanceof Set,nodeClass:st,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,i)=>st.from(e,t,i),resolve(e,t){if(Zr.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new st,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Xa.YAMLSet=st;Xa.set=lm});var eo=y(en=>{"use strict";var um=_t();function Za(e,t){let i=e[0],r=i==="-"||i==="+"?e.substring(1):e,n=o=>t?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 Pl(e){let{value:t}=e,i=o=>o;if(typeof t=="bigint")i=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return um.stringifyNumber(e);let r="";t<0&&(r="-",t*=i(-1));let n=i(60),a=[t%n];return t<60?a.unshift(0):(t=(t-a[0])/n,a.unshift(t%n),t>=60&&(t=(t-a[0])/n,a.unshift(t))),r+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var dm={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:i})=>Za(e,i),stringify:Pl},fm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Za(e,!1),stringify:Pl},xl={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(xl.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-1,n,a||0,o||0,s||0,c),d=t[8];if(d&&d!=="Z"){let f=Za(d,!1);Math.abs(f)<30&&(f*=60),l-=6e4*f}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};en.floatTime=fm;en.intTime=dm;en.timestamp=xl});var Al=y(Cl=>{"use strict";var hm=Ct(),pm=Mr(),mm=At(),vm=vi(),gm=qa(),Rl=bl(),to=kl(),tn=El(),wm=jr(),ym=Ga(),Nm=Ur(),bm=Qa(),io=eo(),km=[hm.map,mm.seq,vm.string,pm.nullTag,Rl.trueTag,Rl.falseTag,tn.intBin,tn.intOct,tn.int,tn.intHex,to.floatNaN,to.floatExp,to.float,gm.binary,wm.merge,ym.omap,Nm.pairs,bm.set,io.intTime,io.floatTime,io.timestamp];Cl.schema=km});var Ll=y(ao=>{"use strict";var jl=Ct(),Sm=Mr(),$l=At(),Em=vi(),Pm=Oa(),ro=Da(),no=La(),xm=cl(),Rm=dl(),Ol=qa(),bi=jr(),Hl=Ga(),Dl=Ur(),_l=Al(),Bl=Qa(),rn=eo(),Tl=new Map([["core",xm.schema],["failsafe",[jl.map,$l.seq,Em.string]],["json",Rm.schema],["yaml11",_l.schema],["yaml-1.1",_l.schema]]),Il={binary:Ol.binary,bool:Pm.boolTag,float:ro.float,floatExp:ro.floatExp,floatNaN:ro.floatNaN,floatTime:rn.floatTime,int:no.int,intHex:no.intHex,intOct:no.intOct,intTime:rn.intTime,map:jl.map,merge:bi.merge,null:Sm.nullTag,omap:Hl.omap,pairs:Dl.pairs,seq:$l.seq,set:Bl.set,timestamp:rn.timestamp},Cm={"tag:yaml.org,2002:binary":Ol.binary,"tag:yaml.org,2002:merge":bi.merge,"tag:yaml.org,2002:omap":Hl.omap,"tag:yaml.org,2002:pairs":Dl.pairs,"tag:yaml.org,2002:set":Bl.set,"tag:yaml.org,2002:timestamp":rn.timestamp};function Am(e,t,i){let r=Tl.get(t);if(r&&!e)return i&&!r.includes(bi.merge)?r.concat(bi.merge):r.slice();let n=r;if(!n)if(Array.isArray(e))n=[];else{let a=Array.from(Tl.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`)}if(Array.isArray(e))for(let a of e)n=n.concat(a);else typeof e=="function"&&(n=e(n.slice()));return i&&(n=n.concat(bi.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Il[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Il).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}ao.coreKnownTags=Cm;ao.getTags=Am});var co=y(Fl=>{"use strict";var oo=P(),_m=Ct(),Tm=At(),Im=vi(),nn=Ll(),jm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,so=class e{constructor({compat:t,customTags:i,merge:r,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(t)?nn.getTags(t,"compat"):t?nn.getTags(null,t):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?nn.coreKnownTags:{},this.tags=nn.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,oo.MAP,{value:_m.map}),Object.defineProperty(this,oo.SCALAR,{value:Im.string}),Object.defineProperty(this,oo.SEQ,{value:Tm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?jm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};Fl.Schema=so});var Vl=y(Ml=>{"use strict";var $m=P(),lo=hi(),ki=li();function Om(e,t){let i=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);c?(i.push(c),r=!0):e.directives.docStart&&(r=!0)}r&&i.push("---");let n=lo.createStringifyContext(e,t),{commentString:a}=n.options;if(e.commentBefore){i.length!==1&&i.unshift("");let c=a(e.commentBefore);i.unshift(ki.indentComment(c,""))}let o=!1,s=null;if(e.contents){if($m.isNode(e.contents)){if(e.contents.spaceBefore&&r&&i.push(""),e.contents.commentBefore){let d=a(e.contents.commentBefore);i.push(ki.indentComment(d,""))}n.forceBlockIndent=!!e.comment,s=e.contents.comment}let c=s?void 0:()=>o=!0,l=lo.stringify(e.contents,n,()=>s=null,c);s&&(l+=ki.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(lo.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=a(e.comment);c.includes(`
58
- `)?(i.push("..."),i.push(ki.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=e.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&i[i.length-1]!==""&&i.push(""),i.push(ki.indentComment(a(c),"")))}return i.join(`
57
+ ${a.comment}`:r.comment}r=n}e.items[i]=Qr.isPair(r)?r:new no.Pair(r)}}else t("Expected a sequence for this tag");return e}function jl(e,t,i){let{replacer:r}=i,n=new Om.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let a=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof r=="function"&&(o=r.call(t,String(a++),o));let s,c;if(Array.isArray(o))if(o.length===2)s=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)s=l[0],c=o[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=o;n.items.push(no.createPair(s,c,i))}return n}var Hm={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Il,createNode:jl};Zr.createPairs=jl;Zr.pairs=Hm;Zr.resolvePairs=Il});var so=y(oo=>{"use strict";var $l=P(),ao=ze(),Pi=Xe(),Dm=Qe(),Ol=en(),ft=class e extends Dm.YAMLSeq{constructor(){super(),this.add=Pi.YAMLMap.prototype.add.bind(this),this.delete=Pi.YAMLMap.prototype.delete.bind(this),this.get=Pi.YAMLMap.prototype.get.bind(this),this.has=Pi.YAMLMap.prototype.has.bind(this),this.set=Pi.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,i){if(!i)return super.toJSON(t);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let a,o;if($l.isPair(n)?(a=ao.toJS(n.key,"",i),o=ao.toJS(n.value,a,i)):a=ao.toJS(n,"",i),r.has(a))throw new Error("Ordered maps must not include duplicate keys");r.set(a,o)}return r}static from(t,i,r){let n=Ol.createPairs(t,i,r),a=new this;return a.items=n.items,a}};ft.tag="tag:yaml.org,2002:omap";var Bm={collection:"seq",identify:e=>e instanceof Map,nodeClass:ft,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let i=Ol.resolvePairs(e,t),r=[];for(let{key:n}of i.items)$l.isScalar(n)&&(r.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new ft,i)},createNode:(e,t,i)=>ft.from(e,t,i)};oo.YAMLOMap=ft;oo.omap=Bm});var ql=y(co=>{"use strict";var Hl=$();function Dl({value:e,source:t},i){return t&&(e?Bl:Ll).test.test(t)?t:e?i.options.trueStr:i.options.falseStr}var Bl={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Hl.Scalar(!0),stringify:Dl},Ll={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Hl.Scalar(!1),stringify:Dl};co.falseTag=Ll;co.trueTag=Bl});var Fl=y(tn=>{"use strict";var Lm=$(),lo=Ht(),qm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:lo.stringifyNumber},Fm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():lo.stringifyNumber(e)}},Mm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Lm.Scalar(parseFloat(e.replace(/_/g,""))),i=e.indexOf(".");if(i!==-1){let r=e.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(t.minFractionDigits=r.length)}return t},stringify:lo.stringifyNumber};tn.float=Mm;tn.floatExp=Fm;tn.floatNaN=qm});var Vl=y(Ri=>{"use strict";var Ml=Ht(),xi=e=>typeof e=="bigint"||Number.isInteger(e);function rn(e,t,i,{intAsBigInt:r}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),r){switch(i){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let a=parseInt(e,i);return n==="-"?-1*a:a}function uo(e,t,i){let{value:r}=e;if(xi(r)){let n=r.toString(t);return r<0?"-"+i+n.substr(1):i+n}return Ml.stringifyNumber(e)}var Vm={identify:xi,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,i)=>rn(e,2,2,i),stringify:e=>uo(e,2,"0b")},Wm={identify:xi,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,i)=>rn(e,1,8,i),stringify:e=>uo(e,8,"0")},zm={identify:xi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,i)=>rn(e,0,10,i),stringify:Ml.stringifyNumber},Jm={identify:xi,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,i)=>rn(e,2,16,i),stringify:e=>uo(e,16,"0x")};Ri.int=zm;Ri.intBin=Vm;Ri.intHex=Jm;Ri.intOct=Wm});var ho=y(fo=>{"use strict";var on=P(),nn=Ke(),an=Xe(),ht=class e extends an.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let i;on.isPair(t)?i=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?i=new nn.Pair(t.key,null):i=new nn.Pair(t,null),an.findPair(this.items,i.key)||this.items.push(i)}get(t,i){let r=an.findPair(this.items,t);return!i&&on.isPair(r)?on.isScalar(r.key)?r.key.value:r.key:r}set(t,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=an.findPair(this.items,t);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new nn.Pair(t))}toJSON(t,i){return super.toJSON(t,i,Set)}toString(t,i,r){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(t,i,r){let{replacer:n}=r,a=new this(t);if(i&&Symbol.iterator in Object(i))for(let o of i)typeof n=="function"&&(o=n.call(i,o,o)),a.items.push(nn.createPair(o,null,r));return a}};ht.tag="tag:yaml.org,2002:set";var Gm={collection:"map",identify:e=>e instanceof Set,nodeClass:ht,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,i)=>ht.from(e,t,i),resolve(e,t){if(on.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new ht,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};fo.YAMLSet=ht;fo.set=Gm});var mo=y(sn=>{"use strict";var Um=Ht();function po(e,t){let i=e[0],r=i==="-"||i==="+"?e.substring(1):e,n=o=>t?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 Wl(e){let{value:t}=e,i=o=>o;if(typeof t=="bigint")i=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Um.stringifyNumber(e);let r="";t<0&&(r="-",t*=i(-1));let n=i(60),a=[t%n];return t<60?a.unshift(0):(t=(t-a[0])/n,a.unshift(t%n),t>=60&&(t=(t-a[0])/n,a.unshift(t))),r+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Km={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:i})=>po(e,i),stringify:Wl},Ym={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>po(e,!1),stringify:Wl},zl={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(zl.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-1,n,a||0,o||0,s||0,c),u=t[8];if(u&&u!=="Z"){let f=po(u,!1);Math.abs(f)<30&&(f*=60),l-=6e4*f}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};sn.floatTime=Ym;sn.intTime=Km;sn.timestamp=zl});var Ul=y(Gl=>{"use strict";var Xm=$t(),Qm=Gr(),Zm=Ot(),ev=Si(),tv=ro(),Jl=ql(),vo=Fl(),cn=Vl(),iv=Lr(),rv=so(),nv=en(),av=ho(),go=mo(),ov=[Xm.map,Zm.seq,ev.string,Qm.nullTag,Jl.trueTag,Jl.falseTag,cn.intBin,cn.intOct,cn.int,cn.intHex,vo.floatNaN,vo.floatExp,vo.float,tv.binary,iv.merge,rv.omap,nv.pairs,av.set,go.intTime,go.floatTime,go.timestamp];Gl.schema=ov});var nu=y(No=>{"use strict";var Ql=$t(),sv=Gr(),Zl=Ot(),cv=Si(),lv=Ka(),wo=Xa(),yo=Za(),uv=Rl(),dv=_l(),eu=ro(),Ci=Lr(),tu=so(),iu=en(),Kl=Ul(),ru=ho(),ln=mo(),Yl=new Map([["core",uv.schema],["failsafe",[Ql.map,Zl.seq,cv.string]],["json",dv.schema],["yaml11",Kl.schema],["yaml-1.1",Kl.schema]]),Xl={binary:eu.binary,bool:lv.boolTag,float:wo.float,floatExp:wo.floatExp,floatNaN:wo.floatNaN,floatTime:ln.floatTime,int:yo.int,intHex:yo.intHex,intOct:yo.intOct,intTime:ln.intTime,map:Ql.map,merge:Ci.merge,null:sv.nullTag,omap:tu.omap,pairs:iu.pairs,seq:Zl.seq,set:ru.set,timestamp:ln.timestamp},fv={"tag:yaml.org,2002:binary":eu.binary,"tag:yaml.org,2002:merge":Ci.merge,"tag:yaml.org,2002:omap":tu.omap,"tag:yaml.org,2002:pairs":iu.pairs,"tag:yaml.org,2002:set":ru.set,"tag:yaml.org,2002:timestamp":ln.timestamp};function hv(e,t,i){let r=Yl.get(t);if(r&&!e)return i&&!r.includes(Ci.merge)?r.concat(Ci.merge):r.slice();let n=r;if(!n)if(Array.isArray(e))n=[];else{let a=Array.from(Yl.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`)}if(Array.isArray(e))for(let a of e)n=n.concat(a);else typeof e=="function"&&(n=e(n.slice()));return i&&(n=n.concat(Ci.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Xl[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Xl).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}No.coreKnownTags=fv;No.getTags=hv});var So=y(au=>{"use strict";var bo=P(),pv=$t(),mv=Ot(),vv=Si(),un=nu(),gv=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,ko=class e{constructor({compat:t,customTags:i,merge:r,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(t)?un.getTags(t,"compat"):t?un.getTags(null,t):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?un.coreKnownTags:{},this.tags=un.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,bo.MAP,{value:pv.map}),Object.defineProperty(this,bo.SCALAR,{value:vv.string}),Object.defineProperty(this,bo.SEQ,{value:mv.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?gv:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};au.Schema=ko});var su=y(ou=>{"use strict";var wv=P(),Eo=Ni(),Ai=vi();function yv(e,t){let i=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);c?(i.push(c),r=!0):e.directives.docStart&&(r=!0)}r&&i.push("---");let n=Eo.createStringifyContext(e,t),{commentString:a}=n.options;if(e.commentBefore){i.length!==1&&i.unshift("");let c=a(e.commentBefore);i.unshift(Ai.indentComment(c,""))}let o=!1,s=null;if(e.contents){if(wv.isNode(e.contents)){if(e.contents.spaceBefore&&r&&i.push(""),e.contents.commentBefore){let u=a(e.contents.commentBefore);i.push(Ai.indentComment(u,""))}n.forceBlockIndent=!!e.comment,s=e.contents.comment}let c=s?void 0:()=>o=!0,l=Eo.stringify(e.contents,n,()=>s=null,c);s&&(l+=Ai.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(Eo.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=a(e.comment);c.includes(`
58
+ `)?(i.push("..."),i.push(Ai.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=e.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&i[i.length-1]!==""&&i.push(""),i.push(Ai.indentComment(a(c),"")))}return i.join(`
59
59
  `)+`
60
- `}Ml.stringifyDocument=Om});var Si=y(ql=>{"use strict";var Hm=si(),Tt=Sr(),oe=P(),Dm=Je(),Bm=Ve(),Lm=co(),Fm=Vl(),uo=yr(),Mm=pa(),Vm=ci(),fo=ha(),ho=class e{constructor(t,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,oe.NODE_TYPE,{value:oe.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 fo.Directives({version:o}),this.setSchema(o,r),this.contents=t===void 0?null:this.createNode(t,n,r)}clone(){let t=Object.create(e.prototype,{[oe.NODE_TYPE]:{value:oe.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=oe.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){It(this.contents)&&this.contents.add(t)}addIn(t,i){It(this.contents)&&this.contents.addIn(t,i)}createAlias(t,i){if(!t.anchor){let r=uo.anchorNames(this);t.anchor=!i||r.has(i)?uo.findNewAnchor(i||"a",r):i}return new Hm.Alias(t.anchor)}createNode(t,i,r){let n;if(typeof i=="function")t=i.call({"":t},"",t),n=i;else if(Array.isArray(i)){let m=N=>typeof N=="number"||N instanceof String||N instanceof Number,g=i.filter(m).map(String);g.length>0&&(i=i.concat(g)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:d}=r??{},{onAnchor:f,setAnchors:u,sourceObjects:p}=uo.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=Vm.createNode(t,d,v);return s&&oe.isCollection(h)&&(h.flow=!0),u(),h}createPair(t,i,r={}){let n=this.createNode(t,null,r),a=this.createNode(i,null,r);return new Dm.Pair(n,a)}delete(t){return It(this.contents)?this.contents.delete(t):!1}deleteIn(t){return Tt.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):It(this.contents)?this.contents.deleteIn(t):!1}get(t,i){return oe.isCollection(this.contents)?this.contents.get(t,i):void 0}getIn(t,i){return Tt.isEmptyPath(t)?!i&&oe.isScalar(this.contents)?this.contents.value:this.contents:oe.isCollection(this.contents)?this.contents.getIn(t,i):void 0}has(t){return oe.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return Tt.isEmptyPath(t)?this.contents!==void 0:oe.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,i){this.contents==null?this.contents=Tt.collectionFromPath(this.schema,[t],i):It(this.contents)&&this.contents.set(t,i)}setIn(t,i){Tt.isEmptyPath(t)?this.contents=i:this.contents==null?this.contents=Tt.collectionFromPath(this.schema,Array.from(t),i):It(this.contents)&&this.contents.setIn(t,i)}setSchema(t,i={}){typeof t=="number"&&(t=String(t));let r;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new fo.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new fo.Directives({version:t}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let n=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new Lm.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!t,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=Bm.toJS(this.contents,i??"",s);if(typeof a=="function")for(let{count:l,res:d}of s.anchors.values())a(d,l);return typeof o=="function"?Mm.applyReviver(o,{"":c},"",c):c}toJSON(t,i){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:i})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let i=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return Fm.stringifyDocument(this,t)}};function It(e){if(oe.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}ql.Document=ho});var xi=y(Pi=>{"use strict";var Ei=class extends Error{constructor(t,i,r,n){super(),this.name=t,this.code=r,this.message=n,this.pos=i}},po=class extends Ei{constructor(t,i,r){super("YAMLParseError",t,i,r)}},mo=class extends Ei{constructor(t,i,r){super("YAMLWarning",t,i,r)}},qm=(e,t)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>t.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let a=n-1,o=e.substring(t.lineStarts[r-1],t.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=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);s.length>80&&(s=s.substring(0,79)+`…
60
+ `}ou.stringifyDocument=yv});var _i=y(cu=>{"use strict";var Nv=pi(),Dt=Ar(),le=P(),bv=Ke(),kv=ze(),Sv=So(),Ev=su(),Po=Pr(),Pv=Ca(),xv=mi(),xo=Ra(),Ro=class e{constructor(t,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,le.NODE_TYPE,{value:le.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 xo.Directives({version:o}),this.setSchema(o,r),this.contents=t===void 0?null:this.createNode(t,n,r)}clone(){let t=Object.create(e.prototype,{[le.NODE_TYPE]:{value:le.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=le.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){Bt(this.contents)&&this.contents.add(t)}addIn(t,i){Bt(this.contents)&&this.contents.addIn(t,i)}createAlias(t,i){if(!t.anchor){let r=Po.anchorNames(this);t.anchor=!i||r.has(i)?Po.findNewAnchor(i||"a",r):i}return new Nv.Alias(t.anchor)}createNode(t,i,r){let n;if(typeof i=="function")t=i.call({"":t},"",t),n=i;else if(Array.isArray(i)){let m=N=>typeof N=="number"||N instanceof String||N instanceof Number,g=i.filter(m).map(String);g.length>0&&(i=i.concat(g)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:u}=r??{},{onAnchor:f,setAnchors:d,sourceObjects:p}=Po.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=xv.createNode(t,u,v);return s&&le.isCollection(h)&&(h.flow=!0),d(),h}createPair(t,i,r={}){let n=this.createNode(t,null,r),a=this.createNode(i,null,r);return new bv.Pair(n,a)}delete(t){return Bt(this.contents)?this.contents.delete(t):!1}deleteIn(t){return Dt.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):Bt(this.contents)?this.contents.deleteIn(t):!1}get(t,i){return le.isCollection(this.contents)?this.contents.get(t,i):void 0}getIn(t,i){return Dt.isEmptyPath(t)?!i&&le.isScalar(this.contents)?this.contents.value:this.contents:le.isCollection(this.contents)?this.contents.getIn(t,i):void 0}has(t){return le.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return Dt.isEmptyPath(t)?this.contents!==void 0:le.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,i){this.contents==null?this.contents=Dt.collectionFromPath(this.schema,[t],i):Bt(this.contents)&&this.contents.set(t,i)}setIn(t,i){Dt.isEmptyPath(t)?this.contents=i:this.contents==null?this.contents=Dt.collectionFromPath(this.schema,Array.from(t),i):Bt(this.contents)&&this.contents.setIn(t,i)}setSchema(t,i={}){typeof t=="number"&&(t=String(t));let r;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new xo.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new xo.Directives({version:t}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let n=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new Sv.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!t,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=kv.toJS(this.contents,i??"",s);if(typeof a=="function")for(let{count:l,res:u}of s.anchors.values())a(u,l);return typeof o=="function"?Pv.applyReviver(o,{"":c},"",c):c}toJSON(t,i){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:i})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let i=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return Ev.stringifyDocument(this,t)}};function Bt(e){if(le.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}cu.Document=Ro});var ji=y(Ii=>{"use strict";var Ti=class extends Error{constructor(t,i,r,n){super(),this.name=t,this.code=r,this.message=n,this.pos=i}},Co=class extends Ti{constructor(t,i,r){super("YAMLParseError",t,i,r)}},Ao=class extends Ti{constructor(t,i,r){super("YAMLWarning",t,i,r)}},Rv=(e,t)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>t.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let a=n-1,o=e.substring(t.lineStarts[r-1],t.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=e.substring(t.lineStarts[r-2],t.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
- `}};Pi.YAMLError=Ei;Pi.YAMLParseError=po;Pi.YAMLWarning=mo;Pi.prettifyError=qm});var Ri=y(Wl=>{"use strict";function Wm(e,{flow:t,indicator:i,next:r,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,d=s,f="",u="",p=!1,v=!1,h=null,m=null,g=null,N=null,w=null,k=null,S=null;for(let b of e)switch(v&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&a(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&b.type!=="comment"&&b.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),b.type){case"space":!t&&(i!=="doc-start"||r?.type!=="flow-collection")&&b.source.includes(" ")&&(h=b),d=!0;break;case"comment":{d||a(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let $=b.source.substring(1)||" ";f?f+=u+$:f=$,u="",l=!1;break}case"newline":l?f?f+=b.source:(!k||i!=="seq-item-ind")&&(c=!0):u+=b.source,l=!0,p=!0,(m||g)&&(N=b),d=!0;break;case"anchor":m&&a(b,"MULTIPLE_ANCHORS","A node can have at most one anchor"),b.source.endsWith(":")&&a(b.offset+b.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=b,S??(S=b.offset),l=!1,d=!1,v=!0;break;case"tag":{g&&a(b,"MULTIPLE_TAGS","A node can have at most one tag"),g=b,S??(S=b.offset),l=!1,d=!1,v=!0;break}case i:(m||g)&&a(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),k&&a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${t??"collection"}`),k=b,l=i==="seq-item-ind"||i==="explicit-key-ind",d=!1;break;case"comma":if(t){w&&a(b,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),w=b,l=!1,d=!1;break}default:a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,d=!1}let E=e[e.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:w,found:k,spaceBefore:c,comment:f,hasNewline:p,anchor:m,tag:g,newlineAfterProp:N,end:C,start:S??C}}Wl.resolveProps=Wm});var an=y(zl=>{"use strict";function vo(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
66
- `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let i of t.start)if(i.type==="newline")return!0;if(t.sep){for(let i of t.sep)if(i.type==="newline")return!0}if(vo(t.key)||vo(t.value))return!0}return!1;default:return!0}}zl.containsNewline=vo});var go=y(Jl=>{"use strict";var zm=an();function Jm(e,t,i){if(t?.type==="flow-collection"){let r=t.end[0];r.indent===e&&(r.source==="]"||r.source==="}")&&zm.containsNewline(t)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Jl.flowIndentCheck=Jm});var wo=y(Ul=>{"use strict";var Gl=P();function Gm(e,t,i){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let n=typeof r=="function"?r:(a,o)=>a===o||Gl.isScalar(a)&&Gl.isScalar(o)&&a.value===o.value;return t.some(a=>n(a.key,i))}Ul.mapIncludes=Gm});var eu=y(Zl=>{"use strict";var Kl=Je(),Um=Ue(),Yl=Ri(),Km=an(),Xl=go(),Ym=wo(),Ql="All mapping items must start at the same column";function Xm({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=a?.nodeClass??Um.YAMLMap,s=new o(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let d of r.items){let{start:f,key:u,sep:p,value:v}=d,h=Yl.resolveProps(f,{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",Ql)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
67
- `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Km.containsNewline(u))&&n(u??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",Ql);i.atKey=!0;let g=h.end,N=u?e(i,u,h,n):t(i,g,f,null,h,n);i.schema.compat&&Xl.flowIndentCheck(r.indent,u,n),i.atKey=!1,Ym.mapIncludes(i,s.items,N)&&n(g,"DUPLICATE_KEY","Map keys must be unique");let w=Yl.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(c=w.end,w.found){m&&(v?.type==="block-map"&&!w.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.options.strict&&h.start<w.found.offset-1024&&n(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=v?e(i,v,w,n):t(i,c,p,null,w,n);i.schema.compat&&Xl.flowIndentCheck(r.indent,v,n),c=k.range[2];let S=new Kl.Pair(N,k);i.options.keepSourceTokens&&(S.srcToken=d),s.items.push(S)}else{m&&n(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),w.comment&&(N.comment?N.comment+=`
68
- `+w.comment:N.comment=w.comment);let k=new Kl.Pair(N);i.options.keepSourceTokens&&(k.srcToken=d),s.items.push(k)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}Zl.resolveBlockMap=Xm});var iu=y(tu=>{"use strict";var Qm=Ke(),Zm=Ri(),ev=go();function tv({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=a?.nodeClass??Qm.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:d,value:f}of r.items){let u=Zm.resolveProps(d,{indicator:"seq-item-ind",next:f,offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||f)f?.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=f?e(i,f,u,n):t(i,u.end,d,null,u,n);i.schema.compat&&ev.flowIndentCheck(r.indent,f,n),c=p.range[2],s.items.push(p)}return s.range=[r.offset,c,l??c],s}tu.resolveBlockSeq=tv});var jt=y(ru=>{"use strict";function iv(e,t,i,r){let n="";if(e){let a=!1,o="";for(let s of e){let{source:c,type:l}=s;switch(l){case"space":a=!0;break;case"comment":{i&&!a&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";n?n+=o+d:n=d,o="";break}case"newline":n&&(o+=c),a=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:n,offset:t}}ru.resolveEnd=iv});var su=y(ou=>{"use strict";var rv=P(),nv=Je(),nu=Ue(),av=Ke(),ov=jt(),au=Ri(),sv=an(),cv=wo(),yo="Block collections are not allowed within flow collections",No=e=>e&&(e.type==="block-map"||e.type==="block-seq");function lv({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=r.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?nu.YAMLMap:av.YAMLSeq),l=new c(i.schema);l.flow=!0;let d=i.atRoot;d&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let f=r.offset+r.start.source.length;for(let m=0;m<r.items.length;++m){let g=r.items[m],{start:N,key:w,sep:k,value:S}=g,E=au.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:w??k?.[0],offset:f,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),f=E.end;continue}!o&&i.options.strict&&sv.containsNewline(w)&&n(w,"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 b of N)switch(b.type){case"comma":case"space":break;case"comment":C=b.source.substring(1);break e;default:break e}if(C){let b=l.items[l.items.length-1];rv.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
70
- `+C:b.comment=C,E.comment=E.comment.substring(C.length+1)}}if(!o&&!k&&!E.found){let C=S?e(i,S,E,n):t(i,E.end,k,null,E,n);l.items.push(C),f=C.range[2],No(S)&&n(C.range,"BLOCK_IN_FLOW",yo)}else{i.atKey=!0;let C=E.end,b=w?e(i,w,E,n):t(i,C,N,null,E,n);No(w)&&n(b.range,"BLOCK_IN_FLOW",yo),i.atKey=!1;let $=au.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:S,offset:b.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if($.found){if(!o&&!E.found&&i.options.strict){if(k)for(let O of k){if(O===$.found)break;if(O.type==="newline"){n(O,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<$.found.offset-1024&&n($.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${s}`):n($.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let Fe=S?e(i,S,$,n):$.found?t(i,$.end,k,null,$,n):null;Fe?No(S)&&n(Fe.range,"BLOCK_IN_FLOW",yo):$.comment&&(b.comment?b.comment+=`
71
- `+$.comment:b.comment=$.comment);let kt=new nv.Pair(b,Fe);if(i.options.keepSourceTokens&&(kt.srcToken=g),o){let O=l;cv.mapIncludes(i,O.items,b)&&n(C,"DUPLICATE_KEY","Map keys must be unique"),O.items.push(kt)}else{let O=new nu.YAMLMap(i.schema);O.flow=!0,O.items.push(kt);let rc=(Fe??b).range;O.range=[b.range[0],rc[1],rc[2]],l.items.push(O)}f=Fe?Fe.range[2]:$.end}}let u=o?"}":"]",[p,...v]=r.end,h=f;if(p?.source===u)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),g=d?`${m} must end with a ${u}`:`${m} in block collection must be sufficiently indented and end with a ${u}`;n(f,d?"MISSING_CHAR":"BAD_INDENT",g),p&&p.source.length!==1&&v.unshift(p)}if(v.length>0){let m=ov.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}ou.resolveFlowCollection=lv});var lu=y(cu=>{"use strict";var uv=P(),dv=I(),fv=Ue(),hv=Ke(),pv=eu(),mv=iu(),vv=su();function bo(e,t,i,r,n,a){let o=i.type==="block-map"?pv.resolveBlockMap(e,t,i,r,a):i.type==="block-seq"?mv.resolveBlockSeq(e,t,i,r,a):vv.resolveFlowCollection(e,t,i,r,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function gv(e,t,i,r,n){let a=r.tag,o=a?t.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===fv.YAMLMap.tagName&&s==="map"||o===hv.YAMLSeq.tagName&&s==="seq")return bo(e,t,i,n,o);let c=t.schema.tags.find(u=>u.tag===o&&u.collection===s);if(!c){let u=t.schema.knownTags[o];if(u?.collection===s)t.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),bo(e,t,i,n,o)}let l=bo(e,t,i,n,o,c),d=c.resolve?.(l,u=>n(a,"TAG_RESOLVE_FAILED",u),t.options)??l,f=uv.isNode(d)?d:new dv.Scalar(d);return f.range=l.range,f.tag=o,c?.format&&(f.format=c.format),f}cu.composeCollection=gv});var So=y(uu=>{"use strict";var ko=I();function wv(e,t,i){let r=t.offset,n=yv(t,e.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let a=n.mode===">"?ko.Scalar.BLOCK_FOLDED:ko.Scalar.BLOCK_LITERAL,o=t.source?Nv(t.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
- `.repeat(Math.max(1,o.length-1)):"",m=r+n.length;return t.source&&(m+=t.source.length),{value:h,type:a,comment:n.comment,range:[r,m,m]}}let c=t.indent+n.indent,l=t.offset+n.length,d=0;for(let h=0;h<s;++h){let[m,g]=o[h];if(g===""||g==="\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),d=h,c===0&&!e.atRoot&&i(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+g.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let f="",u="",p=!1;for(let h=0;h<d;++h)f+=o[h][0].slice(c)+`
74
- `;for(let h=d;h<s;++h){let[m,g]=o[h];l+=m.length+g.length+1;let N=g[g.length-1]==="\r";if(N&&(g=g.slice(0,-1)),g&&m.length<c){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;i(l-g.length-(N?2:1),"BAD_INDENT",k),m=""}a===ko.Scalar.BLOCK_LITERAL?(f+=u+m.slice(c)+g,u=`
75
- `):m.length>c||g[0]===" "?(u===" "?u=`
76
- `:!p&&u===`
77
- `&&(u=`
78
-
79
- `),f+=u+m.slice(c)+g,u=`
80
- `,p=!0):g===""?u===`
65
+ `}};Ii.YAMLError=Ti;Ii.YAMLParseError=Co;Ii.YAMLWarning=Ao;Ii.prettifyError=Rv});var $i=y(lu=>{"use strict";function Cv(e,{flow:t,indicator:i,next:r,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,f="",d="",p=!1,v=!1,h=null,m=null,g=null,N=null,w=null,k=null,S=null;for(let b of e)switch(v&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&a(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&b.type!=="comment"&&b.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),b.type){case"space":!t&&(i!=="doc-start"||r?.type!=="flow-collection")&&b.source.includes(" ")&&(h=b),u=!0;break;case"comment":{u||a(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let H=b.source.substring(1)||" ";f?f+=d+H:f=H,d="",l=!1;break}case"newline":l?f?f+=b.source:(!k||i!=="seq-item-ind")&&(c=!0):d+=b.source,l=!0,p=!0,(m||g)&&(N=b),u=!0;break;case"anchor":m&&a(b,"MULTIPLE_ANCHORS","A node can have at most one anchor"),b.source.endsWith(":")&&a(b.offset+b.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=b,S??(S=b.offset),l=!1,u=!1,v=!0;break;case"tag":{g&&a(b,"MULTIPLE_TAGS","A node can have at most one tag"),g=b,S??(S=b.offset),l=!1,u=!1,v=!0;break}case i:(m||g)&&a(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),k&&a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${t??"collection"}`),k=b,l=i==="seq-item-ind"||i==="explicit-key-ind",u=!1;break;case"comma":if(t){w&&a(b,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),w=b,l=!1,u=!1;break}default:a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,u=!1}let E=e[e.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:w,found:k,spaceBefore:c,comment:f,hasNewline:p,anchor:m,tag:g,newlineAfterProp:N,end:C,start:S??C}}lu.resolveProps=Cv});var dn=y(uu=>{"use strict";function _o(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
66
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let i of t.start)if(i.type==="newline")return!0;if(t.sep){for(let i of t.sep)if(i.type==="newline")return!0}if(_o(t.key)||_o(t.value))return!0}return!1;default:return!0}}uu.containsNewline=_o});var To=y(du=>{"use strict";var Av=dn();function _v(e,t,i){if(t?.type==="flow-collection"){let r=t.end[0];r.indent===e&&(r.source==="]"||r.source==="}")&&Av.containsNewline(t)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}du.flowIndentCheck=_v});var Io=y(hu=>{"use strict";var fu=P();function Tv(e,t,i){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let n=typeof r=="function"?r:(a,o)=>a===o||fu.isScalar(a)&&fu.isScalar(o)&&a.value===o.value;return t.some(a=>n(a.key,i))}hu.mapIncludes=Tv});var yu=y(wu=>{"use strict";var pu=Ke(),Iv=Xe(),mu=$i(),jv=dn(),vu=To(),$v=Io(),gu="All mapping items must start at the same column";function Ov({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=a?.nodeClass??Iv.YAMLMap,s=new o(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let u of r.items){let{start:f,key:d,sep:p,value:v}=u,h=mu.resolveProps(f,{indicator:"explicit-key-ind",next:d??p?.[0],offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0}),m=!h.found;if(m){if(d&&(d.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==r.indent&&n(c,"BAD_INDENT",gu)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||jv.containsNewline(d))&&n(d??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",gu);i.atKey=!0;let g=h.end,N=d?e(i,d,h,n):t(i,g,f,null,h,n);i.schema.compat&&vu.flowIndentCheck(r.indent,d,n),i.atKey=!1,$v.mapIncludes(i,s.items,N)&&n(g,"DUPLICATE_KEY","Map keys must be unique");let w=mu.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=w.end,w.found){m&&(v?.type==="block-map"&&!w.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.options.strict&&h.start<w.found.offset-1024&&n(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=v?e(i,v,w,n):t(i,c,p,null,w,n);i.schema.compat&&vu.flowIndentCheck(r.indent,v,n),c=k.range[2];let S=new pu.Pair(N,k);i.options.keepSourceTokens&&(S.srcToken=u),s.items.push(S)}else{m&&n(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),w.comment&&(N.comment?N.comment+=`
68
+ `+w.comment:N.comment=w.comment);let k=new pu.Pair(N);i.options.keepSourceTokens&&(k.srcToken=u),s.items.push(k)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}wu.resolveBlockMap=Ov});var bu=y(Nu=>{"use strict";var Hv=Qe(),Dv=$i(),Bv=To();function Lv({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=a?.nodeClass??Hv.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:u,value:f}of r.items){let d=Dv.resolveProps(u,{indicator:"seq-item-ind",next:f,offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||f)f?.type==="block-seq"?n(d.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(s.comment=d.comment);continue}let p=f?e(i,f,d,n):t(i,d.end,u,null,d,n);i.schema.compat&&Bv.flowIndentCheck(r.indent,f,n),c=p.range[2],s.items.push(p)}return s.range=[r.offset,c,l??c],s}Nu.resolveBlockSeq=Lv});var Lt=y(ku=>{"use strict";function qv(e,t,i,r){let n="";if(e){let a=!1,o="";for(let s of e){let{source:c,type:l}=s;switch(l){case"space":a=!0;break;case"comment":{i&&!a&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";n?n+=o+u:n=u,o="";break}case"newline":n&&(o+=c),a=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:n,offset:t}}ku.resolveEnd=qv});var xu=y(Pu=>{"use strict";var Fv=P(),Mv=Ke(),Su=Xe(),Vv=Qe(),Wv=Lt(),Eu=$i(),zv=dn(),Jv=Io(),jo="Block collections are not allowed within flow collections",$o=e=>e&&(e.type==="block-map"||e.type==="block-seq");function Gv({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=r.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Su.YAMLMap:Vv.YAMLSeq),l=new c(i.schema);l.flow=!0;let u=i.atRoot;u&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let f=r.offset+r.start.source.length;for(let m=0;m<r.items.length;++m){let g=r.items[m],{start:N,key:w,sep:k,value:S}=g,E=Eu.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:w??k?.[0],offset:f,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),f=E.end;continue}!o&&i.options.strict&&zv.containsNewline(w)&&n(w,"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 b of N)switch(b.type){case"comma":case"space":break;case"comment":C=b.source.substring(1);break e;default:break e}if(C){let b=l.items[l.items.length-1];Fv.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
70
+ `+C:b.comment=C,E.comment=E.comment.substring(C.length+1)}}if(!o&&!k&&!E.found){let C=S?e(i,S,E,n):t(i,E.end,k,null,E,n);l.items.push(C),f=C.range[2],$o(S)&&n(C.range,"BLOCK_IN_FLOW",jo)}else{i.atKey=!0;let C=E.end,b=w?e(i,w,E,n):t(i,C,N,null,E,n);$o(w)&&n(b.range,"BLOCK_IN_FLOW",jo),i.atKey=!1;let H=Eu.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:S,offset:b.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(H.found){if(!o&&!E.found&&i.options.strict){if(k)for(let D of k){if(D===H.found)break;if(D.type==="newline"){n(D,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<H.found.offset-1024&&n(H.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(H.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let Ve=S?e(i,S,H,n):H.found?t(i,H.end,k,null,H,n):null;Ve?$o(S)&&n(Ve.range,"BLOCK_IN_FLOW",jo):H.comment&&(b.comment?b.comment+=`
71
+ `+H.comment:b.comment=H.comment);let At=new Mv.Pair(b,Ve);if(i.options.keepSourceTokens&&(At.srcToken=g),o){let D=l;Jv.mapIncludes(i,D.items,b)&&n(C,"DUPLICATE_KEY","Map keys must be unique"),D.items.push(At)}else{let D=new Su.YAMLMap(i.schema);D.flow=!0,D.items.push(At);let bc=(Ve??b).range;D.range=[b.range[0],bc[1],bc[2]],l.items.push(D)}f=Ve?Ve.range[2]:H.end}}let d=o?"}":"]",[p,...v]=r.end,h=f;if(p?.source===d)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),g=u?`${m} must end with a ${d}`:`${m} in block collection must be sufficiently indented and end with a ${d}`;n(f,u?"MISSING_CHAR":"BAD_INDENT",g),p&&p.source.length!==1&&v.unshift(p)}if(v.length>0){let m=Wv.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}Pu.resolveFlowCollection=Gv});var Cu=y(Ru=>{"use strict";var Uv=P(),Kv=$(),Yv=Xe(),Xv=Qe(),Qv=yu(),Zv=bu(),eg=xu();function Oo(e,t,i,r,n,a){let o=i.type==="block-map"?Qv.resolveBlockMap(e,t,i,r,a):i.type==="block-seq"?Zv.resolveBlockSeq(e,t,i,r,a):eg.resolveFlowCollection(e,t,i,r,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function tg(e,t,i,r,n){let a=r.tag,o=a?t.directives.tagName(a.source,d=>n(a,"TAG_RESOLVE_FAILED",d)):null;if(i.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=r,v=d&&a?d.offset>a.offset?d:a:d??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===Yv.YAMLMap.tagName&&s==="map"||o===Xv.YAMLSeq.tagName&&s==="seq")return Oo(e,t,i,n,o);let c=t.schema.tags.find(d=>d.tag===o&&d.collection===s);if(!c){let d=t.schema.knownTags[o];if(d?.collection===s)t.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?n(a,"BAD_COLLECTION_TYPE",`${d.tag} used for ${s} collection, but expects ${d.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Oo(e,t,i,n,o)}let l=Oo(e,t,i,n,o,c),u=c.resolve?.(l,d=>n(a,"TAG_RESOLVE_FAILED",d),t.options)??l,f=Uv.isNode(u)?u:new Kv.Scalar(u);return f.range=l.range,f.tag=o,c?.format&&(f.format=c.format),f}Ru.composeCollection=tg});var Do=y(Au=>{"use strict";var Ho=$();function ig(e,t,i){let r=t.offset,n=rg(t,e.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let a=n.mode===">"?Ho.Scalar.BLOCK_FOLDED:Ho.Scalar.BLOCK_LITERAL,o=t.source?ng(t.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
+ `.repeat(Math.max(1,o.length-1)):"",m=r+n.length;return t.source&&(m+=t.source.length),{value:h,type:a,comment:n.comment,range:[r,m,m]}}let c=t.indent+n.indent,l=t.offset+n.length,u=0;for(let h=0;h<s;++h){let[m,g]=o[h];if(g===""||g==="\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),u=h,c===0&&!e.atRoot&&i(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+g.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let f="",d="",p=!1;for(let h=0;h<u;++h)f+=o[h][0].slice(c)+`
74
+ `;for(let h=u;h<s;++h){let[m,g]=o[h];l+=m.length+g.length+1;let N=g[g.length-1]==="\r";if(N&&(g=g.slice(0,-1)),g&&m.length<c){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;i(l-g.length-(N?2:1),"BAD_INDENT",k),m=""}a===Ho.Scalar.BLOCK_LITERAL?(f+=d+m.slice(c)+g,d=`
75
+ `):m.length>c||g[0]===" "?(d===" "?d=`
76
+ `:!p&&d===`
77
+ `&&(d=`
78
+
79
+ `),f+=d+m.slice(c)+g,d=`
80
+ `,p=!0):g===""?d===`
81
81
  `?f+=`
82
- `:u=`
83
- `:(f+=u+g,u=" ",p=!1)}switch(n.chomp){case"-":break;case"+":for(let h=s;h<o.length;++h)f+=`
82
+ `:d=`
83
+ `:(f+=d+g,d=" ",p=!1)}switch(n.chomp){case"-":break;case"+":for(let h=s;h<o.length;++h)f+=`
84
84
  `+o[h][0].slice(c);f[f.length-1]!==`
85
85
  `&&(f+=`
86
86
  `);break;default:f+=`
87
- `}let v=r+n.length+t.source.length;return{value:f,type:a,comment:n.comment,range:[r,v,v]}}function yv({offset:e,props:t},i,r){if(t[0].type!=="block-scalar-header")return r(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[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=e+u)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,d="",f=n.length;for(let u=1;u<t.length;++u){let p=t[u];switch(p.type){case"space":l=!0;case"newline":f+=p.source.length;break;case"comment":i&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=p.source.length,d=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),f+=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"&&(f+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:d,length:f}}function Nv(e){let t=e.split(/\n( *)/),i=t[0],r=i.match(/^( *)/),a=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let o=1;o<t.length;o+=2)a.push([t[o],t[o+1]]);return a}uu.resolveBlockScalar=wv});var Po=y(fu=>{"use strict";var Eo=I(),bv=jt();function kv(e,t,i){let{offset:r,type:n,source:a,end:o}=e,s,c,l=(u,p,v)=>i(r+u,p,v);switch(n){case"scalar":s=Eo.Scalar.PLAIN,c=Sv(a,l);break;case"single-quoted-scalar":s=Eo.Scalar.QUOTE_SINGLE,c=Ev(a,l);break;case"double-quoted-scalar":s=Eo.Scalar.QUOTE_DOUBLE,c=Pv(a,l);break;default:return i(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+a.length,r+a.length]}}let d=r+a.length,f=bv.resolveEnd(o,d,t,i);return{value:c,type:s,comment:f.comment,range:[r,d,f.offset]}}function Sv(e,t){let i="";switch(e[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 ${e[0]}`;break}case"@":case"`":{i=`reserved character ${e[0]}`;break}}return i&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),du(e)}function Ev(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),du(e.slice(1,-1)).replace(/''/g,"'")}function du(e){let t,i;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
+ `}let v=r+n.length+t.source.length;return{value:f,type:a,comment:n.comment,range:[r,v,v]}}function rg({offset:e,props:t},i,r){if(t[0].type!=="block-scalar-header")return r(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],a=n[0],o=0,s="",c=-1;for(let d=1;d<n.length;++d){let p=n[d];if(!s&&(p==="-"||p==="+"))s=p;else{let v=Number(p);!o&&v?o=v:c===-1&&(c=e+d)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,u="",f=n.length;for(let d=1;d<t.length;++d){let p=t[d];switch(p.type){case"space":l=!0;case"newline":f+=p.source.length;break;case"comment":i&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=p.source.length,u=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),f+=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"&&(f+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:f}}function ng(e){let t=e.split(/\n( *)/),i=t[0],r=i.match(/^( *)/),a=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let o=1;o<t.length;o+=2)a.push([t[o],t[o+1]]);return a}Au.resolveBlockScalar=ig});var Lo=y(Tu=>{"use strict";var Bo=$(),ag=Lt();function og(e,t,i){let{offset:r,type:n,source:a,end:o}=e,s,c,l=(d,p,v)=>i(r+d,p,v);switch(n){case"scalar":s=Bo.Scalar.PLAIN,c=sg(a,l);break;case"single-quoted-scalar":s=Bo.Scalar.QUOTE_SINGLE,c=cg(a,l);break;case"double-quoted-scalar":s=Bo.Scalar.QUOTE_DOUBLE,c=lg(a,l);break;default:return i(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+a.length,r+a.length]}}let u=r+a.length,f=ag.resolveEnd(o,u,t,i);return{value:c,type:s,comment:f.comment,range:[r,u,f.offset]}}function sg(e,t){let i="";switch(e[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 ${e[0]}`;break}case"@":case"`":{i=`reserved character ${e[0]}`;break}}return i&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),_u(e)}function cg(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),_u(e.slice(1,-1)).replace(/''/g,"'")}function _u(e){let t,i;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
88
88
  `,"sy"),i=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
89
89
  `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let n=r[1],a=" ",o=t.lastIndex;for(i.lastIndex=o;r=i.exec(e);)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(e),n+a+(r?.[1]??"")}function Pv(e,t){let i="";for(let r=1;r<e.length-1;++r){let n=e[r];if(!(n==="\r"&&e[r+1]===`
91
+ `:(n+=a+r[1],a=" "),o=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),n+a+(r?.[1]??"")}function lg(e,t){let i="";for(let r=1;r<e.length-1;++r){let n=e[r];if(!(n==="\r"&&e[r+1]===`
92
92
  `))if(n===`
93
- `){let{fold:a,offset:o}=xv(e,r);i+=a,r=o}else if(n==="\\"){let a=e[++r],o=Rv[a];if(o)i+=o;else if(a===`
93
+ `){let{fold:a,offset:o}=ug(e,r);i+=a,r=o}else if(n==="\\"){let a=e[++r],o=dg[a];if(o)i+=o;else if(a===`
94
94
  `)for(a=e[r+1];a===" "||a===" ";)a=e[++r+1];else if(a==="\r"&&e[r+1]===`
95
- `)for(a=e[++r+1];a===" "||a===" ";)a=e[++r+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;i+=Cv(e,r+1,s,t),r+=s}else{let s=e.substr(r-1,2);t(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let a=r,o=e[r+1];for(;o===" "||o===" ";)o=e[++r+1];o!==`
95
+ `)for(a=e[++r+1];a===" "||a===" ";)a=e[++r+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;i+=fg(e,r+1,s,t),r+=s}else{let s=e.substr(r-1,2);t(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let a=r,o=e[r+1];for(;o===" "||o===" ";)o=e[++r+1];o!==`
96
96
  `&&!(o==="\r"&&e[r+2]===`
97
- `)&&(i+=r>a?e.slice(a,r+1):n)}else i+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),i}function xv(e,t){let i="",r=e[t+1];for(;(r===" "||r===" "||r===`
97
+ `)&&(i+=r>a?e.slice(a,r+1):n)}else i+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),i}function ug(e,t){let i="",r=e[t+1];for(;(r===" "||r===" "||r===`
98
98
  `||r==="\r")&&!(r==="\r"&&e[t+2]!==`
99
99
  `);)r===`
100
100
  `&&(i+=`
101
- `),t+=1,r=e[t+1];return i||(i=" "),{fold:i,offset:t}}var Rv={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Cv(e,t,i,r){let n=e.substr(t,i),o=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=e.substr(t-2,i+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}fu.resolveFlowScalar=kv});var mu=y(pu=>{"use strict";var ct=P(),hu=I(),Av=So(),_v=Po();function Tv(e,t,i,r){let{value:n,type:a,comment:o,range:s}=t.type==="block-scalar"?Av.resolveBlockScalar(e,t,r):_v.resolveFlowScalar(t,e.options.strict,r),c=i?e.directives.tagName(i.source,f=>r(i,"TAG_RESOLVE_FAILED",f)):null,l;e.options.stringKeys&&e.atKey?l=e.schema[ct.SCALAR]:c?l=Iv(e.schema,n,c,i,r):t.type==="scalar"?l=jv(e,n,t,r):l=e.schema[ct.SCALAR];let d;try{let f=l.resolve(n,u=>r(i??t,"TAG_RESOLVE_FAILED",u),e.options);d=ct.isScalar(f)?f:new hu.Scalar(f)}catch(f){let u=f instanceof Error?f.message:String(f);r(i??t,"TAG_RESOLVE_FAILED",u),d=new hu.Scalar(n)}return d.range=s,d.source=n,a&&(d.type=a),c&&(d.tag=c),l.format&&(d.format=l.format),o&&(d.comment=o),d}function Iv(e,t,i,r,n){if(i==="!")return e[ct.SCALAR];let a=[];for(let s of e.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(t))return s;let o=e.knownTags[i];return o&&!o.collection?(e.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"),e[ct.SCALAR])}function jv({atKey:e,directives:t,schema:i},r,n,a){let o=i.tags.find(s=>(s.default===!0||e&&s.default==="key")&&s.test?.test(r))||i[ct.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[ct.SCALAR];if(o.tag!==s.tag){let c=t.tagString(o.tag),l=t.tagString(s.tag),d=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",d,!0)}}return o}pu.composeScalar=Tv});var gu=y(vu=>{"use strict";function $v(e,t,i){if(t){i??(i=t.length);for(let r=i-1;r>=0;--r){let n=t[r];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++r];n?.type==="space";)e+=n.source.length,n=t[++r];break}}return e}vu.emptyScalarPosition=$v});var Nu=y(Ro=>{"use strict";var Ov=si(),Hv=P(),Dv=lu(),wu=mu(),Bv=jt(),Lv=gu(),Fv={composeNode:yu,composeEmptyNode:xo};function yu(e,t,i,r){let n=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=i,l,d=!0;switch(t.type){case"alias":l=Mv(e,t,r),(s||c)&&r(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=wu.composeScalar(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Dv.composeCollection(Fv,e,t,i,r),s&&(l.anchor=s.source.substring(1))}catch(f){let u=f instanceof Error?f.message:String(f);r(t,"RESOURCE_EXHAUSTION",u)}break;default:{let f=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;r(t,"UNEXPECTED_TOKEN",f),d=!1}}return l??(l=xo(e,t.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!Hv.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&d&&(l.srcToken=t),l}function xo(e,t,i,r,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let d={type:"scalar",offset:Lv.emptyScalarPosition(t,i,r),indent:-1,source:""},f=wu.composeScalar(e,d,s,l);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(f.spaceBefore=!0),a&&(f.comment=a,f.range[2]=c),f}function Mv({options:e},{offset:t,source:i,end:r},n){let a=new Ov.Alias(i.substring(1));a.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(t+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+i.length,s=Bv.resolveEnd(r,o,e.strict,n);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}Ro.composeEmptyNode=xo;Ro.composeNode=yu});var Su=y(ku=>{"use strict";var Vv=Si(),bu=Nu(),qv=jt(),Wv=Ri();function zv(e,t,{offset:i,start:r,value:n,end:a},o){let s=Object.assign({_directives:t},e),c=new Vv.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=Wv.resolveProps(r,{indicator:"doc-start",next:n??a?.[0],offset:i,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?bu.composeNode(l,n,d,o):bu.composeEmptyNode(l,d.end,r,null,d,o);let f=c.contents.range[2],u=qv.resolveEnd(a,f,!1,o);return u.comment&&(c.comment=u.comment),c.range=[i,f,u.offset],c}ku.composeDoc=zv});var Ao=y(xu=>{"use strict";var Jv=dr("process"),Gv=ha(),Uv=Si(),Ci=xi(),Eu=P(),Kv=Su(),Yv=jt();function Ai(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:i}=e;return[t,t+(typeof i=="string"?i.length:1)]}function Pu(e){let t="",i=!1,r=!1;for(let n=0;n<e.length;++n){let a=e[n];switch(a[0]){case"#":t+=(t===""?"":r?`
101
+ `),t+=1,r=e[t+1];return i||(i=" "),{fold:i,offset:t}}var dg={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function fg(e,t,i,r){let n=e.substr(t,i),o=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=e.substr(t-2,i+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Tu.resolveFlowScalar=og});var $u=y(ju=>{"use strict";var pt=P(),Iu=$(),hg=Do(),pg=Lo();function mg(e,t,i,r){let{value:n,type:a,comment:o,range:s}=t.type==="block-scalar"?hg.resolveBlockScalar(e,t,r):pg.resolveFlowScalar(t,e.options.strict,r),c=i?e.directives.tagName(i.source,f=>r(i,"TAG_RESOLVE_FAILED",f)):null,l;e.options.stringKeys&&e.atKey?l=e.schema[pt.SCALAR]:c?l=vg(e.schema,n,c,i,r):t.type==="scalar"?l=gg(e,n,t,r):l=e.schema[pt.SCALAR];let u;try{let f=l.resolve(n,d=>r(i??t,"TAG_RESOLVE_FAILED",d),e.options);u=pt.isScalar(f)?f:new Iu.Scalar(f)}catch(f){let d=f instanceof Error?f.message:String(f);r(i??t,"TAG_RESOLVE_FAILED",d),u=new Iu.Scalar(n)}return u.range=s,u.source=n,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function vg(e,t,i,r,n){if(i==="!")return e[pt.SCALAR];let a=[];for(let s of e.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(t))return s;let o=e.knownTags[i];return o&&!o.collection?(e.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"),e[pt.SCALAR])}function gg({atKey:e,directives:t,schema:i},r,n,a){let o=i.tags.find(s=>(s.default===!0||e&&s.default==="key")&&s.test?.test(r))||i[pt.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[pt.SCALAR];if(o.tag!==s.tag){let c=t.tagString(o.tag),l=t.tagString(s.tag),u=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",u,!0)}}return o}ju.composeScalar=mg});var Hu=y(Ou=>{"use strict";function wg(e,t,i){if(t){i??(i=t.length);for(let r=i-1;r>=0;--r){let n=t[r];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++r];n?.type==="space";)e+=n.source.length,n=t[++r];break}}return e}Ou.emptyScalarPosition=wg});var Lu=y(Fo=>{"use strict";var yg=pi(),Ng=P(),bg=Cu(),Du=$u(),kg=Lt(),Sg=Hu(),Eg={composeNode:Bu,composeEmptyNode:qo};function Bu(e,t,i,r){let n=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=i,l,u=!0;switch(t.type){case"alias":l=Pg(e,t,r),(s||c)&&r(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=Du.composeScalar(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=bg.composeCollection(Eg,e,t,i,r),s&&(l.anchor=s.source.substring(1))}catch(f){let d=f instanceof Error?f.message:String(f);r(t,"RESOURCE_EXHAUSTION",d)}break;default:{let f=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;r(t,"UNEXPECTED_TOKEN",f),u=!1}}return l??(l=qo(e,t.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!Ng.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function qo(e,t,i,r,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let u={type:"scalar",offset:Sg.emptyScalarPosition(t,i,r),indent:-1,source:""},f=Du.composeScalar(e,u,s,l);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(f.spaceBefore=!0),a&&(f.comment=a,f.range[2]=c),f}function Pg({options:e},{offset:t,source:i,end:r},n){let a=new yg.Alias(i.substring(1));a.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(t+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+i.length,s=kg.resolveEnd(r,o,e.strict,n);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}Fo.composeEmptyNode=qo;Fo.composeNode=Bu});var Mu=y(Fu=>{"use strict";var xg=_i(),qu=Lu(),Rg=Lt(),Cg=$i();function Ag(e,t,{offset:i,start:r,value:n,end:a},o){let s=Object.assign({_directives:t},e),c=new xg.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=Cg.resolveProps(r,{indicator:"doc-start",next:n??a?.[0],offset:i,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?qu.composeNode(l,n,u,o):qu.composeEmptyNode(l,u.end,r,null,u,o);let f=c.contents.range[2],d=Rg.resolveEnd(a,f,!1,o);return d.comment&&(c.comment=d.comment),c.range=[i,f,d.offset],c}Fu.composeDoc=Ag});var Vo=y(zu=>{"use strict";var _g=wr("process"),Tg=Ra(),Ig=_i(),Oi=ji(),Vu=P(),jg=Mu(),$g=Lt();function Hi(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:i}=e;return[t,t+(typeof i=="string"?i.length:1)]}function Wu(e){let t="",i=!1,r=!1;for(let n=0;n<e.length;++n){let a=e[n];switch(a[0]){case"#":t+=(t===""?"":r?`
103
103
 
104
104
  `:`
105
- `)+(a.substring(1)||" "),i=!0,r=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:t,afterEmptyLine:r}}var Co=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,a)=>{let o=Ai(i);a?this.warnings.push(new Ci.YAMLWarning(o,r,n)):this.errors.push(new Ci.YAMLParseError(o,r,n))},this.directives=new Gv.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,i){let{comment:r,afterEmptyLine:n}=Pu(this.prelude);if(r){let a=t.contents;if(i)t.comment=t.comment?`${t.comment}
106
- ${r}`:r;else if(n||t.directives.docStart||!a)t.commentBefore=r;else if(Eu.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Eu.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${r}
105
+ `)+(a.substring(1)||" "),i=!0,r=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:t,afterEmptyLine:r}}var Mo=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,a)=>{let o=Hi(i);a?this.warnings.push(new Oi.YAMLWarning(o,r,n)):this.errors.push(new Oi.YAMLParseError(o,r,n))},this.directives=new Tg.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,i){let{comment:r,afterEmptyLine:n}=Wu(this.prelude);if(r){let a=t.contents;if(i)t.comment=t.comment?`${t.comment}
106
+ ${r}`:r;else if(n||t.directives.docStart||!a)t.commentBefore=r;else if(Vu.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Vu.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)t.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)t.warnings.push(this.warnings[a])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Pu(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,i=!1,r=-1){for(let n of t)yield*this.next(n);yield*this.end(i,r)}*next(t){switch(Jv.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(i,r,n)=>{let a=Ai(t);a[0]+=i,this.onError(a,"BAD_DIRECTIVE",r,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let i=Kv.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(t,"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(t.source);break;case"error":{let i=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,r=new Ci.YAMLParseError(Ai(t),"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 Ci.YAMLParseError(Ai(t),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=Yv.resolveEnd(t.end,t.offset+t.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 Ci.YAMLParseError(Ai(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let r=Object.assign({_directives:this.directives},this.options),n=new Uv.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}}};xu.Composer=Co});var Au=y(on=>{"use strict";var Xv=So(),Qv=Po(),Zv=xi(),Ru=fi();function eg(e,t=!0,i){if(e){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 Zv.YAMLParseError([s,s+1],a,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Qv.resolveFlowScalar(e,t,r);case"block-scalar":return Xv.resolveBlockScalar({options:{strict:t}},e,r)}}return null}function tg(e,t){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=t,s=Ru.stringifyString({type:o,value:e},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:r,source:`
108
+ ${o}`:r}}if(i){for(let a=0;a<this.errors.length;++a)t.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)t.warnings.push(this.warnings[a])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Wu(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,i=!1,r=-1){for(let n of t)yield*this.next(n);yield*this.end(i,r)}*next(t){switch(_g.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(i,r,n)=>{let a=Hi(t);a[0]+=i,this.onError(a,"BAD_DIRECTIVE",r,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let i=jg.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(t,"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(t.source);break;case"error":{let i=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,r=new Oi.YAMLParseError(Hi(t),"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 Oi.YAMLParseError(Hi(t),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=$g.resolveEnd(t.end,t.offset+t.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 Oi.YAMLParseError(Hi(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let r=Object.assign({_directives:this.directives},this.options),n=new Ig.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}}};zu.Composer=Mo});var Uu=y(fn=>{"use strict";var Og=Do(),Hg=Lo(),Dg=ji(),Ju=yi();function Bg(e,t=!0,i){if(e){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 Dg.YAMLParseError([s,s+1],a,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Hg.resolveFlowScalar(e,t,r);case"block-scalar":return Og.resolveBlockScalar({options:{strict:t}},e,r)}}return null}function Lg(e,t){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=t,s=Ju.stringifyString({type:o,value:e},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:r,source:`
110
110
  `}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
111
- `),d=s.substring(0,l),f=s.substring(l+1)+`
112
- `,u=[{type:"block-scalar-header",offset:a,indent:r,source:d}];return Cu(u,c)||u.push({type:"newline",offset:-1,indent:r,source:`
113
- `}),{type:"block-scalar",offset:a,indent:r,props:u,source:f}}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 ig(e,t,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=i,s="indent"in e?e.indent:null;if(r&&typeof s=="number"&&(s+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Ru.stringifyString({type:o,value:t},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":rg(e,c);break;case'"':_o(e,c,"double-quoted-scalar");break;case"'":_o(e,c,"single-quoted-scalar");break;default:_o(e,c,"scalar")}}function rg(e,t){let i=t.indexOf(`
111
+ `),u=s.substring(0,l),f=s.substring(l+1)+`
112
+ `,d=[{type:"block-scalar-header",offset:a,indent:r,source:u}];return Gu(d,c)||d.push({type:"newline",offset:-1,indent:r,source:`
113
+ `}),{type:"block-scalar",offset:a,indent:r,props:d,source:f}}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 qg(e,t,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=i,s="indent"in e?e.indent:null;if(r&&typeof s=="number"&&(s+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Ju.stringifyString({type:o,value:t},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":Fg(e,c);break;case'"':Wo(e,c,"double-quoted-scalar");break;case"'":Wo(e,c,"single-quoted-scalar");break;default:Wo(e,c,"scalar")}}function Fg(e,t){let i=t.indexOf(`
114
114
  `),r=t.substring(0,i),n=t.substring(i+1)+`
115
- `;if(e.type==="block-scalar"){let a=e.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=r,e.source=n}else{let{offset:a}=e,o="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:r}];Cu(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
- `});for(let c of Object.keys(e))c!=="type"&&c!=="offset"&&delete e[c];Object.assign(e,{type:"block-scalar",indent:o,props:s,source:n})}}function Cu(e,t){if(t)for(let i of t)switch(i.type){case"space":case"comment":e.push(i);break;case"newline":return e.push(i),!0}return!1}function _o(e,t,i){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=i,e.source=t;break;case"block-scalar":{let r=e.props.slice(1),n=t.length;e.props[0].type==="block-scalar-header"&&(n-=e.props[0].source.length);for(let a of r)a.offset+=n;delete e.props,Object.assign(e,{type:i,source:t,end:r});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
117
- `};delete e.items,Object.assign(e,{type:i,source:t,end:[n]});break}default:{let r="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(e))a!=="type"&&a!=="offset"&&delete e[a];Object.assign(e,{type:i,indent:r,source:t,end:n})}}}on.createScalarToken=tg;on.resolveAsScalar=eg;on.setScalarValue=ig});var Tu=y(_u=>{"use strict";var ng=e=>"type"in e?cn(e):sn(e);function cn(e){switch(e.type){case"block-scalar":{let t="";for(let i of e.props)t+=cn(i);return t+e.source}case"block-map":case"block-seq":{let t="";for(let i of e.items)t+=sn(i);return t}case"flow-collection":{let t=e.start.source;for(let i of e.items)t+=sn(i);for(let i of e.end)t+=i.source;return t}case"document":{let t=sn(e);if(e.end)for(let i of e.end)t+=i.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let i of e.end)t+=i.source;return t}}}function sn({start:e,key:t,sep:i,value:r}){let n="";for(let a of e)n+=a.source;if(t&&(n+=cn(t)),i)for(let a of i)n+=a.source;return r&&(n+=cn(r)),n}_u.stringify=ng});var Ou=y($u=>{"use strict";var To=Symbol("break visit"),ag=Symbol("skip children"),Iu=Symbol("remove item");function lt(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),ju(Object.freeze([]),e,t)}lt.BREAK=To;lt.SKIP=ag;lt.REMOVE=Iu;lt.itemAtPath=(e,t)=>{let i=e;for(let[r,n]of t){let a=i?.[r];if(a&&"items"in a)i=a.items[n];else return}return i};lt.parentCollection=(e,t)=>{let i=lt.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function ju(e,t,i){let r=i(t,e);if(typeof r=="symbol")return r;for(let n of["key","value"]){let a=t[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=ju(Object.freeze(e.concat([[n,o]])),a.items[o],i);if(typeof s=="number")o=s-1;else{if(s===To)return To;s===Iu&&(a.items.splice(o,1),o-=1)}}typeof r=="function"&&n==="key"&&(r=r(t,e))}}return typeof r=="function"?r(t,e):r}$u.visit=lt});var ln=y(Q=>{"use strict";var Io=Au(),og=Tu(),sg=Ou(),jo="\uFEFF",$o="",Oo="",Ho="",cg=e=>!!e&&"items"in e,lg=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function ug(e){switch(e){case jo:return"<BOM>";case $o:return"<DOC>";case Oo:return"<FLOW_END>";case Ho:return"<SCALAR>";default:return JSON.stringify(e)}}function dg(e){switch(e){case jo:return"byte-order-mark";case $o:return"doc-mode";case Oo:return"flow-error-end";case Ho:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
+ `;if(e.type==="block-scalar"){let a=e.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=r,e.source=n}else{let{offset:a}=e,o="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:r}];Gu(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
+ `});for(let c of Object.keys(e))c!=="type"&&c!=="offset"&&delete e[c];Object.assign(e,{type:"block-scalar",indent:o,props:s,source:n})}}function Gu(e,t){if(t)for(let i of t)switch(i.type){case"space":case"comment":e.push(i);break;case"newline":return e.push(i),!0}return!1}function Wo(e,t,i){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=i,e.source=t;break;case"block-scalar":{let r=e.props.slice(1),n=t.length;e.props[0].type==="block-scalar-header"&&(n-=e.props[0].source.length);for(let a of r)a.offset+=n;delete e.props,Object.assign(e,{type:i,source:t,end:r});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
117
+ `};delete e.items,Object.assign(e,{type:i,source:t,end:[n]});break}default:{let r="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(e))a!=="type"&&a!=="offset"&&delete e[a];Object.assign(e,{type:i,indent:r,source:t,end:n})}}}fn.createScalarToken=Lg;fn.resolveAsScalar=Bg;fn.setScalarValue=qg});var Yu=y(Ku=>{"use strict";var Mg=e=>"type"in e?pn(e):hn(e);function pn(e){switch(e.type){case"block-scalar":{let t="";for(let i of e.props)t+=pn(i);return t+e.source}case"block-map":case"block-seq":{let t="";for(let i of e.items)t+=hn(i);return t}case"flow-collection":{let t=e.start.source;for(let i of e.items)t+=hn(i);for(let i of e.end)t+=i.source;return t}case"document":{let t=hn(e);if(e.end)for(let i of e.end)t+=i.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let i of e.end)t+=i.source;return t}}}function hn({start:e,key:t,sep:i,value:r}){let n="";for(let a of e)n+=a.source;if(t&&(n+=pn(t)),i)for(let a of i)n+=a.source;return r&&(n+=pn(r)),n}Ku.stringify=Mg});var ed=y(Zu=>{"use strict";var zo=Symbol("break visit"),Vg=Symbol("skip children"),Xu=Symbol("remove item");function mt(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),Qu(Object.freeze([]),e,t)}mt.BREAK=zo;mt.SKIP=Vg;mt.REMOVE=Xu;mt.itemAtPath=(e,t)=>{let i=e;for(let[r,n]of t){let a=i?.[r];if(a&&"items"in a)i=a.items[n];else return}return i};mt.parentCollection=(e,t)=>{let i=mt.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Qu(e,t,i){let r=i(t,e);if(typeof r=="symbol")return r;for(let n of["key","value"]){let a=t[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=Qu(Object.freeze(e.concat([[n,o]])),a.items[o],i);if(typeof s=="number")o=s-1;else{if(s===zo)return zo;s===Xu&&(a.items.splice(o,1),o-=1)}}typeof r=="function"&&n==="key"&&(r=r(t,e))}}return typeof r=="function"?r(t,e):r}Zu.visit=mt});var mn=y(Z=>{"use strict";var Jo=Uu(),Wg=Yu(),zg=ed(),Go="\uFEFF",Uo="",Ko="",Yo="",Jg=e=>!!e&&"items"in e,Gg=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Ug(e){switch(e){case Go:return"<BOM>";case Uo:return"<DOC>";case Ko:return"<FLOW_END>";case Yo:return"<SCALAR>";default:return JSON.stringify(e)}}function Kg(e){switch(e){case Go:return"byte-order-mark";case Uo:return"doc-mode";case Ko:return"flow-error-end";case Yo:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
118
118
  `:case`\r
119
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Q.createScalarToken=Io.createScalarToken;Q.resolveAsScalar=Io.resolveAsScalar;Q.setScalarValue=Io.setScalarValue;Q.stringify=og.stringify;Q.visit=sg.visit;Q.BOM=jo;Q.DOCUMENT=$o;Q.FLOW_END=Oo;Q.SCALAR=Ho;Q.isCollection=cg;Q.isScalar=lg;Q.prettyToken=ug;Q.tokenType=dg});var Lo=y(Du=>{"use strict";var _i=ln();function me(e){switch(e){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var Hu=new Set("0123456789ABCDEFabcdef"),fg=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),un=new Set(",[]{}"),hg=new Set(` ,[]{}
121
- \r `),Do=e=>!e||hg.has(e),Bo=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,i=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let t=this.pos,i=this.buffer[t];for(;i===" "||i===" ";)i=this.buffer[++t];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(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Z.createScalarToken=Jo.createScalarToken;Z.resolveAsScalar=Jo.resolveAsScalar;Z.setScalarValue=Jo.setScalarValue;Z.stringify=Wg.stringify;Z.visit=zg.visit;Z.BOM=Go;Z.DOCUMENT=Uo;Z.FLOW_END=Ko;Z.SCALAR=Yo;Z.isCollection=Jg;Z.isScalar=Gg;Z.prettyToken=Ug;Z.tokenType=Kg});var Zo=y(id=>{"use strict";var Di=mn();function ve(e){switch(e){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var td=new Set("0123456789ABCDEFabcdef"),Yg=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),vn=new Set(",[]{}"),Xg=new Set(` ,[]{}
121
+ \r `),Xo=e=>!e||Xg.has(e),Qo=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,i=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let t=this.pos,i=this.buffer[t];for(;i===" "||i===" ";)i=this.buffer[++t];return!i||i==="#"||i===`
122
122
  `?!0:i==="\r"?this.buffer[t+1]===`
123
123
  `:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let i=this.buffer[t];if(this.indentNext>0){let r=0;for(;i===" ";)i=this.buffer[++r+t];if(i==="\r"){let n=this.buffer[r+t+1];if(n===`
124
124
  `||!n&&!this.atEnd)return t+r+1}return i===`
125
- `||r>=this.indentNext||!i&&!this.atEnd?t+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(t,3);if((r==="---"||r==="...")&&me(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
126
- `,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===_i.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let i=t.length,r=t.indexOf("#");for(;r!==-1;){let a=t[r-1];if(a===" "||a===" "){i=r-1;break}else r=t.indexOf("#",r+1)}for(;;){let a=t[i-1];if(a===" "||a===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-i),yield*this.pushNewline(),"stream"}return yield _i.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let i=this.peek(3);if((i==="---"||i==="...")&&me(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&&!me(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&me(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 t=this.getLine();if(t===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(t[i]){case"#":yield*this.pushCount(t.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(Do),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,i,r=-1;do t=yield*this.pushNewline(),t>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(t+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("..."))&&me(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield _i.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(Do),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||me(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),i=this.buffer.indexOf(t,this.pos+1);if(t==="'")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(`
125
+ `||r>=this.indentNext||!i&&!this.atEnd?t+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(t,3);if((r==="---"||r==="...")&&ve(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
126
+ `,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===Di.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let i=t.length,r=t.indexOf("#");for(;r!==-1;){let a=t[r-1];if(a===" "||a===" "){i=r-1;break}else r=t.indexOf("#",r+1)}for(;;){let a=t[i-1];if(a===" "||a===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-i),yield*this.pushNewline(),"stream"}return yield Di.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let i=this.peek(3);if((i==="---"||i==="...")&&ve(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&&!ve(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&ve(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 t=this.getLine();if(t===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(t[i]){case"#":yield*this.pushCount(t.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(Xo),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,i,r=-1;do t=yield*this.pushNewline(),t>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(t+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("..."))&&ve(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Di.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(Xo),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ve(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),i=this.buffer.indexOf(t,this.pos+1);if(t==="'")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
- `,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 t=this.pos;for(;;){let i=this.buffer[++t];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=>me(i)||i==="#")}*parseBlockScalar(){let t=this.pos-1,i=0,r;e:for(let a=this.pos;r=this.buffer[a];++a)switch(r){case" ":i+=1;break;case`
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 t=this.pos;for(;;){let i=this.buffer[++t];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=>ve(i)||i==="#")}*parseBlockScalar(){let t=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
  `:t=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(t+1);if(a===-1)break;t=this.buffer.indexOf(`
131
131
  `,a)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let n=t+1;for(r=this.buffer[n];r===" ";)r=this.buffer[++n];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
132
132
  `;)r=this.buffer[++n];t=n-1}else if(!this.blockScalarKeep)do{let a=t-1,o=this.buffer[a];o==="\r"&&(o=this.buffer[--a]);let s=a;for(;o===" ";)o=this.buffer[--a];if(o===`
133
- `&&a>=this.pos&&a+1+i>s)t=a;else break}while(!0);return yield _i.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=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(me(a)||t&&un.has(a))break;i=r}else if(me(n)){let a=this.buffer[r+1];if(n==="\r"&&(a===`
133
+ `&&a>=this.pos&&a+1+i>s)t=a;else break}while(!0);return yield Di.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=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(ve(a)||t&&vn.has(a))break;i=r}else if(ve(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==="#"||t&&un.has(a))break;if(n===`
136
- `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(t&&un.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield _i.SCALAR,yield*this.pushToIndex(i+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,i){let r=this.buffer.slice(this.pos,t);return r?(yield r,this.pos+=r.length,r.length):(i&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(Do),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let i=this.flowLevel>0,r=this.charAt(1);if(me(r)||i&&un.has(r)){i?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,i=this.buffer[t];for(;!me(i)&&i!==">";)i=this.buffer[++t];return yield*this.pushToIndex(i===">"?t+1:t,!1)}else{let t=this.pos+1,i=this.buffer[t];for(;i;)if(fg.has(i))i=this.buffer[++t];else if(i==="%"&&Hu.has(this.buffer[t+1])&&Hu.has(this.buffer[t+2]))i=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`
135
+ `,a=this.buffer[r+1]):i=r),a==="#"||t&&vn.has(a))break;if(n===`
136
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(t&&vn.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Di.SCALAR,yield*this.pushToIndex(i+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,i){let r=this.buffer.slice(this.pos,t);return r?(yield r,this.pos+=r.length,r.length):(i&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(Xo),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let i=this.flowLevel>0,r=this.charAt(1);if(ve(r)||i&&vn.has(r)){i?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,i=this.buffer[t];for(;!ve(i)&&i!==">";)i=this.buffer[++t];return yield*this.pushToIndex(i===">"?t+1:t,!1)}else{let t=this.pos+1,i=this.buffer[t];for(;i;)if(Yg.has(i))i=this.buffer[++t];else if(i==="%"&&td.has(this.buffer[t+1])&&td.has(this.buffer[t+2]))i=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`
137
137
  `?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===`
138
- `?yield*this.pushCount(2):0}*pushSpaces(t){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||t&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(t){let i=this.pos,r=this.buffer[i];for(;!t(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};Du.Lexer=Bo});var Mo=y(Bu=>{"use strict";var Fo=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let i=0,r=this.lineStarts.length;for(;i<r;){let a=i+r>>1;this.lineStarts[a]<t?i=a+1:r=a}if(this.lineStarts[i]===t)return{line:i+1,col:1};if(i===0)return{line:0,col:t};let n=this.lineStarts[i-1];return{line:i,col:t-n+1}}}};Bu.LineCounter=Fo});var qo=y(qu=>{"use strict";var pg=dr("process"),Lu=ln(),mg=Lo();function Ye(e,t){for(let i=0;i<e.length;++i)if(e[i].type===t)return!0;return!1}function Fu(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Vu(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function dn(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function $t(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function fn(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let i=0;i<t.length;++i)e.push(t[i])}function Mu(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!Ye(t.start,"explicit-key-ind")&&!Ye(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,Vu(t.value)?t.value.end?fn(t.value.end,t.sep):t.value.end=t.sep:fn(t.start,t.sep),delete t.sep)}var Vo=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new mg.Lexer,this.onNewLine=t}*parse(t,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(t,i))yield*this.next(r);i||(yield*this.end())}*next(t){if(this.source=t,pg.env.LOG_TOKENS&&console.log("|",Lu.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let i=Lu.tokenType(t);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+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let r=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let i=t??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"&&Mu(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&&Fu(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 t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{Fu(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let i=dn(this.peek(2)),r=$t(i),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:r,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let i=this.source.indexOf(`
138
+ `?yield*this.pushCount(2):0}*pushSpaces(t){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||t&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(t){let i=this.pos,r=this.buffer[i];for(;!t(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};id.Lexer=Qo});var ts=y(rd=>{"use strict";var es=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let i=0,r=this.lineStarts.length;for(;i<r;){let a=i+r>>1;this.lineStarts[a]<t?i=a+1:r=a}if(this.lineStarts[i]===t)return{line:i+1,col:1};if(i===0)return{line:0,col:t};let n=this.lineStarts[i-1];return{line:i,col:t-n+1}}}};rd.LineCounter=es});var rs=y(cd=>{"use strict";var Qg=wr("process"),nd=mn(),Zg=Zo();function Ze(e,t){for(let i=0;i<e.length;++i)if(e[i].type===t)return!0;return!1}function ad(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function sd(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function gn(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function qt(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function wn(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let i=0;i<t.length;++i)e.push(t[i])}function od(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!Ze(t.start,"explicit-key-ind")&&!Ze(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,sd(t.value)?t.value.end?wn(t.value.end,t.sep):t.value.end=t.sep:wn(t.start,t.sep),delete t.sep)}var is=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Zg.Lexer,this.onNewLine=t}*parse(t,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(t,i))yield*this.next(r);i||(yield*this.end())}*next(t){if(this.source=t,Qg.env.LOG_TOKENS&&console.log("|",nd.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let i=nd.tokenType(t);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+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let r=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let i=t??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"&&od(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&&ad(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 t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{ad(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let i=gn(this.peek(2)),r=qt(i),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:r,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let 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(t){let i=t.items[t.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):t.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)t.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){fn(n,i.start),n.push(this.sourceToken),t.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let r=!this.onKeyLine&&this.indent===t.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>t.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),t.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),t.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(i.explicitKey)if(i.sep)if(i.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ye(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(Vu(i.key)&&!Ye(i.sep,"newline")){let o=$t(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(Ye(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let o=$t(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?t.items.push({start:a,key:null,sep:[this.sourceToken]}):Ye(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?(t.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(t);if(o){if(o.type==="block-seq"){if(!i.explicitKey&&i.sep&&!Ye(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&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let i=t.items[t.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):t.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){fn(n,i.start),n.push(this.sourceToken),t.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=t.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;i.value||Ye(i.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>t.indent){let r=this.startBlockValue(t);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let i=t.items[t.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(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?t.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?t.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?t.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?t.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":t.end.push(this.sourceToken);return}let r=this.startBlockValue(t);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===t.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=dn(r),a=$t(n);Mu(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:a,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let i=this.source.indexOf(`
140
+ `,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let i=t.items[t.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):t.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)t.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){wn(n,i.start),n.push(this.sourceToken),t.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let r=!this.onKeyLine&&this.indent===t.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>t.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),t.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),t.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(i.explicitKey)if(i.sep)if(i.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ze(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(sd(i.key)&&!Ze(i.sep,"newline")){let o=qt(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(Ze(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let o=qt(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?t.items.push({start:a,key:null,sep:[this.sourceToken]}):Ze(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?(t.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(t);if(o){if(o.type==="block-seq"){if(!i.explicitKey&&i.sep&&!Ze(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&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let i=t.items[t.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):t.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){wn(n,i.start),n.push(this.sourceToken),t.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=t.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;i.value||Ze(i.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>t.indent){let r=this.startBlockValue(t);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let i=t.items[t.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(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?t.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?t.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?t.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?t.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":t.end.push(this.sourceToken);return}let r=this.startBlockValue(t);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===t.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=gn(r),a=qt(n);od(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:a,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let i=this.source.indexOf(`
141
141
  `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
142
- `,i)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=dn(t),r=$t(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=dn(t),r=$t(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,i){return this.type!=="comment"||this.indent<=i?!1:t.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};qu.Parser=Vo});var Uu=y(Ii=>{"use strict";var Wu=Ao(),vg=Si(),Ti=xi(),gg=xa(),wg=P(),yg=Mo(),zu=qo();function Ju(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new yg.LineCounter||null,prettyErrors:t}}function Ng(e,t={}){let{lineCounter:i,prettyErrors:r}=Ju(t),n=new zu.Parser(i?.addNewLine),a=new Wu.Composer(t),o=Array.from(a.compose(n.parse(e)));if(r&&i)for(let s of o)s.errors.forEach(Ti.prettifyError(e,i)),s.warnings.forEach(Ti.prettifyError(e,i));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function Gu(e,t={}){let{lineCounter:i,prettyErrors:r}=Ju(t),n=new zu.Parser(i?.addNewLine),a=new Wu.Composer(t),o=null;for(let s of a.compose(n.parse(e),!0,e.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new Ti.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(o.errors.forEach(Ti.prettifyError(e,i)),o.warnings.forEach(Ti.prettifyError(e,i))),o}function bg(e,t,i){let r;typeof t=="function"?r=t:i===void 0&&t&&typeof t=="object"&&(i=t);let n=Gu(e,i);if(!n)return null;if(n.warnings.forEach(a=>gg.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 kg(e,t,i){let r=null;if(typeof t=="function"||Array.isArray(t)?r=t:i===void 0&&t&&(i=t),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(e===void 0){let{keepUndefined:n}=i??t??{};if(!n)return}return wg.isDocument(e)&&!r?e.toString(i):new vg.Document(e,r,i).toString(i)}Ii.parse=bg;Ii.parseAllDocuments=Ng;Ii.parseDocument=Gu;Ii.stringify=kg});var ji=y(x=>{"use strict";var Sg=Ao(),Eg=Si(),Pg=co(),Wo=xi(),xg=si(),Xe=P(),Rg=Je(),Cg=I(),Ag=Ue(),_g=Ke(),Tg=ln(),Ig=Lo(),jg=Mo(),$g=qo(),hn=Uu(),Ku=ri();x.Composer=Sg.Composer;x.Document=Eg.Document;x.Schema=Pg.Schema;x.YAMLError=Wo.YAMLError;x.YAMLParseError=Wo.YAMLParseError;x.YAMLWarning=Wo.YAMLWarning;x.Alias=xg.Alias;x.isAlias=Xe.isAlias;x.isCollection=Xe.isCollection;x.isDocument=Xe.isDocument;x.isMap=Xe.isMap;x.isNode=Xe.isNode;x.isPair=Xe.isPair;x.isScalar=Xe.isScalar;x.isSeq=Xe.isSeq;x.Pair=Rg.Pair;x.Scalar=Cg.Scalar;x.YAMLMap=Ag.YAMLMap;x.YAMLSeq=_g.YAMLSeq;x.CST=Tg;x.Lexer=Ig.Lexer;x.LineCounter=jg.LineCounter;x.Parser=$g.Parser;x.parse=hn.parse;x.parseAllDocuments=hn.parseAllDocuments;x.parseDocument=hn.parseDocument;x.stringify=hn.stringify;x.visit=Ku.visit;x.visitAsync=Ku.visitAsync});import{randomUUID as qN}from"node:crypto";import{promises as q}from"node:fs";import U from"node:path";import{execFileSync as Jf}from"child_process";import ei from"path";function Zt(e,t){return Jf("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Gf(e,t){let i=ei.normalize(e),r=ei.normalize(t);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function F(e){try{let t=ei.resolve(Zt(e,["rev-parse","--show-toplevel"])),r=Zt(e,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=r?ei.resolve(r.slice(9)):t,a=null;try{a=Zt(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Gf(t,n),currentWorktreeRoot:t,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function St(e){try{Zt(e,["rev-parse","--is-inside-work-tree"])}catch{return[]}return Zt(e,["worktree","list","--porcelain","-z"]).split("\0").filter(i=>i.startsWith("worktree ")).map(i=>ei.resolve(i.slice(9)))}import{randomUUID as Uf}from"crypto";import{promises as W}from"fs";import fe from"path";function Me(e){return e!==0&&e!==0n&&e!=="0"}function te(e,t){return Me(e.dev)&&Me(t.dev)&&Me(e.ino)&&Me(t.ino)}function A(e,t){let i=Me(e.dev)&&Me(t.dev);if(i&&e.dev!==t.dev)return!1;let r=Me(e.ino)&&Me(t.ino);return r&&e.ino!==t.ino?!1:i&&r?!0:e.birthtime===t.birthtime}function ca(e,t){let i=fe.relative(e,t);return i===""||!fe.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${fe.sep}`)}function Kf(e,t){return A({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function sa(e,t){let i={...e,birthtime:e.birthtimeMs},r={...t,birthtime:t.birthtimeMs};return te(i,r)?A(i,r):A(i,r)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function ac(e){let t=await W.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${e}`);return{path:e,realPath:await W.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function ti(e){for(let t of e){let i=await W.lstat(t.path);if(!i.isDirectory()||i.isSymbolicLink()||!Kf(t,i)||await W.realpath(t.path)!==t.realPath)throw new Error(`Native atomic write parent changed before commit: ${t.path}`)}}async function Yf(e,t){let i=fe.resolve(e),r=fe.resolve(t);if(!ca(i,r))throw new Error(`Native atomic write parent is outside its managed root: ${t}`);let n=[await ac(i)],a=fe.relative(i,r).split(fe.sep).filter(Boolean),o=i;for(let s of a){await ti(n),o=fe.join(o,s);try{await W.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await ac(o);if(!ca(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await ti(n),n}async function Xf(e){let t;try{t=await W.open(e,"r"),await t.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await t?.close()}}async function Qf(e,t,i={}){let r=fe.dirname(e),n=i.containedRoot?await Yf(i.containedRoot,r):null;n||await W.mkdir(r,{recursive:!0});let a=fe.join(r,`.${fe.basename(e)}.${Uf()}.tmp`),o,s;try{if(await i.beforeTemporaryOpen?.(),o=await W.open(a,"wx"),s=await o.stat(),n){let[c,l]=await Promise.all([W.lstat(a),W.realpath(a)]);if(await ti(n),!c.isFile()||c.isSymbolicLink()||!sa(s,c)||!ca(n[0].realPath,l))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof t=="string"?await o.writeFile(t,"utf8"):await o.writeFile(t),await o.sync(),!sa(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 ti(n);let c=await W.lstat(a);if(!c.isFile()||c.isSymbolicLink()||!s||!sa(c,s))throw new Error("Native atomic write temporary file changed before commit")}i.exclusive?(await W.link(a,e),await W.unlink(a)):await W.rename(a,e),await Xf(r)}catch(c){if(await o?.close(),!n)await W.rm(a,{force:!0});else try{await ti(n),await W.rm(a,{force:!0})}catch{}throw c}}async function K(e,t,i={}){await Qf(e,t,i)}async function Y(e,t,i={}){await K(e,JSON.stringify(t,null,2)+`
143
- `,i)}import{createHash as ih}from"node:crypto";import{promises as he}from"node:fs";import ae from"node:path";import{TextDecoder as rh}from"node:util";var Zf=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),eh=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function th(e){return e.toLowerCase().startsWith(".env")}function ii(e){let i=e.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>th(r))?"environment-file":i.some(r=>eh.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>Zf.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}var pr=1024*1024;function la(e,t){let i=ae.relative(e,t);return i===""||!ae.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ae.sep}`)}function nh(e){let t=ae.posix.normalize(e);if(e.length===0||e!==e.trim()||e.includes("\\")||Array.from(e).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||ae.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||t!==e||t==="."||e.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${e}`);let i=e.toLowerCase(),r=ii(e);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${e}`);return e}function ah(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native artifact byte limit must be a positive integer");return e}function oh(e,t){return A({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function hr(e,t){let i={...e,birthtime:e.birthtimeMs},r={...t,birthtime:t.birthtimeMs};return te(i,r)?A(i,r):A(i,r)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function oc(e){let t=await he.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${e}`);return{path:e,realPath:await he.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function sh(e,t){let i=ae.resolve(e),r=ae.resolve(t);if(!la(i,r))throw new Error("Native artifact path is outside its root");let n=[await oc(i)],a=i;for(let o of ae.relative(i,r).split(ae.sep).filter(Boolean)){a=ae.join(a,o);let s=await oc(a);if(!la(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function sc(e){for(let t of e){let i=await he.lstat(t.path);if(!i.isDirectory()||i.isSymbolicLink()||!oh(t,i)||await he.realpath(t.path)!==t.realPath)throw new Error(`Native artifact parent changed while reading: ${t.path}`)}}async function B(e){let t=nh(e.ref),i=e.maxBytes===null?null:ah(e.maxBytes??pr),r=ae.resolve(e.root,...t.split("/")),n=await sh(e.root,ae.dirname(r));await e.hooks?.afterParentChainCaptured?.();let a=await he.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${t}`);if(i!==null&&a.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${t}`);let o=await he.realpath(r);if(!la(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${t}`);let s=await he.open(r,"r");try{let[c,l,d]=await Promise.all([s.stat(),he.lstat(r),he.realpath(r)]);if(await sc(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||d!==o||!hr(a,c)||!hr(c,l))throw new Error(`Native artifact changed while opening: ${t}`);await e.hooks?.afterOpen?.();let f=[],u=0,p=Buffer.allocUnsafe(i===null?64*1024:Math.min(64*1024,i+1));for(;;){let w=i===null?p.length:i+1-u,k=await s.read(p,0,Math.min(p.length,w),null);if(k.bytesRead===0)break;if(u+=k.bytesRead,i!==null&&u>i)throw new Error(`Native artifact exceeds ${i} bytes: ${t}`);f.push(Buffer.from(p.subarray(0,k.bytesRead)))}await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),he.lstat(r),he.realpath(r)]);if(await sc(n),!h.isFile()||h.isSymbolicLink()||m!==o||!hr(c,v)||!hr(c,h))throw new Error(`Native artifact changed while reading: ${t}`);let g=Buffer.concat(f,u),N;try{N=new rh("utf-8",{fatal:!0}).decode(g)}catch(w){throw new Error(`Native artifact is not valid UTF-8: ${t}`,{cause:w})}return{ref:t,size:u,hash:e.includeHash===!1?null:ih("sha256").update(g).digest("hex"),text:N}}finally{await s.close()}}var Is=fr(ji(),1);import Jt from"path";var Jo=fr(ji(),1);import pn from"path";var Oi=64*1024,mn=1024,vn=64,Go=5,Og=[".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/**"],Hg=["**/.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"],Dg=[...Og,...Hg].sort((e,t)=>e.localeCompare(t,"en"));var ie={include:["**/*"],exclude:[...Dg],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function Bg(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let i=e.trim();if(i.length===0||pn.posix.isAbsolute(i)||pn.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${t} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${t} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${t} must not contain empty or dot path segments`);return r}function ut(e){let t=Bg(e,"native.artifact_root");return t.length===0?".":t.join("/")}function Xu(e,t="docs"){let i=e??t;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function Uo(e,t,i=!1){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim().replaceAll("\\","/");if(r.length===0||pn.posix.isAbsolute(r)||pn.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${t} must be relative to its declared path base`);let n=r.split("/");if(n.some(a=>a===".."))throw new Error(`${t} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${t} must not contain empty or dot path segments`);if(!i&&/[*?]/u.test(r))throw new Error(`${t} cannot contain wildcards`);return n.join("/")}function $i(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Qu(e,t,i){let r=e??t;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function Ko(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||e.startsWith("/")||e.split("/").includes(".."))throw new Error(`${t} contains an unsafe pattern`);if(e.length>mn)throw new Error(`${t} exceeds ${mn} characters`);let i=0;for(let r=0;r<e.length;r+=1)e[r]==="?"?i+=1:e[r]==="*"&&(i+=1,e[r+1]==="*"&&(r+=1));if(i>vn)throw new Error(`${t} contains more than ${vn} wildcard tokens`);return e}function Yu(e,t,i){if(e===void 0)return[...i];if(!Array.isArray(e))throw new Error(`${t} contains an unsafe pattern`);return[...new Set(e.map(r=>Ko(r,t)))].sort((r,n)=>r.localeCompare(n,"en"))}function zo(e,t,i){let r=e??t;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function Lg(e){if(e===void 0)return{...ie,include:[...ie.include],exclude:[...ie.exclude]};let t=$i(e,"native.snapshot");return{include:Yu(t.include,"native.snapshot.include",ie.include),exclude:Yu(t.exclude,"native.snapshot.exclude",ie.exclude),max_files:zo(t.max_files,ie.max_files,"native.snapshot.max_files"),max_total_bytes:zo(t.max_total_bytes,ie.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:zo(t.max_duration_ms,ie.max_duration_ms,"native.snapshot.max_duration_ms")}}function Fg(e){if(e===void 0)return;let t=$i(e,"native.pending_root_move"),i=t.id,r=t.from_artifact_root,n=t.to_artifact_root,a=t.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(t.cleanup!==void 0){let s=$i(t.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,d=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof d!="string"||!/^[a-f0-9]{64}$/u.test(d))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:d}}return{id:i,fromArtifactRoot:ut(r),toArtifactRoot:ut(n),stage:a,...o?{cleanup:o}:{}}}function Mg(e,t={}){let i=$i(e,"native"),r=i.artifact_root??(t.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??Go;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Fg(i.pending_root_move);return{artifact_root:ut(r),language:Qu(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Lg(i.snapshot),...s?{pending_root_move:s}:{}}}function Vg(e){let t=$i(e,"classic"),i=t.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=t.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=t.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:Xu(t.artifact_layout),language:Qu(t.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function qg(e){let t=e??!0;if(typeof t!="boolean")throw new Error("ambient_resume must be true or false");return t}function Wg(e,t,i,r,n){let a=e.schema!==void 0;if(!(a||e.default_workflow!==void 0||e.workflows!==void 0||!n.allowPartialProject&&e.native!==void 0)||n.allowPartialProject&&!a)return null;if(e.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(e.default_workflow!=="native"&&e.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let s=e.workflows??[e.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(e.default_workflow))throw new Error("workflows must include default_workflow");if(c.includes("native")&&!t)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:e.default_workflow,workflows:c,ambient_resume:r,...t?{native:t}:{},...i?{classic:i}:{}}}function Hi(e,t={}){let i=(0,Jo.parseDocument)(e,{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=qg(n.ambient_resume),o=n.native===void 0?void 0:Mg(n.native,{allowMissingArtifactRoot:t.allowMissingNativeFields}),s=n.classic===void 0?void 0:Vg(n.classic),c=Wg(n,o,s,a,{allowPartialProject:t.allowPartialProject??!1});return{value:n,config:c,ambient_resume:a,...o?{native:o}:{},...s?{classic:s}:{}}}function gn(e="docs",t="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:ut(e),language:t,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Go,snapshot:{...ie,include:[...ie.include],exclude:[...ie.exclude]}}}}import{createHash as Jg}from"crypto";import{promises as Nn}from"fs";import Qe from"path";import{constants as wn,promises as dt}from"fs";var ve=class extends Error{reason;constructor(t,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=t}};function Yo(e){return"birthtimeNs"in e&&typeof e.birthtimeNs=="bigint"?e.birthtimeNs:e.birthtimeMs}function Zu(e){return"ctimeNs"in e&&typeof e.ctimeNs=="bigint"?e.ctimeNs:e.ctimeMs}function Di(e){return{dev:e.dev,ino:e.ino,birthtime:Yo(e)}}function yn(e,t){let i=Di(e),r=Di(t);return te(i,r)?A(i,r):A(i,r)&&Yo(e)===Yo(t)&&Zu(e)===Zu(t)&&e.size===t.size}async function ft(e,t,i={}){if(!Number.isSafeInteger(t)||t<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 dt.lstat(e,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new ve("not-regular-file",`${r} must be a regular file`);if(BigInt(a.size)>BigInt(t))throw new ve("too-large",`${r} exceeds ${t} bytes`);let o=await dt.realpath(e);await i.verify?.("pre-open",{realPath:o,identity:Di(a)});let s=process.platform==="win32"?wn.O_RDONLY:wn.O_RDONLY|wn.O_NOFOLLOW|wn.O_NONBLOCK,c;try{c=await dt.open(e,s)}catch(l){throw l.code==="ELOOP"?new ve("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,d,f]=await Promise.all([c.stat({bigint:n}),dt.lstat(e,{bigint:n}),dt.realpath(e)]);if(!l.isFile()||!d.isFile()||d.isSymbolicLink()||f!==o||!yn(a,l)||!yn(a,d))throw new ve("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:f,identity:Di(l)}),await i.hooks?.afterOpen?.();let u=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let N=t+1-p,{bytesRead:w}=await c.read(v,0,Math.min(v.length,N),null);if(w===0)break;if(p+=w,p>t)throw new ve("too-large",`${r} exceeds ${t} bytes`);u.push(Buffer.from(v.subarray(0,w)))}await i.hooks?.beforeFinalCheck?.();let[h,m,g]=await Promise.all([c.stat({bigint:n}),dt.lstat(e,{bigint:n}),dt.realpath(e)]);if(!m.isFile()||m.isSymbolicLink()||g!==o||!yn(a,h)||!yn(a,m))throw new ve("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:g,identity:Di(h)}),{bytes:Buffer.concat(u,p),stat:h,realPath:g}}finally{await c.close()}}function zg(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function Xo(e,t){let i=Qe.relative(e,t);return i===""||!Qe.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Qe.sep}`)}async function ed(e,t){let i=Qe.resolve(e),r=await Nn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t} project root must be a real directory`);return Nn.realpath(i)}async function td(e,t,i,r){let n=e;for(let a=0;a<i.length;a++){n=Qe.join(n,i[a]);let o;try{o=await Nn.lstat(n)}catch(d){if(zg(d))return{exists:!1,kind:"missing"};throw d}let s=Qe.relative(e,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 Nn.realpath(n);if(!Xo(t,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 Ot(e,t,i){let r=Uo(t,i.label),n=Qe.resolve(e),a=await ed(n,i.label),o=r.split("/"),s=Qe.resolve(n,...o);if(!Xo(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await td(n,a,o,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function Ze(e,t,i,r){let n=await Ot(e,t,{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 ed(n.projectRoot,r.label);return ft(n.target,i,{...r,verify:async(o,s)=>{if(!Xo(a,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await td(n.projectRoot,a,n.relative.split("/"),{label:r.label,expected:"file"})}})}var Bi=".comet/config.yaml";function Gg(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}async function Qo(e,t={}){return(await bn(e,t)).document}async function Ug(e){try{return(await Ze(e,Bi,Oi,{label:Bi})).bytes}catch(t){if(Gg(t))return null;throw t}}function Kg(e){return e?{exists:!0,sha256:Jg("sha256").update(e).digest("hex")}:{exists:!1,sha256:null}}async function bn(e,t={}){let i=await Ug(e);return{document:i?Hi(i.toString("utf8"),t):null,identity:Kg(i)}}var oE=16*1024;import{existsSync as rd,promises as ht}from"fs";import R from"path";import ew from"os";var kn=".comet/config.yaml",tw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function ts(e){try{return await ht.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function iw(e){try{let t=await ht.readFile(e,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(t)}catch(t){if(t.code==="ENOENT")return!1;throw t}}function Dt(e,t){let i=R.relative(e,t);return i===""||!R.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${R.sep}`)}async function Ht(e){let t=[],i=e;for(;!await ts(i);){let n=R.dirname(i);if(n===i)break;t.push(R.basename(i)),i=n}let r=await ht.realpath(i);return R.resolve(r,...t.reverse())}async function is(e){try{return(await ht.lstat(e)).isSymbolicLink()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Sn(e){let t=R.resolve(e);try{(await ht.stat(t)).isDirectory()||(t=R.dirname(t))}catch(n){if(n.code!=="ENOENT")throw n}let i=t,r=R.resolve(ew.homedir());for(;;){if(!(t===r&&i!==r)){let o=R.join(t,...kn.split("/")),s=t===i||await iw(o);if(await ts(o)&&s)return t}if(await ts(R.join(t,".git")))return t;let a=R.dirname(t);if(a===t)return i;t=a}}function En(e){return ut(e)}async function rw(e,t){let i=En(t),r=R.resolve(e,...i.split("/")),n=await ht.realpath(e),a=await Ht(r);if(!Dt(n,a))throw new Error("native.artifact_root resolves outside the project root");return r}async function Bt(e,t){let i=En(t),r=await rw(e,i),n=R.join(r,"comet");if(await is(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([Ht(r),Ht(n)]);if(!Dt(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=R.resolve(e),c=R.join(s,".comet","runtime","native");if(await is(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,d]=await Promise.all([ht.realpath(s),Ht(c)]);if(!Dt(l,d))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(e,...kn.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 nd(e){if(!tw.test(e))throw new Error(`Invalid Native change name: ${e}`)}function Ee(e,t){nd(t);let i=R.join(e.changesRuntimeDir,t);if(!D(e.changesRuntimeDir,i))throw new Error("Native change Runtime path escaped");return i}function rs(e,t){nd(t);let i=R.join(e.changesDir,t,"runtime");if(!D(e.changesDir,i))throw new Error("Legacy Native change Runtime path escaped");return i}function Pe(e,t){let i=Ee(e,t);if(rd(i))return i;let r=rs(e,t);return rd(r)?r:i}function xe(e,t){let i=R.resolve(t);if(D(e.runtimeDir,i))return e.runtimeDir;if(D(e.nativeRoot,i))return e.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${t}`)}function D(e,t){return Dt(R.resolve(e),R.resolve(t))}async function T(e,t){let i=R.resolve(e),r=R.resolve(t);if(!Dt(i,r))throw new Error(`Path is outside the Native root: ${t}`);if(await is(i))throw new Error(`Native root must not be a symbolic link: ${e}`);let[n,a]=await Promise.all([Ht(i),Ht(r)]);if(!Dt(n,a))throw new Error(`Path resolves outside the Native root: ${t}`);return r}function aw(e="docs",t="en"){return gn(e,t)}async function Re(e){let t=(await Qo(e))?.config??null;return t?.native?t:null}async function Fi(e){let t=await Re(e);if(t?.native.pending_root_move)throw new Error(`Native root move ${t.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function ad(e){let t=await Sn(e.startPath),i=await Re(t);if(!i&&e.allowMissingConfig===!1)throw new Error(`${kn} 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=e.explicitArtifactRoot?En(e.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??aw(r??"docs"),a=await Bt(t,n.native.artifact_root);return{config:n,paths:a,configured:i!==null}}import{promises as jy}from"fs";import $y from"path";import{AsyncLocalStorage as ow}from"async_hooks";import{randomUUID as cd}from"crypto";import{promises as se}from"fs";import ld from"os";import G from"path";var od=16*1024,ud=".coordinator",sw=5e3,sd=new ow,Pn=new Map;function cw(e){if(!/^[a-z][a-z0-9-]*$/u.test(e))throw new Error(`Invalid Native lock name: ${e}`);return`${e}.lock`}function lw(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid Native lock metadata: ${t}`);let i=e;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: ${t}`);return i}function dd(e){return{device:e.dev.toString(),inode:e.ino.toString(),size:e.size.toString(),birthtimeNs:e.birthtimeNs.toString(),ctimeNs:e.ctimeNs.toString(),mtimeNs:e.mtimeNs.toString()}}function ns(e,t){let i={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs},r={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs};return te(i,r)?A(i,r):A(i,r)&&e.size===t.size}function as(e,t){return ns(e,t)&&e.size===t.size&&e.birthtimeNs===t.birthtimeNs&&e.ctimeNs===t.ctimeNs&&e.mtimeNs===t.mtimeNs}async function $e(e){let t,i;try{let r=await ft(e,od,{bigint:!0,label:"Native lock"});t=r.bytes,i=r.stat}catch(r){if(r.code==="ENOENT")return null;throw r instanceof ve?r.reason==="too-large"?new Error(`Native lock metadata exceeds ${od} bytes: ${e}`,{cause:r}):r.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${e}`,{cause:r}):new Error(`Native lock changed while reading: ${e}`,{cause:r}):r}return{file:e,owner:lw(JSON.parse(t.toString("utf8")),e),identity:dd(i)}}async function uw(e){return(await $e(e))?.owner??null}function fd(e){if(!e)return{status:"missing",owner:null,identity:null};if(e.owner.hostname!==ld.hostname())return{status:"unknown",owner:e.owner,identity:e.identity};let t=vw(e.owner.pid);return{status:t===!0?"active":t===!1?"stale":"unknown",owner:e.owner,identity:e.identity}}async function dw(e,t){try{await se.lstat(t);return}catch(i){if(i.code!=="ENOENT")throw i}try{await se.rename(e,t)}catch(i){if(i.code!=="ENOENT")throw i}}async function os(e,t){let i=await $e(e.file);if(!i)return"missing";if(i.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!as(i.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);await se.mkdir(t,{recursive:!0});let r=G.join(t,`${G.basename(e.file)}.${e.owner.id}.${cd()}.removed`);try{await se.rename(e.file,r)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await $e(r);if(!n||n.owner.id!==e.owner.id||!ns(n.identity,e.identity))throw await dw(r,e.file),new Error(`Native lock changed before quarantine: ${e.file}`);return await se.rm(r,{force:!0}),"removed"}function hd(e){return{id:cd(),pid:process.pid,hostname:ld.hostname(),createdAt:new Date().toISOString(),operation:e}}async function pd(e,t){let i;try{i=await se.open(e,"wx")}catch(r){if(r.code==="EEXIST"){let n=await uw(e);throw new Error(`Native lock is already held: ${e}${n?` by pid ${n.pid} for ${n.operation}`:""}`,{cause:r})}throw r}try{return await i.writeFile(JSON.stringify(t,null,2)+`
144
- `,"utf8"),await i.sync(),dd(await i.stat({bigint:!0}))}finally{await i.close()}}async function fw(e,t){let i=await T(e.runtimeDir,e.locksDir);await se.mkdir(i,{recursive:!0});let r=await T(e.runtimeDir,G.join(i,ud));await se.mkdir(r,{recursive:!0});let n=hd(t),a=G.join(r,`.${n.id}.tmp`),o=G.join(r,`${n.id}.claim`);try{let s=await pd(a,n);await se.rename(a,o);let c=await $e(o);if(!c||!ns(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:e.runtimeDir,locksDir:i,owner:n,identity:c.identity}}finally{await se.rm(a,{force:!0})}}async function hw(e){let t=G.dirname(e.file),i=!1,r=G.basename(e.file);for(let n of await se.readdir(t,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=G.join(t,n.name);if(G.resolve(a)!==G.resolve(e.file))try{let o=await $e(a),s=fd(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await os(o,t);continue}n.name<r&&(i=!0)}catch{n.name<r&&(i=!0)}}return i}async function md(e){let t=await $e(e.file);if(t){if(t.owner.id!==e.owner.id||!as(t.identity,e.identity))throw new Error(`Native lock coordinator ownership changed: ${e.file}`);await os(t,G.dirname(e.file))}}async function pw(e,t){let i=Date.now()+sw;for(;;){let r=await fw(e,t);if(!await hw(r))return r;if(await md(r),Date.now()>=i)throw new Error(`Native lock coordinator is busy: ${e.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function mw(e){let t=Pn.get(e)??Promise.resolve(),i,r=new Promise(a=>{i=a}),n=t.then(()=>r);return Pn.set(e,n),await t,()=>{i(),Pn.get(e)===n&&Pn.delete(e)}}async function vd(e,t,i){let r=G.resolve(e.locksDir),n=sd.getStore();if(n?.has(r))return i();let a=await mw(r);try{let o=await pw(e,t),s=new Map(n??[]);return s.set(r,o),await sd.run(s,async()=>{try{return await i()}finally{await md(o)}})}finally{a()}}async function xn(e,t,i){return vd(e,`acquire ${t}`,async()=>{let r=await T(e.runtimeDir,e.locksDir);await se.mkdir(r,{recursive:!0});let n=await T(e.runtimeDir,G.join(r,cw(t))),a=hd(i),o=await pd(n,a);return{file:n,nativeRoot:e.runtimeDir,locksDir:r,owner:a,identity:o}})}async function Rn(e){await $e(e.file)&&await vd({runtimeDir:e.nativeRoot,locksDir:e.locksDir},`release ${G.basename(e.file)}`,async()=>{let t=await $e(e.file);if(!t)return;if(t.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!as(t.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);let i=G.join(e.locksDir,ud);await os(t,i)})}function vw(e){try{return process.kill(e,0),!0}catch(t){let i=t.code;return i==="ESRCH"?!1:i==="EPERM"?!0:null}}async function gd(e){return fd(await $e(e))}import bs from"node:path";import Jw from"node:path";import yd from"node:path";import{createHash as gw}from"crypto";function ge(e){throw new TypeError(`Value is not valid canonical JSON: ${e}`)}function ww(e,t){t.has(e)&&ge("cyclic structures are not supported"),t.add(e);try{let i=Object.keys(e);for(let r=0;r<e.length;r+=1)Object.prototype.hasOwnProperty.call(e,r)||ge("sparse arrays are not supported");return(i.length!==e.length||i.some((r,n)=>r!==String(n)))&&ge("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(e).length>0&&ge("symbol properties are not supported"),`[${e.map(r=>ss(r,t)).join(",")}]`}finally{t.delete(e)}}function yw(e,t){let i=Object.getPrototypeOf(e);i!==Object.prototype&&i!==null&&ge("only plain objects are supported"),t.has(e)&&ge("cyclic structures are not supported"),Object.getOwnPropertySymbols(e).length>0&&ge("symbol properties are not supported"),t.add(e);try{let r=Object.getOwnPropertyDescriptors(e);return`{${Object.keys(e).sort().map(o=>{let s=r[o];return(!s||!("value"in s))&&ge("accessor properties are not supported"),`${JSON.stringify(o)}:${ss(s.value,t)}`}).join(",")}}`}finally{t.delete(e)}}function ss(e,t){if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"string":return JSON.stringify(e);case"number":return Number.isFinite(e)||ge("numbers must be finite"),JSON.stringify(Object.is(e,-0)?0:e);case"object":return Array.isArray(e)?ww(e,t):yw(e,t);case"bigint":case"function":case"symbol":case"undefined":return ge(`${typeof e} values are not supported`)}return ge("unsupported value type")}function cs(e){return ss(e,new Set)}function ce(e,t){if(e.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(e))throw new TypeError("Canonical hash tag must not contain a line break");return gw("sha256").update(`${e}
145
- ${cs(t)}`).digest("hex")}var Nw="comet.native.acceptance.v1";var LE=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),qi=Object.freeze({maxCriteria:1024});function us(e){let t=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(e);return t?{level:t[1].length,text:t[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function ls(e,t){let i=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(e);if(!i)return t;let r=i[1][0];return t===null?{marker:r,length:i[1].length}:r===t.marker&&i[1].length>=t.length&&i[2].trim().length===0?null:t}function wd(e){return e.includes("-->")||e.includes("--!>")}function*Mi(e){let t=null,i=!1,r=null,n=new Set(["code","pre","script","style","svg","template"]),a=e.replace(/\r\n?/gu,`
142
+ `,i)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=gn(t),r=qt(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=gn(t),r=qt(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,i){return this.type!=="comment"||this.indent<=i?!1:t.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};cd.Parser=is});var hd=y(Li=>{"use strict";var ld=Vo(),ew=_i(),Bi=ji(),tw=qa(),iw=P(),rw=ts(),ud=rs();function dd(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new rw.LineCounter||null,prettyErrors:t}}function nw(e,t={}){let{lineCounter:i,prettyErrors:r}=dd(t),n=new ud.Parser(i?.addNewLine),a=new ld.Composer(t),o=Array.from(a.compose(n.parse(e)));if(r&&i)for(let s of o)s.errors.forEach(Bi.prettifyError(e,i)),s.warnings.forEach(Bi.prettifyError(e,i));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function fd(e,t={}){let{lineCounter:i,prettyErrors:r}=dd(t),n=new ud.Parser(i?.addNewLine),a=new ld.Composer(t),o=null;for(let s of a.compose(n.parse(e),!0,e.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new Bi.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(o.errors.forEach(Bi.prettifyError(e,i)),o.warnings.forEach(Bi.prettifyError(e,i))),o}function aw(e,t,i){let r;typeof t=="function"?r=t:i===void 0&&t&&typeof t=="object"&&(i=t);let n=fd(e,i);if(!n)return null;if(n.warnings.forEach(a=>tw.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 ow(e,t,i){let r=null;if(typeof t=="function"||Array.isArray(t)?r=t:i===void 0&&t&&(i=t),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(e===void 0){let{keepUndefined:n}=i??t??{};if(!n)return}return iw.isDocument(e)&&!r?e.toString(i):new ew.Document(e,r,i).toString(i)}Li.parse=aw;Li.parseAllDocuments=nw;Li.parseDocument=fd;Li.stringify=ow});var Ft=y(x=>{"use strict";var sw=Vo(),cw=_i(),lw=So(),ns=ji(),uw=pi(),et=P(),dw=Ke(),fw=$(),hw=Xe(),pw=Qe(),mw=mn(),vw=Zo(),gw=ts(),ww=rs(),yn=hd(),pd=ui();x.Composer=sw.Composer;x.Document=cw.Document;x.Schema=lw.Schema;x.YAMLError=ns.YAMLError;x.YAMLParseError=ns.YAMLParseError;x.YAMLWarning=ns.YAMLWarning;x.Alias=uw.Alias;x.isAlias=et.isAlias;x.isCollection=et.isCollection;x.isDocument=et.isDocument;x.isMap=et.isMap;x.isNode=et.isNode;x.isPair=et.isPair;x.isScalar=et.isScalar;x.isSeq=et.isSeq;x.Pair=dw.Pair;x.Scalar=fw.Scalar;x.YAMLMap=hw.YAMLMap;x.YAMLSeq=pw.YAMLSeq;x.CST=mw;x.Lexer=vw.Lexer;x.LineCounter=gw.LineCounter;x.Parser=ww.Parser;x.parse=yn.parse;x.parseAllDocuments=yn.parseAllDocuments;x.parseDocument=yn.parseDocument;x.stringify=yn.stringify;x.visit=pd.visit;x.visitAsync=pd.visitAsync});import{randomUUID as Jb}from"node:crypto";import{promises as z}from"node:fs";import K from"node:path";import{execFileSync as Ah}from"child_process";import si from"path";function oi(e,t){return Ah("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function _h(e,t){let i=si.normalize(e),r=si.normalize(t);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function F(e){try{let t=si.resolve(oi(e,["rev-parse","--show-toplevel"])),r=oi(e,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=r?si.resolve(r.slice(9)):t,a=null;try{a=oi(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!_h(t,n),currentWorktreeRoot:t,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function Sc(e){try{oi(e,["rev-parse","--is-inside-work-tree"]);let t=oi(e,["worktree","list","--porcelain"]).split(/\r?\n/u),i=[],r=null;for(let n of t)n.startsWith("worktree ")?(r&&i.push(r),r={root:si.resolve(n.slice(9)),branch:null,detached:!1}):r&&n.startsWith("branch refs/heads/")?r.branch=n.slice(18):r&&n==="detached"&&(r.detached=!0);return r&&i.push(r),i}catch{return[]}}function lt(e){return Sc(e).map(t=>t.root)}import{randomUUID as Th}from"crypto";import{promises as J}from"fs";import he from"path";function We(e){return e!==0&&e!==0n&&e!=="0"}function Se(e,t){return We(e.dev)&&We(t.dev)&&We(e.ino)&&We(t.ino)}function A(e,t){let i=We(e.dev)&&We(t.dev);if(i&&e.dev!==t.dev)return!1;let r=We(e.ino)&&We(t.ino);return r&&e.ino!==t.ino?!1:i&&r?!0:e.birthtime===t.birthtime}function ba(e,t){let i=he.relative(e,t);return i===""||!he.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${he.sep}`)}function Ih(e,t){return A({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function ka(e,t){return A({dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs},{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs})}function jh(e,t){return ka(e,t)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Ec(e){let t=await J.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${e}`);return{path:e,realPath:await J.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function ci(e){for(let t of e){let i=await J.lstat(t.path);if(!i.isDirectory()||i.isSymbolicLink()||!Ih(t,i)||await J.realpath(t.path)!==t.realPath)throw new Error(`Native atomic write parent changed before commit: ${t.path}`)}}async function $h(e,t){let i=he.resolve(e),r=he.resolve(t);if(!ba(i,r))throw new Error(`Native atomic write parent is outside its managed root: ${t}`);let n=[await Ec(i)],a=he.relative(i,r).split(he.sep).filter(Boolean),o=i;for(let s of a){await ci(n),o=he.join(o,s);try{await J.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Ec(o);if(!ba(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await ci(n),n}async function Oh(e){let t;try{t=await J.open(e,"r"),await t.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await t?.close()}}async function Hh(e,t,i={}){let r=he.dirname(e),n=i.containedRoot?await $h(i.containedRoot,r):null;n||await J.mkdir(r,{recursive:!0});let a=he.join(r,`.${he.basename(e)}.${Th()}.tmp`),o,s,c;try{if(await i.beforeTemporaryOpen?.(),o=await J.open(a,"wx"),s=await o.stat(),n){let[l,u]=await Promise.all([J.lstat(a),J.realpath(a)]);if(await ci(n),!l.isFile()||l.isSymbolicLink()||!ka(s,l)||!ba(n[0].realPath,u))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof t=="string"?await o.writeFile(t,"utf8"):await o.writeFile(t),await o.sync(),c=await o.stat(),!ka(s,c))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await i.beforeCommit?.(),n){await ci(n);let l=await J.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!jh(l,c))throw new Error("Native atomic write temporary file changed before commit")}i.exclusive?(await J.link(a,e),await J.unlink(a)):await J.rename(a,e),await Oh(r)}catch(l){if(await o?.close(),!n)await J.rm(a,{force:!0});else try{await ci(n),await J.rm(a,{force:!0})}catch{}throw l}}async function Y(e,t,i={}){await Hh(e,t,i)}async function X(e,t,i={}){await Y(e,JSON.stringify(t,null,2)+`
143
+ `,i)}import{createHash as qh}from"node:crypto";import{promises as pe}from"node:fs";import ce from"node:path";import{TextDecoder as Fh}from"node:util";var Dh=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Bh=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Lh(e){return e.toLowerCase().startsWith(".env")}function li(e){let i=e.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>Lh(r))?"environment-file":i.some(r=>Bh.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>Dh.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}var Nr=1024*1024;function Sa(e,t){let i=ce.relative(e,t);return i===""||!ce.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ce.sep}`)}function Mh(e){let t=ce.posix.normalize(e);if(e.length===0||e!==e.trim()||e.includes("\\")||Array.from(e).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||ce.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||t!==e||t==="."||e.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${e}`);let i=e.toLowerCase(),r=li(e);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${e}`);return e}function Vh(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native artifact byte limit must be a positive integer");return e}function Wh(e,t){return A({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function yr(e,t){let i={...e,birthtime:e.birthtimeMs},r={...t,birthtime:t.birthtimeMs};return Se(i,r)?A(i,r):A(i,r)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function Pc(e){let t=await pe.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${e}`);return{path:e,realPath:await pe.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function zh(e,t){let i=ce.resolve(e),r=ce.resolve(t);if(!Sa(i,r))throw new Error("Native artifact path is outside its root");let n=[await Pc(i)],a=i;for(let o of ce.relative(i,r).split(ce.sep).filter(Boolean)){a=ce.join(a,o);let s=await Pc(a);if(!Sa(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function xc(e){for(let t of e){let i=await pe.lstat(t.path);if(!i.isDirectory()||i.isSymbolicLink()||!Wh(t,i)||await pe.realpath(t.path)!==t.realPath)throw new Error(`Native artifact parent changed while reading: ${t.path}`)}}async function j(e){let t=Mh(e.ref),i=e.maxBytes===null?null:Vh(e.maxBytes??Nr),r=ce.resolve(e.root,...t.split("/")),n=await zh(e.root,ce.dirname(r));await e.hooks?.afterParentChainCaptured?.();let a=await pe.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${t}`);if(i!==null&&a.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${t}`);let o=await pe.realpath(r);if(!Sa(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${t}`);let s=await pe.open(r,"r");try{let[c,l,u]=await Promise.all([s.stat(),pe.lstat(r),pe.realpath(r)]);if(await xc(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!yr(a,c)||!yr(c,l))throw new Error(`Native artifact changed while opening: ${t}`);await e.hooks?.afterOpen?.();let f=[],d=0,p=Buffer.allocUnsafe(i===null?64*1024:Math.min(64*1024,i+1));for(;;){let w=i===null?p.length:i+1-d,k=await s.read(p,0,Math.min(p.length,w),null);if(k.bytesRead===0)break;if(d+=k.bytesRead,i!==null&&d>i)throw new Error(`Native artifact exceeds ${i} bytes: ${t}`);f.push(Buffer.from(p.subarray(0,k.bytesRead)))}await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),pe.lstat(r),pe.realpath(r)]);if(await xc(n),!h.isFile()||h.isSymbolicLink()||m!==o||!yr(c,v)||!yr(c,h))throw new Error(`Native artifact changed while reading: ${t}`);let g=Buffer.concat(f,d),N;try{N=new Fh("utf-8",{fatal:!0}).decode(g)}catch(w){throw new Error(`Native artifact is not valid UTF-8: ${t}`,{cause:w})}return{ref:t,size:d,hash:e.includeHash===!1?null:qh("sha256").update(g).digest("hex"),text:N}}finally{await s.close()}}var zs=ai(Ft(),1);import Zt from"path";var os=ai(Ft(),1);import Mt from"path";var qi=64*1024,Nn=1024,bn=64,ss=5,yw=12e4,md=6e5,Nw=[".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/**",".grok/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/**"],bw=["**/.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"],kw=[...Nw,...bw].sort((e,t)=>e.localeCompare(t,"en"));var re={include:["**/*"],exclude:[...kw],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function Sw(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let i=e.trim();if(i.length===0||Mt.posix.isAbsolute(i)||Mt.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${t} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${t} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${t} must not contain empty or dot path segments`);return r}function vt(e){let t=Sw(e,"native.artifact_root");return t.length===0?".":t.join("/")}function gd(e,t="docs"){let i=e??t;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function kn(e,t,i=!1){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim().replaceAll("\\","/");if(r.length===0||Mt.posix.isAbsolute(r)||Mt.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${t} must be relative to its declared path base`);let n=r.split("/");if(n.some(a=>a===".."))throw new Error(`${t} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${t} must not contain empty or dot path segments`);if(!i&&/[*?]/u.test(r))throw new Error(`${t} cannot contain wildcards`);return n.join("/")}function tt(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function wd(e,t,i){let r=e??t;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function cs(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||e.startsWith("/")||e.split("/").includes(".."))throw new Error(`${t} contains an unsafe pattern`);if(e.length>Nn)throw new Error(`${t} exceeds ${Nn} characters`);let i=0;for(let r=0;r<e.length;r+=1)e[r]==="?"?i+=1:e[r]==="*"&&(i+=1,e[r+1]==="*"&&(r+=1));if(i>bn)throw new Error(`${t} contains more than ${bn} wildcard tokens`);return e}function vd(e,t,i){if(e===void 0)return[...i];if(!Array.isArray(e))throw new Error(`${t} contains an unsafe pattern`);return[...new Set(e.map(r=>cs(r,t)))].sort((r,n)=>r.localeCompare(n,"en"))}function as(e,t,i){let r=e??t;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function Ew(e){if(e===void 0)return{...re,include:[...re.include],exclude:[...re.exclude]};let t=tt(e,"native.snapshot");return{include:vd(t.include,"native.snapshot.include",re.include),exclude:vd(t.exclude,"native.snapshot.exclude",re.exclude),max_files:as(t.max_files,re.max_files,"native.snapshot.max_files"),max_total_bytes:as(t.max_total_bytes,re.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:as(t.max_duration_ms,re.max_duration_ms,"native.snapshot.max_duration_ms")}}function Pw(e){if(e===void 0)return;let t=tt(e,"native.pending_root_move"),i=t.id,r=t.from_artifact_root,n=t.to_artifact_root,a=t.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(t.cleanup!==void 0){let s=tt(t.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,u=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:u}}return{id:i,fromArtifactRoot:vt(r),toArtifactRoot:vt(n),stage:a,...o?{cleanup:o}:{}}}function xw(e){if(e===void 0)return;let t=tt(e,"native.finish");if(t.pull_request===void 0)return{};let i=tt(t.pull_request,"native.finish.pull_request");if(i.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(i.command)||i.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(i.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let r=i.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(Mt.posix.isAbsolute(r[0])||Mt.win32.isAbsolute(r[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=i.timeout_ms??yw;if(!Number.isSafeInteger(n)||n<1||n>md)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${md}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:n}}}function Rw(e,t={}){let i=tt(e,"native"),r=i.artifact_root??(t.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??ss;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Pw(i.pending_root_move),c=xw(i.finish);return{artifact_root:vt(r),language:wd(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Ew(i.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function Cw(e){let t=tt(e,"classic"),i=t.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=t.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=t.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:gd(t.artifact_layout),language:wd(t.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function Aw(e){let i=tt(e,"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)=>kn(r,`hook.allow_paths[${n}]`)))]}}function _w(e){let t=e??!0;if(typeof t!="boolean")throw new Error("ambient_resume must be true or false");return t}function Tw(e,t,i,r,n,a){let o=e.schema!==void 0;if(!(o||e.default_workflow!==void 0||e.workflows!==void 0||!a.allowPartialProject&&e.native!==void 0)||a.allowPartialProject&&!o)return null;if(e.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(e.default_workflow!=="native"&&e.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let c=e.workflows??[e.default_workflow];if(!Array.isArray(c)||c.length===0||c.some(u=>u!=="native"&&u!=="classic"))throw new Error("workflows must contain native and/or classic");let l=[...new Set(c)];if(!l.includes(e.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:e.default_workflow,workflows:l,ambient_resume:n,...t?{hook:t}:{},...i?{native:i}:{},...r?{classic:r}:{}}}function Fi(e,t={}){let i=(0,os.parseDocument)(e,{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=_w(n.ambient_resume),o=n.hook===void 0?void 0:Aw(n.hook),s=n.native===void 0?void 0:Rw(n.native,{allowMissingArtifactRoot:t.allowMissingNativeFields}),c=n.classic===void 0?void 0:Cw(n.classic),l=Tw(n,o,s,c,a,{allowPartialProject:t.allowPartialProject??!1});return{value:n,config:l,ambient_resume:a,...o?{hook:o}:{},...s?{native:s}:{},...c?{classic:c}:{}}}function Sn(e="docs",t="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:vt(e),language:t,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:ss,snapshot:{...re,include:[...re.include],exclude:[...re.exclude]}}}}import{createHash as jw}from"crypto";import{promises as xn}from"fs";import it from"path";import{constants as En,promises as gt}from"fs";var ge=class extends Error{reason;constructor(t,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=t}};function ls(e){return"birthtimeNs"in e&&typeof e.birthtimeNs=="bigint"?e.birthtimeNs:e.birthtimeMs}function yd(e){return"ctimeNs"in e&&typeof e.ctimeNs=="bigint"?e.ctimeNs:e.ctimeMs}function Mi(e){return{dev:e.dev,ino:e.ino,birthtime:ls(e)}}function Pn(e,t){let i=Mi(e),r=Mi(t);return Se(i,r)?A(i,r):A(i,r)&&ls(e)===ls(t)&&yd(e)===yd(t)&&e.size===t.size}async function wt(e,t,i={}){if(!Number.isSafeInteger(t)||t<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 gt.lstat(e,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new ge("not-regular-file",`${r} must be a regular file`);if(BigInt(a.size)>BigInt(t))throw new ge("too-large",`${r} exceeds ${t} bytes`);let o=await gt.realpath(e);await i.verify?.("pre-open",{realPath:o,identity:Mi(a)});let s=process.platform==="win32"?En.O_RDONLY:En.O_RDONLY|En.O_NOFOLLOW|En.O_NONBLOCK,c;try{c=await gt.open(e,s)}catch(l){throw l.code==="ELOOP"?new ge("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,f]=await Promise.all([c.stat({bigint:n}),gt.lstat(e,{bigint:n}),gt.realpath(e)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||f!==o||!Pn(a,l)||!Pn(a,u))throw new ge("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:f,identity:Mi(l)}),await i.hooks?.afterOpen?.();let d=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let N=t+1-p,{bytesRead:w}=await c.read(v,0,Math.min(v.length,N),null);if(w===0)break;if(p+=w,p>t)throw new ge("too-large",`${r} exceeds ${t} bytes`);d.push(Buffer.from(v.subarray(0,w)))}await i.hooks?.beforeFinalCheck?.();let[h,m,g]=await Promise.all([c.stat({bigint:n}),gt.lstat(e,{bigint:n}),gt.realpath(e)]);if(!m.isFile()||m.isSymbolicLink()||g!==o||!Pn(a,h)||!Pn(a,m))throw new ge("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:g,identity:Mi(h)}),{bytes:Buffer.concat(d,p),stat:h,realPath:g}}finally{await c.close()}}function Iw(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function us(e,t){let i=it.relative(e,t);return i===""||!it.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${it.sep}`)}async function Nd(e,t){let i=it.resolve(e),r=await xn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t} project root must be a real directory`);return xn.realpath(i)}async function bd(e,t,i,r){let n=e;for(let a=0;a<i.length;a++){n=it.join(n,i[a]);let o;try{o=await xn.lstat(n)}catch(u){if(Iw(u))return{exists:!1,kind:"missing"};throw u}let s=it.relative(e,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 xn.realpath(n);if(!us(t,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 Vt(e,t,i){let r=kn(t,i.label),n=it.resolve(e),a=await Nd(n,i.label),o=r.split("/"),s=it.resolve(n,...o);if(!us(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await bd(n,a,o,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function rt(e,t,i,r){let n=await Vt(e,t,{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 Nd(n.projectRoot,r.label);return wt(n.target,i,{...r,verify:async(o,s)=>{if(!us(a,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await bd(n.projectRoot,a,n.relative.split("/"),{label:r.label,expected:"file"})}})}var Vi=".comet/config.yaml";function $w(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}async function Rn(e,t={}){return(await Cn(e,t)).document}async function Ow(e){try{return(await rt(e,Vi,qi,{label:Vi})).bytes}catch(t){if($w(t))return null;throw t}}function Hw(e){return e?{exists:!0,sha256:jw("sha256").update(e).digest("hex")}:{exists:!1,sha256:null}}async function Cn(e,t={}){let i=await Ow(e);return{document:i?Fi(i.toString("utf8"),t):null,identity:Hw(i)}}async function ds(e){return(await Rn(e))?.config??null}var gP=16*1024;import{existsSync as Sd,promises as yt}from"fs";import R from"path";import Fw from"os";var An=".comet/config.yaml",Mw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function ps(e){try{return await yt.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Vw(e){try{let t=await yt.readFile(e,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(t)}catch(t){if(t.code==="ENOENT")return!1;throw t}}function zt(e,t){let i=R.relative(e,t);return i===""||!R.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${R.sep}`)}async function Wt(e){let t=[],i=e;for(;!await ps(i);){let n=R.dirname(i);if(n===i)break;t.push(R.basename(i)),i=n}let r=await yt.realpath(i);return R.resolve(r,...t.reverse())}async function ms(e){try{return(await yt.lstat(e)).isSymbolicLink()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function _n(e){let t=R.resolve(e);try{(await yt.stat(t)).isDirectory()||(t=R.dirname(t))}catch(n){if(n.code!=="ENOENT")throw n}let i=t,r=R.resolve(Fw.homedir());for(;;){if(!(t===r&&i!==r)){let o=R.join(t,...An.split("/")),s=t===i||await Vw(o);if(await ps(o)&&s)return t}if(await ps(R.join(t,".git")))return t;let a=R.dirname(t);if(a===t)return i;t=a}}function Tn(e){return vt(e)}async function Ww(e,t){let i=Tn(t),r=R.resolve(e,...i.split("/")),n=await yt.realpath(e),a=await Wt(r);if(!zt(n,a))throw new Error("native.artifact_root resolves outside the project root");return r}async function nt(e,t){let i=Tn(t),r=await Ww(e,i),n=R.join(r,"comet");if(await ms(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([Wt(r),Wt(n)]);if(!zt(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=R.resolve(e),c=R.join(s,".comet","runtime","native");if(await ms(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,u]=await Promise.all([yt.realpath(s),Wt(c)]);if(!zt(l,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(e,...An.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 Ed(e){if(!Mw.test(e))throw new Error(`Invalid Native change name: ${e}`)}function xe(e,t){Ed(t);let i=R.join(e.changesRuntimeDir,t);if(!L(e.changesRuntimeDir,i))throw new Error("Native change Runtime path escaped");return i}function vs(e,t){Ed(t);let i=R.join(e.changesDir,t,"runtime");if(!L(e.changesDir,i))throw new Error("Legacy Native change Runtime path escaped");return i}function Re(e,t){let i=xe(e,t);if(Sd(i))return i;let r=vs(e,t);return Sd(r)?r:i}function Ce(e,t){let i=R.resolve(t);if(L(e.runtimeDir,i))return e.runtimeDir;if(L(e.nativeRoot,i))return e.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${t}`)}function L(e,t){return zt(R.resolve(e),R.resolve(t))}async function T(e,t){let i=R.resolve(e),r=R.resolve(t);if(!zt(i,r))throw new Error(`Path is outside the Native root: ${t}`);if(await ms(i))throw new Error(`Native root must not be a symbolic link: ${e}`);let[n,a]=await Promise.all([Wt(i),Wt(r)]);if(!zt(n,a))throw new Error(`Path resolves outside the Native root: ${t}`);return r}function Jw(e="docs",t="en"){return Sn(e,t)}async function we(e){let t=(await Rn(e))?.config??null;return t?.native?t:null}async function zi(e){let t=await we(e);if(t?.native.pending_root_move)throw new Error(`Native root move ${t.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function Pd(e){let t=await _n(e.startPath),i=await we(t);if(!i&&e.allowMissingConfig===!1)throw new Error(`${An} 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=e.explicitArtifactRoot?Tn(e.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??Jw(r??"docs"),a=await nt(t,n.native.artifact_root);return{config:n,paths:a,configured:i!==null}}import{promises as kN}from"fs";import SN from"path";import{AsyncLocalStorage as Gw}from"async_hooks";import{randomUUID as Cd}from"crypto";import{promises as ue}from"fs";import Ad from"os";import U from"path";var xd=16*1024,_d=".coordinator",Uw=5e3,Rd=new Gw,In=new Map;function Kw(e){if(!/^[a-z][a-z0-9-]*$/u.test(e))throw new Error(`Invalid Native lock name: ${e}`);return`${e}.lock`}function Yw(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid Native lock metadata: ${t}`);let i=e;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: ${t}`);return i}function Td(e){return{device:e.dev.toString(),inode:e.ino.toString(),size:e.size.toString(),birthtimeNs:e.birthtimeNs.toString(),ctimeNs:e.ctimeNs.toString(),mtimeNs:e.mtimeNs.toString()}}function gs(e,t){let i={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs},r={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs};return Se(i,r)?A(i,r):A(i,r)&&e.size===t.size}function ws(e,t){return gs(e,t)&&e.size===t.size&&e.birthtimeNs===t.birthtimeNs&&e.ctimeNs===t.ctimeNs&&e.mtimeNs===t.mtimeNs}async function Oe(e){let t,i;try{let r=await wt(e,xd,{bigint:!0,label:"Native lock"});t=r.bytes,i=r.stat}catch(r){if(r.code==="ENOENT")return null;throw r instanceof ge?r.reason==="too-large"?new Error(`Native lock metadata exceeds ${xd} bytes: ${e}`,{cause:r}):r.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${e}`,{cause:r}):new Error(`Native lock changed while reading: ${e}`,{cause:r}):r}return{file:e,owner:Yw(JSON.parse(t.toString("utf8")),e),identity:Td(i)}}async function Xw(e){return(await Oe(e))?.owner??null}function Id(e){if(!e)return{status:"missing",owner:null,identity:null};if(e.owner.hostname!==Ad.hostname())return{status:"unknown",owner:e.owner,identity:e.identity};let t=ry(e.owner.pid);return{status:t===!0?"active":t===!1?"stale":"unknown",owner:e.owner,identity:e.identity}}async function Qw(e,t){try{await ue.lstat(t);return}catch(i){if(i.code!=="ENOENT")throw i}try{await ue.rename(e,t)}catch(i){if(i.code!=="ENOENT")throw i}}async function ys(e,t){let i=await Oe(e.file);if(!i)return"missing";if(i.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!ws(i.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);await ue.mkdir(t,{recursive:!0});let r=U.join(t,`${U.basename(e.file)}.${e.owner.id}.${Cd()}.removed`);try{await ue.rename(e.file,r)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await Oe(r);if(!n||n.owner.id!==e.owner.id||!gs(n.identity,e.identity))throw await Qw(r,e.file),new Error(`Native lock changed before quarantine: ${e.file}`);return await ue.rm(r,{force:!0}),"removed"}function jd(e){return{id:Cd(),pid:process.pid,hostname:Ad.hostname(),createdAt:new Date().toISOString(),operation:e}}async function $d(e,t){let i;try{i=await ue.open(e,"wx")}catch(r){if(r.code==="EEXIST"){let n=await Xw(e);throw new Error(`Native lock is already held: ${e}${n?` by pid ${n.pid} for ${n.operation}`:""}`,{cause:r})}throw r}try{return await i.writeFile(JSON.stringify(t,null,2)+`
144
+ `,"utf8"),await i.sync(),Td(await i.stat({bigint:!0}))}finally{await i.close()}}async function Zw(e,t){let i=await T(e.runtimeDir,e.locksDir);await ue.mkdir(i,{recursive:!0});let r=await T(e.runtimeDir,U.join(i,_d));await ue.mkdir(r,{recursive:!0});let n=jd(t),a=U.join(r,`.${n.id}.tmp`),o=U.join(r,`${n.id}.claim`);try{let s=await $d(a,n);await ue.rename(a,o);let c=await Oe(o);if(!c||!gs(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:e.runtimeDir,locksDir:i,owner:n,identity:c.identity}}finally{await ue.rm(a,{force:!0})}}async function ey(e){let t=U.dirname(e.file),i=!1,r=U.basename(e.file);for(let n of await ue.readdir(t,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=U.join(t,n.name);if(U.resolve(a)!==U.resolve(e.file))try{let o=await Oe(a),s=Id(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await ys(o,t);continue}n.name<r&&(i=!0)}catch{n.name<r&&(i=!0)}}return i}async function Od(e){let t=await Oe(e.file);if(t){if(t.owner.id!==e.owner.id||!ws(t.identity,e.identity))throw new Error(`Native lock coordinator ownership changed: ${e.file}`);await ys(t,U.dirname(e.file))}}async function ty(e,t){let i=Date.now()+Uw;for(;;){let r=await Zw(e,t);if(!await ey(r))return r;if(await Od(r),Date.now()>=i)throw new Error(`Native lock coordinator is busy: ${e.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function iy(e){let t=In.get(e)??Promise.resolve(),i,r=new Promise(a=>{i=a}),n=t.then(()=>r);return In.set(e,n),await t,()=>{i(),In.get(e)===n&&In.delete(e)}}async function Hd(e,t,i){let r=U.resolve(e.locksDir),n=Rd.getStore();if(n?.has(r))return i();let a=await iy(r);try{let o=await ty(e,t),s=new Map(n??[]);return s.set(r,o),await Rd.run(s,async()=>{try{return await i()}finally{await Od(o)}})}finally{a()}}async function jn(e,t,i){return Hd(e,`acquire ${t}`,async()=>{let r=await T(e.runtimeDir,e.locksDir);await ue.mkdir(r,{recursive:!0});let n=await T(e.runtimeDir,U.join(r,Kw(t))),a=jd(i),o=await $d(n,a);return{file:n,nativeRoot:e.runtimeDir,locksDir:r,owner:a,identity:o}})}async function $n(e){await Oe(e.file)&&await Hd({runtimeDir:e.nativeRoot,locksDir:e.locksDir},`release ${U.basename(e.file)}`,async()=>{let t=await Oe(e.file);if(!t)return;if(t.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!ws(t.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);let i=U.join(e.locksDir,_d);await ys(t,i)})}function ry(e){try{return process.kill(e,0),!0}catch(t){let i=t.code;return i==="ESRCH"?!1:i==="EPERM"?!0:null}}async function Dd(e){return Id(await Oe(e))}import $s from"node:path";import Oy from"node:path";import Ld from"node:path";import{createHash as ny}from"crypto";function ye(e){throw new TypeError(`Value is not valid canonical JSON: ${e}`)}function ay(e,t){t.has(e)&&ye("cyclic structures are not supported"),t.add(e);try{let i=Object.keys(e);for(let r=0;r<e.length;r+=1)Object.prototype.hasOwnProperty.call(e,r)||ye("sparse arrays are not supported");return(i.length!==e.length||i.some((r,n)=>r!==String(n)))&&ye("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(e).length>0&&ye("symbol properties are not supported"),`[${e.map(r=>Ns(r,t)).join(",")}]`}finally{t.delete(e)}}function oy(e,t){let i=Object.getPrototypeOf(e);i!==Object.prototype&&i!==null&&ye("only plain objects are supported"),t.has(e)&&ye("cyclic structures are not supported"),Object.getOwnPropertySymbols(e).length>0&&ye("symbol properties are not supported"),t.add(e);try{let r=Object.getOwnPropertyDescriptors(e);return`{${Object.keys(e).sort().map(o=>{let s=r[o];return(!s||!("value"in s))&&ye("accessor properties are not supported"),`${JSON.stringify(o)}:${Ns(s.value,t)}`}).join(",")}}`}finally{t.delete(e)}}function Ns(e,t){if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"string":return JSON.stringify(e);case"number":return Number.isFinite(e)||ye("numbers must be finite"),JSON.stringify(Object.is(e,-0)?0:e);case"object":return Array.isArray(e)?ay(e,t):oy(e,t);case"bigint":case"function":case"symbol":case"undefined":return ye(`${typeof e} values are not supported`)}return ye("unsupported value type")}function bs(e){return Ns(e,new Set)}function ee(e,t){if(e.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(e))throw new TypeError("Canonical hash tag must not contain a line break");return ny("sha256").update(`${e}
145
+ ${bs(t)}`).digest("hex")}var sy="comet.native.acceptance.v1";var YP=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Ui=Object.freeze({maxCriteria:1024});function Ss(e){let t=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(e);return t?{level:t[1].length,text:t[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function ks(e,t){let i=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(e);if(!i)return t;let r=i[1][0];return t===null?{marker:r,length:i[1].length}:r===t.marker&&i[1].length>=t.length&&i[2].trim().length===0?null:t}function Bd(e){return e.includes("-->")||e.includes("--!>")}function*Ji(e){let t=null,i=!1,r=null,n=new Set(["code","pre","script","style","svg","template"]),a=e.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:t===null&&!i&&r===null,index:s},s+=1,t!==null)t=ls(l,t);else if(i)wd(l)&&(i=!1);else if(r!==null)new RegExp(`</${r}\\s*>`,"iu").test(l)&&(r=null);else{let f=ls(l,null);if(f!==null)t=f;else{let u=l.trimStart();if(u.startsWith("<!--")&&!wd(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(e){return e.normalize("NFC").replace(/\s+/gu," ").trim()}function ds(e,t,i,r=[],n="content-hash"){let a=Vi(i),o=t.replaceAll("\\","/").trim(),s=r.map(Vi);if(a.length===0)throw new Error(`${e} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${e} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${ce(Nw,{kind:e,source:o,context:s,text:a})}`:"",kind:e,source:o,context:s,text:a}}function fs(e,t,i="content-hash"){let r=new Set;for(let n of e){let a=i==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(r.has(a))throw new Error(`${t} contains duplicate acceptance criteria`);r.add(a)}return e}function bw(e){let t=null,i=null,r=0,n=0;for(let{line:a,body:o,index:s}of Mi(e)){n=s+1;let c=o?us(a):null;c?.level===1&&(c.text.toLocaleLowerCase("en-US")==="acceptance examples"?(r+=1,r===1&&(t=s+1)):t!==null&&i===null&&(i=s))}if(r===0||t===null)return null;if(r!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:t,end:i??n}}function hs(e,t="brief.md",i=qi.maxCriteria,r="content-hash"){if(!Number.isSafeInteger(i)||i<0)throw new Error("Native brief acceptance budget is invalid");let n=bw(e);if(n===null)return[];let a=null;for(let{line:l,body:d,index:f}of Mi(e)){if(f<n.start||f>=n.end)continue;let u=d?/^( {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:d,index:f}of Mi(e)){if(f<n.start||f>=n.end)continue;let u=d?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(l):null;u&&u[1].length===a?(c(),s=[u[2]]):s!==null&&s.push(l)}return c(),fs(o.map(l=>ds("brief-example",t,l.join(`
148
- `),[],r)),"Brief",r)}function ps(e,t="spec.md",i=qi.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(ds("spec-scenario",t,[o.title,...o.body].join(`
149
- `),o.context,r)),o=null}};for(let{line:c,body:l}of Mi(e)){let d=l?us(c):null,f=d?/^Scenario\s*:\s*(.*)$/iu.exec(d.text):null;if(f){for(s();a.at(-1)&&a.at(-1).level>=d.level;)a.pop();let u=Vi(f[1]);if(u.length===0)throw new Error("Scenario title must not be empty");o={level:d.level,title:u,body:[],context:a.map(p=>p.text)}}else if(d){for(o!==null&&d.level<=o.level?s():o!==null&&o.body.push(c);a.at(-1)&&a.at(-1).level>=d.level;)a.pop();a.push(d)}else o!==null&&l&&o.body.push(c)}return s(),fs(n,"Specification",r)}function ms(e,t="spec.md",i=qi.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(ds("spec-must",t,s.parts.join(" "),s.context,r)),s=null}},l=()=>a.some(d=>/^(?:non-?goals?|非目标)$/iu.test(d.text.trim()));for(let{line:d,body:f}of Mi(e)){let u=f?us(d):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=d.trim();if(!f||o!==null||l()){c();continue}if(p.length===0||ls(d,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(d);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(),fs(n,"Specification mandatory requirements",r)}var kw=/^A[1-9]\d*$/u;function Nd(e,t){if(e.length===0||e!==e.trim()||e.includes("\\")||yd.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||yd.posix.normalize(e)!==e||e==="."||e.endsWith("/"))throw new Error(`${t} must be a normalized change-relative ref`);return e}function Sw(e,t){return e.localeCompare(t,"en")}function Cn(e){let t=Nd(e.briefSource??"brief.md","Native brief source"),i=[...e.specs??[]].sort((a,o)=>Sw(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=hs(e.briefMarkdown,t,Number.MAX_SAFE_INTEGER,"none").map(({source:a,text:o})=>({source:a,text:o}));for(let a of i){let o=Nd(a.source,`Native spec source for ${a.capability}`);r.push(...ps(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})),...ms(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 bd(e){let t=e.map(({id:i})=>i);if(new Set(t).size!==t.length)throw new Error("Native acceptance IDs must be unique");for(let i=0;i<t.length;i+=1)if(!kw.test(t[i])||t[i]!==`A${i+1}`)throw new Error("Native acceptance IDs must be the contiguous sequence A1..An")}function kd(e,t){return e.length===t.length&&e.every((i,r)=>i.source===t[r]?.source&&i.text===t[r]?.text)}var Tn=fr(ji(),1);import{promises as Ew}from"node:fs";var Lt="comet.native.v4",Wi="comet.native.local-execution.v4";function vs(){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 Pw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,xw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Rw=/^A[1-9][0-9]*$/u,Cw=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"]),_n=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(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function ee(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function z(e,t,i){if(typeof e!="string"||!i?.empty&&e.length===0)throw new Error(`${t} must be ${i?.empty?"a string":"a non-empty string"}`);return e}function ws(e,t){return e===null?null:z(e,t)}function Ft(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function _(e,t,i=0){if(!Number.isSafeInteger(e)||e<i)throw new Error(`${t} must be a safe integer greater than or equal to ${i}`);return e}function Aw(e,t){return e===null?null:_(e,t,Number.MIN_SAFE_INTEGER)}function V(e,t,i){if(typeof e!="string"||!t.includes(e))throw new Error(`${i} must be one of: ${t.join(", ")}`);return e}function Ce(e,t,i){if(!Array.isArray(e))throw new Error(`${t} must be an array`);return e.map((r,n)=>i(r,n))}function In(e,t){return Ce(e,t,(i,r)=>z(i,`${t}[${r}]`))}function pt(e,t){if(new Set(e).size!==e.length)throw new Error(`${t} must be unique`)}function Mt(e,t){let i=z(e,t);if(Number.isNaN(Date.parse(i)))throw new Error(`${t} must be an ISO date or timestamp`);return i}function ys(e,t,i=!1){let r=z(e,t);if(r.includes("\\")||r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").includes("..")||!i&&(r==="."||r.split("/").includes(".")))throw new Error(`${t} must be a portable relative path`);return r}function we(e,t){let i=Z(e,t);return ee(i,new Set(["text","truncated"]),t),{text:z(i.text,`${t}.text`,{empty:!0}),truncated:Ft(i.truncated,`${t}.truncated`)}}function _w(e,t){let i=`Native spec_changes[${t}]`,r=Z(e,i);ee(r,new Set(["capability","operation","source"]),i);let n=z(r.capability,`${i}.capability`);if(!xw.test(n))throw new Error(`${i}.capability is invalid`);let a=V(r.operation,["create","modify","remove"],`${i}.operation`),o=r.source===null?null:ys(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 Tw(e){let t="Native workspace",i=Z(e,t);ee(i,new Set(["isolation","change_branch","target_branch","finish"]),t);let r=V(i.isolation,["current","branch","worktree"],`${t}.isolation`),n=ws(i.change_branch,`${t}.change_branch`),a=ws(i.target_branch,`${t}.target_branch`),o=i.finish===null?null:V(i.finish,["merge","push","pull-request","keep"],`${t}.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 Iw(e){let t="Native loop",i=Z(e,t);ee(i,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","execution_failure_count","previous_unresolved_ids","next_action"]),t);let r=In(i.previous_unresolved_ids,`${t}.previous_unresolved_ids`);return pt(r,`${t}.previous_unresolved_ids`),{stage:V(i.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${t}.stage`),goal_cycle:_(i.goal_cycle,`${t}.goal_cycle`,1),iteration:_(i.iteration,`${t}.iteration`),attempt:_(i.attempt,`${t}.attempt`),retry_epoch:_(i.retry_epoch,`${t}.retry_epoch`),failed_iteration_count:_(i.failed_iteration_count,`${t}.failed_iteration_count`),no_progress_count:_(i.no_progress_count,`${t}.no_progress_count`),execution_failure_count:_(i.execution_failure_count,`${t}.execution_failure_count`),previous_unresolved_ids:r,next_action:ws(i.next_action,`${t}.next_action`)}}function jw(e,t){let i=`Native acceptance[${t}]`,r=Z(e,i);ee(r,new Set(["id","source","text","result","reason"]),i);let n=z(r.id,`${i}.id`);if(!Rw.test(n))throw new Error(`${i}.id must use A1, A2, ...`);return{id:n,source:ys(r.source,`${i}.source`),text:z(r.text,`${i}.text`),result:V(r.result,["pending","passed","failed","blocked"],`${i}.result`),reason:r.reason===null?null:we(r.reason,`${i}.reason`)}}function $w(e,t){let i=`Native builder_handoff.checks[${t}]`,r=Z(e,i);return ee(r,new Set(["name","result","note"]),i),{name:we(r.name,`${i}.name`),result:V(r.result,["passed","failed","not-run"],`${i}.result`),note:r.note===null?null:we(r.note,`${i}.note`)}}function Ow(e){let t="Native builder_handoff",i=Z(e,t);ee(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"]),t);let r=In(i.addressed_acceptance_ids,`${t}.addressed_acceptance_ids`);return pt(r,`${t}.addressed_acceptance_ids`),{candidate_id:z(i.candidate_id,`${t}.candidate_id`),identity_provider:z(i.identity_provider,`${t}.identity_provider`),builder_execution_ref:z(i.builder_execution_ref,`${t}.builder_execution_ref`),iteration:_(i.iteration,`${t}.iteration`,1),summary:we(i.summary,`${t}.summary`),addressed_acceptance_ids:r,checks:Ce(i.checks,`${t}.checks`,$w),checks_truncated:Ft(i.checks_truncated,`${t}.checks_truncated`),known_limits:Ce(i.known_limits,`${t}.known_limits`,(n,a)=>we(n,`${t}.known_limits[${a}]`)),known_limits_truncated:Ft(i.known_limits_truncated,`${t}.known_limits_truncated`),submitted_at:Mt(i.submitted_at,`${t}.submitted_at`)}}function Hw(e,t){let i=`Native blockers[${t}]`,r=Z(e,i);ee(r,new Set(["owner","reason","acceptance_ids","resolution_action"]),i);let n=In(r.acceptance_ids,`${i}.acceptance_ids`);return pt(n,`${i}.acceptance_ids`),{owner:V(r.owner,["builder","runtime","verifier","user","external"],`${i}.owner`),reason:we(r.reason,`${i}.reason`),acceptance_ids:n,resolution_action:V(r.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${i}.resolution_action`)}}function Dw(e,t){let i=`Native verification.checks[${t}]`,r=Z(e,i);return ee(r,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),i),{id:z(r.id,`${i}.id`),name:we(r.name,`${i}.name`),argv_display:Ce(r.argv_display,`${i}.argv_display`,(n,a)=>we(n,`${i}.argv_display[${a}]`)),argv_truncated:Ft(r.argv_truncated,`${i}.argv_truncated`),cwd_ref:ys(r.cwd_ref,`${i}.cwd_ref`,!0),status:V(r.status,["passed","failed","interrupted"],`${i}.status`),exit_code:Aw(r.exit_code,`${i}.exit_code`),duration_ms:_(r.duration_ms,`${i}.duration_ms`)}}function Bw(e){let t="Native verification",i=Z(e,t);ee(i,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),t);let r=Ce(i.checks,`${t}.checks`,Dw);pt(r.map(a=>a.id),`${t}.checks IDs`);let n=z(i.identity_provider,`${t}.identity_provider`);return{candidate_id:z(i.candidate_id,`${t}.candidate_id`),identity_provider:n,verifier_execution_ref:z(i.verifier_execution_ref,`${t}.verifier_execution_ref`),iteration:_(i.iteration,`${t}.iteration`,1),attempt:_(i.attempt,`${t}.attempt`,1),assurance:i.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":V(i.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${t}.assurance`),verdict:V(i.verdict,["pass","fail","blocked"],`${t}.verdict`),checks:r,summary:we(i.summary,`${t}.summary`),risks:Ce(i.risks,`${t}.risks`,(a,o)=>we(a,`${t}.risks[${o}]`)),risks_truncated:Ft(i.risks_truncated,`${t}.risks_truncated`),completed_at:Mt(i.completed_at,`${t}.completed_at`)}}function Sd(e,t){let i=`Native history[${t}]`,r=Z(e,i);ee(r,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),i);let n=In(r.unresolved_ids,`${i}.unresolved_ids`);return pt(n,`${i}.unresolved_ids`),{goal_cycle:_(r.goal_cycle,`${i}.goal_cycle`,1),iteration:_(r.iteration,`${i}.iteration`),attempt:_(r.attempt,`${i}.attempt`),outcome:V(r.outcome,["pass","fail","blocked","execution-error","recovery"],`${i}.outcome`),unresolved_ids:n,summary:we(r.summary,`${i}.summary`),completed_at:Mt(r.completed_at,`${i}.completed_at`)}}function Lw(e){let t="Native history_overflow.outcome_counts",i=Z(e,t),r=["pass","fail","blocked","execution-error","recovery"];return ee(i,new Set(r),t),{pass:_(i.pass,`${t}.pass`),fail:_(i.fail,`${t}.fail`),blocked:_(i.blocked,`${t}.blocked`),"execution-error":_(i["execution-error"],`${t}.execution-error`),recovery:_(i.recovery,`${t}.recovery`)}}function Fw(e){let t="Native history_overflow",i=Z(e,t);ee(i,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),t);let r=_(i.dropped_entries,`${t}.dropped_entries`),n=i.first_dropped_at===null?null:Mt(i.first_dropped_at,`${t}.first_dropped_at`),a=i.last_dropped_at===null?null:Mt(i.last_dropped_at,`${t}.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=Lw(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 Mw(e){let t=new Set(e.acceptance.map(i=>i.id));for(let i of e.loop.previous_unresolved_ids)if(!t.has(i))throw new Error(`Native loop references unknown acceptance ID ${i}`);for(let i of e.builder_handoff?.addressed_acceptance_ids??[])if(!t.has(i))throw new Error(`Native builder handoff references unknown ID ${i}`);for(let i of e.blockers)for(let r of i.acceptance_ids)if(!t.has(r))throw new Error(`Native blocker references unknown ID ${r}`);if(e.builder_handoff&&!(e.builder_handoff.iteration===e.loop.iteration||e.phase==="build"&&e.loop.stage==="repairing"&&e.builder_handoff.iteration===e.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(e.verification){if(!e.builder_handoff)throw new Error("Native verification requires a builder handoff");if(e.verification.candidate_id!==e.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(e.verification.identity_provider!==e.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(e.verification.assurance)!==(e.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(e.verification.assurance==="semantic-verification-unavailable"&&e.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(e.verification.assurance==="user-confirmed-degraded"&&e.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(e.verification.verifier_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let r=e.verification.iteration===e.loop.iteration&&e.verification.attempt===e.loop.attempt,n=e.phase==="build"&&e.loop.stage==="repairing"&&e.verification.iteration===e.loop.iteration-1&&e.verification.iteration===e.builder_handoff.iteration;if(!r&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Vw(e){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[e.phase].has(e.loop.stage))throw new Error(`Native loop stage ${e.loop.stage} is invalid for phase ${e.phase}`);let i=e.status==="await-user"?"await-user":e.status==="blocked"?"blocked":e.status==="done"?"done":null;if(i!==null&&e.loop.stage!==i)throw new Error(`Native status ${e.status} requires loop stage ${i}`);if(e.status==="active"&&["await-user","blocked","done"].includes(e.loop.stage))throw new Error(`Native active status cannot use loop stage ${e.loop.stage}`);if(e.archived!==(e.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(e.archived&&e.phase!=="archive")throw new Error("Native archived state must be in Archive");if(e.verification_result==="pass"){if(e.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(e.acceptance.some(r=>r.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(e.verification.checks.some(r=>r.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(e.verification?.assurance==="semantic-verification-unavailable"&&(e.phase!=="verify"||e.status!=="await-user"||e.verification_result!=="blocked"||e.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(e.verification_report!==null&&e.verification===null)throw new Error("Native verification report requires persisted verification")}function le(e){let t=Z(e,"Native portable state");if(ee(t,Cw,"Native portable state"),t.schema!==Lt)throw new Error(`Native portable state schema must be ${Lt}`);let i=z(t.name,"Native state name");if(!Pw.test(i))throw new Error("Native state name is invalid");if(t.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let r=Ce(t.spec_changes,"Native spec_changes",_w);pt(r.map(s=>s.capability),"Native spec change capabilities");let n=Ce(t.acceptance,"Native acceptance",jw);pt(n.map(s=>s.id),"Native acceptance IDs");let a=Ce(t.history,"Native history",Sd);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Lt,name:i,language:V(t.language,["en","zh-CN"],"Native state language"),phase:V(t.phase,["shape","build","verify","archive"],"Native state phase"),status:V(t.status,["active","await-user","blocked","done"],"Native state status"),state_version:_(t.state_version,"Native state_version",1),brief:"brief.md",spec_changes:r,workspace:Tw(t.workspace),loop:Iw(t.loop),acceptance:n,builder_handoff:t.builder_handoff===null?null:Ow(t.builder_handoff),blockers:Ce(t.blockers,"Native blockers",Hw),verification:t.verification===null?null:Bw(t.verification),history:a,history_overflow:Fw(t.history_overflow),verification_result:V(t.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:t.verification_report===null?null:V(t.verification_report,["verification.md"],"Native verification_report"),archived:Ft(t.archived,"Native archived"),created_at:Mt(t.created_at,"Native created_at")};return Mw(o),Vw(o),o}function Vt(e,t){let i=le(e),r=Sd(t,i.history.length),n=[...i.history,r],a={...i.history_overflow,outcome_counts:{...i.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return le({...i,history:n,history_overflow:a})}function qw(e,t){let i=(0,Tn.parseDocument)(e,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`${t} is invalid YAML: ${i.errors[0].message}`);return i.toJS({mapAsMap:!1})}async function ue(e){let t=await Ew.readFile(e,"utf8");return le(qw(t,"Native portable state"))}async function jn(e,t,i={}){let r=le(t);await K(e,(0,Tn.stringify)(r),i)}var An=new Map;async function Ww(e,t){let i=An.get(e)??Promise.resolve(),r,n=new Promise(o=>{r=o}),a=i.then(()=>n);An.set(e,a),await i;try{return await t()}finally{r(),An.get(e)===a&&An.delete(e)}}async function mt(e){return Ww(e.file,async()=>{let t=_(e.expectedStateVersion,"Native expected state version",1),i=le(e.next);if(i.state_version!==t+1)throw new Error("Native CAS next state_version must increment exactly once");let r=await ue(e.file);if(r.state_version===i.state_version&&JSON.stringify(r)===JSON.stringify(i))return r;if(r.state_version!==t)throw new _n(t,r.state_version);return await jn(e.file,i,{...e.containedRoot?{containedRoot:e.containedRoot}:{},beforeCommit:async()=>{let n=await ue(e.file);if(n.state_version!==t)throw new _n(t,n.state_version)}}),i})}function zw(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function et(e,t=16384){if(typeof e!="string")throw new Error("Native portable text must be a string");if(zw(t),Buffer.byteLength(e,"utf8")<=t)return{text:e,truncated:!1};let i="",r=0;for(let n of e){let a=Buffer.byteLength(n,"utf8");if(r+a>t)break;i+=n,r+=a}return{text:i,truncated:!0}}var Oe="comet.native.v3",Ae="comet.native.v2",_e="comet.native.v1";var $n="comet.native.portable-migration.v1",Gw=new Set(["schema","id","change","fromSchema","status","createdAt"]),Uw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Kw=/^[a-z0-9][a-z0-9-]{7,127}$/u,Yw=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),Xw=new Set([_e,Ae,Oe]);function Qw(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Zw(e,t){let i=e instanceof Date?new Date(e.valueOf()):new Date(e);if(Number.isNaN(i.valueOf()))throw new Error(`${t} must be a valid timestamp`);return i.toISOString()}function ey(e,t){if(typeof e!="string")throw new Error(`${t} must be an ISO timestamp`);let i=new Date(e);if(Number.isNaN(i.valueOf())||i.toISOString()!==e)throw new Error(`${t} must be a canonical ISO timestamp`);return e}function ty(e){return e.schema===_e?zi(e):e.schema===Ae?Ji(e):Gi(e)}function iy(e){return Jw.posix.normalize(e.replaceAll("\\","/"))}function ry(e){return e.spec_changes.map(t=>t.operation==="remove"?{capability:t.capability,operation:"remove",source:null}:{capability:t.capability,operation:t.operation==="replace"?"modify":"create",source:iy(t.source)})}function ny(e){return e==="shape"?"shape":"build"}function ay(e,t){return e==="zh-CN"?t==="shape"?"继续澄清并确认验收项":"重新提交候选实现":t==="shape"?"Continue clarification and confirm acceptance":"Submit a fresh implementation candidate"}function oy(e,t,i){return e==="zh-CN"?`从旧版 ${t} ${i} 状态恢复;旧版 Loop、验证结论和运行记录未继承。`:`Recovered from legacy ${t} ${i} state; prior Loop, verification results, and execution records were not inherited.`}function Ed(e){let t=ty(e.state);bd(e.acceptance);let i=ny(t.phase),r=i==="shape"?0:1,n=Zw(e.migratedAt??`${t.created_at}T00:00:00.000Z`,"Native portable migration time"),a=e.acceptance.map(o=>({id:o.id,source:o.source,text:o.text,result:"pending",reason:null}));return le({schema:Lt,name:t.name,language:t.language,phase:i,status:"active",state_version:1,brief:"brief.md",spec_changes:ry(t),workspace:e.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:ay(t.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:et(oy(t.language,t.schema,t.phase)),completed_at:n}],history_overflow:vs(),verification_result:"pending",verification_report:null,archived:!1,created_at:`${t.created_at}T00:00:00.000Z`})}function Ns(e){let t=Qw(e,"Native portable migration transaction"),i=Object.keys(t).filter(r=>!Gw.has(r));if(i.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${i.join(", ")}`);if(t.schema!==$n)throw new Error("Unsupported Native portable migration transaction schema");if(typeof t.id!="string"||!Kw.test(t.id))throw new Error("Native portable migration transaction id is invalid");if(typeof t.change!="string"||!Uw.test(t.change))throw new Error("Native portable migration transaction change is invalid");if(typeof t.fromSchema!="string"||!Xw.has(t.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof t.status!="string"||!Yw.has(t.status))throw new Error("Native portable migration transaction status is invalid");return{schema:$n,id:t.id,change:t.change,fromSchema:t.fromSchema,status:t.status,createdAt:ey(t.createdAt,"Native portable migration transaction createdAt")}}function Pd(e){switch(Ns(e).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 On="comet.native.archive-transaction.v4",xd="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",sy=new RegExp(`^portable-archive-(${xd})\\.json$`,"u"),cy=new RegExp(`^portable-migration-(${xd})\\.json$`,"u"),ly=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,uy=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,dy=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),fy=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),hy=new Set(["capability","operation","source","content"]),Rd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function Cd(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Ad(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`);if(Object.keys(e).length!==t.size)throw new Error(`${i} fields are invalid`)}function py(e,t){let i=`Native portable Archive spec_changes[${t}]`,r=Cd(e,i);if(Ad(r,hy,i),typeof r.capability!="string"||!Rd.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 my(e){let t=Cd(e,"Native portable Archive transaction");if(Ad(t,fy,"Native portable Archive transaction"),t.schema!==On)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof t.id!="string"||!ly.test(t.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof t.change!="string"||!Rd.test(t.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(t.start_state_version)||Number(t.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof t.archive_ref!="string"||!uy.test(t.archive_ref)||!t.archive_ref.endsWith(`-${t.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof t.status!="string"||!dy.has(t.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let i=t.spec_changes.map(py);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(t.next_spec_index)||Number(t.next_spec_index)<0||Number(t.next_spec_index)>i.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof t.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let r=new Date(t.created_at);if(Number.isNaN(r.valueOf())||r.toISOString()!==t.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:On,id:t.id,change:t.change,start_state_version:Number(t.start_state_version),archive_ref:t.archive_ref,status:t.status,next_spec_index:Number(t.next_spec_index),spec_changes:i,created_at:t.created_at}}function Hn(e){let t=sy.exec(e);if(t)return{kind:"archive",change:t[1]};let i=cy.exec(e);return i?{kind:"migration",change:i[1]}:null}function vt(e,t){let i=`${t.kind==="archive"?"portable-archive":"portable-migration"}-${t.change}.json`,r=Hn(i);if(!r||r.kind!==t.kind||r.change!==t.change)throw new Error(`Invalid Native portable transaction change: ${t.change}`);return bs.join(e.transactionsDir,i)}async function ks(e,t){let i=Hn(t);if(!i)return null;let r=await B({root:e.transactionsDir,ref:t,maxBytes:null,includeHash:!1}),n=JSON.parse(r.text),a=bs.join(e.transactionsDir,t);if(i.kind==="archive"){let s=my(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=Ns(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 qt(e,t){let i=vt(e,t);try{return await ks(e,bs.basename(i))}catch(r){if(r.code==="ENOENT")return null;throw r}}function _d(e){return e.kind==="archive"||e.journal.status!=="committed"}import He from"path";import{TextDecoder as Sy}from"util";import{createHash as vy}from"node:crypto";import{constants as Dn,promises as ye}from"node:fs";import Ne from"node:path";function Ln(e,t){let i=Ne.relative(e,t);return i===""||!Ne.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Ne.sep}`)}function gy(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native protected file byte limit must be a positive integer");return e}function wy(e,t){return A({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function yy(e){return{dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs,ctimeMs:e.ctimeMs,mtimeMs:e.mtimeMs,size:e.size}}function Bn(e,t){return A({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Ss(e,t){let i=await ye.lstat(e);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${t} parent must be a real directory: ${e}`);return{path:e,realPath:await ye.realpath(e),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function Ny(e,t,i){let r=Ne.resolve(e),n=Ne.resolve(t);if(!Ln(r,n))throw new Error(`${i} is outside its managed root`);let a=[await Ss(r,i)],o=r;for(let s of Ne.relative(r,n).split(Ne.sep).filter(Boolean)){await gt(a,i),o=Ne.join(o,s);let c=await Ss(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 gt(a,i),a}async function gt(e,t){for(let i of e){let r=await ye.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!wy(i,r)||await ye.realpath(i.path)!==i.realPath)throw new Error(`${t} parent changed during I/O: ${i.path}`)}}async function by(e,t,i){let r=[],n=0,a=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let o=t+1-n,{bytesRead:s}=await e.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,n>t)throw new Error(`${i} exceeds ${t} bytes`);r.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(r,n)}async function Wt(e){let t=gy(e.maxBytes),i=Ne.resolve(e.file),r=await Ny(e.root,Ne.dirname(i),e.label),n=await Promise.all((e.forbiddenRoots??[]).map(d=>Ss(Ne.resolve(d),e.label)));await e.hooks?.afterParentChainCaptured?.(),await gt(r,e.label);let a=await ye.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);if(a.size>t)throw new Error(`${e.label} exceeds ${t} bytes`);let o=yy(a),s=await ye.realpath(i);if(!Ln(r[0].realPath,s))throw new Error(`${e.label} resolves outside its managed root`);if(n.some(d=>Ln(d.realPath,s)))throw new Error(`${e.label} resolves inside an excluded root`);let c=process.platform==="win32"?Dn.O_RDONLY:Dn.O_RDONLY|Dn.O_NOFOLLOW|Dn.O_NONBLOCK,l=await ye.open(i,c);try{let d=await l.stat();await e.hooks?.afterOpen?.();let[f,u]=await Promise.all([ye.lstat(i),ye.realpath(i)]);if(await gt(r,e.label),await gt(n,e.label),!d.isFile()||!f.isFile()||f.isSymbolicLink()||u!==s||!Bn(o,d)||!Bn(o,f))throw new Error(`${e.label} changed while opening`);await e.hooks?.beforeRead?.();let p=await by(l,t,e.label);await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),ye.lstat(i),ye.realpath(i)]);if(await gt(r,e.label),await gt(n,e.label),!h.isFile()||h.isSymbolicLink()||m!==s||!Bn(o,v)||!Bn(o,h))throw new Error(`${e.label} changed while reading`);return{bytes:p,hash:vy("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}var Ey=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),Py=new Set(["id","type","source","target","staged","backup"]),xy=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Ry=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var jd=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var Cy=256*1024,SP=1024*1024,EP=16*1024;var PP=64*1024*1024;var Ay=new Sy("utf-8",{fatal:!0});function Mn(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Vn(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function $d(e){if(typeof e!="string")return!1;let t=new Date(e);return!Number.isNaN(t.valueOf())&&t.toISOString()===e}function Es(e,t){if(typeof e!="string"||e.length===0||He.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native root`)}function Fn(e,t){if(typeof e!="string"||!/^[a-f0-9]{64}$/u.test(e))throw new Error(`${t} must be a SHA-256 hash`)}function Td(e,t){if(Es(e,t),e.includes("\\")||e!==He.posix.normalize(e)||e.split("/").includes(".")||e.endsWith("/")||Buffer.byteLength(e,"utf8")>1024)throw new Error(`${t} must be a normalized Native-relative ref`)}function _y(e,t){let i=Mn(e,`transaction operations[${t}]`);if(Vn(i,Py,`transaction operations[${t}]`),typeof i.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.id))throw new Error(`transaction operations[${t}].id is invalid`);if(i.type!=="write"&&i.type!=="remove"&&i.type!=="move")throw new Error(`transaction operation ${i.id} has an invalid type`);Es(i.target,`transaction operation ${i.id} target`);for(let r of["source","staged","backup"])i[r]!==void 0&&Es(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 Od(e){let t=Mn(e,"Native Archive transaction journal");if(Vn(t,xy,"Native Archive transaction journal"),t.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native Archive transaction id is invalid");if(t.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof t.status!="string"||!jd.has(t.status))throw new Error("Native Archive transaction status is invalid");if(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change))throw new Error("Native Archive transaction change name is invalid");if(!$d(t.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Fn(t.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(t.operations)||t.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let i=t.operations.map((s,c)=>{let l=Mn(s,`Archive transaction operations[${c}]`);if(Vn(l,Ry,`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`);Td(l.target,`Archive transaction operation ${l.id} target`);for(let d of["source","staged","backup"])l[d]!==void 0&&Td(l[d],`Archive transaction operation ${l.id} ${d}`);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/${t.id}`,a=i.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${t.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${t.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:t.id,kind:"archive",status:t.status,change:t.change,createdAt:t.createdAt,preflightHash:t.preflightHash,operations:i}}function Ty(e){let t=Mn(e,"Native transaction journal");if(t.schema==="comet.native.transaction.v2")return Od(t);if(Vn(t,Ey,"Native transaction journal"),t.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native transaction id is invalid");if(t.kind!=="archive"&&t.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof t.status!="string"||!jd.has(t.status))throw new Error("Native transaction status is invalid");if(typeof t.projectRoot!="string"||!He.isAbsolute(t.projectRoot)||typeof t.nativeRoot!="string"||!He.isAbsolute(t.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(t.change!==void 0&&(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change)))throw new Error("Native transaction change name is invalid");if(!$d(t.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(t.operations))throw new Error("Native transaction operations must be an array");let i=t.operations.map(_y),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:t.id,kind:t.kind,status:t.status,projectRoot:t.projectRoot,nativeRoot:t.nativeRoot,...typeof t.change=="string"?{change:t.change}:{},createdAt:t.createdAt,operations:i}}function Iy(e,t){if(!/^[a-f0-9-]{8,}$/u.test(t))throw new Error(`Invalid Native transaction id: ${t}`);return He.join(e.transactionsDir,t)}function Hd(e,t){let i=Iy(e,t);return{directory:i,journal:He.join(i,"transaction.json"),events:He.join(i,"events.jsonl"),staged:He.join(i,"staged"),backups:He.join(i,"backups")}}async function xs(e,t){let i=Hd(e,t);return await Promise.all(Object.values(i).map(r=>T(e.runtimeDir,r))),i}async function Rs(e,t,i={}){let r=await xs(e,t),n=await Wt({root:e.runtimeDir,file:r.journal,maxBytes:Cy,label:`Native transaction journal ${t}`,hooks:i.hooks}),a=JSON.parse(Ay.decode(n.bytes)),o=Ty(a);if(o.id!==t)throw new Error(`Invalid Native transaction journal: ${t}`);return o}async function Oy(e,t,i){let r;try{r=await jy.readdir(e.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 Rs(e,n.name);if(a.id!==t&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of r)if(Hn(n.name))try{let a=await ks(e,n.name);if(!a||i?.kind===a.kind&&i.change===a.change)continue;if(_d(a))return!0}catch{return!0}return!1}async function Hy(e,t){let i=Date.now()+5e3,r=$y.join(e.locksDir,"root-move.lock");for(;;)try{return await xn(e,"root-move",t)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await gd(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 J(e,t,i,r){let n=await Hy(e,t);try{if(await Fi(e.projectRoot),await Oy(e,r?.allowedTransactionId,r?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await i()}finally{await Rn(n)}}import{createHash as Dy}from"crypto";function de(e){return Dy("sha256").update(e).digest("hex")}var JP={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024};var GP=8*1024*1024;var UP=64*1024,KP=64*1024;var YP={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},XP={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};var QP=(1n<<256n)-1n;var Wy=fr(ji(),1);var px=4*1024*1024;var cR=256*1024;var bR={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 zt from"node:path";var Ui=/^[a-f0-9]{64}$/u,Bd=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,Gy=16*1024,DR=process.platform;function Uy(e,t){let i=zt.relative(e,t);return zt.isAbsolute(i)||i===".."||i.startsWith(`..${zt.sep}`)?null:i.replaceAll("\\","/")||"."}function Ld(e){return Array.from(e).some(t=>{let i=t.codePointAt(0)??0;return i<=31||i===127})}function Fd(e,t){if(e.length===0||Ld(e)||e.includes("\\")||zt.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes(".."))throw new Error(`${t} must be a portable project-relative path`);let i=zt.posix.normalize(e);if(i!==e||i===".."||i.startsWith("../"))throw new Error(`${t} must be a normalized project-relative path`);return i}function Ky(e){if(typeof e!="string")throw new Error("Native workspace capturedAt is invalid");let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw new Error("Native workspace capturedAt is invalid");return e}function Cs(e,t){if(e===null)return null;if(typeof e!="string"||e.length===0||e.trim()!==e||Ld(e))throw new Error(`${t} must be a non-empty branch name or null`);return e}function Yy(e){if(!new Set(["current","branch","worktree"]).has(e.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Cs(e.changeBranch,"Native workspace change branch"),Cs(e.targetBranch,"Native workspace target branch"),(e.isolation==="branch"||e.isolation==="worktree")&&(e.changeBranch===null||e.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function Xy(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace Git provenance must be an object");let t=e,i=new Set(["provider","baseCommit","targetBranch","targetCommit"]),r=Object.keys(t).filter(n=>!i.has(n));if(r.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${r.join(", ")}`);if(t.provider!=="git"||typeof t.baseCommit!="string"||!Bd.test(t.baseCommit)||typeof t.targetCommit!="string"||!Bd.test(t.targetCommit))throw new Error("Native workspace Git provenance is invalid");Cs(t.targetBranch,"Native workspace Git target branch")}function Qy(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace identity must be an object");let t=e,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(t).filter(o=>!i.has(o));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.join(", ")}`);if(t.schema!=="comet.native.workspace.v2"&&t.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(t.capturedRevision)||t.capturedRevision<1||typeof t.nativeRootRef!="string"||!Ui.test(String(t.projectRootId))||!Ui.test(String(t.nativeRootId)))throw new Error("Native workspace identity is invalid");Ky(t.capturedAt),Fd(t.nativeRootRef,"Native workspace root ref");let n=t.projectRootPathId!==void 0,a=t.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!Ui.test(String(t.projectRootPathId))||a&&!Ui.test(String(t.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(t.sessionHash!==void 0&&!Ui.test(String(t.sessionHash)))throw new Error("Native workspace session hash is invalid");if(t.git!==void 0&&Xy(t.git),t.schema==="comet.native.workspace.v2"){if(t.isolation!==void 0||t.changeBranch!==void 0||t.targetBranch!==void 0||t.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof t.isolation!="string"||t.changeBranch===void 0||t.targetBranch===void 0||t.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(Yy(t),t.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(t.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function Zy(e,t){return zt.join(Pe(e,t),"workspace.json")}function eN(e,t){let i=Zy(e,t),r=xe(e,i),n=Uy(r,i);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:r,ref:Fd(n,"Native workspace file ref")}}async function tN(e,t){try{let i=eN(e,t),r=await B({root:i.root,ref:i.ref,maxBytes:Gy});return JSON.parse(r.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Ki(e,t){let i=await tN(e,t);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(Qy(i),i)}var Vd=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],nN=new Set(Vd),qd=new Set([...Vd,"minimum_runtime_version","revision"]),aN=new Set([...qd,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),oN=new Set(["capability","operation","source","base_hash"]),sN=new Set(["shape","build","verify","archive"]),cN=new Set(["implicit","confirmed"]),lN=new Set(["pending","pass","fail"]),wt="comet-state.yaml",_s=/^[a-f0-9]{64}$/u,Wd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,uN=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Ts=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"},Gt=class extends Error{constructor(i,r){super(i!==Oe||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"},qn=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"},Yi=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"},Wn=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"},sC=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
150
- `);function Qi(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function zd(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function js(e){if(!Wd.test(e))throw new Error(`Invalid Native change name: ${e}`)}function dN(e){if(!Wd.test(e))throw new Error(`Invalid Native capability id: ${e}`)}function Jd(e,t){if(e.length===0||Jt.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native change`)}function fN(e,t){let i=Qi(e,`spec_changes[${t}]`);if(zd(i,oN,`spec_changes[${t}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(dN(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"&&Jd(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"||!_s.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"||!_s.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 hN(e){return/^\d{4}-\d{2}-\d{2}$/u.test(e)?new Date(`${e}T00:00:00.000Z`).toISOString().slice(0,10)===e:!1}function $s(e,t){if(zd(e,t,wt),typeof e.name!="string")throw new Error("Native change name is required");if(js(e.name),e.language!=="en"&&e.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof e.phase!="string"||!sN.has(e.phase))throw new Error("Native change phase is invalid");if(e.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(e.approval!==null&&!cN.has(e.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native spec_changes must be an array");let i=e.spec_changes.map(fN),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 e.verification_result!="string"||!lN.has(e.verification_result))throw new Error("Native verification_result is invalid");if(e.verification_report!==null&&typeof e.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof e.verification_report=="string"&&Jd(e.verification_report,"Native verification_report"),typeof e.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof e.created_at!="string"||!hN(e.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(e.run_id!==null&&(typeof e.run_id!="string"||e.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:e.name,language:e.language,phase:e.phase,brief:"brief.md",approval:e.approval,spec_changes:i,verification_result:e.verification_result,verification_report:e.verification_report,archived:e.archived,created_at:e.created_at,run_id:e.run_id}}function zi(e){let t=Qi(e,wt);if(t.schema!==_e)throw new Error(`Expected ${_e}`);return{schema:_e,...$s(t,nN)}}function Xi(e,t){if(!Number.isSafeInteger(e)||e<1)throw new Error(`${t} must be a positive integer`);return e}function As(e,t,i){if(e===null)return null;let r=typeof e=="string"?uN.exec(e):null;if(!r||r[1]!==i)throw new Error(`${t} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return e}function pN(e){if(e==null)return null;if(typeof e!="string"||!_s.test(e))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return e}function mN(e){if(e===void 0)return"legacy-v1";if(e!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return e}function Ji(e){let t=Qi(e,wt);if(t.schema!==Ae)throw new Error(`Expected ${Ae}`);if(Xi(t.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Ae} minimum_runtime_version must be 2`);return{schema:Ae,minimum_runtime_version:2,revision:Xi(t.revision,"Native v2 revision"),...$s(t,qd)}}function Gi(e){let t=Qi(e,wt);if(t.schema!==Oe){if(t.schema===_e||t.schema===Ae){let o=t.schema===_e?zi(t):Ji(t);throw new Ts(o.name,o.schema)}throw new Gt(typeof t.schema=="string"?t.schema:"(missing)",typeof t.minimum_runtime_version=="number"?t.minimum_runtime_version:null)}let i=Xi(t.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new Gt(t.schema,i);if(i!==3)throw new Error(`Native ${t.schema} minimum_runtime_version must be ${3}`);let r=Xi(t.revision,"Native revision"),n=$s(t,aN),a=pN(t.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Oe,minimum_runtime_version:3,revision:r,verification_protocol:mN(t.verification_protocol),...n,approved_contract_hash:a,implementation_scope:As(t.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:As(t.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:As(t.partial_allowance,"Native partial_allowance","allowances")}}function vN(e){let t=Qi(e,wt);if(t.schema===_e){let n=zi(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Oe}`}}if(t.schema===Ae){let n=Ji(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Oe}`}}if(t.schema!==Oe){let n=typeof t.minimum_runtime_version=="number"&&Number.isSafeInteger(t.minimum_runtime_version)?t.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof t.schema=="string"?t.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new Gt(typeof t.schema=="string"?t.schema:"(missing)",n).message}}let i=Xi(t.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:t.schema,minimumRuntimeVersion:i,state:null,message:new Gt(t.schema,i).message};let r=Gi(t);return{status:"current",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r}}function re(e,t){js(t);let i=Jt.join(e.changesDir,t);if(!D(e.changesDir,i))throw new Error("Native change path escaped");return i}var gN=256*1024;async function wN(e,t=Jt.dirname(e)){let i=Jt.relative(t,e).split(Jt.sep).join("/"),r=await B({root:t,ref:i,maxBytes:gN}),n=(0,Is.parseDocument)(r.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${e}: ${n.errors[0].message}`);return n.toJS()}async function zn(e,t){let i=Jt.join(re(e,t),wt);await T(e.nativeRoot,i);let r=vN(await wN(i,e.nativeRoot));if(r.state&&r.state.name!==t)throw new Error(`Native change directory/name mismatch: ${t}`);return r}import{promises as rr}from"node:fs";import Be from"node:path";var lC=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");var Jn="skill-coordinated";function kN(e){return e.state_version+1}function SN(e){return e.map(t=>({...t,result:"pending",reason:null}))}function EN(e){return{goal_cycle:e.state.loop.goal_cycle,iteration:e.state.loop.iteration,attempt:e.state.loop.attempt,outcome:e.outcome,unresolved_ids:e.unresolvedIds??[],summary:et(e.summary),completed_at:e.completedAt}}function Os(e){let t=le(e.state);if(t.phase!=="verify"&&t.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let i=(e.now??new Date).toISOString(),r=Vt(t,EN({state:t,outcome:"recovery",summary:e.reason,completedAt:i}));return le({...r,phase:"build",status:"active",state_version:kN(t),verification_result:"pending",verification_report:null,verification:null,builder_handoff:null,blockers:[],acceptance:SN(t.acceptance),loop:{...t.loop,stage:"repairing",iteration:t.loop.iteration+1,attempt:0,execution_failure_count:0,next_action:"submit-builder-candidate"}})}import{promises as Ud}from"node:fs";import er from"node:path";function Gn(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Un(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Te(e,t,i=!1){if(typeof e!="string"||!i&&e.length===0)throw new Error(`${t} must be ${i?"a string":"a non-empty string"}`);return e}function Gd(e,t){return e===null?null:Te(e,t)}function Yn(e,t,i=0){if(!Number.isSafeInteger(e)||e<i)throw new Error(`${t} must be a safe integer greater than or equal to ${i}`);return e}function PN(e,t){if(e===null)return null;if(!Number.isSafeInteger(e))throw new Error(`${t} must be null or a safe integer`);return e}function xN(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function Kn(e,t,i){if(typeof e!="string"||!t.includes(e))throw new Error(`${i} must be one of: ${t.join(", ")}`);return e}function Hs(e,t){if(e===null)return null;let i=Te(e,t);if(Number.isNaN(Date.parse(i)))throw new Error(`${t} must be an ISO timestamp`);return i}function Ds(e,t){let i=Te(e,t);if(!er.isAbsolute(i))throw new Error(`${t} must be absolute`);return er.resolve(i)}function RN(e,t){let i=`Native local checks[${t}]`,r=Gn(e,i);if(Un(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,d)=>Te(l,`${i}.argv[${d}]`,!0)),a=Kn(r.status,["planned","running","passed","failed","interrupted"],`${i}.status`),o=Hs(r.startedAt,`${i}.startedAt`),s=Hs(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=Yn(r.timeoutMs,`${i}.timeoutMs`);if(c<1)throw new Error(`${i}.timeoutMs must be positive`);return{id:Te(r.id,`${i}.id`),name:Te(r.name,`${i}.name`),operationId:Te(r.operationId,`${i}.operationId`),status:a,repeatable:xN(r.repeatable,`${i}.repeatable`),timeoutMs:c,executionCount:Yn(r.executionCount,`${i}.executionCount`),argv:n,cwd:Ds(r.cwd,`${i}.cwd`),exitCode:PN(r.exitCode,`${i}.exitCode`),startedAt:o,completedAt:s,log:Te(r.log,`${i}.log`)}}function Bs(e){let t="Native local execution state",i=Gn(e,t);if(Un(i,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),t),i.schema!==Wi)throw new Error(`Native local execution schema must be ${Wi}`);let r=Gn(i.workspace,"Native local workspace");Un(r,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(i.execution!==null){let o=Gn(i.execution,"Native local execution");Un(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=Hs(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Te(o.operationId,"Native local execution.operationId"),stage:Kn(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Kn(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Gd(o.executionId,"Native local execution.executionId"),status:Kn(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Yn(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(RN);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:Te(i.change,"Native local change"),basedOnStateVersion:Yn(i.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:Ds(r.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Ds(r.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Gd(r.branch,"Native local workspace.branch")},execution:n,checks:a}}function yt(e){return Bs({schema:Wi,change:e.portableState.name,basedOnStateVersion:e.portableState.state_version,workspace:{projectRoot:er.resolve(e.projectRoot),worktreeRoot:er.resolve(e.worktreeRoot??e.projectRoot),branch:e.branch??null},execution:null,checks:[]})}async function Ls(e){let t;try{t=await Ud.readFile(e,"utf8")}catch(r){if(r.code==="ENOENT")return null;throw r}let i;try{i=JSON.parse(t)}catch(r){throw new Error(`Native local execution state is invalid JSON: ${r.message}`,{cause:r})}return Bs(i)}async function it(e,t,i={}){let r=Bs(t);await Ud.mkdir(er.dirname(e),{recursive:!0}),await Y(e,r,i)}import{promises as CN}from"node:fs";function rt(e){return e===null?"—":`${e.text.replace(/\r\n?/gu,`
151
- `).replace(/\s+/gu," ").trim()||"—"}${e.truncated?" … (truncated)":""}`}function De(e){return e.replaceAll("|","\\|").replace(/\r?\n/gu,"<br>")}function AN(e){return e.verification?.assurance==="semantic-verification-unavailable"?"Semantic verification unavailable, user confirmation required":e.verification?.assurance==="user-confirmed-degraded"?"Passed with user-confirmed degraded assurance":e.verification_result==="pass"?e.phase==="verify"&&e.loop.next_action==="confirm-skill-coordinated-pass"?"Passed, user confirmation required":"Passed":e.verification_result==="blocked"?"Blocked":e.verification_result==="fail"?"Failed":"Pending"}function _N(e){return e.verification?.assurance??(e.builder_handoff?.identity_provider===Jn?Jn:"host-attested")}function TN(e){if(e.verification===null)throw new Error("Native verification report requires a stable Verifier result");let t=e.acceptance.map(o=>`| ${De(o.id)} | ${De(o.result)} | ${De(o.source)} | ${De(o.text)} | ${De(rt(o.reason))} |`).join(`
152
- `),i=e.verification.checks.length===0?"_No Runtime checks were recorded._":["| Check | Command | Working directory | Status | Exit | Duration |","| --- | --- | --- | --- | ---: | ---: |",...e.verification.checks.map(o=>{let s=o.argv_display.map(rt).join(" ");return`| ${De(rt(o.name))} | ${De(s||"—")} | ${De(o.cwd_ref)} | ${o.status} | ${o.exit_code??"—"} | ${o.duration_ms} ms |`})].join(`
153
- `),r=e.blockers.length===0?"_None._":e.blockers.map(o=>`- **${o.owner}**: ${rt(o.reason)}${o.acceptance_ids.length>0?` (acceptance: ${o.acceptance_ids.join(", ")})`:""} — next: \`${o.resolution_action}\``).join(`
154
- `),n=e.verification.risks.length===0?"_None reported._":e.verification.risks.map(o=>`- ${rt(o)}`).join(`
155
- `),a=e.history.length===0?"_No previous iterations._":["| Goal cycle | Iteration | Attempt | Outcome | Unresolved | Summary | Completed |","| ---: | ---: | ---: | --- | --- | --- | --- |",...e.history.map(o=>`| ${o.goal_cycle} | ${o.iteration} | ${o.attempt} | ${o.outcome} | ${o.unresolved_ids.join(", ")||"—"} | ${De(rt(o.summary))} | ${o.completed_at} |`)].join(`
147
+ `,o),l=c===-1?a.slice(o):a.slice(o,c);if(yield{line:l,body:t===null&&!i&&r===null,index:s},s+=1,t!==null)t=ks(l,t);else if(i)Bd(l)&&(i=!1);else if(r!==null)new RegExp(`</${r}\\s*>`,"iu").test(l)&&(r=null);else{let f=ks(l,null);if(f!==null)t=f;else{let d=l.trimStart();if(d.startsWith("<!--")&&!Bd(d))i=!0;else{let p=/^<([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/u.exec(d);p&&n.has(p[1].toLowerCase())&&!d.startsWith("</")&&!d.endsWith("/>")&&!new RegExp(`</${p[1]}\\s*>`,"iu").test(d)&&(r=p[1])}}}if(c===-1)break;o=c+1}}function Gi(e){return e.normalize("NFC").replace(/\s+/gu," ").trim()}function Es(e,t,i,r=[],n="content-hash"){let a=Gi(i),o=t.replaceAll("\\","/").trim(),s=r.map(Gi);if(a.length===0)throw new Error(`${e} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${e} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${ee(sy,{kind:e,source:o,context:s,text:a})}`:"",kind:e,source:o,context:s,text:a}}function Ps(e,t,i="content-hash"){let r=new Set;for(let n of e){let a=i==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(r.has(a))throw new Error(`${t} contains duplicate acceptance criteria`);r.add(a)}return e}function cy(e){let t=null,i=null,r=0,n=0;for(let{line:a,body:o,index:s}of Ji(e)){n=s+1;let c=o?Ss(a):null;c?.level===1&&(c.text.toLocaleLowerCase("en-US")==="acceptance examples"?(r+=1,r===1&&(t=s+1)):t!==null&&i===null&&(i=s))}if(r===0||t===null)return null;if(r!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:t,end:i??n}}function xs(e,t="brief.md",i=Ui.maxCriteria,r="content-hash"){if(!Number.isSafeInteger(i)||i<0)throw new Error("Native brief acceptance budget is invalid");let n=cy(e);if(n===null)return[];let a=null;for(let{line:l,body:u,index:f}of Ji(e)){if(f<n.start||f>=n.end)continue;let d=u?/^( {0,3})[-*+][ \t]+/u.exec(l):null;if(d===null)continue;let p=d[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:u,index:f}of Ji(e)){if(f<n.start||f>=n.end)continue;let d=u?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(l):null;d&&d[1].length===a?(c(),s=[d[2]]):s!==null&&s.push(l)}return c(),Ps(o.map(l=>Es("brief-example",t,l.join(`
148
+ `),[],r)),"Brief",r)}function Rs(e,t="spec.md",i=Ui.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(Es("spec-scenario",t,[o.title,...o.body].join(`
149
+ `),o.context,r)),o=null}};for(let{line:c,body:l}of Ji(e)){let u=l?Ss(c):null,f=u?/^Scenario\s*:\s*(.*)$/iu.exec(u.text):null;if(f){for(s();a.at(-1)&&a.at(-1).level>=u.level;)a.pop();let d=Gi(f[1]);if(d.length===0)throw new Error("Scenario title must not be empty");o={level:u.level,title:d,body:[],context:a.map(p=>p.text)}}else if(u){for(o!==null&&u.level<=o.level?s():o!==null&&o.body.push(c);a.at(-1)&&a.at(-1).level>=u.level;)a.pop();a.push(u)}else o!==null&&l&&o.body.push(c)}return s(),Ps(n,"Specification",r)}function Cs(e,t="spec.md",i=Ui.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(Es("spec-must",t,s.parts.join(" "),s.context,r)),s=null}},l=()=>a.some(u=>/^(?:non-?goals?|非目标)$/iu.test(u.text.trim()));for(let{line:u,body:f}of Ji(e)){let d=f?Ss(u):null;if(d){for(c(),o!==null&&d.level<=o&&(o=null);a.at(-1)&&a.at(-1).level>=d.level;)a.pop();a.push(d),/^Scenario\s*:/iu.test(d.text)&&(o=d.level);continue}let p=u.trim();if(!f||o!==null||l()){c();continue}if(p.length===0||ks(u,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(u);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(),Ps(n,"Specification mandatory requirements",r)}var ly=/^A[1-9]\d*$/u;function qd(e,t){if(e.length===0||e!==e.trim()||e.includes("\\")||Ld.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||Ld.posix.normalize(e)!==e||e==="."||e.endsWith("/"))throw new Error(`${t} must be a normalized change-relative ref`);return e}function uy(e,t){return e.localeCompare(t,"en")}function On(e){let t=qd(e.briefSource??"brief.md","Native brief source"),i=[...e.specs??[]].sort((a,o)=>uy(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=xs(e.briefMarkdown,t,Number.MAX_SAFE_INTEGER,"none").map(({source:a,text:o})=>({source:a,text:o}));for(let a of i){let o=qd(a.source,`Native spec source for ${a.capability}`);r.push(...Rs(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})),...Cs(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=Gi(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 Fd(e){let t=e.map(({id:i})=>i);if(new Set(t).size!==t.length)throw new Error("Native acceptance IDs must be unique");for(let i=0;i<t.length;i+=1)if(!ly.test(t[i])||t[i]!==`A${i+1}`)throw new Error("Native acceptance IDs must be the contiguous sequence A1..An")}function Md(e,t){return e.length===t.length&&e.every((i,r)=>i.source===t[r]?.source&&i.text===t[r]?.text)}var Bn=ai(Ft(),1);import{promises as dy}from"node:fs";var Jt="comet.native.v4",Ki="comet.native.local-execution.v4";function As(){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 fy=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,hy=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,py=/^A[1-9][0-9]*$/u,my=/^[a-f0-9]{64}$/u,vy=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"]),Dn=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 te(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function ie(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function W(e,t,i){if(typeof e!="string"||!i?.empty&&e.length===0)throw new Error(`${t} must be ${i?.empty?"a string":"a non-empty string"}`);return e}function Ts(e,t){return e===null?null:W(e,t)}function gy(e,t){let i=W(e,t);if(!my.test(i))throw new Error(`${t} must be a SHA-256 hash`);return i}function Gt(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function _(e,t,i=0){if(!Number.isSafeInteger(e)||e<i)throw new Error(`${t} must be a safe integer greater than or equal to ${i}`);return e}function wy(e,t){return e===null?null:_(e,t,Number.MIN_SAFE_INTEGER)}function V(e,t,i){if(typeof e!="string"||!t.includes(e))throw new Error(`${i} must be one of: ${t.join(", ")}`);return e}function Ae(e,t,i){if(!Array.isArray(e))throw new Error(`${t} must be an array`);return e.map((r,n)=>i(r,n))}function Ln(e,t){return Ae(e,t,(i,r)=>W(i,`${t}[${r}]`))}function Nt(e,t){if(new Set(e).size!==e.length)throw new Error(`${t} must be unique`)}function Ut(e,t){let i=W(e,t);if(Number.isNaN(Date.parse(i)))throw new Error(`${t} must be an ISO date or timestamp`);return i}function Is(e,t,i=!1){let r=W(e,t);if(r.includes("\\")||r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").includes("..")||!i&&(r==="."||r.split("/").includes(".")))throw new Error(`${t} must be a portable relative path`);return r}function Ne(e,t){let i=te(e,t);return ie(i,new Set(["text","truncated"]),t),{text:W(i.text,`${t}.text`,{empty:!0}),truncated:Gt(i.truncated,`${t}.truncated`)}}function yy(e,t){let i=`Native spec_changes[${t}]`,r=te(e,i);ie(r,new Set(["capability","operation","source"]),i);let n=W(r.capability,`${i}.capability`);if(!hy.test(n))throw new Error(`${i}.capability is invalid`);let a=V(r.operation,["create","modify","remove"],`${i}.operation`),o=r.source===null?null:Is(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 Ny(e){let t="Native workspace",i=te(e,t);ie(i,new Set(["isolation","change_branch","target_branch","finish"]),t);let r=V(i.isolation,["current","branch","worktree"],`${t}.isolation`),n=Ts(i.change_branch,`${t}.change_branch`),a=Ts(i.target_branch,`${t}.target_branch`),o=i.finish===null?null:V(i.finish,["merge","push","pull-request","keep"],`${t}.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 by(e){let t="Native loop",i=te(e,t);ie(i,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","execution_failure_count","previous_unresolved_ids","next_action"]),t);let r=Ln(i.previous_unresolved_ids,`${t}.previous_unresolved_ids`);return Nt(r,`${t}.previous_unresolved_ids`),{stage:V(i.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${t}.stage`),goal_cycle:_(i.goal_cycle,`${t}.goal_cycle`,1),iteration:_(i.iteration,`${t}.iteration`),attempt:_(i.attempt,`${t}.attempt`),retry_epoch:_(i.retry_epoch,`${t}.retry_epoch`),failed_iteration_count:_(i.failed_iteration_count,`${t}.failed_iteration_count`),no_progress_count:_(i.no_progress_count,`${t}.no_progress_count`),execution_failure_count:_(i.execution_failure_count,`${t}.execution_failure_count`),previous_unresolved_ids:r,next_action:Ts(i.next_action,`${t}.next_action`)}}function ky(e,t){let i=`Native acceptance[${t}]`,r=te(e,i);ie(r,new Set(["id","source","text","result","reason"]),i);let n=W(r.id,`${i}.id`);if(!py.test(n))throw new Error(`${i}.id must use A1, A2, ...`);return{id:n,source:Is(r.source,`${i}.source`),text:W(r.text,`${i}.text`),result:V(r.result,["pending","passed","failed","blocked"],`${i}.result`),reason:r.reason===null?null:Ne(r.reason,`${i}.reason`)}}function Sy(e,t){let i=`Native builder_handoff.checks[${t}]`,r=te(e,i);return ie(r,new Set(["name","result","note"]),i),{name:Ne(r.name,`${i}.name`),result:V(r.result,["passed","failed","not-run"],`${i}.result`),note:r.note===null?null:Ne(r.note,`${i}.note`)}}function Ey(e){let t="Native builder_handoff",i=te(e,t);ie(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"]),t);let r=Ln(i.addressed_acceptance_ids,`${t}.addressed_acceptance_ids`);return Nt(r,`${t}.addressed_acceptance_ids`),{candidate_id:W(i.candidate_id,`${t}.candidate_id`),identity_provider:W(i.identity_provider,`${t}.identity_provider`),builder_execution_ref:W(i.builder_execution_ref,`${t}.builder_execution_ref`),iteration:_(i.iteration,`${t}.iteration`,1),summary:Ne(i.summary,`${t}.summary`),addressed_acceptance_ids:r,checks:Ae(i.checks,`${t}.checks`,Sy),checks_truncated:Gt(i.checks_truncated,`${t}.checks_truncated`),known_limits:Ae(i.known_limits,`${t}.known_limits`,(n,a)=>Ne(n,`${t}.known_limits[${a}]`)),known_limits_truncated:Gt(i.known_limits_truncated,`${t}.known_limits_truncated`),submitted_at:Ut(i.submitted_at,`${t}.submitted_at`)}}function Py(e,t){let i=`Native blockers[${t}]`,r=te(e,i);ie(r,new Set(["owner","reason","acceptance_ids","resolution_action"]),i);let n=Ln(r.acceptance_ids,`${i}.acceptance_ids`);return Nt(n,`${i}.acceptance_ids`),{owner:V(r.owner,["builder","runtime","verifier","user","external"],`${i}.owner`),reason:Ne(r.reason,`${i}.reason`),acceptance_ids:n,resolution_action:V(r.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${i}.resolution_action`)}}function xy(e,t){let i=`Native verification.checks[${t}]`,r=te(e,i);return ie(r,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),i),{id:W(r.id,`${i}.id`),name:Ne(r.name,`${i}.name`),argv_display:Ae(r.argv_display,`${i}.argv_display`,(n,a)=>Ne(n,`${i}.argv_display[${a}]`)),argv_truncated:Gt(r.argv_truncated,`${i}.argv_truncated`),cwd_ref:Is(r.cwd_ref,`${i}.cwd_ref`,!0),status:V(r.status,["passed","failed","interrupted"],`${i}.status`),exit_code:wy(r.exit_code,`${i}.exit_code`),duration_ms:_(r.duration_ms,`${i}.duration_ms`)}}function Ry(e){let t="Native verification",i=te(e,t);ie(i,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),t);let r=Ae(i.checks,`${t}.checks`,xy);Nt(r.map(a=>a.id),`${t}.checks IDs`);let n=W(i.identity_provider,`${t}.identity_provider`);return{candidate_id:W(i.candidate_id,`${t}.candidate_id`),identity_provider:n,verifier_execution_ref:W(i.verifier_execution_ref,`${t}.verifier_execution_ref`),iteration:_(i.iteration,`${t}.iteration`,1),attempt:_(i.attempt,`${t}.attempt`,1),assurance:i.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":V(i.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${t}.assurance`),verdict:V(i.verdict,["pass","fail","blocked"],`${t}.verdict`),checks:r,summary:Ne(i.summary,`${t}.summary`),risks:Ae(i.risks,`${t}.risks`,(a,o)=>Ne(a,`${t}.risks[${o}]`)),risks_truncated:Gt(i.risks_truncated,`${t}.risks_truncated`),completed_at:Ut(i.completed_at,`${t}.completed_at`)}}function Vd(e,t){let i=`Native history[${t}]`,r=te(e,i);ie(r,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),i);let n=Ln(r.unresolved_ids,`${i}.unresolved_ids`);return Nt(n,`${i}.unresolved_ids`),{goal_cycle:_(r.goal_cycle,`${i}.goal_cycle`,1),iteration:_(r.iteration,`${i}.iteration`),attempt:_(r.attempt,`${i}.attempt`),outcome:V(r.outcome,["pass","fail","blocked","execution-error","recovery"],`${i}.outcome`),unresolved_ids:n,summary:Ne(r.summary,`${i}.summary`),completed_at:Ut(r.completed_at,`${i}.completed_at`)}}function Cy(e){let t="Native history_overflow.outcome_counts",i=te(e,t),r=["pass","fail","blocked","execution-error","recovery"];return ie(i,new Set(r),t),{pass:_(i.pass,`${t}.pass`),fail:_(i.fail,`${t}.fail`),blocked:_(i.blocked,`${t}.blocked`),"execution-error":_(i["execution-error"],`${t}.execution-error`),recovery:_(i.recovery,`${t}.recovery`)}}function Ay(e){let t="Native history_overflow",i=te(e,t);ie(i,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),t);let r=_(i.dropped_entries,`${t}.dropped_entries`),n=i.first_dropped_at===null?null:Ut(i.first_dropped_at,`${t}.first_dropped_at`),a=i.last_dropped_at===null?null:Ut(i.last_dropped_at,`${t}.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=Cy(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 _y(e){let t=new Set(e.acceptance.map(i=>i.id));for(let i of e.loop.previous_unresolved_ids)if(!t.has(i))throw new Error(`Native loop references unknown acceptance ID ${i}`);for(let i of e.builder_handoff?.addressed_acceptance_ids??[])if(!t.has(i))throw new Error(`Native builder handoff references unknown ID ${i}`);for(let i of e.blockers)for(let r of i.acceptance_ids)if(!t.has(r))throw new Error(`Native blocker references unknown ID ${r}`);if(e.builder_handoff&&!(e.builder_handoff.iteration===e.loop.iteration||e.phase==="build"&&e.loop.stage==="repairing"&&e.builder_handoff.iteration===e.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(e.verification){if(!e.builder_handoff)throw new Error("Native verification requires a builder handoff");if(e.verification.candidate_id!==e.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(e.verification.identity_provider!==e.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(e.verification.assurance)!==(e.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(e.verification.assurance==="semantic-verification-unavailable"&&e.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(e.verification.assurance==="user-confirmed-degraded"&&e.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(e.verification.verifier_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let r=e.verification.iteration===e.loop.iteration&&e.verification.attempt===e.loop.attempt,n=e.phase==="build"&&e.loop.stage==="repairing"&&e.verification.iteration===e.loop.iteration-1&&e.verification.iteration===e.builder_handoff.iteration;if(!r&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Ty(e){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[e.phase].has(e.loop.stage))throw new Error(`Native loop stage ${e.loop.stage} is invalid for phase ${e.phase}`);let i=e.status==="await-user"?"await-user":e.status==="blocked"?"blocked":e.status==="done"?"done":null;if(i!==null&&e.loop.stage!==i)throw new Error(`Native status ${e.status} requires loop stage ${i}`);if(e.status==="active"&&["await-user","blocked","done"].includes(e.loop.stage))throw new Error(`Native active status cannot use loop stage ${e.loop.stage}`);if(e.archived!==(e.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(e.archived&&e.phase!=="archive")throw new Error("Native archived state must be in Archive");if(e.verification_result==="pass"){if(e.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(e.acceptance.some(r=>r.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(e.verification.checks.some(r=>r.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(e.verification?.assurance==="semantic-verification-unavailable"&&(e.phase!=="verify"||e.status!=="await-user"||e.verification_result!=="blocked"||e.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(e.verification_report!==null&&e.verification===null)throw new Error("Native verification report requires persisted verification")}function ne(e){let t=te(e,"Native portable state");if(ie(t,vy,"Native portable state"),t.schema!==Jt)throw new Error(`Native portable state schema must be ${Jt}`);let i=W(t.name,"Native state name");if(!fy.test(i))throw new Error("Native state name is invalid");if(t.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let r=Ae(t.spec_changes,"Native spec_changes",yy);Nt(r.map(s=>s.capability),"Native spec change capabilities");let n=Ae(t.acceptance,"Native acceptance",ky);Nt(n.map(s=>s.id),"Native acceptance IDs");let a=Ae(t.history,"Native history",Vd);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Jt,name:i,language:V(t.language,["en","zh-CN"],"Native state language"),phase:V(t.phase,["shape","build","verify","archive"],"Native state phase"),status:V(t.status,["active","await-user","blocked","done"],"Native state status"),state_version:_(t.state_version,"Native state_version",1),brief:"brief.md",...t.children_contract_hash===void 0?{}:{children_contract_hash:gy(t.children_contract_hash,"Native children contract hash")},spec_changes:r,workspace:Ny(t.workspace),loop:by(t.loop),acceptance:n,builder_handoff:t.builder_handoff===null?null:Ey(t.builder_handoff),blockers:Ae(t.blockers,"Native blockers",Py),verification:t.verification===null?null:Ry(t.verification),history:a,history_overflow:Ay(t.history_overflow),verification_result:V(t.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:t.verification_report===null?null:V(t.verification_report,["verification.md"],"Native verification_report"),archived:Gt(t.archived,"Native archived"),created_at:Ut(t.created_at,"Native created_at")};return _y(o),Ty(o),o}function Kt(e,t){let i=ne(e),r=Vd(t,i.history.length),n=[...i.history,r],a={...i.history_overflow,outcome_counts:{...i.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return ne({...i,history:n,history_overflow:a})}function Iy(e,t){let i=(0,Bn.parseDocument)(e,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`${t} is invalid YAML: ${i.errors[0].message}`);return i.toJS({mapAsMap:!1})}async function ae(e){let t=await dy.readFile(e,"utf8");return ne(Iy(t,"Native portable state"))}async function qn(e,t,i={}){let r=ne(t);await Y(e,(0,Bn.stringify)(r),i)}var Hn=new Map;async function jy(e,t){let i=Hn.get(e)??Promise.resolve(),r,n=new Promise(o=>{r=o}),a=i.then(()=>n);Hn.set(e,a),await i;try{return await t()}finally{r(),Hn.get(e)===a&&Hn.delete(e)}}async function bt(e){return jy(e.file,async()=>{let t=_(e.expectedStateVersion,"Native expected state version",1),i=ne(e.next);if(i.state_version!==t+1)throw new Error("Native CAS next state_version must increment exactly once");let r=await ae(e.file);if(r.state_version===i.state_version&&JSON.stringify(r)===JSON.stringify(i))return r;if(r.state_version!==t)throw new Dn(t,r.state_version);return await qn(e.file,i,{...e.containedRoot?{containedRoot:e.containedRoot}:{},beforeCommit:async()=>{let n=await ae(e.file);if(n.state_version!==t)throw new Dn(t,n.state_version)}}),i})}function $y(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function at(e,t=16384){if(typeof e!="string")throw new Error("Native portable text must be a string");if($y(t),Buffer.byteLength(e,"utf8")<=t)return{text:e,truncated:!1};let i="",r=0;for(let n of e){let a=Buffer.byteLength(n,"utf8");if(r+a>t)break;i+=n,r+=a}return{text:i,truncated:!0}}var He="comet.native.v3",_e="comet.native.v2",Te="comet.native.v1";var Fn="comet.native.portable-migration.v1",Hy=new Set(["schema","id","change","fromSchema","status","createdAt"]),Dy=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,By=/^[a-z0-9][a-z0-9-]{7,127}$/u,Ly=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),qy=new Set([Te,_e,He]);function Fy(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function My(e,t){let i=e instanceof Date?new Date(e.valueOf()):new Date(e);if(Number.isNaN(i.valueOf()))throw new Error(`${t} must be a valid timestamp`);return i.toISOString()}function Vy(e,t){if(typeof e!="string")throw new Error(`${t} must be an ISO timestamp`);let i=new Date(e);if(Number.isNaN(i.valueOf())||i.toISOString()!==e)throw new Error(`${t} must be a canonical ISO timestamp`);return e}function Wy(e){return e.schema===Te?Yi(e):e.schema===_e?Xi(e):Qi(e)}function zy(e){return Oy.posix.normalize(e.replaceAll("\\","/"))}function Jy(e){return e.spec_changes.map(t=>t.operation==="remove"?{capability:t.capability,operation:"remove",source:null}:{capability:t.capability,operation:t.operation==="replace"?"modify":"create",source:zy(t.source)})}function Gy(e){return e==="shape"?"shape":"build"}function Uy(e,t){return e==="zh-CN"?t==="shape"?"继续澄清并确认验收项":"重新提交候选实现":t==="shape"?"Continue clarification and confirm acceptance":"Submit a fresh implementation candidate"}function Ky(e,t,i){return e==="zh-CN"?`从旧版 ${t} ${i} 状态恢复;旧版 Loop、验证结论和运行记录未继承。`:`Recovered from legacy ${t} ${i} state; prior Loop, verification results, and execution records were not inherited.`}function Wd(e){let t=Wy(e.state);Fd(e.acceptance);let i=Gy(t.phase),r=i==="shape"?0:1,n=My(e.migratedAt??`${t.created_at}T00:00:00.000Z`,"Native portable migration time"),a=e.acceptance.map(o=>({id:o.id,source:o.source,text:o.text,result:"pending",reason:null}));return ne({schema:Jt,name:t.name,language:t.language,phase:i,status:"active",state_version:1,brief:"brief.md",spec_changes:Jy(t),workspace:e.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:Uy(t.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:at(Ky(t.language,t.schema,t.phase)),completed_at:n}],history_overflow:As(),verification_result:"pending",verification_report:null,archived:!1,created_at:`${t.created_at}T00:00:00.000Z`})}function js(e){let t=Fy(e,"Native portable migration transaction"),i=Object.keys(t).filter(r=>!Hy.has(r));if(i.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${i.join(", ")}`);if(t.schema!==Fn)throw new Error("Unsupported Native portable migration transaction schema");if(typeof t.id!="string"||!By.test(t.id))throw new Error("Native portable migration transaction id is invalid");if(typeof t.change!="string"||!Dy.test(t.change))throw new Error("Native portable migration transaction change is invalid");if(typeof t.fromSchema!="string"||!qy.has(t.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof t.status!="string"||!Ly.has(t.status))throw new Error("Native portable migration transaction status is invalid");return{schema:Fn,id:t.id,change:t.change,fromSchema:t.fromSchema,status:t.status,createdAt:Vy(t.createdAt,"Native portable migration transaction createdAt")}}function zd(e){switch(js(e).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 Mn="comet.native.archive-transaction.v4",Jd="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",Yy=new RegExp(`^portable-archive-(${Jd})\\.json$`,"u"),Xy=new RegExp(`^portable-migration-(${Jd})\\.json$`,"u"),Qy=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,Zy=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,eN=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),tN=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),iN=new Set(["capability","operation","source","content"]),Gd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function Ud(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Kd(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`);if(Object.keys(e).length!==t.size)throw new Error(`${i} fields are invalid`)}function rN(e,t){let i=`Native portable Archive spec_changes[${t}]`,r=Ud(e,i);if(Kd(r,iN,i),typeof r.capability!="string"||!Gd.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 nN(e){let t=Ud(e,"Native portable Archive transaction");if(Kd(t,tN,"Native portable Archive transaction"),t.schema!==Mn)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof t.id!="string"||!Qy.test(t.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof t.change!="string"||!Gd.test(t.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(t.start_state_version)||Number(t.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof t.archive_ref!="string"||!Zy.test(t.archive_ref)||!t.archive_ref.endsWith(`-${t.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof t.status!="string"||!eN.has(t.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let i=t.spec_changes.map(rN);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(t.next_spec_index)||Number(t.next_spec_index)<0||Number(t.next_spec_index)>i.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof t.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let r=new Date(t.created_at);if(Number.isNaN(r.valueOf())||r.toISOString()!==t.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:Mn,id:t.id,change:t.change,start_state_version:Number(t.start_state_version),archive_ref:t.archive_ref,status:t.status,next_spec_index:Number(t.next_spec_index),spec_changes:i,created_at:t.created_at}}function Vn(e){let t=Yy.exec(e);if(t)return{kind:"archive",change:t[1]};let i=Xy.exec(e);return i?{kind:"migration",change:i[1]}:null}function kt(e,t){let i=`${t.kind==="archive"?"portable-archive":"portable-migration"}-${t.change}.json`,r=Vn(i);if(!r||r.kind!==t.kind||r.change!==t.change)throw new Error(`Invalid Native portable transaction change: ${t.change}`);return $s.join(e.transactionsDir,i)}async function Os(e,t){let i=Vn(t);if(!i)return null;let r=await j({root:e.transactionsDir,ref:t,maxBytes:null,includeHash:!1}),n=JSON.parse(r.text),a=$s.join(e.transactionsDir,t);if(i.kind==="archive"){let s=nN(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=js(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 Yt(e,t){let i=kt(e,t);try{return await Os(e,$s.basename(i))}catch(r){if(r.code==="ENOENT")return null;throw r}}function Yd(e){return e.kind==="archive"||e.journal.status!=="committed"}import De from"path";import{TextDecoder as fN}from"util";import{createHash as aN}from"node:crypto";import{constants as Wn,promises as be}from"node:fs";import ke from"node:path";function Jn(e,t){let i=ke.relative(e,t);return i===""||!ke.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ke.sep}`)}function oN(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native protected file byte limit must be a positive integer");return e}function sN(e,t){return A({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function cN(e){return{dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs,ctimeMs:e.ctimeMs,mtimeMs:e.mtimeMs,size:e.size}}function zn(e,t){return A({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Hs(e,t){let i=await be.lstat(e);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${t} parent must be a real directory: ${e}`);return{path:e,realPath:await be.realpath(e),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function lN(e,t,i){let r=ke.resolve(e),n=ke.resolve(t);if(!Jn(r,n))throw new Error(`${i} is outside its managed root`);let a=[await Hs(r,i)],o=r;for(let s of ke.relative(r,n).split(ke.sep).filter(Boolean)){await St(a,i),o=ke.join(o,s);let c=await Hs(o,i);if(!Jn(a[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${o}`);a.push(c)}return await St(a,i),a}async function St(e,t){for(let i of e){let r=await be.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!sN(i,r)||await be.realpath(i.path)!==i.realPath)throw new Error(`${t} parent changed during I/O: ${i.path}`)}}async function uN(e,t,i){let r=[],n=0,a=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let o=t+1-n,{bytesRead:s}=await e.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,n>t)throw new Error(`${i} exceeds ${t} bytes`);r.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(r,n)}async function Xt(e){let t=oN(e.maxBytes),i=ke.resolve(e.file),r=await lN(e.root,ke.dirname(i),e.label),n=await Promise.all((e.forbiddenRoots??[]).map(u=>Hs(ke.resolve(u),e.label)));await e.hooks?.afterParentChainCaptured?.(),await St(r,e.label);let a=await be.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);if(a.size>t)throw new Error(`${e.label} exceeds ${t} bytes`);let o=cN(a),s=await be.realpath(i);if(!Jn(r[0].realPath,s))throw new Error(`${e.label} resolves outside its managed root`);if(n.some(u=>Jn(u.realPath,s)))throw new Error(`${e.label} resolves inside an excluded root`);let c=process.platform==="win32"?Wn.O_RDONLY:Wn.O_RDONLY|Wn.O_NOFOLLOW|Wn.O_NONBLOCK,l=await be.open(i,c);try{let u=await l.stat();await e.hooks?.afterOpen?.();let[f,d]=await Promise.all([be.lstat(i),be.realpath(i)]);if(await St(r,e.label),await St(n,e.label),!u.isFile()||!f.isFile()||f.isSymbolicLink()||d!==s||!zn(o,u)||!zn(o,f))throw new Error(`${e.label} changed while opening`);await e.hooks?.beforeRead?.();let p=await uN(l,t,e.label);await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),be.lstat(i),be.realpath(i)]);if(await St(r,e.label),await St(n,e.label),!h.isFile()||h.isSymbolicLink()||m!==s||!zn(o,v)||!zn(o,h))throw new Error(`${e.label} changed while reading`);return{bytes:p,hash:aN("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}var hN=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),pN=new Set(["id","type","source","target","staged","backup"]),mN=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),vN=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var Zd=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var gN=256*1024,$x=1024*1024,Ox=16*1024;var Hx=64*1024*1024;var wN=new fN("utf-8",{fatal:!0});function Un(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Kn(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function ef(e){if(typeof e!="string")return!1;let t=new Date(e);return!Number.isNaN(t.valueOf())&&t.toISOString()===e}function Ds(e,t){if(typeof e!="string"||e.length===0||De.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native root`)}function Gn(e,t){if(typeof e!="string"||!/^[a-f0-9]{64}$/u.test(e))throw new Error(`${t} must be a SHA-256 hash`)}function Xd(e,t){if(Ds(e,t),e.includes("\\")||e!==De.posix.normalize(e)||e.split("/").includes(".")||e.endsWith("/")||Buffer.byteLength(e,"utf8")>1024)throw new Error(`${t} must be a normalized Native-relative ref`)}function yN(e,t){let i=Un(e,`transaction operations[${t}]`);if(Kn(i,pN,`transaction operations[${t}]`),typeof i.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.id))throw new Error(`transaction operations[${t}].id is invalid`);if(i.type!=="write"&&i.type!=="remove"&&i.type!=="move")throw new Error(`transaction operation ${i.id} has an invalid type`);Ds(i.target,`transaction operation ${i.id} target`);for(let r of["source","staged","backup"])i[r]!==void 0&&Ds(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 tf(e){let t=Un(e,"Native Archive transaction journal");if(Kn(t,mN,"Native Archive transaction journal"),t.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native Archive transaction id is invalid");if(t.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof t.status!="string"||!Zd.has(t.status))throw new Error("Native Archive transaction status is invalid");if(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change))throw new Error("Native Archive transaction change name is invalid");if(!ef(t.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Gn(t.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(t.operations)||t.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let i=t.operations.map((s,c)=>{let l=Un(s,`Archive transaction operations[${c}]`);if(Kn(l,vN,`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`);Xd(l.target,`Archive transaction operation ${l.id} target`);for(let u of["source","staged","backup"])l[u]!==void 0&&Xd(l[u],`Archive transaction operation ${l.id} ${u}`);if(l.expectedTargetHash!==null&&Gn(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(Gn(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`);Gn(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/${t.id}`,a=i.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${t.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${t.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:t.id,kind:"archive",status:t.status,change:t.change,createdAt:t.createdAt,preflightHash:t.preflightHash,operations:i}}function NN(e){let t=Un(e,"Native transaction journal");if(t.schema==="comet.native.transaction.v2")return tf(t);if(Kn(t,hN,"Native transaction journal"),t.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native transaction id is invalid");if(t.kind!=="archive"&&t.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof t.status!="string"||!Zd.has(t.status))throw new Error("Native transaction status is invalid");if(typeof t.projectRoot!="string"||!De.isAbsolute(t.projectRoot)||typeof t.nativeRoot!="string"||!De.isAbsolute(t.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(t.change!==void 0&&(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change)))throw new Error("Native transaction change name is invalid");if(!ef(t.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(t.operations))throw new Error("Native transaction operations must be an array");let i=t.operations.map(yN),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:t.id,kind:t.kind,status:t.status,projectRoot:t.projectRoot,nativeRoot:t.nativeRoot,...typeof t.change=="string"?{change:t.change}:{},createdAt:t.createdAt,operations:i}}function bN(e,t){if(!/^[a-f0-9-]{8,}$/u.test(t))throw new Error(`Invalid Native transaction id: ${t}`);return De.join(e.transactionsDir,t)}function rf(e,t){let i=bN(e,t);return{directory:i,journal:De.join(i,"transaction.json"),events:De.join(i,"events.jsonl"),staged:De.join(i,"staged"),backups:De.join(i,"backups")}}async function Ls(e,t){let i=rf(e,t);return await Promise.all(Object.values(i).map(r=>T(e.runtimeDir,r))),i}async function qs(e,t,i={}){let r=await Ls(e,t),n=await Xt({root:e.runtimeDir,file:r.journal,maxBytes:gN,label:`Native transaction journal ${t}`,hooks:i.hooks}),a=JSON.parse(wN.decode(n.bytes)),o=NN(a);if(o.id!==t)throw new Error(`Invalid Native transaction journal: ${t}`);return o}async function EN(e,t,i){let r;try{r=await kN.readdir(e.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 qs(e,n.name);if(a.id!==t&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of r)if(Vn(n.name))try{let a=await Os(e,n.name);if(!a||i?.kind===a.kind&&i.change===a.change)continue;if(Yd(a))return!0}catch{return!0}return!1}async function PN(e,t){let i=Date.now()+5e3,r=SN.join(e.locksDir,"root-move.lock");for(;;)try{return await jn(e,"root-move",t)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Dd(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 G(e,t,i,r){let n=await PN(e,t);try{if(await zi(e.projectRoot),await EN(e,r?.allowedTransactionId,r?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await i()}finally{await $n(n)}}import{createHash as xN}from"crypto";function de(e){return xN("sha256").update(e).digest("hex")}var rR={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024};var nR=8*1024*1024;var aR=64*1024,oR=64*1024;var sR={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},cR={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};var lR=(1n<<256n)-1n;var jN=ai(Ft(),1);var PR=4*1024*1024;var $N=null;function ON(e,t){let i=e;for(let r of t)i+="\0"+(typeof r=="string"?r:JSON.stringify(r));return i}function nf(e,t){return(...i)=>{let r=$N;if(r===null)return t(...i);let n=ON(`async:${e}`,i),a=r.entries.get(n);if(a)return a.value;let o=t(...i).catch(s=>{throw r.entries.delete(n),s});return r.entries.set(n,{value:o}),o}}var _R=nf("hookWritePolicy",async e=>(await ds(e))?.hook??{allow_paths:[]});var PC=256*1024;var BC={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 Qt from"node:path";var Zi=/^[a-f0-9]{64}$/u,of=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,BN=16*1024,eA=process.platform;function LN(e,t){let i=Qt.relative(e,t);return Qt.isAbsolute(i)||i===".."||i.startsWith(`..${Qt.sep}`)?null:i.replaceAll("\\","/")||"."}function sf(e){return Array.from(e).some(t=>{let i=t.codePointAt(0)??0;return i<=31||i===127})}function cf(e,t){if(e.length===0||sf(e)||e.includes("\\")||Qt.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes(".."))throw new Error(`${t} must be a portable project-relative path`);let i=Qt.posix.normalize(e);if(i!==e||i===".."||i.startsWith("../"))throw new Error(`${t} must be a normalized project-relative path`);return i}function qN(e){if(typeof e!="string")throw new Error("Native workspace capturedAt is invalid");let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw new Error("Native workspace capturedAt is invalid");return e}function Fs(e,t){if(e===null)return null;if(typeof e!="string"||e.length===0||e.trim()!==e||sf(e))throw new Error(`${t} must be a non-empty branch name or null`);return e}function FN(e){if(!new Set(["current","branch","worktree"]).has(e.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Fs(e.changeBranch,"Native workspace change branch"),Fs(e.targetBranch,"Native workspace target branch"),(e.isolation==="branch"||e.isolation==="worktree")&&(e.changeBranch===null||e.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function MN(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace Git provenance must be an object");let t=e,i=new Set(["provider","baseCommit","targetBranch","targetCommit"]),r=Object.keys(t).filter(n=>!i.has(n));if(r.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${r.join(", ")}`);if(t.provider!=="git"||typeof t.baseCommit!="string"||!of.test(t.baseCommit)||typeof t.targetCommit!="string"||!of.test(t.targetCommit))throw new Error("Native workspace Git provenance is invalid");Fs(t.targetBranch,"Native workspace Git target branch")}function VN(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace identity must be an object");let t=e,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(t).filter(o=>!i.has(o));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.join(", ")}`);if(t.schema!=="comet.native.workspace.v2"&&t.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(t.capturedRevision)||t.capturedRevision<1||typeof t.nativeRootRef!="string"||!Zi.test(String(t.projectRootId))||!Zi.test(String(t.nativeRootId)))throw new Error("Native workspace identity is invalid");qN(t.capturedAt),cf(t.nativeRootRef,"Native workspace root ref");let n=t.projectRootPathId!==void 0,a=t.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!Zi.test(String(t.projectRootPathId))||a&&!Zi.test(String(t.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(t.sessionHash!==void 0&&!Zi.test(String(t.sessionHash)))throw new Error("Native workspace session hash is invalid");if(t.git!==void 0&&MN(t.git),t.schema==="comet.native.workspace.v2"){if(t.isolation!==void 0||t.changeBranch!==void 0||t.targetBranch!==void 0||t.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof t.isolation!="string"||t.changeBranch===void 0||t.targetBranch===void 0||t.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(FN(t),t.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(t.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function WN(e,t){return Qt.join(Re(e,t),"workspace.json")}function zN(e,t){let i=WN(e,t),r=Ce(e,i),n=LN(r,i);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:r,ref:cf(n,"Native workspace file ref")}}async function JN(e,t){try{let i=zN(e,t),r=await j({root:i.root,ref:i.ref,maxBytes:BN});return JSON.parse(r.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function er(e,t){let i=await JN(e,t);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(VN(i),i)}var uf=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],KN=new Set(uf),df=new Set([...uf,"minimum_runtime_version","revision"]),YN=new Set([...df,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),XN=new Set(["capability","operation","source","base_hash"]),QN=new Set(["shape","build","verify","archive"]),ZN=new Set(["implicit","confirmed"]),eb=new Set(["pending","pass","fail"]),Et="comet-state.yaml",Vs=/^[a-f0-9]{64}$/u,ff=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,tb=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Ws=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"},ei=class extends Error{constructor(i,r){super(i!==He||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"},Yn=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"},tr=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"},Xn=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"},EA=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
150
+ `);function rr(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function hf(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Js(e){if(!ff.test(e))throw new Error(`Invalid Native change name: ${e}`)}function ib(e){if(!ff.test(e))throw new Error(`Invalid Native capability id: ${e}`)}function pf(e,t){if(e.length===0||Zt.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native change`)}function rb(e,t){let i=rr(e,`spec_changes[${t}]`);if(hf(i,XN,`spec_changes[${t}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(ib(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"&&pf(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"||!Vs.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"||!Vs.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 nb(e){return/^\d{4}-\d{2}-\d{2}$/u.test(e)?new Date(`${e}T00:00:00.000Z`).toISOString().slice(0,10)===e:!1}function Gs(e,t){if(hf(e,t,Et),typeof e.name!="string")throw new Error("Native change name is required");if(Js(e.name),e.language!=="en"&&e.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof e.phase!="string"||!QN.has(e.phase))throw new Error("Native change phase is invalid");if(e.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(e.approval!==null&&!ZN.has(e.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native spec_changes must be an array");let i=e.spec_changes.map(rb),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 e.verification_result!="string"||!eb.has(e.verification_result))throw new Error("Native verification_result is invalid");if(e.verification_report!==null&&typeof e.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof e.verification_report=="string"&&pf(e.verification_report,"Native verification_report"),typeof e.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof e.created_at!="string"||!nb(e.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(e.run_id!==null&&(typeof e.run_id!="string"||e.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:e.name,language:e.language,phase:e.phase,brief:"brief.md",approval:e.approval,spec_changes:i,verification_result:e.verification_result,verification_report:e.verification_report,archived:e.archived,created_at:e.created_at,run_id:e.run_id}}function Yi(e){let t=rr(e,Et);if(t.schema!==Te)throw new Error(`Expected ${Te}`);return{schema:Te,...Gs(t,KN)}}function ir(e,t){if(!Number.isSafeInteger(e)||e<1)throw new Error(`${t} must be a positive integer`);return e}function Ms(e,t,i){if(e===null)return null;let r=typeof e=="string"?tb.exec(e):null;if(!r||r[1]!==i)throw new Error(`${t} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return e}function ab(e){if(e==null)return null;if(typeof e!="string"||!Vs.test(e))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return e}function ob(e){if(e===void 0)return"legacy-v1";if(e!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return e}function Xi(e){let t=rr(e,Et);if(t.schema!==_e)throw new Error(`Expected ${_e}`);if(ir(t.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${_e} minimum_runtime_version must be 2`);return{schema:_e,minimum_runtime_version:2,revision:ir(t.revision,"Native v2 revision"),...Gs(t,df)}}function Qi(e){let t=rr(e,Et);if(t.schema!==He){if(t.schema===Te||t.schema===_e){let o=t.schema===Te?Yi(t):Xi(t);throw new Ws(o.name,o.schema)}throw new ei(typeof t.schema=="string"?t.schema:"(missing)",typeof t.minimum_runtime_version=="number"?t.minimum_runtime_version:null)}let i=ir(t.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new ei(t.schema,i);if(i!==3)throw new Error(`Native ${t.schema} minimum_runtime_version must be ${3}`);let r=ir(t.revision,"Native revision"),n=Gs(t,YN),a=ab(t.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:He,minimum_runtime_version:3,revision:r,verification_protocol:ob(t.verification_protocol),...n,approved_contract_hash:a,implementation_scope:Ms(t.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Ms(t.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Ms(t.partial_allowance,"Native partial_allowance","allowances")}}function sb(e){let t=rr(e,Et);if(t.schema===Te){let n=Yi(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${He}`}}if(t.schema===_e){let n=Xi(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${He}`}}if(t.schema!==He){let n=typeof t.minimum_runtime_version=="number"&&Number.isSafeInteger(t.minimum_runtime_version)?t.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof t.schema=="string"?t.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new ei(typeof t.schema=="string"?t.schema:"(missing)",n).message}}let i=ir(t.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:t.schema,minimumRuntimeVersion:i,state:null,message:new ei(t.schema,i).message};let r=Qi(t);return{status:"current",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r}}function oe(e,t){Js(t);let i=Zt.join(e.changesDir,t);if(!L(e.changesDir,i))throw new Error("Native change path escaped");return i}var cb=256*1024;async function lb(e,t=Zt.dirname(e)){let i=Zt.relative(t,e).split(Zt.sep).join("/"),r=await j({root:t,ref:i,maxBytes:cb}),n=(0,zs.parseDocument)(r.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${e}: ${n.errors[0].message}`);return n.toJS()}async function Qn(e,t){let i=Zt.join(oe(e,t),Et);await T(e.nativeRoot,i);let r=sb(await lb(i,e.nativeRoot));if(r.state&&r.state.name!==t)throw new Error(`Native change directory/name mismatch: ${t}`);return r}import{promises as lr}from"node:fs";import qe from"node:path";var Nf=ai(Ft(),1);import{promises as hb}from"node:fs";import pb from"node:path";import{execFileSync as ub}from"node:child_process";var db=3e4,fb=8*1024*1024,Us=class extends Error{constructor(i,r,n){super(`git ${r.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=i;this.args=r;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr};function mf(e,t){try{return ub("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:db,maxBuffer:fb,windowsHide:!0})}catch(i){let r=typeof i.stderr=="string"?i.stderr.trim():Buffer.isBuffer(i.stderr)?i.stderr.toString("utf8").trim():"";throw new Us(e,t,r)}}function I(e,t){return mf(e,t).trim()}function Zn(e){return I(e,["status","--porcelain=v1","-z","--untracked-files=all"])===""}function Ks(e){let t=mf(e,["status","--porcelain=v1","-z","--untracked-files=all"]);if(!t)return[];let i=t.split("\0").filter(Boolean),r=[];for(let n=0;n<i.length;n+=1){let a=i[n];if(a.length<4)throw new Error("Git status returned an invalid porcelain record");if(r.push(a.slice(3).replaceAll("\\","/")),a[0]==="R"||a[0]==="C"||a[1]==="R"||a[1]==="C"){let o=i[n+1];if(!o)throw new Error("Git status returned an incomplete rename record");r.push(o.replaceAll("\\","/")),n+=1}}return[...new Set(r)].sort()}function vf(e,t){try{let r=I(e,["config","--get",`branch.${t}.remote`]);if(r&&r!==".")return r}catch{}let i=I(e,["remote"]).split(/\r?\n/u).map(r=>r.trim()).filter(Boolean);if(i.includes("origin"))return"origin";if(i.length===1)return i[0];throw new Error(i.length===0?"Native workspace finish requires a configured Git remote":`Native workspace finish requires an unambiguous Git remote: ${i.join(", ")}`)}var gf="children.yaml",Ys="comet.native.children.v1",nr="comet.native.children.v2",mb=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,vb=new Set(["schema","children"]),gb=new Set(["schema","acceptance_index","children"]),wb=new Set(["name","depends_on","covers"]);function ta(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function ea(e,t,i){let r=Object.keys(e).filter(a=>!t.has(a)),n=[...t].filter(a=>!(a in e));if(r.length>0||n.length>0)throw new Error(`${i} fields are invalid`)}function wf(e,t){if(!Array.isArray(e)||!e.every(i=>typeof i=="string"))throw new Error(`${t} must be an array of strings`);return[...new Set(e)].sort((i,r)=>i.localeCompare(r,"en"))}function yb(e){let t=new Map(e.map(a=>[a.name,a])),i=new Set,r=new Set,n=a=>{if(!r.has(a)){if(i.has(a))throw new Error(`Native children dependency cycle includes ${a}`);i.add(a);for(let o of t.get(a).depends_on)n(o);i.delete(a),r.add(a)}};for(let a of e)n(a.name)}function yf(e,t,i=t){let r=new Set(t);for(let o of e){let s=o.covers.filter(c=>!r.has(c));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(e.flatMap(o=>o.covers)),a=i.filter(o=>!n.has(o));if(a.length>0)throw new Error(`Native children do not cover parent acceptance: ${a.join(", ")}`)}function bf(e){let t=new Set(e.acceptance.filter(({source:i})=>i===e.brief).map(({id:i})=>i));if(e.loop.stage==="repairing"&&e.verification_result==="fail"){let i=[...e.history].reverse().find(({outcome:r})=>r==="fail");for(let r of i?.unresolved_ids??[])t.add(r)}return{acceptanceCatalog:e.acceptance,requiredAcceptanceIds:[...t]}}function Nb(e){let t=ta(e,"Native children acceptance_index"),i={};for(let[r,n]of Object.entries(t)){let a=ta(n,`Native children acceptance_index.${r}`);if(ea(a,new Set(["source","text"]),`Native children acceptance_index.${r}`),typeof a.source!="string"||a.source.length===0)throw new Error(`Native children acceptance_index.${r}.source must be a non-empty string`);if(typeof a.text!="string"||a.text.length===0)throw new Error(`Native children acceptance_index.${r}.text must be a non-empty string`);i[r]={source:a.source,text:a.text}}return i}function bb(e,t,i){let r=i.requiredAcceptanceIds??t??[],n=Object.keys(e),a=r.filter(c=>!(c in e)),o=n.filter(c=>!r.includes(c));if(a.length>0||o.length>0)throw new Error(`Native children acceptance_index must match the required acceptance: missing ${a.join(", ")||"none"}; extra ${o.join(", ")||"none"}`);let s=new Map((i.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of r){let l=s.get(c);if(!l)continue;let u=e[c];if(u.source!==l.source||u.text!==l.text)throw new Error(`Native children acceptance_index.${c} does not match the acceptance catalog`)}}function kb(e,t,i={}){let r=(0,Nf.parseDocument)(e,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${r.errors[0].message}`);let n=ta(r.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a===nr?ea(n,gb,"Native children contract"):ea(n,vb,"Native children contract"),a!==Ys&&a!==nr)throw new Error(`Native children schema must be ${Ys} or ${nr}`);if(!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let o=n.children.map((l,u)=>{let f=ta(l,`Native child ${u}`);if(ea(f,wb,`Native child ${u}`),typeof f.name!="string"||!mb.test(f.name))throw new Error(`Native child ${u} name is invalid`);return{name:f.name,depends_on:wf(f.depends_on,`Native child ${f.name} depends_on`),covers:wf(f.covers,`Native child ${f.name} covers`)}}),s=o.map(({name:l})=>l);if(new Set(s).size!==s.length)throw new Error("Native child names must be unique");let c=new Set(s);for(let l of o){let u=l.depends_on.filter(f=>!c.has(f));if(u.length>0)throw new Error(`Native child ${l.name} depends on unknown child: ${u.join(", ")}`)}if(yb(o),a===nr){let l=Nb(n.acceptance_index);if(bb(l,t,i),t){let u=Object.keys(l);yf(o,u,u)}return{schema:nr,acceptance_index:l,children:o}}return t&&yf(o,t),{schema:Ys,children:o}}async function kf(e){let t=pb.join(e.changeDir,gf);try{await hb.lstat(t)}catch(r){if(r.code==="ENOENT")return null;throw r}let i=await j({root:e.changeDir,ref:gf});return{contract:kb(i.text,e.acceptanceIds,e.validation),size:i.size}}function Sf(e){return ee("comet.native.parent-contract.v1",{acceptance:e.acceptance.map(({id:t,source:i,text:r})=>({id:t,source:i,text:r})),children:e.children})}var BA=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");var ia="skill-coordinated";function xb(e){return e.state_version+1}function Rb(e){return e.map(t=>({...t,result:"pending",reason:null}))}function Cb(e){return{goal_cycle:e.state.loop.goal_cycle,iteration:e.state.loop.iteration,attempt:e.state.loop.attempt,outcome:e.outcome,unresolved_ids:e.unresolvedIds??[],summary:at(e.summary),completed_at:e.completedAt}}function Xs(e){let t=ne(e.state);if(t.phase!=="verify"&&t.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let i=(e.now??new Date).toISOString(),r=Kt(t,Cb({state:t,outcome:"recovery",summary:e.reason,completedAt:i}));return ne({...r,phase:"build",status:"active",state_version:xb(t),verification_result:"pending",verification_report:null,verification:null,builder_handoff:null,blockers:[],acceptance:Rb(t.acceptance),loop:{...t.loop,stage:"repairing",iteration:t.loop.iteration+1,attempt:0,execution_failure_count:0,next_action:"submit-builder-candidate"}})}import{promises as Pf}from"node:fs";import or from"node:path";function ra(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function na(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Ie(e,t,i=!1){if(typeof e!="string"||!i&&e.length===0)throw new Error(`${t} must be ${i?"a string":"a non-empty string"}`);return e}function Ef(e,t){return e===null?null:Ie(e,t)}function oa(e,t,i=0){if(!Number.isSafeInteger(e)||e<i)throw new Error(`${t} must be a safe integer greater than or equal to ${i}`);return e}function Ab(e,t){if(e===null)return null;if(!Number.isSafeInteger(e))throw new Error(`${t} must be null or a safe integer`);return e}function _b(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function aa(e,t,i){if(typeof e!="string"||!t.includes(e))throw new Error(`${i} must be one of: ${t.join(", ")}`);return e}function Qs(e,t){if(e===null)return null;let i=Ie(e,t);if(Number.isNaN(Date.parse(i)))throw new Error(`${t} must be an ISO timestamp`);return i}function Zs(e,t){let i=Ie(e,t);if(!or.isAbsolute(i))throw new Error(`${t} must be absolute`);return or.resolve(i)}function Tb(e,t){let i=`Native local checks[${t}]`,r=ra(e,i);if(na(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,u)=>Ie(l,`${i}.argv[${u}]`,!0)),a=aa(r.status,["planned","running","passed","failed","interrupted"],`${i}.status`),o=Qs(r.startedAt,`${i}.startedAt`),s=Qs(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=oa(r.timeoutMs,`${i}.timeoutMs`);if(c<1)throw new Error(`${i}.timeoutMs must be positive`);return{id:Ie(r.id,`${i}.id`),name:Ie(r.name,`${i}.name`),operationId:Ie(r.operationId,`${i}.operationId`),status:a,repeatable:_b(r.repeatable,`${i}.repeatable`),timeoutMs:c,executionCount:oa(r.executionCount,`${i}.executionCount`),argv:n,cwd:Zs(r.cwd,`${i}.cwd`),exitCode:Ab(r.exitCode,`${i}.exitCode`),startedAt:o,completedAt:s,log:Ie(r.log,`${i}.log`)}}function ec(e){let t="Native local execution state",i=ra(e,t);if(na(i,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),t),i.schema!==Ki)throw new Error(`Native local execution schema must be ${Ki}`);let r=ra(i.workspace,"Native local workspace");na(r,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(i.execution!==null){let o=ra(i.execution,"Native local execution");na(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=Qs(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Ie(o.operationId,"Native local execution.operationId"),stage:aa(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:aa(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Ef(o.executionId,"Native local execution.executionId"),status:aa(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:oa(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(Tb);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:Ki,change:Ie(i.change,"Native local change"),basedOnStateVersion:oa(i.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:Zs(r.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Zs(r.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Ef(r.branch,"Native local workspace.branch")},execution:n,checks:a}}function st(e){return ec({schema:Ki,change:e.portableState.name,basedOnStateVersion:e.portableState.state_version,workspace:{projectRoot:or.resolve(e.projectRoot),worktreeRoot:or.resolve(e.worktreeRoot??e.projectRoot),branch:e.branch??null},execution:null,checks:[]})}async function tc(e){let t;try{t=await Pf.readFile(e,"utf8")}catch(r){if(r.code==="ENOENT")return null;throw r}let i;try{i=JSON.parse(t)}catch(r){throw new Error(`Native local execution state is invalid JSON: ${r.message}`,{cause:r})}return ec(i)}async function Be(e,t,i={}){let r=ec(t);await Pf.mkdir(or.dirname(e),{recursive:!0}),await X(e,r,i)}import{promises as Ib}from"node:fs";function ct(e){return e===null?"—":`${e.text.replace(/\r\n?/gu,`
151
+ `).replace(/\s+/gu," ").trim()||"—"}${e.truncated?" … (truncated)":""}`}function Le(e){return e.replaceAll("|","\\|").replace(/\r?\n/gu,"<br>")}function jb(e){return e.verification?.assurance==="semantic-verification-unavailable"?"Semantic verification unavailable, user confirmation required":e.verification?.assurance==="user-confirmed-degraded"?"Passed with user-confirmed degraded assurance":e.verification_result==="pass"?e.phase==="verify"&&e.loop.next_action==="confirm-skill-coordinated-pass"?"Passed, user confirmation required":"Passed":e.verification_result==="blocked"?"Blocked":e.verification_result==="fail"?"Failed":"Pending"}function $b(e){return e.verification?.assurance??(e.builder_handoff?.identity_provider===ia?ia:"host-attested")}function Ob(e){if(e.verification===null)throw new Error("Native verification report requires a stable Verifier result");let t=e.acceptance.map(o=>`| ${Le(o.id)} | ${Le(o.result)} | ${Le(o.source)} | ${Le(o.text)} | ${Le(ct(o.reason))} |`).join(`
152
+ `),i=e.verification.checks.length===0?"_No Runtime checks were recorded._":["| Check | Command | Working directory | Status | Exit | Duration |","| --- | --- | --- | --- | ---: | ---: |",...e.verification.checks.map(o=>{let s=o.argv_display.map(ct).join(" ");return`| ${Le(ct(o.name))} | ${Le(s||"—")} | ${Le(o.cwd_ref)} | ${o.status} | ${o.exit_code??"—"} | ${o.duration_ms} ms |`})].join(`
153
+ `),r=e.blockers.length===0?"_None._":e.blockers.map(o=>`- **${o.owner}**: ${ct(o.reason)}${o.acceptance_ids.length>0?` (acceptance: ${o.acceptance_ids.join(", ")})`:""} — next: \`${o.resolution_action}\``).join(`
154
+ `),n=e.verification.risks.length===0?"_None reported._":e.verification.risks.map(o=>`- ${ct(o)}`).join(`
155
+ `),a=e.history.length===0?"_No previous iterations._":["| Goal cycle | Iteration | Attempt | Outcome | Unresolved | Summary | Completed |","| ---: | ---: | ---: | --- | --- | --- | --- |",...e.history.map(o=>`| ${o.goal_cycle} | ${o.iteration} | ${o.attempt} | ${o.outcome} | ${o.unresolved_ids.join(", ")||"—"} | ${Le(ct(o.summary))} | ${o.completed_at} |`)].join(`
156
156
  `);return`---
157
157
  generated_from_state_version: ${e.state_version}
158
158
  ---
@@ -161,13 +161,13 @@ generated_from_state_version: ${e.state_version}
161
161
 
162
162
  ## Current result
163
163
 
164
- - Result: **${AN(e)}**
165
- - Assurance: **${_N(e)}**
164
+ - Result: **${jb(e)}**
165
+ - Assurance: **${$b(e)}**
166
166
  - Goal cycle: ${e.loop.goal_cycle}
167
167
  - Iteration: ${e.verification.iteration}
168
168
  - Verifier attempt: ${e.verification.attempt}
169
169
  - Completed: ${e.verification.completed_at}
170
- - Summary: ${rt(e.verification.summary)}
170
+ - Summary: ${ct(e.verification.summary)}
171
171
 
172
172
  ## Acceptance
173
173
 
@@ -195,22 +195,23 @@ ${e.history_overflow.dropped_entries>0?`Earlier history entries folded into summ
195
195
 
196
196
  `:""}## Conclusion
197
197
 
198
- ${rt(e.verification.summary)}
199
- `}function IN(e){let t=/^---\r?\ngenerated_from_state_version: ([1-9]\d*)\r?\n---(?:\r?\n|$)/u.exec(e);if(!t)return null;let i=Number(t[1]);return Number.isSafeInteger(i)?i:null}async function tr(e){let t;try{t=await CN.readFile(e.file,"utf8")}catch(r){if(r.code==="ENOENT")return"missing";throw r}let i=IN(t);return i===null?"invalid":i===e.stateVersion?"aligned":"stale"}async function ir(e){await K(e.file,TN(e.state))}var Kd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,jN="comet-state.yaml",$N="state.json";function be(e,t){if(!Kd.test(t))throw new Error(`Invalid Native change name: ${t}`);let i=Be.join(e.changesDir,t);if(!D(e.changesDir,i))throw new Error("Native change path escaped");return i}function ne(e,t){return Be.join(be(e,t),jN)}function Ut(e,t){return Be.join(Ee(e,t),$N)}async function nr(e,t){try{let i=await rr.readFile(ne(e,t),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(i)}catch(i){if(i.code==="ENOENT")return!1;throw i}}function ON(e){return F(e).currentBranch}async function Le(e,t){return ue(ne(e,t))}async function Yd(e){let t=await mt({file:ne(e.paths,e.previous.name),expectedStateVersion:e.previous.state_version,next:e.next,containedRoot:e.paths.nativeRoot});if(t.verification===null&&t.verification_report===null){let i=Be.join(be(e.paths,t.name),"verification.md");await T(e.paths.nativeRoot,i),await rr.rm(i,{force:!0})}return t}async function HN(e){let t=be(e.paths,e.state.name),i=Be.join(t,"specs"),r=new Map(e.state.spec_changes.filter(({operation:o})=>o==="remove").map(o=>[o.capability,o])),n;try{n=await rr.readdir(i,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")n=[];else throw o}let a=[];for(let o of n.sort((s,c)=>s.name.localeCompare(c.name,"en"))){if(o.isSymbolicLink())throw new Error(`Native spec capability is unsafe: ${o.name}`);if(!o.isDirectory())continue;if(!Kd.test(o.name))throw new Error(`Invalid Native capability: ${o.name}`);if(r.has(o.name))throw new Error(`Capability ${o.name} cannot be proposed and removed together`);let s=`specs/${o.name}/spec.md`,c=Be.join(t,...s.split("/")),l=await rr.lstat(c);if(!l.isFile()||l.isSymbolicLink())throw new Error(`Native proposed spec must be a regular file: ${s}`);let d=Be.join(e.paths.specsDir,o.name,"spec.md"),f="create";try{let u=await rr.lstat(d);if(!u.isFile()||u.isSymbolicLink())throw new Error(`Canonical Native spec is unsafe: ${o.name}`);f="modify"}catch(u){if(u.code!=="ENOENT")throw u}a.push({capability:o.name,operation:f,source:s})}return a.push(...r.values()),a.sort((o,s)=>o.capability.localeCompare(s.capability,"en"))}async function DN(e){let t=be(e.paths,e.state.name),i=await B({root:t,ref:"brief.md",maxBytes:null,includeHash:!1}),r=[];for(let n of e.specChanges){if(n.source===null)continue;let a=await B({root:t,ref:n.source,maxBytes:null,includeHash:!1});r.push({capability:n.capability,source:a.ref,markdown:a.text})}return Cn({briefMarkdown:i.text,specs:r})}async function Fs(e){let t=await HN(e);if(!(t.length===e.state.spec_changes.length&&t.every((a,o)=>{let s=e.state.spec_changes[o];return s!==void 0&&a.capability===s.capability&&a.source===s.source&&(a.operation===s.operation||e.ignoreSpecOperationFor?.has(a.capability)===!0)})))return{drifted:!0,reason:"Native target specification declarations changed"};let r=await DN({...e,specChanges:t}),n=e.state.acceptance.map(({source:a,text:o})=>({source:a,text:o}));return kd(n,r)?{drifted:!1,reason:null}:{drifted:!0,reason:"Native confirmed acceptance criteria changed"}}async function Xd(e){return J(e.paths,`set portable workspace finish ${e.name}`,async()=>{let t=await Le(e.paths,e.name);if(t.workspace.isolation==="current")throw new Error("Native current-workspace isolation does not accept a finish action");let i={...t,state_version:t.state_version+1,workspace:{...t.workspace,finish:e.finish}},r=await Yd({paths:e.paths,previous:t,next:i});return r.verification!==null&&await ir({file:Be.join(be(e.paths,t.name),"verification.md"),state:r}),r})}async function Qd(e){let{state:t}=e;if(t.archived)throw new Error(`Native change ${t.name} is already archived`);let r={...Vt(t,{goal_cycle:t.loop.goal_cycle,iteration:t.loop.iteration,attempt:t.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:et(e.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:t.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:t.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"confirm-shape"}},n=await Yd({paths:e.paths,previous:t,next:r});return await it(Ut(e.paths,t.name),yt({portableState:n,projectRoot:e.paths.projectRoot,branch:ON(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),n}async function Xn(e){if(e.state.verification===null)return"not-applicable";let t=Be.join(be(e.paths,e.state.name),"verification.md");return await tr({file:t,stateVersion:e.state.state_version})==="aligned"?"aligned":(await ir({file:t,state:e.state}),"rebuilt")}import{promises as BN}from"fs";import LN from"path";var Ms="comet.selection.v2",FN=16*1024;function Qn(e){return LN.join(e,".comet","current-change.json")}function MN(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Zd(e){return e===null||typeof e=="string"}function VN(e){let t;try{t=JSON.parse(e)}catch(i){throw new Error(`current change selection contains invalid JSON: ${i instanceof Error?i.message:String(i)}`,{cause:i})}if(!MN(t))throw new Error("current change selection must be a JSON object");if(t.version===1){if(typeof t.change!="string")throw new Error("legacy current change selection change must be a string");if(t.branch!==void 0&&!Zd(t.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:Ms,workflow:"classic",change:t.change,branch:t.branch??null},legacy:!0}}if(t.schema!==Ms)throw new Error(`current change selection schema must be ${Ms}`);if(t.workflow!=="native"&&t.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof t.change!="string")throw new Error("current change selection change must be a string");if(!Zd(t.branch))throw new Error("current change selection branch must be a string or null");if(t.workflow==="native"&&t.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:t,legacy:!1}}async function ef(e){let t;try{let r=Qn(e),{bytes:n}=await ft(r,FN,{label:"current change selection"});t=n.toString("utf8")}catch(r){if(r.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${r instanceof Error?r.message:String(r)}`,{cause:r})}return{status:"selected",...VN(t)}}async function tf(e){await BN.rm(Qn(e),{force:!0})}async function rf(e,t,i){let r=await ef(e);return r.status!=="selected"||r.selection.workflow!==t||r.selection.change!==i?!1:(await tf(e),!0)}var IA=16*1024;function Vs(e){return Qn(e.projectRoot)}async function Zn(e,t){return await Fi(e.projectRoot),rf(e.projectRoot,"native",t)}var ar=class extends Error{peers;constructor(t){super(t.length===0?"Native Archive serial capability decision is stale":`Native Archive requires a serial capability decision: ${t.join(", ")}`),this.name="NativePortableArchiveOrderRequiredError",this.peers=[...t]}};function qs(e){return`${(e.verification?.completed_at??e.created_at).slice(0,10)}-${e.name}`}function Ws(e,t){if(!/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t))throw new Error("Native portable Archive ref is invalid");let i=U.join(e.archiveDir,t);if(!D(e.archiveDir,i))throw new Error("Native Archive path escaped");return i}async function ea(e){try{return await q.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}function nf(e,t){let i=U.normalize(U.resolve(e)),r=U.normalize(U.resolve(t));return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}async function af(e,t){let i;try{i=await q.readdir(e.archiveDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return null;throw n}let r=[];for(let n of i){if(!n.isDirectory()||n.isSymbolicLink())continue;let a=U.join(e.archiveDir,n.name);try{let o=await ue(U.join(a,"comet-state.yaml"));o.name===t&&r.push({dir:a,state:o})}catch{}}if(r.length>1)throw new Error(`Multiple Native portable archives exist for ${t}`);return r[0]??null}async function zs(e,t){let i=await qt(e,{kind:"archive",change:t});return i?.kind==="archive"?i.journal:null}async function of(e,t){return await zs(e,t)!==null||await af(e,t)!==null}async function Nt(e,t){await q.mkdir(e.transactionsDir,{recursive:!0}),await Y(vt(e,{kind:"archive",change:t.change}),t,{containedRoot:e.runtimeDir})}async function sf(e){let t=new Set(e.state.spec_changes.map(({capability:a})=>a));if(t.size===0)return[];let i=St(e.paths.projectRoot);i.some(a=>nf(a,e.paths.projectRoot))||i.push(e.paths.projectRoot);let r=[];for(let a of i){let o=await Re(a);if(!o)continue;let s=await Bt(a,o.native.artifact_root);r.some(c=>nf(c.changesDir,s.changesDir))||r.push(s)}r.length===0&&r.push(e.paths);let n=new Set;for(let a of r){let o;try{o=await q.readdir(a.changesDir,{withFileTypes:!0})}catch(s){if(s.code==="ENOENT")continue;throw s}for(let s of o)if(!(!s.isDirectory()||s.isSymbolicLink()||s.name===e.state.name))try{let c=await ue(U.join(a.changesDir,s.name,"comet-state.yaml"));c.status!=="done"&&c.spec_changes.some(({capability:l})=>t.has(l))&&n.add(c.name)}catch{let c=await zn(a,s.name).catch(()=>null);c?.state&&c.state.spec_changes.some(({capability:l})=>t.has(l))&&n.add(c.state.name)}}return[...n].sort((a,o)=>a.localeCompare(o,"en"))}function WN(e){if(e===void 0)return null;if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e))throw new Error("Native Archive serial capability decision is invalid");return e}async function zN(e){let t=U.join(e.paths.specsDir,e.change.capability),i=U.join(t,"spec.md");if(!D(e.paths.specsDir,i))throw new Error("Native canonical spec path escaped");if(e.change.operation==="remove"){let n;try{n=await q.lstat(e.paths.specsDir)}catch(c){if(c.code==="ENOENT")return;throw c}if(!n.isDirectory()||n.isSymbolicLink())throw new Error("Native canonical specs root is unsafe");let a;try{a=await q.lstat(t)}catch(c){if(c.code==="ENOENT")return;throw c}if(!a.isDirectory()||a.isSymbolicLink())throw new Error(`Canonical Native capability directory is unsafe: ${e.change.capability}`);let[o,s]=await Promise.all([q.realpath(e.paths.specsDir),q.realpath(t)]);if(!D(o,s))throw new Error("Native canonical capability path escaped");try{let c=await q.lstat(i);if(!c.isFile()||c.isSymbolicLink())throw new Error(`Canonical Native spec is unsafe: ${e.change.capability}`);await q.unlink(i)}catch(c){if(c.code!=="ENOENT")throw c}await q.rmdir(t).catch(c=>{if(c.code!=="ENOENT"&&c.code!=="ENOTEMPTY")throw c});return}if(e.change.source===null||e.change.content===null)throw new Error(`Native ${e.change.operation} spec requires frozen source content`);let r=U.join(be(e.paths,e.state.name),e.change.source);await K(r,e.change.content,{containedRoot:e.paths.nativeRoot}),await q.mkdir(t,{recursive:!0}),await K(i,e.change.content,{containedRoot:e.paths.nativeRoot})}function Js(e){if(e.phase!=="archive"||e.status!=="active"||e.loop.stage!=="archive-ready"||e.verification_result!=="pass"||e.verification?.verdict!=="pass"||e.verification_report!=="verification.md")throw new Error(`Native change ${e.name} is not archive-ready`)}async function JN(e,t){let i=be(e,t.name),r=[];for(let n of t.spec_changes){if(n.source===null){r.push({...n,content:null});continue}let a=await B({root:i,ref:n.source,maxBytes:null,includeHash:!1});r.push({...n,content:a.text})}return r}function GN(e,t){if(t.archived){if(t.status!=="done"||t.loop.stage!=="done"||t.state_version!==e.start_state_version+1)throw new Error("Native Archive transaction no longer matches the finalized portable state");return}if(t.state_version!==e.start_state_version)throw new Error("Native Archive transaction is stale for the current portable state");if(Js(t),e.status!=="prepared"&&e.status!=="specs-applied")throw new Error(`Native Archive transaction ${e.status} requires a finalized portable state`)}async function Gs(e){let t=await Le(e.paths,e.name),i=[];try{Js(t)}catch(o){i.push(o.message)}if(await zs(e.paths,e.name)===null)try{let o=await Fs({paths:e.paths,state:t});o.drifted&&i.push(o.reason??"Native confirmed requirements changed")}catch(o){i.push(o.message)}let n=t.verification===null?"missing":await tr({file:U.join(be(e.paths,t.name),"verification.md"),stateVersion:t.state_version});n!=="aligned"&&i.push(`verification.md is ${n}`);let a=await sf({paths:e.paths,state:t});return a.length>0&&i.push(`capabilities are also declared by: ${a.join(", ")}`),{ready:i.length===0,blockers:i,capabilityPeers:a,archiveDir:Ws(e.paths,qs(t)),stateVersion:t.state_version}}async function cf(e){return J(e.paths,`archive portable change ${e.name}`,async()=>{let t=WN(e.serialFirstChange);if(t!==null&&t!==e.name)throw new Error("Native Archive --serial-first must name the change being archived");let i=await zs(e.paths,e.name),r=be(e.paths,e.name),n=await ea(r),a=n?null:await af(e.paths,e.name),o;if(n)o=await Le(e.paths,e.name);else if(i)o=await ue(U.join(Ws(e.paths,i.archive_ref),"comet-state.yaml"));else if(a)o=a.state;else throw new Error(`Native active change is missing: ${e.name}`);if(n&&!o.archived&&i===null){let l=await Fs({paths:e.paths,state:o});if(l.drifted){let d=l.reason??"Native confirmed requirements changed";throw await Qd({paths:e.paths,state:o,reason:d}),new Error(`${d}; Native change returned to Shape and requires confirmation`)}}let s=Ws(e.paths,i?.archive_ref??qs(o)),c=await ea(s);if(i&&GN(i,o),n&&c)throw new Error("Native active and archive directories both exist; doctor intervention is required");if(!n&&!i&&a){if(!o.archived||o.status!=="done"||o.loop.stage!=="done")throw new Error("Native archive exists without a completed portable state");return await Zn(e.paths,o.name),await q.rm(Ee(e.paths,o.name),{recursive:!0,force:!0}),{change:o.name,archiveDir:a.dir,transactionId:`recovered-${o.state_version}`,state:o}}if(!i){if(!o.archived)Js(o);else if(o.status!=="done"||o.loop.stage!=="done")throw new Error("Native active archived state is inconsistent");let l=await sf({paths:e.paths,state:o});if(!o.archived&&l.length>0&&t!==o.name)throw new ar(l);i={schema:On,id:qN(),change:o.name,start_state_version:o.archived?o.state_version-1:o.state_version,archive_ref:qs(o),status:o.archived?"state-finalized":"prepared",next_spec_index:o.archived?o.spec_changes.length:0,spec_changes:await JN(e.paths,o),created_at:new Date().toISOString()},await Nt(e.paths,i)}if(!n&&c&&i.status==="report-aligned")i={...i,status:"moved"},await Nt(e.paths,i);else if(!n&&c&&i.status!=="moved")throw new Error(`Native Archive layout contradicts transaction state ${i.status}; doctor intervention is required`);if(i.status==="prepared"){for(let l=i.next_spec_index;l<i.spec_changes.length;l+=1)await zN({paths:e.paths,state:o,change:i.spec_changes[l]}),i={...i,next_spec_index:l+1},await Nt(e.paths,i),await e.hooks?.afterSpecApplied?.(l);i={...i,status:"specs-applied"},await Nt(e.paths,i)}if(i.status==="specs-applied"){if(!o.archived){let l={...o,phase:"archive",status:"done",state_version:o.state_version+1,archived:!0,blockers:[],loop:{...o.loop,stage:"done",next_action:null}};o=await mt({file:ne(e.paths,o.name),expectedStateVersion:o.state_version,next:l,containedRoot:e.paths.nativeRoot})}i={...i,status:"state-finalized"},await Nt(e.paths,i),await e.hooks?.afterFinalState?.()}if(i.status==="state-finalized"){let l=await ea(r)?r:s;if(await ir({file:U.join(l,"verification.md"),state:o}),await tr({file:U.join(l,"verification.md"),stateVersion:o.state_version})!=="aligned")throw new Error("Native final verification report is not aligned");i={...i,status:"report-aligned"},await Nt(e.paths,i),await e.hooks?.afterReportAligned?.()}if(i.status==="report-aligned"){if(await q.mkdir(e.paths.archiveDir,{recursive:!0}),await ea(s))throw new Error(`Native Archive target already exists: ${s}`);await q.rename(r,s),i={...i,status:"moved"},await Nt(e.paths,i),await e.hooks?.afterMove?.()}return i.status==="moved"&&(await Zn(e.paths,o.name),await q.rm(Ee(e.paths,o.name),{recursive:!0,force:!0}),await e.hooks?.afterRuntimeCleanup?.(),await q.rm(vt(e.paths,{kind:"archive",change:o.name}),{force:!0})),{change:o.name,archiveDir:s,transactionId:i.id,state:o}},{allowedPortableTransaction:{kind:"archive",change:e.name}})}function or(e){let t={schema:"comet.native.continuation.v2",skill:"comet-native",change:e.name,phase:e.phase,status:e.status,stateVersion:e.state_version,inputOptions:[]},i=r=>({kind:r,candidateId:e.builder_handoff?.candidate_id??null,iteration:e.loop.iteration,attempt:e.loop.attempt});if(e.status==="done")return{...t,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:i("none")};if(e.status==="await-user")return e.phase==="verify"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass"?{...t,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:["comet","native","next",e.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")}:e.phase==="verify"&&e.verification?.assurance==="semantic-verification-unavailable"&&e.loop.next_action==="confirm-verifier-unavailable"?{...t,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:["comet","native","next",e.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")}:e.phase==="verify"&&e.loop.next_action==="resolve-verifier-blocker"?{...t,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:["comet","native","next",e.name,"--summary","<summary>","--resolve-verifier-blocker"],requiredInputs:["summary","user-resolution"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:i("none")}:e.phase==="verify"&&e.loop.next_action==="await-user"?{...t,disposition:"await-user",action:"resolve-loop-stop",commandArgs:["comet","native","next",e.name,"--return-to-build","--summary","<summary>"],requiredInputs:["summary","user-decision"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:i("none")}:{...t,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:i("none")};if(e.status==="blocked"){let r=e.blockers.some(({resolution_action:n})=>n==="retry-verifier");return{...t,disposition:"blocked",action:r?"retry-verifier":"none",commandArgs:r?["comet","native","next",e.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(e.phase==="shape")return{...t,disposition:"continue",action:"confirm-shape",commandArgs:["comet","native","next",e.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(e.phase==="build")return{...t,disposition:"continue",action:e.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[]}}],runnerAction:i("builder-handoff")};if(e.phase==="verify"){let r=e.loop.next_action==="await-verifier-result";return{...t,disposition:"continue",action:r?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",e.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:e.loop.iteration,attempt:e.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:e.loop.iteration,attempt:e.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:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:[]}}],runnerAction:i(r?"await-verifier":"dispatch-verifier")}}return{...t,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:i("none")}}import{randomUUID as UN}from"node:crypto";import{promises as sr}from"node:fs";import KN from"node:path";var YN=["evidence.md","verification.md","repair.md","archive.md","checkpoint.md"];async function XN(e,t){let i=await qt(e,{kind:"migration",change:t});return i?.kind==="migration"?i.journal:null}async function lf(e,t){await sr.mkdir(e.transactionsDir,{recursive:!0}),await Y(vt(e,{kind:"migration",change:t.change}),t,{containedRoot:e.runtimeDir})}async function uf(e,t){await Promise.all([sr.rm(Ee(e,t),{recursive:!0,force:!0}),sr.rm(rs(e,t),{recursive:!0,force:!0}),...YN.map(i=>sr.rm(KN.join(re(e,t),i),{force:!0}))])}async function df(e,t){await it(Ut(e,t.name),yt({portableState:t,projectRoot:e.projectRoot}),{containedRoot:e.runtimeDir})}async function ff(e,t){try{let i=await Ki(e,t);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 hf(e,t){if(t.isolation==="current"&&t.change_branch===null)return;let i=F(e.projectRoot);if(!i.isGitWorktree)throw new Error("Native legacy migration requires its bound Git branch or worktree");if(i.currentBranch!==t.change_branch)throw new Error(`Native legacy migration expected branch ${t.change_branch??"(missing)"}, current branch is ${i.currentBranch??"(detached)"}`);if(t.isolation==="worktree"&&!i.isSecondaryWorktree)throw new Error("Native legacy migration requires its bound linked worktree")}async function QN(e){let t=re(e.paths,e.state.name),i=await B({root:t,ref:e.state.brief,maxBytes:null,includeHash:!1}),r=[];for(let n of e.state.spec_changes){if(n.operation==="remove"||!n.source)continue;let a=await B({root:t,ref:n.source,maxBytes:null,includeHash:!1});r.push({capability:n.capability,source:a.ref,markdown:a.text})}try{return Cn({briefMarkdown:i.text,specs:r})}catch(n){if(e.state.phase==="shape"&&n.message.includes("at least one acceptance"))return[];throw n}}async function pf(e,t){let i=await zn(e,t);if(!i.state)throw new Error(`Native legacy change ${t} is unreadable`);return i.state}async function mf(e){return J(e.paths,`migrate ${e.name} to portable Native`,async()=>{let t=await XN(e.paths,e.name),i=await nr(e.paths,e.name)?await ue(ne(e.paths,e.name)):null;if(!t&&i)return await uf(e.paths,e.name),await df(e.paths,i),i;let r=null,n=null;for(t||(r=await pf(e.paths,e.name),n=await ff(e.paths,e.name),hf(e.paths,n),t={schema:$n,id:UN(),change:r.name,fromSchema:r.schema,status:"prepared",createdAt:(e.now??new Date).toISOString()},await lf(e.paths,t));;){let a=Pd(t);if(a.action==="done")break;a.action==="commit-portable-yaml"?i||(r??=await pf(e.paths,e.name),n??=await ff(e.paths,e.name),hf(e.paths,n),i=Ed({state:r,acceptance:await QN({paths:e.paths,state:r}),workspace:n,migratedAt:e.now}),await jn(ne(e.paths,e.name),i,{containedRoot:e.paths.nativeRoot})):a.action==="cleanup-legacy-runtime"?await uf(e.paths,e.name):a.action==="commit-transaction"&&(i??=await ue(ne(e.paths,e.name)),await df(e.paths,i)),t={...t,status:a.nextStatus},await lf(e.paths,t)}return await sr.rm(vt(e.paths,{kind:"migration",change:e.name}),{force:!0}),i??ue(ne(e.paths,e.name))},{allowedPortableTransaction:{kind:"migration",change:e.name}})}import{promises as vf}from"node:fs";import gf from"node:path";function ZN(e,t){let i=F(e.projectRoot);if(t.workspace.change_branch!==null){if(!i.isGitWorktree)return"The portable change requires a Git branch/worktree";if(i.currentBranch!==t.workspace.change_branch)return`Expected Native change branch ${t.workspace.change_branch}, current branch is ${i.currentBranch??"(detached)"}`}return t.workspace.isolation==="current"?null:i.isGitWorktree?t.workspace.isolation==="worktree"&&!i.isSecondaryWorktree?"The portable change requires its linked worktree":null:"The portable change requires a Git branch/worktree"}function eb(e){return e.acceptance.map(t=>({...t,result:"pending",reason:null}))}function tb(e,t){let i=new Date().toISOString(),r=e.verification===null?e:Vt(e,{goal_cycle:e.loop.goal_cycle,iteration:e.loop.iteration,attempt:e.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:et(t),completed_at:i});return le({...r,phase:"verify",status:"active",state_version:e.state_version+1,acceptance:eb(e),verification:null,verification_result:"pending",verification_report:null,blockers:[],loop:{...e.loop,stage:"verify-ready",next_action:"run-required-checks-and-dispatch-verifier"}})}async function ib(e){try{let t=await Ls(e);return t===null?{local:null,reason:"missing"}:{local:t,reason:"available"}}catch(t){if(t.code&&t.code!=="ENOENT")throw t;return{local:null,reason:"invalid"}}}async function wf(e){return J(e.paths,`recover portable change ${e.name}`,async()=>{let t=await Le(e.paths,e.name);if(t.status==="done")return await Xn({paths:e.paths,state:t}),{state:t,local:null,action:"done",reason:"done",message:"Archived Native changes do not require a local execution overlay."};let i=ZN(e.paths,t);if(i)return{state:t,local:null,action:"await-user",reason:"workspace-mismatch",message:i};let r=Ut(e.paths,e.name),n=await ib(r),a=n.reason==="available"&&(n.local?.change!==t.name||n.local?.basedOnStateVersion!==t.state_version)?"stale":n.reason;if(a==="available"&&!e.preserveRunningExecution&&n.local?.execution!==null&&n.local?.execution?.status!=="completed"&&n.local&&(a="interrupted",n.local.execution?.status==="running"&&(n.local={...n.local,execution:{...n.local.execution,status:"interrupted"},checks:n.local.checks.map(u=>u.status==="planned"||u.status==="running"?{...u,status:"interrupted"}:u)},await it(r,n.local,{containedRoot:e.paths.runtimeDir}))),a==="available")return await Xn({paths:e.paths,state:t}),{state:t,local:n.local,action:"resume-stable-boundary",reason:a,message:"Native local execution overlay matches the portable state."};let s=a==="interrupted"?n.local?.checks.find(u=>u.status==="interrupted"&&!u.repeatable):void 0;if(s){let u=Os({state:t,reason:`Check ${s.id} was interrupted and is not declared repeatable; a new Builder candidate is required before retrying.`});t=await mt({file:ne(e.paths,t.name),expectedStateVersion:t.state_version,next:u,containedRoot:e.paths.nativeRoot}),await vf.rm(gf.join(e.paths.changesDir,e.name,"verification.md"),{force:!0});let p=yt({portableState:t,projectRoot:e.paths.projectRoot,branch:t.workspace.change_branch});return await it(r,p,{containedRoot:e.paths.runtimeDir}),{state:t,local:p,action:"resume-stable-boundary",reason:a,message:`Native check ${s.id} was not repeatable; the change returned to Build for a new candidate.`}}let c=t.phase==="verify"&&t.loop.next_action==="await-verifier-result",l=t.phase==="archive"&&t.loop.stage==="archive-ready"&&t.verification_result==="pass",d=c||l;if(d){let u=tb(t,l?"Local Runtime was unavailable at Archive ready; the synchronized implementation must be verified again.":"The previous Verifier execution was unavailable; dispatch a new attempt from the stable Verify boundary.");t=await mt({file:ne(e.paths,t.name),expectedStateVersion:t.state_version,next:u,containedRoot:e.paths.nativeRoot})}let f=yt({portableState:t,projectRoot:e.paths.projectRoot,branch:F(e.paths.projectRoot).currentBranch});return await vf.mkdir(gf.dirname(Ut(e.paths,t.name)),{recursive:!0}),await it(r,f,{containedRoot:e.paths.runtimeDir}),await Xn({paths:e.paths,state:t}),{state:t,local:f,action:d?"reverify":"resume-stable-boundary",reason:a,message:d?"Rebuilt local execution from the portable boundary; previous pass/execution was not reused.":`Rebuilt local execution from the portable ${t.phase}/${t.loop.stage} boundary.`}})}import{promises as fb}from"node:fs";import Yt from"node:path";import{execFileSync as rb}from"node:child_process";var nb=6e4,ab=8*1024*1024,Us=class extends Error{constructor(i,r,n,a){super(`${i} ${r.join(" ")} failed${n?`: ${n}`:""}`,a);this.command=i;this.args=r;this.stderr=n;this.name="ExternalCommandError"}command;args;stderr};function Ks(e,t,i={}){let r=i.timeoutMs??nb,n=i.maxBufferBytes??ab;if(!Number.isSafeInteger(r)||r<1)throw new Error("External command timeout must be a positive integer");if(!Number.isSafeInteger(n)||n<1)throw new Error("External command max buffer must be a positive integer");try{return rb(e,[...t],{...i.cwd?{cwd:i.cwd}:{},encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:r,maxBuffer:n,windowsHide:!0,shell:!1})}catch(a){let o=typeof a.stderr=="string"?a.stderr.trim():Buffer.isBuffer(a.stderr)?a.stderr.toString("utf8").trim():"";throw new Us(e,t,o,{cause:a})}}import{execFileSync as ob}from"node:child_process";var sb=3e4,cb=8*1024*1024,Ys=class extends Error{constructor(i,r,n){super(`git ${r.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=i;this.args=r;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr};function yf(e,t){try{return ob("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:sb,maxBuffer:cb,windowsHide:!0})}catch(i){let r=typeof i.stderr=="string"?i.stderr.trim():Buffer.isBuffer(i.stderr)?i.stderr.toString("utf8").trim():"";throw new Ys(e,t,r)}}function L(e,t){return yf(e,t).trim()}function ta(e){return L(e,["status","--porcelain=v1","-z","--untracked-files=all"])===""}function Xs(e){let t=yf(e,["status","--porcelain=v1","-z","--untracked-files=all"]);if(!t)return[];let i=t.split("\0").filter(Boolean),r=[];for(let n=0;n<i.length;n+=1){let a=i[n];if(a.length<4)throw new Error("Git status returned an invalid porcelain record");if(r.push(a.slice(3).replaceAll("\\","/")),a[0]==="R"||a[0]==="C"||a[1]==="R"||a[1]==="C"){let o=i[n+1];if(!o)throw new Error("Git status returned an incomplete rename record");r.push(o.replaceAll("\\","/")),n+=1}}return[...new Set(r)].sort()}function Nf(e,t){try{let r=L(e,["config","--get",`branch.${t}.remote`]);if(r&&r!==".")return r}catch{}let i=L(e,["remote"]).split(/\r?\n/u).map(r=>r.trim()).filter(Boolean);if(i.includes("origin"))return"origin";if(i.length===1)return i[0];throw new Error(i.length===0?"Native workspace finish requires a configured Git remote":`Native workspace finish requires an unambiguous Git remote: ${i.join(", ")}`)}import ub from"path";var db=["Outcome","Scope","Non-goals","Acceptance examples"],j_=[...db,"Constraints and invariants","Decisions","Open questions","Verification expectations"];function ia(e,t){return ub.join(e.specsDir,t,"spec.md")}var cr=class extends Error{constructor(i){super(i.message??"Native workspace finish is blocked");this.result=i;this.name="NativeWorkspaceFinishError"}result};function hb(e,t){let i=Yt.relative(e,t);return i===""||!Yt.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Yt.sep}`)}function bt(e,t){let i=Yt.relative(e,t).replaceAll("\\","/");if(!i||i===".."||i.startsWith("../")||Yt.isAbsolute(i))throw new Error(`Native workspace finish path escaped the project: ${t}`);return i}function bf(e,t){return t.some(i=>e===i||e.startsWith(`${i}/`))}function pb(e){try{if(L(e,["config","--get","user.name"])&&L(e,["config","--get","user.email"]))return}catch{}throw new Error("Native workspace finish requires configured Git user.name and user.email")}function mb(e,t){for(let i of St(e))if(F(i).currentBranch===t)return i;return null}function vb(e,t){try{Ks(e,t,{timeoutMs:1e4})}catch(i){throw new Error(`${e} is required for the selected Native workspace finish`,{cause:i})}}async function Qs(e){let{paths:t,state:i}=e,r=i.workspace;if(r.isolation==="current")return null;if(!r.finish||!r.change_branch||!r.target_branch)throw new Error("Native isolated workspace finish is not persisted");if(r.change_branch===r.target_branch)throw new Error("Native change and target branches must be different for workspace finish");let n=F(t.projectRoot);if(!n.primaryWorktreeRoot||n.currentBranch!==r.change_branch)throw new Error(`Native workspace finish requires branch ${r.change_branch} in the current registered worktree`);pb(t.projectRoot);let a=[bt(t.projectRoot,Vs(t))];e.archiveDir&&a.push(bt(t.projectRoot,re(t,i.name)),bt(t.projectRoot,e.archiveDir));let o=Xs(t.projectRoot).filter(l=>!bf(l,a));if(o.length>0)throw new Error(`Native workspace finish is blocked until change-owned implementation and artifacts are committed; remaining paths: ${o.slice(0,20).join(", ")}${o.length>20?", ...":""}`);let s=r.isolation==="branch"?t.projectRoot:mb(n.primaryWorktreeRoot,r.target_branch);if(r.finish==="merge"&&r.isolation==="worktree"){if(!s)throw new Error(`Native merge finish requires a registered worktree on target branch ${r.target_branch}`);if(!ta(s))throw new Error(`Native merge target worktree is not clean: ${s}`)}let c=r.finish==="push"||r.finish==="pull-request"?Nf(t.projectRoot,r.change_branch):null;return r.finish==="pull-request"&&vb("gh",["--version"]),{finish:r.finish,changeRoot:t.projectRoot,primaryRoot:n.primaryWorktreeRoot,changeBranch:r.change_branch,targetBranch:r.target_branch,targetRoot:s,remote:c,isolation:r.isolation}}function gb(e,t){try{return Ks("gh",t,{cwd:e,timeoutMs:6e4}).trim()}catch(i){throw new Error(`gh ${t.join(" ")} failed: ${i.message}`,{cause:i})}}async function wb(e){try{return await fb.access(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}function yb(e){return{action:e.finish,status:e.finish==="keep"?"kept":"completed",commit:null,remote:e.remote,pushed:!1,pullRequestUrl:null,merged:!1,targetRoot:e.targetRoot,cleanup:{performed:!1,reason:null},message:null,recoveryArgs:null}}async function kf(e){let t=yb(e.plan),i=null;try{let r=[bt(e.paths.projectRoot,re(e.paths,e.name)),bt(e.paths.projectRoot,e.archiveDir),...e.state.spec_changes.map(c=>bt(e.paths.projectRoot,ia(e.paths,c.capability))),bt(e.paths.projectRoot,Vs(e.paths))],n=Xs(e.plan.changeRoot).filter(c=>!bf(c,r));if(n.length>0)throw new Error(`Native Archive produced or encountered paths outside the authorized finish scope: ${n.slice(0,20).join(", ")}${n.length>20?", ...":""}`);let a=[];for(let c of r){let l=Yt.resolve(e.paths.projectRoot,...c.split("/")),d=L(e.plan.changeRoot,["ls-files","--",c])!=="";(await wb(l)||d)&&a.push(c)}if(a.length>0&&L(e.plan.changeRoot,["add","-A","--",...a]),L(e.plan.changeRoot,["diff","--cached","--name-only","-z"])&&L(e.plan.changeRoot,["commit","-m",`chore(native): archive ${e.name}`]),t.commit=L(e.plan.changeRoot,["rev-parse","HEAD"]),!ta(e.plan.changeRoot))throw new Error("Native archive commit left unexpected working-tree changes");if(e.plan.finish==="keep")return t;if(e.plan.finish==="push"||e.plan.finish==="pull-request"){if(L(e.plan.changeRoot,["push","--set-upstream",e.plan.remote,e.plan.changeBranch]),t.pushed=!0,e.plan.finish==="pull-request"&&(t.pullRequestUrl=gb(e.plan.changeRoot,["pr","create","--base",e.plan.targetBranch,"--head",e.plan.changeBranch,"--fill"]).split(/\r?\n/u).find(l=>/^https?:\/\//u.test(l.trim()))??null,!t.pullRequestUrl))throw new Error("GitHub CLI did not return a pull request URL");let c=hb(e.plan.changeRoot,process.cwd());return e.plan.isolation==="worktree"&&!c?(L(e.plan.primaryRoot,["worktree","remove",e.plan.changeRoot]),t.cleanup={performed:!0,reason:null}):e.plan.isolation==="worktree"&&(t.cleanup={performed:!1,reason:"invocation-working-directory-is-the-change-worktree"}),t}let s=e.plan.targetRoot??e.plan.changeRoot;return e.plan.isolation==="branch"&&(L(s,["switch",e.plan.targetBranch]),i=s),L(s,["merge","--no-ff","--no-edit",e.plan.changeBranch]),t.merged=!0,t.targetRoot=s,t.cleanup={performed:!1,reason:"post-merge-validation-required-before-cleanup"},t}catch(r){if(i!==null){let n;try{L(i,["merge","--abort"])}catch{}try{F(i).currentBranch===e.plan.targetBranch&&L(i,["switch",e.plan.changeBranch]),n=F(i).currentBranch===e.plan.changeBranch}catch{n=!1}n||(t.targetRoot=i)}throw t.status="blocked",t.message=r.message,t.recoveryArgs=e.plan.finish==="merge"&&t.targetRoot?["git","-C",t.targetRoot,"status","--short"]:["git","-C",e.plan.changeRoot,"status","--short"],new cr(t)}}import tc from"path";var Nb=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 Sf=1024*1024;var Pf="scoped-text-safety",bb=1,kb=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var Sb="comet.native.checker-policy.v1";var pT=ce(Sb,{policy:Pf,version:bb,limits:kb,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var Eb=["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"],mT=new Set(Eb);var Rb=Sf,IT=3*Rb;var xf={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:[]},Ab=de("comet-native-runtime:v3:scope-reopen"),aI=[{skillVersion:"3",skillHash:de("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:de("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:de("comet-native-runtime:v1")}];var Cf=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],LI=new Set(Cf),Hb=new Set([...Cf,"minimum_runtime_version","revision"]),FI=new Set([...Hb,"operation"]),MI=512*1024,Db=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),VI=new Set([...Db,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var JI={maxAcceptanceCriteria:qi.maxCriteria};var XI={maxSpecs:64,maxFileBytes:pr,maxTotalBytes:4*1024*1024};import{execFile as Jb}from"node:child_process";import{promisify as Gb}from"node:util";var sj={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var Cj=512*1024;var lr=class extends Error{recovery;constructor(t,i){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=i}};var Xj=64*1024;var Qj=3600*1e3;var Zj=Gb(Jb);var ra=class extends Error{details;constructor(t){let i=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(r=>`${r.ref}${r.acceptanceId?`[${r.acceptanceId}]`:""} -> ${r.mismatches.join("; ")}`).join(" | ")}`;super(i),this.name="NativeVerificationReceiptBindingError",this.details=t}};var B$={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var U$=16*1024*1024,K$=256*1024,Y$=16*1024;var tO=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var WO=16*1024*1024,na=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"},aa=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 oa=class extends Error{constructor(i,r,n){super(i,n);this.preparation=r;this.name="NativeWorkspacePreparationError"}preparation};var Tf=["--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."],ec=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:Tf,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]
200
- 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]
201
- 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 Zs(e,t){return`${e}:
198
+ ${ct(e.verification.summary)}
199
+ `}function Hb(e){let t=/^---\r?\ngenerated_from_state_version: ([1-9]\d*)\r?\n---(?:\r?\n|$)/u.exec(e);if(!t)return null;let i=Number(t[1]);return Number.isSafeInteger(i)?i:null}async function sr(e){let t;try{t=await Ib.readFile(e.file,"utf8")}catch(r){if(r.code==="ENOENT")return"missing";throw r}let i=Hb(t);return i===null?"invalid":i===e.stateVersion?"aligned":"stale"}async function cr(e){await Y(e.file,Ob(e.state))}var xf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Db="comet-state.yaml",Bb="state.json";function fe(e,t){if(!xf.test(t))throw new Error(`Invalid Native change name: ${t}`);let i=qe.join(e.changesDir,t);if(!L(e.changesDir,i))throw new Error("Native change path escaped");return i}function se(e,t){return qe.join(fe(e,t),Db)}function Pt(e,t){return qe.join(xe(e,t),Bb)}async function ur(e,t){try{let i=await lr.readFile(se(e,t),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(i)}catch(i){if(i.code==="ENOENT")return!1;throw i}}function Rf(e){return F(e).currentBranch}async function Fe(e,t){return ae(se(e,t))}async function Cf(e){let t=await bt({file:se(e.paths,e.previous.name),expectedStateVersion:e.previous.state_version,next:e.next,containedRoot:e.paths.nativeRoot});if(t.verification===null&&t.verification_report===null){let i=qe.join(fe(e.paths,t.name),"verification.md");await T(e.paths.nativeRoot,i),await lr.rm(i,{force:!0})}return t}async function Lb(e){let t=fe(e.paths,e.state.name),i=qe.join(t,"specs"),r=new Map(e.state.spec_changes.filter(({operation:o})=>o==="remove").map(o=>[o.capability,o])),n;try{n=await lr.readdir(i,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")n=[];else throw o}let a=[];for(let o of n.sort((s,c)=>s.name.localeCompare(c.name,"en"))){if(o.isSymbolicLink())throw new Error(`Native spec capability is unsafe: ${o.name}`);if(!o.isDirectory())continue;if(!xf.test(o.name))throw new Error(`Invalid Native capability: ${o.name}`);if(r.has(o.name))throw new Error(`Capability ${o.name} cannot be proposed and removed together`);let s=`specs/${o.name}/spec.md`,c=qe.join(t,...s.split("/")),l=await lr.lstat(c);if(!l.isFile()||l.isSymbolicLink())throw new Error(`Native proposed spec must be a regular file: ${s}`);let u=qe.join(e.paths.specsDir,o.name,"spec.md"),f="create";try{let d=await lr.lstat(u);if(!d.isFile()||d.isSymbolicLink())throw new Error(`Canonical Native spec is unsafe: ${o.name}`);f="modify"}catch(d){if(d.code!=="ENOENT")throw d}a.push({capability:o.name,operation:f,source:s})}return a.push(...r.values()),a.sort((o,s)=>o.capability.localeCompare(s.capability,"en"))}async function qb(e){let t=fe(e.paths,e.state.name),i=await j({root:t,ref:"brief.md",maxBytes:null,includeHash:!1}),r=[];for(let n of e.specChanges){if(n.source===null)continue;let a=await j({root:t,ref:n.source,maxBytes:null,includeHash:!1});r.push({capability:n.capability,source:a.ref,markdown:a.text})}return On({briefMarkdown:i.text,specs:r})}async function ic(e){let t=await Lb(e),i=e.ignoreSpecOperationFor??(e.state.children_contract_hash?new Set(e.state.spec_changes.map(({capability:c})=>c)):void 0);if(!(t.length===e.state.spec_changes.length&&t.every((c,l)=>{let u=e.state.spec_changes[l];return u!==void 0&&c.capability===u.capability&&c.source===u.source&&(c.operation===u.operation||i?.has(c.capability)===!0)})))return{drifted:!0,reason:"Native target specification declarations changed"};let n=await qb({...e,specChanges:t}),a=e.state.acceptance.map(({source:c,text:l})=>({source:c,text:l}));if(!Md(a,n))return{drifted:!0,reason:"Native confirmed acceptance criteria changed"};let o;try{o=await kf({changeDir:fe(e.paths,e.state.name),acceptanceIds:n.map(({id:c})=>c),validation:bf({...e.state,acceptance:n})})}catch{return{drifted:!0,reason:"Native child declarations changed"}}return(o?Sf({acceptance:n,children:o.contract}):null)===(e.state.children_contract_hash??null)?{drifted:!1,reason:null}:{drifted:!0,reason:"Native child declarations changed"}}async function Af(e){return G(e.paths,`set portable workspace finish ${e.name}`,async()=>{let t=await Fe(e.paths,e.name);if(t.workspace.isolation==="current")throw new Error("Native current-workspace isolation does not accept a finish action");let i={...t,state_version:t.state_version+1,workspace:{...t.workspace,finish:e.finish}},r=await Cf({paths:e.paths,previous:t,next:i});return await Be(Pt(e.paths,t.name),st({portableState:r,projectRoot:e.paths.projectRoot,branch:Rf(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),r.verification!==null&&await cr({file:qe.join(fe(e.paths,t.name),"verification.md"),state:r}),r})}async function _f(e){let{state:t}=e;if(t.archived)throw new Error(`Native change ${t.name} is already archived`);let r={...Kt(t,{goal_cycle:t.loop.goal_cycle,iteration:t.loop.iteration,attempt:t.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:at(e.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:t.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:t.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"confirm-shape"}};delete r.children_contract_hash;let n=await Cf({paths:e.paths,previous:t,next:r});return await Be(Pt(e.paths,t.name),st({portableState:n,projectRoot:e.paths.projectRoot,branch:Rf(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),n}async function sa(e){if(e.state.verification===null)return"not-applicable";let t=qe.join(fe(e.paths,e.state.name),"verification.md");return await sr({file:t,stateVersion:e.state.state_version})==="aligned"?"aligned":(await cr({file:t,state:e.state}),"rebuilt")}import{promises as Fb}from"fs";import Mb from"path";var rc="comet.selection.v2",Vb=16*1024;function ca(e){return Mb.join(e,".comet","current-change.json")}function Wb(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Tf(e){return e===null||typeof e=="string"}function zb(e){let t;try{t=JSON.parse(e)}catch(i){throw new Error(`current change selection contains invalid JSON: ${i instanceof Error?i.message:String(i)}`,{cause:i})}if(!Wb(t))throw new Error("current change selection must be a JSON object");if(t.version===1){if(typeof t.change!="string")throw new Error("legacy current change selection change must be a string");if(t.branch!==void 0&&!Tf(t.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:rc,workflow:"classic",change:t.change,branch:t.branch??null},legacy:!0}}if(t.schema!==rc)throw new Error(`current change selection schema must be ${rc}`);if(t.workflow!=="native"&&t.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof t.change!="string")throw new Error("current change selection change must be a string");if(!Tf(t.branch))throw new Error("current change selection branch must be a string or null");if(t.workflow==="native"&&t.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:t,legacy:!1}}async function If(e){let t;try{let r=ca(e),{bytes:n}=await wt(r,Vb,{label:"current change selection"});t=n.toString("utf8")}catch(r){if(r.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${r instanceof Error?r.message:String(r)}`,{cause:r})}return{status:"selected",...zb(t)}}async function jf(e){await Fb.rm(ca(e),{force:!0})}async function $f(e,t,i){let r=await If(e);return r.status!=="selected"||r.selection.workflow!==t||r.selection.change!==i?!1:(await jf(e),!0)}var uT=16*1024;function nc(e){return ca(e.projectRoot)}async function la(e,t){return await zi(e.projectRoot),$f(e.projectRoot,"native",t)}var dr=class extends Error{peers;constructor(t){super(t.length===0?"Native Archive serial capability decision is stale":`Native Archive requires a serial capability decision: ${t.join(", ")}`),this.name="NativePortableArchiveOrderRequiredError",this.peers=[...t]}};function ac(e){return`${(e.verification?.completed_at??e.created_at).slice(0,10)}-${e.name}`}function oc(e,t){if(!/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t))throw new Error("Native portable Archive ref is invalid");let i=K.join(e.archiveDir,t);if(!L(e.archiveDir,i))throw new Error("Native Archive path escaped");return i}async function ua(e){try{return await z.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}function Of(e,t){let i=K.normalize(K.resolve(e)),r=K.normalize(K.resolve(t));return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}async function Hf(e,t){let i;try{i=await z.readdir(e.archiveDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return null;throw n}let r=[];for(let n of i){if(!n.isDirectory()||n.isSymbolicLink())continue;let a=K.join(e.archiveDir,n.name);try{let o=await ae(K.join(a,"comet-state.yaml"));o.name===t&&r.push({dir:a,state:o})}catch{}}if(r.length>1)throw new Error(`Multiple Native portable archives exist for ${t}`);return r[0]??null}async function sc(e,t){let i=await Yt(e,{kind:"archive",change:t});return i?.kind==="archive"?i.journal:null}async function Df(e,t){return await sc(e,t)!==null||await Hf(e,t)!==null}async function xt(e,t){await z.mkdir(e.transactionsDir,{recursive:!0}),await X(kt(e,{kind:"archive",change:t.change}),t,{containedRoot:e.runtimeDir})}async function Bf(e){let t=new Set(e.state.spec_changes.map(({capability:a})=>a));if(t.size===0)return[];let i=lt(e.paths.projectRoot);i.some(a=>Of(a,e.paths.projectRoot))||i.push(e.paths.projectRoot);let r=[];for(let a of i){let o=await we(a);if(!o)continue;let s=await nt(a,o.native.artifact_root);r.some(c=>Of(c.changesDir,s.changesDir))||r.push(s)}r.length===0&&r.push(e.paths);let n=new Set;for(let a of r){let o;try{o=await z.readdir(a.changesDir,{withFileTypes:!0})}catch(s){if(s.code==="ENOENT")continue;throw s}for(let s of o)if(!(!s.isDirectory()||s.isSymbolicLink()||s.name===e.state.name))try{let c=await ae(K.join(a.changesDir,s.name,"comet-state.yaml"));c.status!=="done"&&c.spec_changes.some(({capability:l})=>t.has(l))&&n.add(c.name)}catch{let c=await Qn(a,s.name).catch(()=>null);c?.state&&c.state.spec_changes.some(({capability:l})=>t.has(l))&&n.add(c.state.name)}}return[...n].sort((a,o)=>a.localeCompare(o,"en"))}function Gb(e){if(e===void 0)return null;if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e))throw new Error("Native Archive serial capability decision is invalid");return e}async function Ub(e){let t=K.join(e.paths.specsDir,e.change.capability),i=K.join(t,"spec.md");if(!L(e.paths.specsDir,i))throw new Error("Native canonical spec path escaped");if(e.change.operation==="remove"){let n;try{n=await z.lstat(e.paths.specsDir)}catch(c){if(c.code==="ENOENT")return;throw c}if(!n.isDirectory()||n.isSymbolicLink())throw new Error("Native canonical specs root is unsafe");let a;try{a=await z.lstat(t)}catch(c){if(c.code==="ENOENT")return;throw c}if(!a.isDirectory()||a.isSymbolicLink())throw new Error(`Canonical Native capability directory is unsafe: ${e.change.capability}`);let[o,s]=await Promise.all([z.realpath(e.paths.specsDir),z.realpath(t)]);if(!L(o,s))throw new Error("Native canonical capability path escaped");try{let c=await z.lstat(i);if(!c.isFile()||c.isSymbolicLink())throw new Error(`Canonical Native spec is unsafe: ${e.change.capability}`);await z.unlink(i)}catch(c){if(c.code!=="ENOENT")throw c}await z.rmdir(t).catch(c=>{if(c.code!=="ENOENT"&&c.code!=="ENOTEMPTY")throw c});return}if(e.change.source===null||e.change.content===null)throw new Error(`Native ${e.change.operation} spec requires frozen source content`);let r=K.join(fe(e.paths,e.state.name),e.change.source);await Y(r,e.change.content,{containedRoot:e.paths.nativeRoot}),await z.mkdir(t,{recursive:!0}),await Y(i,e.change.content,{containedRoot:e.paths.nativeRoot})}function cc(e){if(e.phase!=="archive"||e.status!=="active"||e.loop.stage!=="archive-ready"||e.verification_result!=="pass"||e.verification?.verdict!=="pass"||e.verification_report!=="verification.md")throw new Error(`Native change ${e.name} is not archive-ready`)}async function Kb(e,t){let i=fe(e,t.name),r=[];for(let n of t.spec_changes){if(n.source===null){r.push({...n,content:null});continue}let a=await j({root:i,ref:n.source,maxBytes:null,includeHash:!1});r.push({...n,content:a.text})}return r}function Yb(e,t){if(t.archived){if(t.status!=="done"||t.loop.stage!=="done"||t.state_version!==e.start_state_version+1)throw new Error("Native Archive transaction no longer matches the finalized portable state");return}if(t.state_version!==e.start_state_version)throw new Error("Native Archive transaction is stale for the current portable state");if(cc(t),e.status!=="prepared"&&e.status!=="specs-applied")throw new Error(`Native Archive transaction ${e.status} requires a finalized portable state`)}async function lc(e){let t=await Fe(e.paths,e.name),i=[];try{cc(t)}catch(o){i.push(o.message)}if(await sc(e.paths,e.name)===null)try{let o=await ic({paths:e.paths,state:t});o.drifted&&i.push(o.reason??"Native confirmed requirements changed")}catch(o){i.push(o.message)}let n=t.verification===null?"missing":await sr({file:K.join(fe(e.paths,t.name),"verification.md"),stateVersion:t.state_version});n!=="aligned"&&i.push(`verification.md is ${n}`);let a=await Bf({paths:e.paths,state:t});return a.length>0&&i.push(`capabilities are also declared by: ${a.join(", ")}`),{ready:i.length===0,blockers:i,capabilityPeers:a,archiveDir:oc(e.paths,ac(t)),stateVersion:t.state_version}}async function Lf(e){return G(e.paths,`archive portable change ${e.name}`,async()=>{let t=Gb(e.serialFirstChange);if(t!==null&&t!==e.name)throw new Error("Native Archive --serial-first must name the change being archived");let i=await sc(e.paths,e.name),r=fe(e.paths,e.name),n=await ua(r),a=n?null:await Hf(e.paths,e.name),o;if(n)o=await Fe(e.paths,e.name);else if(i)o=await ae(K.join(oc(e.paths,i.archive_ref),"comet-state.yaml"));else if(a)o=a.state;else throw new Error(`Native active change is missing: ${e.name}`);if(n&&!o.archived&&i===null){let l=await ic({paths:e.paths,state:o});if(l.drifted){let u=l.reason??"Native confirmed requirements changed";throw await _f({paths:e.paths,state:o,reason:u}),new Error(`${u}; Native change returned to Shape and requires confirmation`)}}let s=oc(e.paths,i?.archive_ref??ac(o)),c=await ua(s);if(i&&Yb(i,o),n&&c)throw new Error("Native active and archive directories both exist; doctor intervention is required");if(!n&&!i&&a){if(!o.archived||o.status!=="done"||o.loop.stage!=="done")throw new Error("Native archive exists without a completed portable state");return await la(e.paths,o.name),await z.rm(xe(e.paths,o.name),{recursive:!0,force:!0}),{change:o.name,archiveDir:a.dir,transactionId:`recovered-${o.state_version}`,state:o}}if(!i){if(!o.archived)cc(o);else if(o.status!=="done"||o.loop.stage!=="done")throw new Error("Native active archived state is inconsistent");let l=await Bf({paths:e.paths,state:o});if(!o.archived&&l.length>0&&t!==o.name)throw new dr(l);i={schema:Mn,id:Jb(),change:o.name,start_state_version:o.archived?o.state_version-1:o.state_version,archive_ref:ac(o),status:o.archived?"state-finalized":"prepared",next_spec_index:o.archived?o.spec_changes.length:0,spec_changes:await Kb(e.paths,o),created_at:new Date().toISOString()},await xt(e.paths,i)}if(!n&&c&&i.status==="report-aligned")i={...i,status:"moved"},await xt(e.paths,i);else if(!n&&c&&i.status!=="moved")throw new Error(`Native Archive layout contradicts transaction state ${i.status}; doctor intervention is required`);if(i.status==="prepared"){for(let l=i.next_spec_index;l<i.spec_changes.length;l+=1)await Ub({paths:e.paths,state:o,change:i.spec_changes[l]}),i={...i,next_spec_index:l+1},await xt(e.paths,i),await e.hooks?.afterSpecApplied?.(l);i={...i,status:"specs-applied"},await xt(e.paths,i)}if(i.status==="specs-applied"){if(!o.archived){let l={...o,phase:"archive",status:"done",state_version:o.state_version+1,archived:!0,blockers:[],loop:{...o.loop,stage:"done",next_action:null}};o=await bt({file:se(e.paths,o.name),expectedStateVersion:o.state_version,next:l,containedRoot:e.paths.nativeRoot})}i={...i,status:"state-finalized"},await xt(e.paths,i),await e.hooks?.afterFinalState?.()}if(i.status==="state-finalized"){let l=await ua(r)?r:s;if(await cr({file:K.join(l,"verification.md"),state:o}),await sr({file:K.join(l,"verification.md"),stateVersion:o.state_version})!=="aligned")throw new Error("Native final verification report is not aligned");i={...i,status:"report-aligned"},await xt(e.paths,i),await e.hooks?.afterReportAligned?.()}if(i.status==="report-aligned"){if(await z.mkdir(e.paths.archiveDir,{recursive:!0}),await ua(s))throw new Error(`Native Archive target already exists: ${s}`);await z.rename(r,s),i={...i,status:"moved"},await xt(e.paths,i),await e.hooks?.afterMove?.()}return i.status==="moved"&&(await la(e.paths,o.name),await z.rm(xe(e.paths,o.name),{recursive:!0,force:!0}),await e.hooks?.afterRuntimeCleanup?.(),await z.rm(kt(e.paths,{kind:"archive",change:o.name}),{force:!0})),{change:o.name,archiveDir:s,transactionId:i.id,state:o}},{allowedPortableTransaction:{kind:"archive",change:e.name}})}function da(e){return["comet","native","next",e.change,"--summary","<summary>",e.flag,"--expected-state-version",String(e.stateVersion),"--expected-action",e.action]}function fa(e,t){return{name:e,flag:t,valueKind:"text",required:!0,template:null}}function Xb(e,t){return{name:e,flag:t,valueKind:"confirmation",required:!0,template:null}}function ha(e){return{name:e.name,stateVersion:e.stateVersion,expectedAction:e.expectedAction,commandArgs:da({change:e.change,stateVersion:e.stateVersion,action:e.expectedAction,flag:e.flag}),requiredInputs:["summary",e.confirmationInput],inputOptions:[fa("summary","--summary"),Xb(e.name,e.flag)]}}function uc(e){return[ha({name:"revise-implementation",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),ha({name:"revise-requirements",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function fr(e,t){let i={schema:"comet.native.continuation.v2",skill:"comet-native",change:e.name,phase:e.phase,status:e.status,stateVersion:e.state_version,inputOptions:[]},r=n=>({kind:n,candidateId:e.builder_handoff?.candidate_id??null,iteration:e.loop.iteration,attempt:e.loop.attempt});if(e.status==="done")return{...i,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:r("none")};if(e.status==="await-user")return e.phase==="verify"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass"?{...i,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[fa("summary","--summary")],commandAlternatives:[ha({name:"accept-result",change:e.name,stateVersion:e.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...uc({change:e.name,stateVersion:e.state_version})],runnerAction:r("none")}:e.phase==="verify"&&e.verification?.assurance==="semantic-verification-unavailable"&&e.loop.next_action==="confirm-verifier-unavailable"?{...i,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:da({change:e.name,stateVersion:e.state_version,action:"confirm-verifier-unavailable",flag:"--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")}:e.phase==="verify"&&e.loop.next_action==="resolve-verifier-blocker"?{...i,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[fa("summary","--summary")],commandAlternatives:[ha({name:"resolve-verifier-blocker",change:e.name,stateVersion:e.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...uc({change:e.name,stateVersion:e.state_version})],runnerAction:r("none")}:e.phase==="verify"&&e.loop.next_action==="await-user"?{...i,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[fa("summary","--summary")],commandAlternatives:uc({change:e.name,stateVersion:e.state_version}),runnerAction:r("none")}:{...i,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:r("none")};if(e.status==="blocked"){let n=e.blockers.some(({resolution_action:a})=>a==="retry-verifier");return{...i,disposition:"blocked",action:n?"retry-verifier":"none",commandArgs:n?da({change:e.name,stateVersion:e.state_version,action:"retry-verifier",flag:"--retry-verifier"}):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(e.phase==="shape")return{...i,disposition:"continue",action:"confirm-shape",commandArgs:da({change:e.name,stateVersion:e.state_version,action:"confirm-shape",flag:"--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(e.phase==="build"){if(t){if(!t.confirmed)return{...i,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")};if(e.loop.stage==="repairing"&&e.verification_result==="fail")return{...i,disposition:"continue",action:"repair",commandArgs:null,requiredInputs:["repair-child"],inputOptions:[],runnerAction:r("none")};if(t.allDone)return{...i,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")};let n=t.children.some(({status:o})=>o==="blocked"),a=t.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:e.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[]}}],runnerAction:r("builder-handoff")}}if(e.phase==="verify"){let n=e.loop.next_action==="await-verifier-result";return{...i,disposition:"continue",action:n?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",e.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:e.loop.iteration,attempt:e.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:e.loop.iteration,attempt:e.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:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:[]}}],runnerAction:r(n?"await-verifier":"dispatch-verifier")}}return{...i,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:r("none")}}import{randomUUID as Qb}from"node:crypto";import{promises as hr}from"node:fs";import Zb from"node:path";var qf=["evidence.md","repair.md","archive.md","checkpoint.md"],ek="verification.md";async function tk(e,t){let i=await Yt(e,{kind:"migration",change:t});return i?.kind==="migration"?i.journal:null}async function Ff(e,t){await hr.mkdir(e.transactionsDir,{recursive:!0}),await X(kt(e,{kind:"migration",change:t.change}),t,{containedRoot:e.runtimeDir})}async function Mf(e,t,i={}){let r=i.removeVerificationReport===!1?qf:[...qf,ek];await Promise.all([hr.rm(xe(e,t),{recursive:!0,force:!0}),hr.rm(vs(e,t),{recursive:!0,force:!0}),...r.map(n=>hr.rm(Zb.join(oe(e,t),n),{force:!0}))])}async function Vf(e,t){await Be(Pt(e,t.name),st({portableState:t,projectRoot:e.projectRoot}),{containedRoot:e.runtimeDir})}async function Wf(e,t){try{let i=await er(e,t);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 zf(e,t){if(t.isolation==="current"&&t.change_branch===null)return;let i=F(e.projectRoot);if(!i.isGitWorktree)throw new Error("Native legacy migration requires its bound Git branch or worktree");if(i.currentBranch!==t.change_branch)throw new Error(`Native legacy migration expected branch ${t.change_branch??"(missing)"}, current branch is ${i.currentBranch??"(detached)"}`);if(t.isolation==="worktree"&&!i.isSecondaryWorktree)throw new Error("Native legacy migration requires its bound linked worktree")}async function ik(e){let t=oe(e.paths,e.state.name),i=await j({root:t,ref:e.state.brief,maxBytes:null,includeHash:!1}),r=[];for(let n of e.state.spec_changes){if(n.operation==="remove"||!n.source)continue;let a=await j({root:t,ref:n.source,maxBytes:null,includeHash:!1});r.push({capability:n.capability,source:a.ref,markdown:a.text})}try{return On({briefMarkdown:i.text,specs:r})}catch(n){if(e.state.phase==="shape"&&n.message.includes("at least one acceptance"))return[];throw n}}async function Jf(e,t){let i=await Qn(e,t);if(!i.state)throw new Error(`Native legacy change ${t} is unreadable`);return i.state}async function Gf(e){return G(e.paths,`migrate ${e.name} to portable Native`,async()=>{let t=await tk(e.paths,e.name),i=await ur(e.paths,e.name)?await ae(se(e.paths,e.name)):null;if(!t&&i)return await Mf(e.paths,e.name,{removeVerificationReport:!1}),await Vf(e.paths,i),i;let r=null,n=null;for(t||(r=await Jf(e.paths,e.name),n=await Wf(e.paths,e.name),zf(e.paths,n),t={schema:Fn,id:Qb(),change:r.name,fromSchema:r.schema,status:"prepared",createdAt:(e.now??new Date).toISOString()},await Ff(e.paths,t));;){let a=zd(t);if(a.action==="done")break;a.action==="commit-portable-yaml"?i||(r??=await Jf(e.paths,e.name),n??=await Wf(e.paths,e.name),zf(e.paths,n),i=Wd({state:r,acceptance:await ik({paths:e.paths,state:r}),workspace:n,migratedAt:e.now}),await qn(se(e.paths,e.name),i,{containedRoot:e.paths.nativeRoot})):a.action==="cleanup-legacy-runtime"?await Mf(e.paths,e.name):a.action==="commit-transaction"&&(i??=await ae(se(e.paths,e.name)),await Vf(e.paths,i)),t={...t,status:a.nextStatus},await Ff(e.paths,t)}return await hr.rm(kt(e.paths,{kind:"migration",change:e.name}),{force:!0}),i??ae(se(e.paths,e.name))},{allowedPortableTransaction:{kind:"migration",change:e.name}})}import{promises as Uf}from"node:fs";import Kf from"node:path";function rk(e,t){let i=F(e.projectRoot);if(t.workspace.change_branch!==null){if(!i.isGitWorktree)return"The portable change requires a Git branch/worktree";if(i.currentBranch!==t.workspace.change_branch)return`Expected Native change branch ${t.workspace.change_branch}, current branch is ${i.currentBranch??"(detached)"}`}return t.workspace.isolation==="current"?null:i.isGitWorktree?t.workspace.isolation==="worktree"&&!i.isSecondaryWorktree?"The portable change requires its linked worktree":null:"The portable change requires a Git branch/worktree"}function nk(e){return e.acceptance.map(t=>({...t,result:"pending",reason:null}))}function ak(e,t){let i=new Date().toISOString(),r=e.verification===null?e:Kt(e,{goal_cycle:e.loop.goal_cycle,iteration:e.loop.iteration,attempt:e.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:at(t),completed_at:i});return ne({...r,phase:"verify",status:"active",state_version:e.state_version+1,acceptance:nk(e),verification:null,verification_result:"pending",verification_report:null,blockers:[],loop:{...e.loop,stage:"verify-ready",next_action:"run-required-checks-and-dispatch-verifier"}})}async function ok(e){try{let t=await tc(e);return t===null?{local:null,reason:"missing"}:{local:t,reason:"available"}}catch(t){if(t.code&&t.code!=="ENOENT")throw t;return{local:null,reason:"invalid"}}}async function Yf(e){return G(e.paths,`recover portable change ${e.name}`,async()=>{let t=await Fe(e.paths,e.name);if(t.status==="done")return await sa({paths:e.paths,state:t}),{state:t,local:null,action:"done",reason:"done",message:"Archived Native changes do not require a local execution overlay."};let i=rk(e.paths,t);if(i)return{state:t,local:null,action:"await-user",reason:"workspace-mismatch",message:i};let r=Pt(e.paths,e.name),n=await ok(r),a=n.reason==="available"&&(n.local?.change!==t.name||n.local?.basedOnStateVersion!==t.state_version)?"stale":n.reason;if(a==="available"&&!e.preserveRunningExecution&&n.local?.execution!==null&&n.local?.execution?.status!=="completed"&&n.local&&(a="interrupted",n.local.execution?.status==="running"&&(n.local={...n.local,execution:{...n.local.execution,status:"interrupted"},checks:n.local.checks.map(d=>d.status==="planned"||d.status==="running"?{...d,status:"interrupted"}:d)},await Be(r,n.local,{containedRoot:e.paths.runtimeDir}))),a==="available")return await sa({paths:e.paths,state:t}),{state:t,local:n.local,action:"resume-stable-boundary",reason:a,message:"Native local execution overlay matches the portable state."};let s=a==="interrupted"?n.local?.checks.find(d=>d.status==="interrupted"&&!d.repeatable):void 0;if(s){let d=Xs({state:t,reason:`Check ${s.id} was interrupted and is not declared repeatable; a new Builder candidate is required before retrying.`});t=await bt({file:se(e.paths,t.name),expectedStateVersion:t.state_version,next:d,containedRoot:e.paths.nativeRoot}),await Uf.rm(Kf.join(e.paths.changesDir,e.name,"verification.md"),{force:!0});let p=st({portableState:t,projectRoot:e.paths.projectRoot,branch:t.workspace.change_branch});return await Be(r,p,{containedRoot:e.paths.runtimeDir}),{state:t,local:p,action:"resume-stable-boundary",reason:a,message:`Native check ${s.id} was not repeatable; the change returned to Build for a new candidate.`}}let c=t.phase==="verify"&&t.loop.next_action==="await-verifier-result",l=t.phase==="archive"&&t.loop.stage==="archive-ready"&&t.verification_result==="pass",u=c||l;if(u){let d=ak(t,l?"Local Runtime was unavailable at Archive ready; the synchronized implementation must be verified again.":"The previous Verifier execution was unavailable; dispatch a new attempt from the stable Verify boundary.");t=await bt({file:se(e.paths,t.name),expectedStateVersion:t.state_version,next:d,containedRoot:e.paths.nativeRoot})}let f=st({portableState:t,projectRoot:e.paths.projectRoot,branch:F(e.paths.projectRoot).currentBranch});return await Uf.mkdir(Kf.dirname(Pt(e.paths,t.name)),{recursive:!0}),await Be(r,f,{containedRoot:e.paths.runtimeDir}),await sa({paths:e.paths,state:t}),{state:t,local:f,action:u?"reverify":"resume-stable-boundary",reason:a,message:u?"Rebuilt local execution from the portable boundary; previous pass/execution was not reused.":`Rebuilt local execution from the portable ${t.phase}/${t.loop.stage} boundary.`}})}import{accessSync as yk,constants as Nk,promises as bk}from"node:fs";import Me from"node:path";import{execFileSync as sk}from"node:child_process";var ck=6e4,lk=8*1024*1024,dc=class extends Error{constructor(i,r,n,a){super(`${i} ${r.join(" ")} failed${n?`: ${n}`:""}`,a);this.command=i;this.args=r;this.stderr=n;this.name="ExternalCommandError"}command;args;stderr};function ii(e,t,i={}){let r=i.timeoutMs??ck,n=i.maxBufferBytes??lk;if(!Number.isSafeInteger(r)||r<1)throw new Error("External command timeout must be a positive integer");if(!Number.isSafeInteger(n)||n<1)throw new Error("External command max buffer must be a positive integer");try{return sk(e,[...t],{...i.cwd?{cwd:i.cwd}:{},...i.input!==void 0?{input:i.input}:{},encoding:"utf8",stdio:[i.input===void 0?"ignore":"pipe","pipe","pipe"],timeout:r,maxBuffer:n,windowsHide:!0,shell:!1})}catch(a){let o=typeof a.stderr=="string"?a.stderr.trim():Buffer.isBuffer(a.stderr)?a.stderr.toString("utf8").trim():"";throw new dc(e,t,o,{cause:a})}}import dk from"path";var fk=["Outcome","Scope","Non-goals","Acceptance examples"],lI=[...fk,"Constraints and invariants","Decisions","Open questions","Verification expectations"];function pa(e,t){return dk.join(e.specsDir,t,"spec.md")}var hk=6e4,q=class extends Error{constructor(i,r,n){super(i,n);this.pullRequest=r;this.name="NativePullRequestFinishError"}pullRequest};function fc(e,t){try{return ii("gh",t,{cwd:e,timeoutMs:hk}).trim()}catch(i){throw new Error(`gh ${t.join(" ")} failed: ${i.message}`,{cause:i})}}function hc(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a JSON object`);return e}function pc(e,t){try{return JSON.parse(e)}catch(i){throw new Error(`${t} must be valid JSON`,{cause:i})}}function Xf(e,t){if(!Number.isSafeInteger(e)||e<1)throw new Error(`${t} must be a positive integer`);return e}function Rt(e,t){if(typeof e!="string"||e.trim().length===0)throw new Error(`${t} must be a non-empty string`);return e}function Qf(e,t){let i=Rt(e,t),r;try{r=new URL(i)}catch(n){throw new Error(`${t} must be an absolute HTTP URL`,{cause:n})}if(r.protocol!=="https:"&&r.protocol!=="http:")throw new Error(`${t} must be an absolute HTTP URL`);return i}function va(e,t){let i=Rt(e,t);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/iu.test(i))throw new Error(`${t} must be a Git object ID`);return i.toLowerCase()}function Zf(e,t){let i=hc(e,t);if(Rt(i.state,`${t}.state`)!=="OPEN")throw new Error(`${t}.state must be OPEN`);return{number:Xf(i.number,`${t}.number`),url:Qf(i.url,`${t}.url`),baseBranch:Rt(i.baseRefName,`${t}.baseRefName`),headBranch:Rt(i.headRefName,`${t}.headRefName`),headSha:va(i.headRefOid,`${t}.headRefOid`),state:"OPEN"}}function pk(e){let t=hc(e,"pull request finish provider output.pullRequest");return{number:Xf(t.number,"pull request finish provider output.pullRequest.number"),url:Qf(t.url,"pull request finish provider output.pullRequest.url"),baseBranch:Rt(t.baseBranch,"pull request finish provider output.pullRequest.baseBranch"),headBranch:Rt(t.headBranch,"pull request finish provider output.pullRequest.headBranch"),headSha:va(t.headSha,"pull request finish provider output.pullRequest.headSha")}}function mk(e){let t=hc(pc(e,"pull request finish provider output"),"pull request finish provider output");if(t.schema!=="comet.native.pull-request-finish-result.v1")throw new Error("pull request finish provider output.schema must be comet.native.pull-request-finish-result.v1");if(t.disposition!=="created"&&t.disposition!=="reused")throw new Error("pull request finish provider output.disposition must be created or reused");if(t.remoteVerified!==!0)throw new Error("pull request finish provider did not confirm repository-owned remote verification");let i=pk(t.pullRequest);return{schema:"comet.native.pull-request-finish-result.v1",disposition:t.disposition,remoteVerified:!0,pullRequest:i}}function mc(e){let t=fc(e.projectRoot,["pr","list","--state","open","--base",e.baseBranch,"--head",e.headBranch,"--limit","2","--json","number,url,baseRefName,headRefName,headRefOid,state"]),i=pc(t,"gh pr list output");if(!Array.isArray(i))throw new Error("gh pr list output must be a JSON array");if(i.length>1)throw new Error(`Multiple open pull requests match ${e.headBranch} -> ${e.baseBranch}`);return i.length===0?null:Zf(i[0],"gh pr list output[0]")}function eh(e){let t=fc(e.projectRoot,["pr","view",String(e.pullRequest.number),"--json","number,url,baseRefName,headRefName,headRefOid,state"]),i=Zf(pc(t,"gh pr view output"),"gh pr view output"),r=va(e.headSha,"Native Archive head SHA");if(i.number!==e.pullRequest.number||i.url!==e.pullRequest.url)throw new q("Pull request provider result does not match the pull request observed from GitHub",i);if(i.baseBranch!==e.baseBranch)throw new q(`Pull request base branch mismatch: expected ${e.baseBranch}, got ${i.baseBranch}`,i);if(i.headBranch!==e.headBranch)throw new q(`Pull request head branch mismatch: expected ${e.headBranch}, got ${i.headBranch}`,i);if(i.headSha!==r)throw new q(`Pull request head SHA mismatch: expected ${r}, got ${i.headSha}`,i);return i}function ma(e){try{return mc(e)}catch{return null}}function vk(e){return JSON.stringify({schema:"comet.native.pull-request-finish-input.v1",projectRoot:e.projectRoot,change:{name:e.changeName,branch:e.headBranch,headSha:e.headSha},target:{branch:e.baseBranch},remote:e.remote,transactionId:e.transactionId,existingPullRequest:e.existingPullRequest},null,2)}function gk(e){let t=e.existingPullRequest,i=t?"reused":"created";if(!t)try{let a=fc(e.projectRoot,["pr","create","--base",e.baseBranch,"--head",e.headBranch,"--fill"]).split(/\r?\n/u).map(o=>o.trim()).find(o=>/^https?:\/\//u.test(o));if(!a)throw new Error("GitHub CLI did not return a pull request URL");if(t=mc(e),!t)throw new Error("GitHub CLI created a pull request that could not be observed uniquely");if(t.url!==a)throw new q("GitHub CLI returned a pull request URL that does not match the remotely observed pull request",t)}catch(n){if(n instanceof q)throw n;let a=ma(e);if(!a)throw new q(n.message,null,{cause:n});t=a,i="reused"}let r;try{r=eh({...e,pullRequest:t})}catch(n){throw n instanceof q?n:new q(`Final GitHub pull request verification failed: ${n.message}`,t,{cause:n})}return{provider:"github-fill",disposition:i,pullRequest:r,remoteVerified:!0}}function wk(e){let[t,...i]=e.config.command,r;try{let o=ii(t,i,{cwd:e.projectRoot,timeoutMs:e.config.timeout_ms,input:`${vk(e)}
200
+ `}).trim();r=mk(o)}catch(o){if(o instanceof q)throw o;let s=ma(e)??e.existingPullRequest;throw new q(`Repository pull request finish provider failed: ${o.message}`,s,{cause:o})}let n={...r.pullRequest,state:"OPEN"};if(n.baseBranch!==e.baseBranch||n.headBranch!==e.headBranch||n.headSha!==va(e.headSha,"Native Archive head SHA")){let o=ma(e)??e.existingPullRequest;throw new q("Repository pull request finish provider returned a pull request outside the authorized base, head, or head SHA",o)}let a;try{a=eh({...e,pullRequest:n})}catch(o){if(o instanceof q)throw o;let s=ma(e)??e.existingPullRequest??n;throw new q(`Final repository pull request verification failed: ${o.message}`,s,{cause:o})}return{provider:"repository-command",disposition:r.disposition,pullRequest:a,remoteVerified:!0}}function th(e){let t=mc(e);return e.config?wk({...e,existingPullRequest:t,config:e.config}):gk({...e,existingPullRequest:t})}var pr=class extends Error{constructor(i){super(i.message??"Native workspace finish is blocked");this.result=i;this.name="NativeWorkspaceFinishError"}result};function ih(e,t){let i=Me.relative(e,t);return i===""||!Me.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Me.sep}`)}function Ct(e,t){let i=Me.relative(e,t).replaceAll("\\","/");if(!i||i===".."||i.startsWith("../")||Me.isAbsolute(i))throw new Error(`Native workspace finish path escaped the project: ${t}`);return i}function rh(e,t){return t.some(i=>e===i||e.startsWith(`${i}/`))}function nh(e){return e.split("\0").filter(Boolean)}function kk(e,t){return nh(I(e,["ls-files","-z","--",t]))}function Sk(e,t){return nh(I(e,["ls-files","--others","--exclude-standard","-z","--",t]))}function Ek(e){try{if(I(e,["config","--get","user.name"])&&I(e,["config","--get","user.email"]))return}catch{}throw new Error("Native workspace finish requires configured Git user.name and user.email")}function Pk(e,t){for(let i of lt(e))if(F(i).currentBranch===t)return i;return null}function xk(e,t){try{ii(e,t,{timeoutMs:1e4})}catch(i){throw new Error(`${e} is required for the selected Native workspace finish`,{cause:i})}}function Rk(e,t){if(!t)return;let i=t.command[0];try{if(Me.posix.isAbsolute(i)||Me.win32.isAbsolute(i))throw new Error("configured executable must not be an absolute path");if(/[\\/]/u.test(i)){let n=Me.resolve(e,i);if(!ih(e,n))throw new Error("configured executable escapes the project root");yk(n,Nk.X_OK);return}ii(process.platform==="win32"?"where":"which",[i],{timeoutMs:1e4})}catch(r){throw new Error(`Configured Native pull request finish executable is not available: ${i}`,{cause:r})}}async function vc(e){let{paths:t,state:i}=e,r=i.workspace;if(r.isolation==="current")return null;if(!r.finish||!r.change_branch||!r.target_branch)throw new Error("Native isolated workspace finish is not persisted");if(r.change_branch===r.target_branch)throw new Error("Native change and target branches must be different for workspace finish");let n=F(t.projectRoot);if(!n.primaryWorktreeRoot||n.currentBranch!==r.change_branch)throw new Error(`Native workspace finish requires branch ${r.change_branch} in the current registered worktree`);Ek(t.projectRoot);let a=[Ct(t.projectRoot,nc(t))];e.archiveDir&&a.push(Ct(t.projectRoot,oe(t,i.name)),Ct(t.projectRoot,e.archiveDir));let o=Ks(t.projectRoot).filter(l=>!rh(l,a));if(o.length>0)throw new Error(`Native workspace finish is blocked until change-owned implementation and artifacts are committed; remaining paths: ${o.slice(0,20).join(", ")}${o.length>20?", ...":""}`);let s=r.isolation==="branch"?t.projectRoot:Pk(n.primaryWorktreeRoot,r.target_branch);if(r.finish==="merge"&&r.isolation==="worktree"){if(!s)throw new Error(`Native merge finish requires a registered worktree on target branch ${r.target_branch}`);if(!Zn(s))throw new Error(`Native merge target worktree is not clean: ${s}`)}let c=r.finish==="push"||r.finish==="pull-request"?vf(t.projectRoot,r.change_branch):null;return r.finish==="pull-request"&&(xk("gh",["--version"]),Rk(t.projectRoot,e.pullRequestFinish)),{finish:r.finish,changeRoot:t.projectRoot,primaryRoot:n.primaryWorktreeRoot,changeBranch:r.change_branch,targetBranch:r.target_branch,targetRoot:s,remote:c,isolation:r.isolation,pullRequestFinish:e.pullRequestFinish??null}}async function Ck(e){try{return await bk.access(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}function Ak(e){return{action:e.finish,status:e.finish==="keep"?"kept":"completed",commit:null,remote:e.remote,pushed:!1,pullRequestUrl:null,pullRequest:null,merged:!1,targetRoot:e.targetRoot,cleanup:{performed:!1,reason:null},message:null,recoveryArgs:null}}async function ah(e){let t=Ak(e.plan),i=null;try{let r=[Ct(e.paths.projectRoot,oe(e.paths,e.name)),Ct(e.paths.projectRoot,e.archiveDir),...e.state.spec_changes.map(l=>Ct(e.paths.projectRoot,pa(e.paths,l.capability))),Ct(e.paths.projectRoot,nc(e.paths))],n=Ks(e.plan.changeRoot).filter(l=>!rh(l,r));if(n.length>0)throw new Error(`Native Archive produced or encountered paths outside the authorized finish scope: ${n.slice(0,20).join(", ")}${n.length>20?", ...":""}`);let a=[],o=new Set;for(let l of r){let u=Me.resolve(e.paths.projectRoot,...l.split("/"));if(kk(e.plan.changeRoot,l).length>0&&a.push(l),await Ck(u))for(let d of Sk(e.plan.changeRoot,l))o.add(d)}if(a.length>0&&I(e.plan.changeRoot,["add","-u","--",...a]),o.size>0&&I(e.plan.changeRoot,["add","--",...o]),I(e.plan.changeRoot,["diff","--cached","--name-only","-z"])&&I(e.plan.changeRoot,["commit","-m",`chore(native): archive ${e.name}`]),t.commit=I(e.plan.changeRoot,["rev-parse","HEAD"]),!Zn(e.plan.changeRoot))throw new Error("Native archive commit left unexpected working-tree changes");if(e.plan.finish==="keep")return t;if(e.plan.finish==="push"||e.plan.finish==="pull-request"){I(e.plan.changeRoot,["push","--set-upstream",e.plan.remote,e.plan.changeBranch]),t.pushed=!0,e.plan.finish==="pull-request"&&(t.pullRequest=th({projectRoot:e.plan.changeRoot,changeName:e.name,transactionId:e.transactionId,remote:e.plan.remote,baseBranch:e.plan.targetBranch,headBranch:e.plan.changeBranch,headSha:t.commit,config:e.plan.pullRequestFinish}),t.pullRequestUrl=t.pullRequest.pullRequest.url);let l=ih(e.plan.changeRoot,process.cwd());return e.plan.isolation==="worktree"&&!l?(I(e.plan.primaryRoot,["worktree","remove",e.plan.changeRoot]),t.cleanup={performed:!0,reason:null}):e.plan.isolation==="worktree"&&(t.cleanup={performed:!1,reason:"invocation-working-directory-is-the-change-worktree"}),t}let c=e.plan.targetRoot??e.plan.changeRoot;return e.plan.isolation==="branch"&&(I(c,["switch",e.plan.targetBranch]),i=c),I(c,["merge","--no-ff","--no-edit",e.plan.changeBranch]),t.merged=!0,t.targetRoot=c,t.cleanup={performed:!1,reason:"post-merge-validation-required-before-cleanup"},t}catch(r){if(r instanceof q&&r.pullRequest&&(t.pullRequestUrl=r.pullRequest.url),i!==null){let n;try{I(i,["merge","--abort"])}catch{}try{F(i).currentBranch===e.plan.targetBranch&&I(i,["switch",e.plan.changeBranch]),n=F(i).currentBranch===e.plan.changeBranch}catch{n=!1}n||(t.targetRoot=i)}throw t.status="blocked",t.message=r.message,t.recoveryArgs=e.plan.finish==="pull-request"?["comet","native","archive",e.name,"--confirmed"]:e.plan.finish==="merge"&&t.targetRoot?["git","-C",t.targetRoot,"status","--short"]:["git","-C",e.plan.changeRoot,"status","--short"],new pr(t)}}import vr from"path";import{realpathSync as dS}from"fs";var _k=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 oh=1024*1024;var ch="scoped-text-safety",Tk=1,Ik=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var jk="comet.native.checker-policy.v1";var UI=ee(jk,{policy:ch,version:Tk,limits:Ik,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var $k=["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"],KI=new Set($k);var Dk=oh,fj=3*Dk;var lh={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:[]},Lk=de("comet-native-runtime:v3:scope-reopen"),Lj=[{skillVersion:"3",skillHash:de("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:de("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:de("comet-native-runtime:v1")}];var dh=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],y$=new Set(dh),Jk=new Set([...dh,"minimum_runtime_version","revision"]),N$=new Set([...Jk,"operation"]),b$=512*1024,Gk=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),k$=new Set([...Gk,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var x$={maxAcceptanceCriteria:Ui.maxCriteria};var T$={maxSpecs:64,maxFileBytes:Nr,maxTotalBytes:4*1024*1024};import{execFile as iS}from"node:child_process";import{promisify as rS}from"node:util";var F$={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var cO=512*1024;var mr=class extends Error{recovery;constructor(t,i){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=i}};var TO=64*1024;var IO=3600*1e3;var jO=rS(iS);var ga=class extends Error{details;constructor(t){let i=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(r=>`${r.ref}${r.acceptanceId?`[${r.acceptanceId}]`:""} -> ${r.mismatches.join("; ")}`).join(" | ")}`;super(i),this.name="NativeVerificationReceiptBindingError",this.details=t}};var w0={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var C0=16*1024*1024,A0=256*1024,_0=16*1024;var O0=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var EH=16*1024*1024,wa=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"},ya=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 Na=class extends Error{constructor(i,r,n){super(i,n);this.preparation=r;this.name="NativeWorkspacePreparationError"}preparation};var ph=["--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."],wc=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:ph,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|--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker]
201
+ 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 or an explicitly degraded verifier-unavailable fallback before Archive.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify to Shape when user-visible goals or acceptance criteria must change.","--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.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, 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 "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep]
202
+ 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 gc(e,t){return`${e}:
202
203
  ${t.map(i=>` ${i}`).join(`
203
- `)}`}function Qb(e){let t=e.filter(r=>r!=="--help");if(t.length===0)return"";let i=t.slice(0,2).join(" ");return ec[i]||t.length>1&&ec[t[0]]?.subcommands?i:t[0]}function Zb(e=[]){let t=Qb(e),i=ec[t];if(!i)throw new Error(`Unknown Native help topic: ${t}`);let r=[`Usage: ${i.usage}`,"",i.purpose];i.subcommands&&r.push("",Zs("Commands",i.subcommands));let n=t===""?i.options:[...i.options??[],...Tf];return n&&n.length>0&&r.push("",Zs("Options",n)),r.push("",`Output:
204
- ${i.output}`),i.examples&&r.push("",Zs("Examples",i.examples)),t===""&&r.push("","Run `comet native <command> --help` for command-specific details."),{topic:t,usage:`${r.join(`
204
+ `)}`}function cS(e){let t=e.filter(r=>r!=="--help");if(t.length===0)return"";let i=t.slice(0,2).join(" ");return wc[i]||t.length>1&&wc[t[0]]?.subcommands?i:t[0]}function lS(e=[]){let t=cS(e),i=wc[t];if(!i)throw new Error(`Unknown Native help topic: ${t}`);let r=[`Usage: ${i.usage}`,"",i.purpose];i.subcommands&&r.push("",gc("Commands",i.subcommands));let n=t===""?i.options:[...i.options??[],...ph];return n&&n.length>0&&r.push("",gc("Options",n)),r.push("",`Output:
205
+ ${i.output}`),i.examples&&r.push("",gc("Examples",i.examples)),t===""&&r.push("","Run `comet native <command> --help` for command-specific details."),{topic:t,usage:`${r.join(`
205
206
  `)}
206
- `}}var ek=Zb().usage;var c0=10*1024*1024,j=class extends Error{};function ur(e,t){let i=e.flatMap((r,n)=>r===t?[n]:[]);if(i.length>1)throw new j(`${t} may only be provided once`);return i.length===0?!1:(e.splice(i[0],1),!0)}function Xt(e,t){let i=e.flatMap((a,o)=>a===t?[o]:[]);if(i.length>1)throw new j(`${t} may only be provided once`);if(i.length===0)return;let r=i[0],n=e[r+1];if(n===void 0||n.startsWith("--"))throw new j(`${t} requires a value`);return e.splice(r,2),n}function ic(e){if(e.length>0)throw new j(`Unexpected argument: ${e[0]}`)}function jf(e,t){let i=e.shift();if(!i||i.startsWith("--"))throw new j(`${t} is required`);return i}function If(e,t){let i=tc.normalize(e),r=tc.normalize(t);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function tk(e){let t=tc.resolve(e),i=F(process.cwd());if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return t;let r=F(t);return!r.isGitWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null||!If(i.primaryWorktreeRoot,r.primaryWorktreeRoot)||If(i.currentWorktreeRoot,r.currentWorktreeRoot)?t:i.currentWorktreeRoot}async function $f(e){return e?tk(e):Sn(process.cwd())}async function Of(e){let t=await ad({startPath:e,allowMissingConfig:!1});return{config:t.config,paths:t.paths}}function Qt(e,t,i){return{command:e,exitCode:0,data:t,text:i??JSON.stringify(t,null,2)+`
207
- `}}function Hf(e,t){if(t instanceof j)return{command:e,exitCode:64,error:{code:"usage",message:t.message}};if(t instanceof na)return{command:e,exitCode:73,data:{capability:t.capability,expectedHash:t.expectedHash,actualHash:t.actualHash,canonicalPath:t.canonicalPath},error:{code:"conflict",message:t.message}};if(t instanceof aa)return{command:e,exitCode:73,data:t.preflight,error:{code:"conflict",message:t.message}};if(t instanceof qn)return{command:e,exitCode:73,data:{change:t.change,expectedRevision:t.expectedRevision,actualRevision:t.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:t.message}};if(t instanceof Yi)return{command:e,exitCode:73,data:{requestedIsolation:t.requestedIsolation,activeChanges:t.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:t.message}};if(t instanceof oa)return{command:e,exitCode:73,data:{preparation:t.preparation},error:{code:"workspace-preparation-incomplete",message:t.message}};if(t instanceof Wn)return{command:e,exitCode:65,data:{change:t.change,complete:!1,omittedCount:t.omittedCount,omittedByReason:t.omittedByReason,samplePaths:t.samplePaths,sampleTruncated:t.sampleTruncated,effectiveLimits:t.effectiveLimits,policyHash:t.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:t.message}};if(t instanceof ra)return{command:e,exitCode:65,data:{receiptBindingFailures:t.details},error:{code:"invalid-data",message:t.message}};if(t instanceof lr)return{command:e,exitCode:65,data:t.recovery,error:{code:"implementation-scope-stale",message:t.message}};if(t instanceof Error){let i=t.code;if(i&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(i))return{command:e,exitCode:70,error:{code:"internal",message:t.message}};let r=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(t.message);return{command:e,exitCode:r?73:65,error:{code:r?"conflict":"invalid-data",message:t.message}}}return{command:e,exitCode:70,error:{code:"internal",message:String(t)}}}function Df(e,t){return t?{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
208
- `}:e.error?{exitCode:e.exitCode,stderr:e.error.message}:{exitCode:e.exitCode,stdout:e.text}}async function Bf(e,t){let i=jf(e,"change name"),r=ur(e,"--dry-run"),n=Xt(e,"--expect-preflight"),a=ur(e,"--confirmed"),o=Xt(e,"--finish"),s=Xt(e,"--serial-first");if(s!==void 0&&!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(s))throw new j("--serial-first must be one Native change name");let c=o;if(c!==void 0&&c!=="merge"&&c!=="push"&&c!=="pull-request"&&c!=="keep")throw new j("--finish must be merge, push, pull-request, or keep");let l=await Of(t),d=await nr(l.paths,i),f=d?await qt(l.paths,{kind:"archive",change:i}):null,u=d?!1:await of(l.paths,i);if(d||u){if(n)throw new j("Portable Native Archive does not use preflight hashes");if(r&&a)throw new j("--confirmed is only valid when executing Archive");if(r&&s)throw new j("--serial-first is only valid when executing Archive");if(!r&&c)throw new j("--finish is only valid with --dry-run");ic(e);let v=d&&!r&&f?.kind!=="archive"?await wf({paths:l.paths,name:i}):null,h=v?.state??(d?await Le(l.paths,i):null);if(v?.action==="reverify"||v?.action==="await-user")return Qt(r?"archive --dry-run":"archive",{archived:!1,state:v.state,recovery:v,continuation:or(v.state)},`${v.message}
209
- `);if(r){if(!h)return Qt("archive --dry-run",{change:i,ready:!0,archiveRecovery:!0,continuation:{disposition:"continue",reason:"Resume the interrupted Native Archive transaction.",commandArgs:["comet","native","archive",i,"--confirmed"],inputOptions:[],runnerAction:null}},`Native Archive recovery is ready for ${i}
210
- `);if(c)h=await Xd({paths:l.paths,name:i,finish:c});else if(h.workspace.isolation!=="current"&&h.workspace.finish===null)throw new j("Native branch and worktree isolation require --finish with --dry-run");let w=await Gs({paths:l.paths,name:i}),k=or(h),S=w.capabilityPeers.length>0?{...k,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["choose-first-archive"],runnerAction:{...k.runnerAction,kind:"none"}}:k;return Qt("archive --dry-run",{...w,workspaceFinish:h.workspace.finish,continuation:S},`Native Archive preview: ${w.ready?"ready":"blocked"}
211
- `)}if(l.config.native.archive_confirmation==="required"&&!a)throw new j("archive requires --confirmed when native.archive_confirmation is required");if(h&&h.workspace.isolation!=="current"&&h.workspace.finish===null)throw new j("Native branch and worktree isolation require a persisted --finish preview");let m=h?await Qs({paths:l.paths,state:h}):null,g;try{g=await cf({paths:l.paths,name:i,...s?{serialFirstChange:s}:{}})}catch(w){if(!(w instanceof ar)||!h)throw w;let k=await Gs({paths:l.paths,name:i}),S=w.peers.length>0?["comet","native","archive",i,"--confirmed","--serial-first",i]:["comet","native","archive",i,"--confirmed"];return{command:"archive",exitCode:73,data:{...k,workspaceFinish:h.workspace.finish,workspaceFinishResult:null,continuation:{disposition:"await-user",reason:w.message,commandArgs:S,inputOptions:w.peers.length>0?["serial-first-change"]:[],runnerAction:null}},error:{code:"conflict",message:w.message}}}h=g.state,!m&&h.workspace.isolation!=="current"&&(m=await Qs({paths:l.paths,state:h,archiveDir:g.archiveDir}));let N=null;if(m)try{N=await kf({paths:l.paths,state:g.state,name:i,archiveDir:g.archiveDir,transactionId:g.transactionId,plan:m})}catch(w){if(!(w instanceof cr))throw w;return{command:"archive",exitCode:73,data:{...g,workspaceFinish:g.state.workspace.finish,workspaceFinishResult:w.result,continuation:{disposition:"blocked",reason:w.message,commandArgs:w.result.recoveryArgs,inputOptions:[],runnerAction:null}},error:{code:"conflict",message:w.message}}}return Qt("archive",{...g,workspaceFinish:g.state.workspace.finish,workspaceFinishResult:N,continuation:or(g.state)},`Archived Native change ${i} to ${g.archiveDir}
212
- `)}if(s)throw new j("--serial-first is only valid for portable Native changes");if(!r&&c)throw new j("--finish is only valid with --dry-run");if(ic(e),r)return{command:"archive --dry-run",exitCode:65,data:{change:i,migrationRequired:!0,repairCommand:`comet native doctor ${i} --repair`},error:{code:"invalid-data",message:`Native active change ${i} must migrate before Archive preview`}};let p=await mf({paths:l.paths,name:i});return Qt("archive",{migration:{from:"legacy",to:p.schema,completed:!0},state:p,continuation:or(p)},`Migrated Native change ${i}; follow the returned portable continuation before Archive
213
- `)}function ik(e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
214
- `}}async function Lf(e,t,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{ur(n,"--json"),s=Xt(n,"--project-root");let d=[...n,...a],f=await $f(s);c=await t(d,f)}catch(d){c=Hf(e,d)}let l=o?ik(c):Df(c,!1);return l.stdout&&process.stdout.write(l.stdout),l.stderr&&process.stderr.write(l.stderr+(l.stderr.endsWith(`
207
+ `}}var uS=lS().usage;var UH=10*1024*1024,O=class extends Error{};function gr(e,t){let i=e.flatMap((r,n)=>r===t?[n]:[]);if(i.length>1)throw new O(`${t} may only be provided once`);return i.length===0?!1:(e.splice(i[0],1),!0)}function ri(e,t){let i=e.flatMap((a,o)=>a===t?[o]:[]);if(i.length>1)throw new O(`${t} may only be provided once`);if(i.length===0)return;let r=i[0],n=e[r+1];if(n===void 0||n.startsWith("--"))throw new O(`${t} requires a value`);return e.splice(r,2),n}function Nc(e){if(e.length>0)throw new O(`Unexpected argument: ${e[0]}`)}function vh(e,t){let i=e.shift();if(!i||i.startsWith("--"))throw new O(`${t} is required`);return i}function yc(e,t){let i=vr.normalize(mh(e)),r=vr.normalize(mh(t));return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function mh(e){let t=vr.resolve(e);try{return dS.native(t)}catch{return t}}function fS(e){let t=vr.resolve(e),i=F(process.cwd());if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return t;let r=F(t);return!r.isGitWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null||!yc(i.primaryWorktreeRoot,r.primaryWorktreeRoot)||yc(i.currentWorktreeRoot,r.currentWorktreeRoot)?t:yc(process.cwd(),i.currentWorktreeRoot)?vr.resolve(process.cwd()):i.currentWorktreeRoot}async function gh(e){return e?fS(e):_n(process.cwd())}async function wh(e){let t=await Pd({startPath:e,allowMissingConfig:!1});return{config:t.config,paths:t.paths}}function ni(e,t,i){return{command:e,exitCode:0,data:t,text:i??JSON.stringify(t,null,2)+`
208
+ `}}function yh(e,t){if(t instanceof O)return{command:e,exitCode:64,error:{code:"usage",message:t.message}};if(t instanceof wa)return{command:e,exitCode:73,data:{capability:t.capability,expectedHash:t.expectedHash,actualHash:t.actualHash,canonicalPath:t.canonicalPath},error:{code:"conflict",message:t.message}};if(t instanceof ya)return{command:e,exitCode:73,data:t.preflight,error:{code:"conflict",message:t.message}};if(t instanceof Yn)return{command:e,exitCode:73,data:{change:t.change,expectedRevision:t.expectedRevision,actualRevision:t.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:t.message}};if(t instanceof tr)return{command:e,exitCode:73,data:{requestedIsolation:t.requestedIsolation,activeChanges:t.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:t.message}};if(t instanceof Na)return{command:e,exitCode:73,data:{preparation:t.preparation},error:{code:"workspace-preparation-incomplete",message:t.message}};if(t instanceof Xn)return{command:e,exitCode:65,data:{change:t.change,complete:!1,omittedCount:t.omittedCount,omittedByReason:t.omittedByReason,samplePaths:t.samplePaths,sampleTruncated:t.sampleTruncated,effectiveLimits:t.effectiveLimits,policyHash:t.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:t.message}};if(t instanceof ga)return{command:e,exitCode:65,data:{receiptBindingFailures:t.details},error:{code:"invalid-data",message:t.message}};if(t instanceof mr)return{command:e,exitCode:65,data:t.recovery,error:{code:"implementation-scope-stale",message:t.message}};if(t instanceof Error){let i=t.code;if(i&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(i))return{command:e,exitCode:70,error:{code:"internal",message:t.message}};let r=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(t.message);return{command:e,exitCode:r?73:65,error:{code:r?"conflict":"invalid-data",message:t.message}}}return{command:e,exitCode:70,error:{code:"internal",message:String(t)}}}function Nh(e,t){return t?{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
209
+ `}:e.error?{exitCode:e.exitCode,stderr:e.error.message}:{exitCode:e.exitCode,stdout:e.text}}async function bh(e,t){let i=vh(e,"change name"),r=gr(e,"--dry-run"),n=ri(e,"--expect-preflight"),a=gr(e,"--confirmed"),o=ri(e,"--finish"),s=ri(e,"--serial-first");if(s!==void 0&&!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(s))throw new O("--serial-first must be one Native change name");let c=o;if(c!==void 0&&c!=="merge"&&c!=="push"&&c!=="pull-request"&&c!=="keep")throw new O("--finish must be merge, push, pull-request, or keep");let l=await wh(t),u=await ur(l.paths,i),f=u?await Yt(l.paths,{kind:"archive",change:i}):null,d=u?!1:await Df(l.paths,i);if(u||d){if(n)throw new O("Portable Native Archive does not use preflight hashes");if(r&&a)throw new O("--confirmed is only valid when executing Archive");if(r&&s)throw new O("--serial-first is only valid when executing Archive");if(!r&&c)throw new O("--finish is only valid with --dry-run");Nc(e);let v=u&&!r&&f?.kind!=="archive"?await Yf({paths:l.paths,name:i}):null,h=v?.state??(u?await Fe(l.paths,i):null);if(v?.action==="reverify"||v?.action==="await-user")return ni(r?"archive --dry-run":"archive",{archived:!1,state:v.state,recovery:v,continuation:fr(v.state)},`${v.message}
210
+ `);if(r){if(!h)return ni("archive --dry-run",{change:i,ready:!0,archiveRecovery:!0,continuation:{disposition:"continue",reason:"Resume the interrupted Native Archive transaction.",commandArgs:["comet","native","archive",i,"--confirmed"],inputOptions:[],runnerAction:null}},`Native Archive recovery is ready for ${i}
211
+ `);if(c)h=await Af({paths:l.paths,name:i,finish:c});else if(h.workspace.isolation!=="current"&&h.workspace.finish===null)throw new O("Native branch and worktree isolation require --finish with --dry-run");let w=await lc({paths:l.paths,name:i}),k=fr(h),S=w.capabilityPeers.length>0?{...k,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["choose-first-archive"],runnerAction:{...k.runnerAction,kind:"none"}}:k;return ni("archive --dry-run",{...w,workspaceFinish:h.workspace.finish,continuation:S},`Native Archive preview: ${w.ready?"ready":"blocked"}
212
+ `)}if(l.config.native.archive_confirmation==="required"&&!a)throw new O("archive requires --confirmed when native.archive_confirmation is required");if(h&&h.workspace.isolation!=="current"&&h.workspace.finish===null)throw new O("Native branch and worktree isolation require a persisted --finish preview");let m=h?await vc({paths:l.paths,state:h,pullRequestFinish:l.config.native.finish?.pull_request}):null,g;try{g=await Lf({paths:l.paths,name:i,...s?{serialFirstChange:s}:{}})}catch(w){if(!(w instanceof dr)||!h)throw w;let k=await lc({paths:l.paths,name:i}),S=w.peers.length>0?["comet","native","archive",i,"--confirmed","--serial-first",i]:["comet","native","archive",i,"--confirmed"];return{command:"archive",exitCode:73,data:{...k,workspaceFinish:h.workspace.finish,workspaceFinishResult:null,continuation:{disposition:"await-user",reason:w.message,commandArgs:S,inputOptions:w.peers.length>0?["serial-first-change"]:[],runnerAction:null}},error:{code:"conflict",message:w.message}}}h=g.state,!m&&h.workspace.isolation!=="current"&&(m=await vc({paths:l.paths,state:h,archiveDir:g.archiveDir,pullRequestFinish:l.config.native.finish?.pull_request}));let N=null;if(m)try{N=await ah({paths:l.paths,state:g.state,name:i,archiveDir:g.archiveDir,transactionId:g.transactionId,plan:m})}catch(w){if(!(w instanceof pr))throw w;return{command:"archive",exitCode:73,data:{...g,workspaceFinish:g.state.workspace.finish,workspaceFinishResult:w.result,continuation:{disposition:"blocked",reason:w.message,commandArgs:w.result.recoveryArgs,inputOptions:[],runnerAction:null}},error:{code:"conflict",message:w.message}}}return ni("archive",{...g,workspaceFinish:g.state.workspace.finish,workspaceFinishResult:N,continuation:fr(g.state)},`Archived Native change ${i} to ${g.archiveDir}
213
+ `)}if(s)throw new O("--serial-first is only valid for portable Native changes");if(!r&&c)throw new O("--finish is only valid with --dry-run");if(Nc(e),r)return{command:"archive --dry-run",exitCode:65,data:{change:i,migrationRequired:!0,repairCommand:`comet native doctor ${i} --repair`},error:{code:"invalid-data",message:`Native active change ${i} must migrate before Archive preview`}};let p=await Gf({paths:l.paths,name:i});return ni("archive",{migration:{from:"legacy",to:p.schema,completed:!0},state:p,continuation:fr(p)},`Migrated Native change ${i}; follow the returned portable continuation before Archive
214
+ `)}function hS(e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
215
+ `}}async function kh(e,t,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{gr(n,"--json"),s=ri(n,"--project-root");let u=[...n,...a],f=await gh(s);c=await t(u,f)}catch(u){c=yh(e,u)}let l=o?hS(c):Nh(c,!1);return l.stdout&&process.stdout.write(l.stdout),l.stderr&&process.stderr.write(l.stderr+(l.stderr.endsWith(`
215
216
  `)?"":`
216
- `)),l.exitCode}process.exitCode=await Lf("archive",Bf);
217
+ `)),l.exitCode}process.exitCode=await kh("archive",bh);