@rpamis/comet 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +41 -1
  2. package/assets/manifest.json +1 -1
  3. package/assets/skills/comet/scripts/comet-archive.mjs +97 -94
  4. package/assets/skills/comet/scripts/comet-guard.mjs +131 -131
  5. package/assets/skills/comet/scripts/comet-hook-guard.mjs +91 -91
  6. package/assets/skills/comet/scripts/comet-hook-router.mjs +202 -193
  7. package/assets/skills/comet/scripts/comet-resume-probe.mjs +82 -82
  8. package/assets/skills/comet/scripts/comet-runtime.mjs +287 -285
  9. package/assets/skills/comet/scripts/comet-state.mjs +199 -198
  10. package/assets/skills/comet-archive/SKILL.md +9 -5
  11. package/assets/skills/comet-native/reference/artifacts.md +44 -0
  12. package/assets/skills/comet-native/reference/clarification.md +1 -1
  13. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +199 -192
  14. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +173 -166
  15. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +150 -143
  16. package/assets/skills/comet-native/scripts/comet-native-init.mjs +103 -99
  17. package/assets/skills/comet-native/scripts/comet-native-new.mjs +209 -205
  18. package/assets/skills/comet-native/scripts/comet-native-next.mjs +180 -173
  19. package/assets/skills/comet-native/scripts/comet-native-root.mjs +106 -102
  20. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +182 -175
  21. package/assets/skills/comet-native/scripts/comet-native-select.mjs +124 -117
  22. package/assets/skills/comet-native/scripts/comet-native-show.mjs +99 -95
  23. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +143 -136
  24. package/assets/skills/comet-native/scripts/comet-native-status.mjs +120 -113
  25. package/assets/skills-zh/comet-archive/SKILL.md +9 -5
  26. package/assets/skills-zh/comet-native/reference/artifacts.md +44 -0
  27. package/assets/skills-zh/comet-native/reference/clarification.md +1 -1
  28. package/dist/app/cli/index.js +1 -0
  29. package/dist/app/cli/index.js.map +1 -1
  30. package/dist/app/commands/doctor.d.ts.map +1 -1
  31. package/dist/app/commands/doctor.js +17 -10
  32. package/dist/app/commands/doctor.js.map +1 -1
  33. package/dist/app/commands/i18n.d.ts +1 -1
  34. package/dist/app/commands/i18n.d.ts.map +1 -1
  35. package/dist/app/commands/i18n.js +4 -0
  36. package/dist/app/commands/i18n.js.map +1 -1
  37. package/dist/app/commands/project-knowledge.d.ts +2 -0
  38. package/dist/app/commands/project-knowledge.d.ts.map +1 -1
  39. package/dist/app/commands/project-knowledge.js +64 -7
  40. package/dist/app/commands/project-knowledge.js.map +1 -1
  41. package/dist/app/commands/uninstall.d.ts +1 -0
  42. package/dist/app/commands/uninstall.d.ts.map +1 -1
  43. package/dist/app/commands/uninstall.js +65 -10
  44. package/dist/app/commands/uninstall.js.map +1 -1
  45. package/dist/domains/agent-learning/coordinator.d.ts +8 -1
  46. package/dist/domains/agent-learning/coordinator.d.ts.map +1 -1
  47. package/dist/domains/agent-learning/coordinator.js +58 -0
  48. package/dist/domains/agent-learning/coordinator.js.map +1 -1
  49. package/dist/domains/agent-learning/experience-journal.d.ts +21 -1
  50. package/dist/domains/agent-learning/experience-journal.d.ts.map +1 -1
  51. package/dist/domains/agent-learning/experience-journal.js +190 -11
  52. package/dist/domains/agent-learning/experience-journal.js.map +1 -1
  53. package/dist/domains/bundle/bundle-platform.d.ts.map +1 -1
  54. package/dist/domains/bundle/bundle-platform.js +6 -1
  55. package/dist/domains/bundle/bundle-platform.js.map +1 -1
  56. package/dist/domains/comet-classic/classic-archive.d.ts.map +1 -1
  57. package/dist/domains/comet-classic/classic-archive.js +5 -1
  58. package/dist/domains/comet-classic/classic-archive.js.map +1 -1
  59. package/dist/domains/comet-classic/classic-design-readiness.d.ts +1 -1
  60. package/dist/domains/comet-classic/classic-progress.d.ts +60 -2
  61. package/dist/domains/comet-classic/classic-progress.d.ts.map +1 -1
  62. package/dist/domains/comet-classic/classic-progress.js +199 -22
  63. package/dist/domains/comet-classic/classic-progress.js.map +1 -1
  64. package/dist/domains/comet-classic/classic-recovery.d.ts +20 -1
  65. package/dist/domains/comet-classic/classic-recovery.d.ts.map +1 -1
  66. package/dist/domains/comet-native/native-artifact-language.d.ts +7 -0
  67. package/dist/domains/comet-native/native-artifact-language.d.ts.map +1 -1
  68. package/dist/domains/comet-native/native-artifact-language.js +61 -1
  69. package/dist/domains/comet-native/native-artifact-language.js.map +1 -1
  70. package/dist/domains/comet-native/native-artifacts.d.ts +2 -0
  71. package/dist/domains/comet-native/native-artifacts.d.ts.map +1 -1
  72. package/dist/domains/comet-native/native-artifacts.js +116 -19
  73. package/dist/domains/comet-native/native-artifacts.js.map +1 -1
  74. package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
  75. package/dist/domains/comet-native/native-hook-guard.js +3 -2
  76. package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
  77. package/dist/domains/comet-native/native-portable-requirements.d.ts.map +1 -1
  78. package/dist/domains/comet-native/native-portable-requirements.js +12 -5
  79. package/dist/domains/comet-native/native-portable-requirements.js.map +1 -1
  80. package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
  81. package/dist/domains/comet-native/native-portable-state.js +4 -2
  82. package/dist/domains/comet-native/native-portable-state.js.map +1 -1
  83. package/dist/domains/comet-native/native-portable-types.d.ts +1 -1
  84. package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
  85. package/dist/domains/comet-plugin/integration.d.ts +1 -0
  86. package/dist/domains/comet-plugin/integration.d.ts.map +1 -1
  87. package/dist/domains/comet-plugin/integration.js +20 -10
  88. package/dist/domains/comet-plugin/integration.js.map +1 -1
  89. package/dist/domains/comet-plugin/plugin-runtime.d.ts +8 -2
  90. package/dist/domains/comet-plugin/plugin-runtime.d.ts.map +1 -1
  91. package/dist/domains/comet-plugin/plugin-runtime.js +18 -4
  92. package/dist/domains/comet-plugin/plugin-runtime.js.map +1 -1
  93. package/dist/domains/dashboard/project-directory.d.ts +4 -0
  94. package/dist/domains/dashboard/project-directory.d.ts.map +1 -1
  95. package/dist/domains/dashboard/project-directory.js +30 -2
  96. package/dist/domains/dashboard/project-directory.js.map +1 -1
  97. package/dist/domains/dashboard/server.d.ts.map +1 -1
  98. package/dist/domains/dashboard/server.js +28 -3
  99. package/dist/domains/dashboard/server.js.map +1 -1
  100. package/dist/domains/dashboard/web/assets/{abnfDiagram-VCTEODGH-CFEU4PQU.js → abnfDiagram-VCTEODGH-m9_t3fwH.js} +1 -1
  101. package/dist/domains/dashboard/web/assets/{arc-BeYYJor9.js → arc-CDiwRrMg.js} +1 -1
  102. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-ypJOsR2Y.js +1 -0
  103. package/dist/domains/dashboard/web/assets/{architectureDiagram-5GKGNRK7-CqTy4fyH.js → architectureDiagram-5GKGNRK7-Xwj-hlQB.js} +1 -1
  104. package/dist/domains/dashboard/web/assets/{blockDiagram-I7D4REHJ-SR_5S4SA.js → blockDiagram-I7D4REHJ-Cme6qNK_.js} +1 -1
  105. package/dist/domains/dashboard/web/assets/{c4Diagram-7LVT6UL2-DzphG2XS.js → c4Diagram-7LVT6UL2-Cxs1dU7y.js} +1 -1
  106. package/dist/domains/dashboard/web/assets/channel-BFTjR7Ng.js +1 -0
  107. package/dist/domains/dashboard/web/assets/{chunk-4HAMMTFA-BpthUtIs.js → chunk-4HAMMTFA-DBQykIWE.js} +1 -1
  108. package/dist/domains/dashboard/web/assets/{chunk-75Z2AOVW-CxAdhPhG.js → chunk-75Z2AOVW-Dh-E6TAx.js} +1 -1
  109. package/dist/domains/dashboard/web/assets/{chunk-DU6HZSFF-5peVNfxp.js → chunk-DU6HZSFF-W3lPaoVP.js} +2 -2
  110. package/dist/domains/dashboard/web/assets/{chunk-F27PBJKO-CwG4xi2V.js → chunk-F27PBJKO-dzf1fpYi.js} +1 -1
  111. package/dist/domains/dashboard/web/assets/{chunk-GMAD6QVW-BuFFY783.js → chunk-GMAD6QVW-CeuSGVHV.js} +1 -1
  112. package/dist/domains/dashboard/web/assets/{chunk-GVQU2GXP-OyUFmjE-.js → chunk-GVQU2GXP-BrGrIBgk.js} +1 -1
  113. package/dist/domains/dashboard/web/assets/{chunk-IMKFNOWR-DmTme45C.js → chunk-IMKFNOWR-DXiTC1Xo.js} +1 -1
  114. package/dist/domains/dashboard/web/assets/{chunk-L3NEJ4N5-D6BHbKty.js → chunk-L3NEJ4N5-DnyD3Ocj.js} +1 -1
  115. package/dist/domains/dashboard/web/assets/{chunk-OSK3NFVY-CCz1v1Nv.js → chunk-OSK3NFVY-6vxhPm51.js} +1 -1
  116. package/dist/domains/dashboard/web/assets/{chunk-P2QGCYS3-C1_7kDYS.js → chunk-P2QGCYS3-DChNsVqO.js} +1 -1
  117. package/dist/domains/dashboard/web/assets/{chunk-POPQ4Y6H-buFKlAdG.js → chunk-POPQ4Y6H-RBgha6dE.js} +1 -1
  118. package/dist/domains/dashboard/web/assets/{chunk-PWAF6VOD-B_K6Jrsv.js → chunk-PWAF6VOD-CayoKmnh.js} +1 -1
  119. package/dist/domains/dashboard/web/assets/{chunk-SHT3W25Y-CRRLsXmS.js → chunk-SHT3W25Y-sOkLJZoB.js} +1 -1
  120. package/dist/domains/dashboard/web/assets/{chunk-SVP7TREG-Q5zCQTul.js → chunk-SVP7TREG-j0QRwmsq.js} +1 -1
  121. package/dist/domains/dashboard/web/assets/{chunk-TICWLB2K-Zc5XaO5Z.js → chunk-TICWLB2K-D7Re_d_T.js} +1 -1
  122. package/dist/domains/dashboard/web/assets/{chunk-XXDRQBXY-BAIB2h_r.js → chunk-XXDRQBXY-BFV70fKF.js} +1 -1
  123. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-gDSLbV2K.js +1 -0
  124. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-gDSLbV2K.js +1 -0
  125. package/dist/domains/dashboard/web/assets/{cose-bilkent-JH36ORCC-C7jkFYhm.js → cose-bilkent-JH36ORCC-k7gqx2Br.js} +1 -1
  126. package/dist/domains/dashboard/web/assets/{cynefin-OW5HDTMX-4yS-l7kx.js → cynefin-OW5HDTMX-CWI6FZT8.js} +1 -1
  127. package/dist/domains/dashboard/web/assets/{cynefinDiagram-5FMLGOSQ-DAkfQ8jW.js → cynefinDiagram-5FMLGOSQ-D-O3RrOu.js} +1 -1
  128. package/dist/domains/dashboard/web/assets/{dagre-GXQ25YYZ-D3b16ruz.js → dagre-GXQ25YYZ-BR1jxWfn.js} +1 -1
  129. package/dist/domains/dashboard/web/assets/{diagram-S7CK7UJ4-BXZHtdNz.js → diagram-S7CK7UJ4-B6gXFYBj.js} +1 -1
  130. package/dist/domains/dashboard/web/assets/{diagram-UQ7AKVKN-B4nIzofw.js → diagram-UQ7AKVKN-BBW6aRk8.js} +1 -1
  131. package/dist/domains/dashboard/web/assets/{diagram-VSXAHHWV-B6d7KNj1.js → diagram-VSXAHHWV-BC0CZeyH.js} +1 -1
  132. package/dist/domains/dashboard/web/assets/{diagram-VX7I27RA-CHr0Rg8a.js → diagram-VX7I27RA-BmwBIkwS.js} +1 -1
  133. package/dist/domains/dashboard/web/assets/{diagram-Z3DM3KII-BO2IxR9N.js → diagram-Z3DM3KII-DTZgX9SF.js} +1 -1
  134. package/dist/domains/dashboard/web/assets/{dist-0wyW4qbm.js → dist-brXLwleg.js} +1 -1
  135. package/dist/domains/dashboard/web/assets/{ebnfDiagram-PWID7BFC-CHRK8Hyg.js → ebnfDiagram-PWID7BFC-CsMXo0C6.js} +1 -1
  136. package/dist/domains/dashboard/web/assets/{erDiagram-RLTQ6QDP-_HFHzZlc.js → erDiagram-RLTQ6QDP-DQ9ewX94.js} +1 -1
  137. package/dist/domains/dashboard/web/assets/{es-kjndkyYX.js → es-CgcAhzLf.js} +1 -1
  138. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-Ll12Q19y.js +1 -0
  139. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-Bf2-9XUn.js +1 -0
  140. package/dist/domains/dashboard/web/assets/{ganttDiagram-EL5Y4UJY-CxhSw1PI.js → ganttDiagram-EL5Y4UJY-DIFkXe6G.js} +1 -1
  141. package/dist/domains/dashboard/web/assets/{gitGraph-4MIJSDKK-Cbw-3Dnk.js → gitGraph-4MIJSDKK-BHY8ZnpE.js} +1 -1
  142. package/dist/domains/dashboard/web/assets/{gitGraphDiagram-WWUBYQGX-Cx93hwtL.js → gitGraphDiagram-WWUBYQGX-cBn9dMzs.js} +1 -1
  143. package/dist/domains/dashboard/web/assets/{index-CQb8j5OE.js → index-C_6nf1Fw.js} +2 -2
  144. package/dist/domains/dashboard/web/assets/{info-A6RAGUB7--d4EMiIK.js → info-A6RAGUB7-DtUaS9jN.js} +1 -1
  145. package/dist/domains/dashboard/web/assets/{infoDiagram-27XIBGKW-DMkRRNGB.js → infoDiagram-27XIBGKW-CIl0e_EN.js} +1 -1
  146. package/dist/domains/dashboard/web/assets/{ishikawaDiagram-5VMMS53U-CjKh_jHT.js → ishikawaDiagram-5VMMS53U-DAdtPZ_c.js} +1 -1
  147. package/dist/domains/dashboard/web/assets/{journeyDiagram-3NMN7TZE-CG735M_M.js → journeyDiagram-3NMN7TZE-CBokRgde.js} +1 -1
  148. package/dist/domains/dashboard/web/assets/{kanban-definition-UXKFOSKX-CgXFmhFM.js → kanban-definition-UXKFOSKX-DrqCYJ-7.js} +1 -1
  149. package/dist/domains/dashboard/web/assets/katex-D29apahB.js +257 -0
  150. package/dist/domains/dashboard/web/assets/{line-Bhf8l3gG.js → line-BDlVqlh4.js} +1 -1
  151. package/dist/domains/dashboard/web/assets/{linear-YWT9mnmu.js → linear-DTAzui9x.js} +1 -1
  152. package/dist/domains/dashboard/web/assets/{mermaid-parser.core-COzQ1kq0.js → mermaid-parser.core-CFw-xbYY.js} +3 -3
  153. package/dist/domains/dashboard/web/assets/{mermaid.core-Cc1lMpx-.js → mermaid.core-Ck7fB8UD.js} +4 -4
  154. package/dist/domains/dashboard/web/assets/{mindmap-definition-YA3MSWOX-B_VOgUSO.js → mindmap-definition-YA3MSWOX-C7kb9KL9.js} +1 -1
  155. package/dist/domains/dashboard/web/assets/{packet-AYTQ26CC-CXbJLNC9.js → packet-AYTQ26CC-P8Mtt0tp.js} +1 -1
  156. package/dist/domains/dashboard/web/assets/{pegDiagram-XKGWAZYB-BuS0hioo.js → pegDiagram-XKGWAZYB-DUDD9qv5.js} +1 -1
  157. package/dist/domains/dashboard/web/assets/{pie-WAS4IAKB-BEaGwdWZ.js → pie-WAS4IAKB-dEmLxiDR.js} +1 -1
  158. package/dist/domains/dashboard/web/assets/{pieDiagram-E7YTZNPT-DDzYv-_9.js → pieDiagram-E7YTZNPT-BUssAcqk.js} +1 -1
  159. package/dist/domains/dashboard/web/assets/{quadrantDiagram-AXDQQJYC-DExT--Ut.js → quadrantDiagram-AXDQQJYC-BzaAWdQL.js} +1 -1
  160. package/dist/domains/dashboard/web/assets/{radar-RG4KPBEZ-C1JtzGr8.js → radar-RG4KPBEZ-mqtvaz9w.js} +1 -1
  161. package/dist/domains/dashboard/web/assets/{railroad-74A4TZTK-CMpkXATR.js → railroad-74A4TZTK-7tTnGpoz.js} +1 -1
  162. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CpJvyBJM.js +1 -0
  163. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-BJ5g77l6.js +1 -0
  164. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-BslCK-Gr.js +1 -0
  165. package/dist/domains/dashboard/web/assets/{railroadDiagram-O6MQD6OU-BCE65sLR.js → railroadDiagram-O6MQD6OU-DM1AKXm0.js} +1 -1
  166. package/dist/domains/dashboard/web/assets/{requirementDiagram-BXWQKSXE-CmyX3vGG.js → requirementDiagram-BXWQKSXE--H5KiPSc.js} +1 -1
  167. package/dist/domains/dashboard/web/assets/{sankeyDiagram-P5KCCOFB-BFKrX2dv.js → sankeyDiagram-P5KCCOFB-JweUq_u2.js} +1 -1
  168. package/dist/domains/dashboard/web/assets/{sequenceDiagram-WJ2MYXX4-DqodS9W-.js → sequenceDiagram-WJ2MYXX4-pxb1iTGb.js} +1 -1
  169. package/dist/domains/dashboard/web/assets/{src-BVUP3QzK.js → src-joFOxopw.js} +1 -1
  170. package/dist/domains/dashboard/web/assets/{stateDiagram-D77RDMKH-nHai_EZh.js → stateDiagram-D77RDMKH-CDu5crd8.js} +1 -1
  171. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-wV5AqWaM.js +1 -0
  172. package/dist/domains/dashboard/web/assets/{swimlanes-42K2YHIH-BODBARYN.js → swimlanes-42K2YHIH-ioSqowJ4.js} +1 -1
  173. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-DOPLn-V5.js +8 -0
  174. package/dist/domains/dashboard/web/assets/{timeline-definition-24CTP7MA-RVnG8rgK.js → timeline-definition-24CTP7MA-2YXSYkS3.js} +1 -1
  175. package/dist/domains/dashboard/web/assets/{treeView-Q6P3EWNA-B6lrg3KQ.js → treeView-Q6P3EWNA-DEGims38.js} +1 -1
  176. package/dist/domains/dashboard/web/assets/{treemap-WGGIJYW6-CJfMKVf4.js → treemap-WGGIJYW6-CJvBhTlR.js} +1 -1
  177. package/dist/domains/dashboard/web/assets/{vennDiagram-4TSXK5OY-CZMWJiN7.js → vennDiagram-4TSXK5OY-CHdNWhBK.js} +1 -1
  178. package/dist/domains/dashboard/web/assets/{wardley-WFR3VGLG-BoUsbNlx.js → wardley-WFR3VGLG-CVO9PCjo.js} +1 -1
  179. package/dist/domains/dashboard/web/assets/{wardleyDiagram-VM6X3IG4-BwBCykVb.js → wardleyDiagram-VM6X3IG4-RToPmij6.js} +1 -1
  180. package/dist/domains/dashboard/web/assets/{xychartDiagram-S5SC5T6Z-vutnbx57.js → xychartDiagram-S5SC5T6Z-DaWHnpHE.js} +1 -1
  181. package/dist/domains/dashboard/web/index.html +1 -1
  182. package/dist/domains/project-knowledge/host-review.d.ts +15 -2
  183. package/dist/domains/project-knowledge/host-review.d.ts.map +1 -1
  184. package/dist/domains/project-knowledge/host-review.js +65 -25
  185. package/dist/domains/project-knowledge/host-review.js.map +1 -1
  186. package/dist/domains/project-knowledge/index.d.ts +1 -0
  187. package/dist/domains/project-knowledge/index.d.ts.map +1 -1
  188. package/dist/domains/project-knowledge/index.js +1 -0
  189. package/dist/domains/project-knowledge/index.js.map +1 -1
  190. package/dist/domains/project-knowledge/learning.d.ts +2 -1
  191. package/dist/domains/project-knowledge/learning.d.ts.map +1 -1
  192. package/dist/domains/project-knowledge/learning.js +6 -0
  193. package/dist/domains/project-knowledge/learning.js.map +1 -1
  194. package/dist/domains/project-knowledge/plugin.d.ts.map +1 -1
  195. package/dist/domains/project-knowledge/plugin.js +3 -1
  196. package/dist/domains/project-knowledge/plugin.js.map +1 -1
  197. package/dist/domains/skill/dsh-adapter.d.ts +5 -1
  198. package/dist/domains/skill/dsh-adapter.d.ts.map +1 -1
  199. package/dist/domains/skill/dsh-adapter.js +222 -87
  200. package/dist/domains/skill/dsh-adapter.js.map +1 -1
  201. package/dist/domains/skill/platform-inspect.d.ts +1 -0
  202. package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
  203. package/dist/domains/skill/platform-inspect.js +8 -4
  204. package/dist/domains/skill/platform-inspect.js.map +1 -1
  205. package/dist/domains/skill/platform-install.d.ts.map +1 -1
  206. package/dist/domains/skill/platform-install.js +7 -7
  207. package/dist/domains/skill/platform-install.js.map +1 -1
  208. package/dist/platform/fs/file-system.d.ts +2 -0
  209. package/dist/platform/fs/file-system.d.ts.map +1 -1
  210. package/dist/platform/fs/file-system.js +11 -0
  211. package/dist/platform/fs/file-system.js.map +1 -1
  212. package/dist/platform/install/dsh-profiles.d.ts +3 -0
  213. package/dist/platform/install/dsh-profiles.d.ts.map +1 -0
  214. package/dist/platform/install/dsh-profiles.js +40 -0
  215. package/dist/platform/install/dsh-profiles.js.map +1 -0
  216. package/dist/platform/install/platforms.d.ts.map +1 -1
  217. package/dist/platform/install/platforms.js +1 -0
  218. package/dist/platform/install/platforms.js.map +1 -1
  219. package/dist/platform/install/project-registry.d.ts +7 -1
  220. package/dist/platform/install/project-registry.d.ts.map +1 -1
  221. package/dist/platform/install/project-registry.js +49 -5
  222. package/dist/platform/install/project-registry.js.map +1 -1
  223. package/dist/platform/paths/project-worktree-root.d.ts +3 -0
  224. package/dist/platform/paths/project-worktree-root.d.ts.map +1 -0
  225. package/dist/platform/paths/project-worktree-root.js +14 -0
  226. package/dist/platform/paths/project-worktree-root.js.map +1 -0
  227. package/dist/platform/process/hook-adapter.d.ts.map +1 -1
  228. package/dist/platform/process/hook-adapter.js +13 -0
  229. package/dist/platform/process/hook-adapter.js.map +1 -1
  230. package/eval/local/tasks/comet-classic-layout-lifecycle/environment/current-comet-package.json +11 -3
  231. package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/environment/current-comet-package.json +11 -3
  232. package/eval/local/tests/scaffold/test_task_resolution.py +6 -2
  233. package/package.json +14 -8
  234. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-YphM8Wtg.js +0 -1
  235. package/dist/domains/dashboard/web/assets/channel-BkwcGbYR.js +0 -1
  236. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-DzpQhyL3.js +0 -1
  237. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-DzpQhyL3.js +0 -1
  238. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-CG-cVTEg.js +0 -1
  239. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-C3RaJz-z.js +0 -1
  240. package/dist/domains/dashboard/web/assets/katex-CXMH3UgJ.js +0 -257
  241. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-BM35gYWg.js +0 -1
  242. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-CN60GGp0.js +0 -1
  243. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-DRUSW4g7.js +0 -1
  244. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-BL6vE1m9.js +0 -1
  245. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-XHK_nuTj.js +0 -8
@@ -1,41 +1,41 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var Rv=Object.create;var Zo=Object.defineProperty;var Pv=Object.getOwnPropertyDescriptor;var _v=Object.getOwnPropertyNames;var Av=Object.getPrototypeOf,Iv=Object.prototype.hasOwnProperty;var jn=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var x=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(i){throw r=[i],i}};var k=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Tv=(t,e)=>{for(var r in e)Zo(t,r,{get:e[r],enumerable:!0})},jv=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _v(e))!Iv.call(t,n)&&n!==r&&Zo(t,n,{get:()=>e[n],enumerable:!(i=Pv(e,n))||i.enumerable});return t};var et=(t,e,r)=>(r=t!=null?Rv(Av(t)):{},jv(e||!t||!t.__esModule?Zo(r,"default",{value:t,enumerable:!0}):r,t));var A=k(X=>{"use strict";var es=Symbol.for("yaml.alias"),Ru=Symbol.for("yaml.document"),$n=Symbol.for("yaml.map"),Pu=Symbol.for("yaml.pair"),ts=Symbol.for("yaml.scalar"),On=Symbol.for("yaml.seq"),tt=Symbol.for("yaml.node.type"),$v=t=>!!t&&typeof t=="object"&&t[tt]===es,Ov=t=>!!t&&typeof t=="object"&&t[tt]===Ru,Hv=t=>!!t&&typeof t=="object"&&t[tt]===$n,Dv=t=>!!t&&typeof t=="object"&&t[tt]===Pu,_u=t=>!!t&&typeof t=="object"&&t[tt]===ts,Bv=t=>!!t&&typeof t=="object"&&t[tt]===On;function Au(t){if(t&&typeof t=="object")switch(t[tt]){case $n:case On:return!0}return!1}function Lv(t){if(t&&typeof t=="object")switch(t[tt]){case es:case $n:case ts:case On:return!0}return!1}var Fv=t=>(_u(t)||Au(t))&&!!t.anchor;X.ALIAS=es;X.DOC=Ru;X.MAP=$n;X.NODE_TYPE=tt;X.PAIR=Pu;X.SCALAR=ts;X.SEQ=On;X.hasAnchor=Fv;X.isAlias=$v;X.isCollection=Au;X.isDocument=Ov;X.isMap=Hv;X.isNode=Lv;X.isPair=Dv;X.isScalar=_u;X.isSeq=Bv});var ii=k(rs=>{"use strict";var z=A(),ce=Symbol("break visit"),Iu=Symbol("skip children"),Fe=Symbol("remove node");function Hn(t,e){let r=Tu(e);z.isDocument(t)?gr(null,t.contents,r,Object.freeze([t]))===Fe&&(t.contents=null):gr(null,t,r,Object.freeze([]))}Hn.BREAK=ce;Hn.SKIP=Iu;Hn.REMOVE=Fe;function gr(t,e,r,i){let n=ju(t,e,r,i);if(z.isNode(n)||z.isPair(n))return $u(t,i,n),gr(t,n,r,i);if(typeof n!="symbol"){if(z.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=gr(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ce)return ce;o===Fe&&(e.items.splice(a,1),a-=1)}}}else if(z.isPair(e)){i=Object.freeze(i.concat(e));let a=gr("key",e.key,r,i);if(a===ce)return ce;a===Fe&&(e.key=null);let o=gr("value",e.value,r,i);if(o===ce)return ce;o===Fe&&(e.value=null)}}return n}async function Dn(t,e){let r=Tu(e);z.isDocument(t)?await wr(null,t.contents,r,Object.freeze([t]))===Fe&&(t.contents=null):await wr(null,t,r,Object.freeze([]))}Dn.BREAK=ce;Dn.SKIP=Iu;Dn.REMOVE=Fe;async function wr(t,e,r,i){let n=await ju(t,e,r,i);if(z.isNode(n)||z.isPair(n))return $u(t,i,n),wr(t,n,r,i);if(typeof n!="symbol"){if(z.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await wr(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ce)return ce;o===Fe&&(e.items.splice(a,1),a-=1)}}}else if(z.isPair(e)){i=Object.freeze(i.concat(e));let a=await wr("key",e.key,r,i);if(a===ce)return ce;a===Fe&&(e.key=null);let o=await wr("value",e.value,r,i);if(o===ce)return ce;o===Fe&&(e.value=null)}}return n}function Tu(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function ju(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(z.isMap(e))return r.Map?.(t,e,i);if(z.isSeq(e))return r.Seq?.(t,e,i);if(z.isPair(e))return r.Pair?.(t,e,i);if(z.isScalar(e))return r.Scalar?.(t,e,i);if(z.isAlias(e))return r.Alias?.(t,e,i)}function $u(t,e,r){let i=e[e.length-1];if(z.isCollection(i))i.items[t]=r;else if(z.isPair(i))t==="key"?i.key=r:i.value=r;else if(z.isDocument(i))i.contents=r;else{let n=z.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}rs.visit=Hn;rs.visitAsync=Dn});var is=k(Hu=>{"use strict";var Ou=A(),qv=ii(),Mv={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Vv=t=>t.replace(/[!,[\]{}]/g,e=>Mv[e]),ni=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=e.match(/^(.*!)([^!]*)$/s);n||r(`The ${e} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,i]of Object.entries(this.tags))if(e.startsWith(i))return r+Vv(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&Ou.isNode(e.contents)){let a={};qv.visit(e.contents,(o,s)=>{Ou.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(`
5
- `)}};ni.defaultYaml={explicit:!1,version:"1.2"};ni.defaultTags={"!!":"tag:yaml.org,2002:"};Hu.Directives=ni});var Bn=k(ai=>{"use strict";var Du=A(),Wv=ii();function zv(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(r)}return!0}function Bu(t){let e=new Set;return Wv.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function Lu(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function Gv(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Bu(t));let o=Lu(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Du.isScalar(o.node)||Du.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:i}}ai.anchorIsValid=zv;ai.anchorNames=Bu;ai.createNodeAnchors=Gv;ai.findNewAnchor=Lu});var ns=k(Fu=>{"use strict";function oi(t,e,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=oi(t,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=oi(t,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=oi(t,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=oi(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}Fu.applyReviver=oi});var vt=k(Mu=>{"use strict";var Jv=A();function qu(t,e,r){if(Array.isArray(t))return t.map((i,n)=>qu(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!Jv.hasAnchor(t))return t.toJSON(e,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(t,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=t.toJSON(e,r);return r.onCreate&&r.onCreate(n),n}return typeof t=="bigint"&&!r?.keep?Number(t):t}Mu.toJS=qu});var Ln=k(Wu=>{"use strict";var Uv=ns(),Vu=A(),Kv=vt(),as=class{constructor(e){Object.defineProperty(this,Vu.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!Vu.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=Kv.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?Uv.applyReviver(a,{"":s},"",s):s}};Wu.NodeBase=as});var si=k(zu=>{"use strict";var Yv=Bn(),Xv=ii(),yr=A(),Qv=Ln(),Zv=vt(),os=class extends Qv.NodeBase{constructor(e){super(yr.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],Xv.visit(e,{Node:(a,o)=>{(yr.isAlias(o)||yr.hasAnchor(o))&&i.push(o)}}),r&&(r.aliasResolveCache=i));let n;for(let a of i){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,r){if(!r)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:a}=r,o=this.resolve(n,r);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=i.get(o);if(s||(Zv.toJS(o,null,r),s=i.get(o)),s?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=Fn(n,o,i)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,r,i){let n=`*${this.source}`;if(e){if(Yv.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(e.implicitKey)return`${n} `}return n}};function Fn(t,e,r){if(yr.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(yr.isCollection(e)){let i=0;for(let n of e.items){let a=Fn(t,n,r);a>i&&(i=a)}return i}else if(yr.isPair(e)){let i=Fn(t,e.key,r),n=Fn(t,e.value,r);return Math.max(i,n)}return 1}zu.Alias=os});var V=k(ss=>{"use strict";var eg=A(),tg=Ln(),rg=vt(),ig=t=>!t||typeof t!="function"&&typeof t!="object",gt=class extends tg.NodeBase{constructor(e){super(eg.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:rg.toJS(this.value,e,r)}toString(){return String(this.value)}};gt.BLOCK_FOLDED="BLOCK_FOLDED";gt.BLOCK_LITERAL="BLOCK_LITERAL";gt.PLAIN="PLAIN";gt.QUOTE_DOUBLE="QUOTE_DOUBLE";gt.QUOTE_SINGLE="QUOTE_SINGLE";ss.Scalar=gt;ss.isScalarValue=ig});var ci=k(Ju=>{"use strict";var ng=si(),zt=A(),Gu=V(),ag="tag:yaml.org,2002:";function og(t,e,r){if(e){let i=r.filter(a=>a.tag===e),n=i.find(a=>!a.format)??i[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return r.find(i=>i.identify?.(t)&&!i.format)}function sg(t,e,r){if(zt.isDocument(t)&&(t=t.contents),zt.isNode(t))return t;if(zt.isPair(t)){let u=r.schema[zt.MAP].createNode?.(r.schema,null,r);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=r,c;if(i&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new ng.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=ag+e.slice(2));let l=og(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new Gu.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?o[zt.MAP]:Symbol.iterator in Object(t)?o[zt.SEQ]:o[zt.MAP]}a&&(a(l),delete r.onTagObj);let d=l?.createNode?l.createNode(r.schema,t,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,t,r):new Gu.Scalar(t);return e?d.tag=e:l.default||(d.tag=l.tag),c&&(c.node=d),d}Ju.createNode=sg});var Mn=k(qn=>{"use strict";var cg=ci(),qe=A(),lg=Ln();function cs(t,e,r){let i=r;for(let n=e.length-1;n>=0;--n){let a=e[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return cg.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Uu=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,ls=class extends lg.NodeBase{constructor(e,r){super(e),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(e){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(r.schema=e),r.items=r.items.map(i=>qe.isNode(i)||qe.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(Uu(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(qe.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,cs(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[r,...i]=e;if(i.length===0)return this.delete(r);let n=this.get(r,!0);if(qe.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}getIn(e,r){let[i,...n]=e,a=this.get(i,!0);return n.length===0?!r&&qe.isScalar(a)?a.value:a:qe.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!qe.isPair(r))return!1;let i=r.value;return i==null||e&&qe.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[r,...i]=e;if(i.length===0)return this.has(r);let n=this.get(r,!0);return qe.isCollection(n)?n.hasIn(i):!1}setIn(e,r){let[i,...n]=e;if(n.length===0)this.set(i,r);else{let a=this.get(i,!0);if(qe.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,cs(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};qn.Collection=ls;qn.collectionFromPath=cs;qn.isEmptyPath=Uu});var li=k(Vn=>{"use strict";var ug=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function us(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var dg=(t,e,r)=>t.endsWith(`
6
- `)?us(r,e):r.includes(`
4
+ var Av=Object.create;var es=Object.defineProperty;var Iv=Object.getOwnPropertyDescriptor;var Tv=Object.getOwnPropertyNames;var jv=Object.getPrototypeOf,$v=Object.prototype.hasOwnProperty;var $n=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var x=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(i){throw r=[i],i}};var k=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Ov=(t,e)=>{for(var r in e)es(t,r,{get:e[r],enumerable:!0})},Hv=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Tv(e))!$v.call(t,n)&&n!==r&&es(t,n,{get:()=>e[n],enumerable:!(i=Iv(e,n))||i.enumerable});return t};var et=(t,e,r)=>(r=t!=null?Av(jv(t)):{},Hv(e||!t||!t.__esModule?es(r,"default",{value:t,enumerable:!0}):r,t));var A=k(X=>{"use strict";var ts=Symbol.for("yaml.alias"),Pu=Symbol.for("yaml.document"),On=Symbol.for("yaml.map"),_u=Symbol.for("yaml.pair"),rs=Symbol.for("yaml.scalar"),Hn=Symbol.for("yaml.seq"),tt=Symbol.for("yaml.node.type"),Dv=t=>!!t&&typeof t=="object"&&t[tt]===ts,Bv=t=>!!t&&typeof t=="object"&&t[tt]===Pu,Lv=t=>!!t&&typeof t=="object"&&t[tt]===On,Fv=t=>!!t&&typeof t=="object"&&t[tt]===_u,Au=t=>!!t&&typeof t=="object"&&t[tt]===rs,qv=t=>!!t&&typeof t=="object"&&t[tt]===Hn;function Iu(t){if(t&&typeof t=="object")switch(t[tt]){case On:case Hn:return!0}return!1}function Mv(t){if(t&&typeof t=="object")switch(t[tt]){case ts:case On:case rs:case Hn:return!0}return!1}var Vv=t=>(Au(t)||Iu(t))&&!!t.anchor;X.ALIAS=ts;X.DOC=Pu;X.MAP=On;X.NODE_TYPE=tt;X.PAIR=_u;X.SCALAR=rs;X.SEQ=Hn;X.hasAnchor=Vv;X.isAlias=Dv;X.isCollection=Iu;X.isDocument=Bv;X.isMap=Lv;X.isNode=Mv;X.isPair=Fv;X.isScalar=Au;X.isSeq=qv});var ii=k(is=>{"use strict";var z=A(),ce=Symbol("break visit"),Tu=Symbol("skip children"),Fe=Symbol("remove node");function Dn(t,e){let r=ju(e);z.isDocument(t)?gr(null,t.contents,r,Object.freeze([t]))===Fe&&(t.contents=null):gr(null,t,r,Object.freeze([]))}Dn.BREAK=ce;Dn.SKIP=Tu;Dn.REMOVE=Fe;function gr(t,e,r,i){let n=$u(t,e,r,i);if(z.isNode(n)||z.isPair(n))return Ou(t,i,n),gr(t,n,r,i);if(typeof n!="symbol"){if(z.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=gr(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ce)return ce;o===Fe&&(e.items.splice(a,1),a-=1)}}}else if(z.isPair(e)){i=Object.freeze(i.concat(e));let a=gr("key",e.key,r,i);if(a===ce)return ce;a===Fe&&(e.key=null);let o=gr("value",e.value,r,i);if(o===ce)return ce;o===Fe&&(e.value=null)}}return n}async function Bn(t,e){let r=ju(e);z.isDocument(t)?await wr(null,t.contents,r,Object.freeze([t]))===Fe&&(t.contents=null):await wr(null,t,r,Object.freeze([]))}Bn.BREAK=ce;Bn.SKIP=Tu;Bn.REMOVE=Fe;async function wr(t,e,r,i){let n=await $u(t,e,r,i);if(z.isNode(n)||z.isPair(n))return Ou(t,i,n),wr(t,n,r,i);if(typeof n!="symbol"){if(z.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await wr(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ce)return ce;o===Fe&&(e.items.splice(a,1),a-=1)}}}else if(z.isPair(e)){i=Object.freeze(i.concat(e));let a=await wr("key",e.key,r,i);if(a===ce)return ce;a===Fe&&(e.key=null);let o=await wr("value",e.value,r,i);if(o===ce)return ce;o===Fe&&(e.value=null)}}return n}function ju(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function $u(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(z.isMap(e))return r.Map?.(t,e,i);if(z.isSeq(e))return r.Seq?.(t,e,i);if(z.isPair(e))return r.Pair?.(t,e,i);if(z.isScalar(e))return r.Scalar?.(t,e,i);if(z.isAlias(e))return r.Alias?.(t,e,i)}function Ou(t,e,r){let i=e[e.length-1];if(z.isCollection(i))i.items[t]=r;else if(z.isPair(i))t==="key"?i.key=r:i.value=r;else if(z.isDocument(i))i.contents=r;else{let n=z.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}is.visit=Dn;is.visitAsync=Bn});var ns=k(Du=>{"use strict";var Hu=A(),Wv=ii(),zv={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Gv=t=>t.replace(/[!,[\]{}]/g,e=>zv[e]),ni=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=e.match(/^(.*!)([^!]*)$/s);n||r(`The ${e} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,i]of Object.entries(this.tags))if(e.startsWith(i))return r+Gv(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&Hu.isNode(e.contents)){let a={};Wv.visit(e.contents,(o,s)=>{Hu.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(`
5
+ `)}};ni.defaultYaml={explicit:!1,version:"1.2"};ni.defaultTags={"!!":"tag:yaml.org,2002:"};Du.Directives=ni});var Ln=k(ai=>{"use strict";var Bu=A(),Jv=ii();function Uv(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(r)}return!0}function Lu(t){let e=new Set;return Jv.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function Fu(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function Kv(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Lu(t));let o=Fu(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Bu.isScalar(o.node)||Bu.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:i}}ai.anchorIsValid=Uv;ai.anchorNames=Lu;ai.createNodeAnchors=Kv;ai.findNewAnchor=Fu});var as=k(qu=>{"use strict";function oi(t,e,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=oi(t,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=oi(t,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=oi(t,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=oi(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}qu.applyReviver=oi});var vt=k(Vu=>{"use strict";var Yv=A();function Mu(t,e,r){if(Array.isArray(t))return t.map((i,n)=>Mu(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!Yv.hasAnchor(t))return t.toJSON(e,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(t,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=t.toJSON(e,r);return r.onCreate&&r.onCreate(n),n}return typeof t=="bigint"&&!r?.keep?Number(t):t}Vu.toJS=Mu});var Fn=k(zu=>{"use strict";var Xv=as(),Wu=A(),Qv=vt(),os=class{constructor(e){Object.defineProperty(this,Wu.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!Wu.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=Qv.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?Xv.applyReviver(a,{"":s},"",s):s}};zu.NodeBase=os});var si=k(Gu=>{"use strict";var Zv=Ln(),eg=ii(),yr=A(),tg=Fn(),rg=vt(),ss=class extends tg.NodeBase{constructor(e){super(yr.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],eg.visit(e,{Node:(a,o)=>{(yr.isAlias(o)||yr.hasAnchor(o))&&i.push(o)}}),r&&(r.aliasResolveCache=i));let n;for(let a of i){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,r){if(!r)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:a}=r,o=this.resolve(n,r);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=i.get(o);if(s||(rg.toJS(o,null,r),s=i.get(o)),s?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=qn(n,o,i)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,r,i){let n=`*${this.source}`;if(e){if(Zv.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(e.implicitKey)return`${n} `}return n}};function qn(t,e,r){if(yr.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(yr.isCollection(e)){let i=0;for(let n of e.items){let a=qn(t,n,r);a>i&&(i=a)}return i}else if(yr.isPair(e)){let i=qn(t,e.key,r),n=qn(t,e.value,r);return Math.max(i,n)}return 1}Gu.Alias=ss});var V=k(cs=>{"use strict";var ig=A(),ng=Fn(),ag=vt(),og=t=>!t||typeof t!="function"&&typeof t!="object",gt=class extends ng.NodeBase{constructor(e){super(ig.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:ag.toJS(this.value,e,r)}toString(){return String(this.value)}};gt.BLOCK_FOLDED="BLOCK_FOLDED";gt.BLOCK_LITERAL="BLOCK_LITERAL";gt.PLAIN="PLAIN";gt.QUOTE_DOUBLE="QUOTE_DOUBLE";gt.QUOTE_SINGLE="QUOTE_SINGLE";cs.Scalar=gt;cs.isScalarValue=og});var ci=k(Uu=>{"use strict";var sg=si(),zt=A(),Ju=V(),cg="tag:yaml.org,2002:";function lg(t,e,r){if(e){let i=r.filter(a=>a.tag===e),n=i.find(a=>!a.format)??i[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return r.find(i=>i.identify?.(t)&&!i.format)}function ug(t,e,r){if(zt.isDocument(t)&&(t=t.contents),zt.isNode(t))return t;if(zt.isPair(t)){let u=r.schema[zt.MAP].createNode?.(r.schema,null,r);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=r,c;if(i&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new sg.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=cg+e.slice(2));let l=lg(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new Ju.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?o[zt.MAP]:Symbol.iterator in Object(t)?o[zt.SEQ]:o[zt.MAP]}a&&(a(l),delete r.onTagObj);let d=l?.createNode?l.createNode(r.schema,t,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,t,r):new Ju.Scalar(t);return e?d.tag=e:l.default||(d.tag=l.tag),c&&(c.node=d),d}Uu.createNode=ug});var Vn=k(Mn=>{"use strict";var dg=ci(),qe=A(),pg=Fn();function ls(t,e,r){let i=r;for(let n=e.length-1;n>=0;--n){let a=e[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return dg.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Ku=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,us=class extends pg.NodeBase{constructor(e,r){super(e),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(e){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(r.schema=e),r.items=r.items.map(i=>qe.isNode(i)||qe.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(Ku(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(qe.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,ls(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[r,...i]=e;if(i.length===0)return this.delete(r);let n=this.get(r,!0);if(qe.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}getIn(e,r){let[i,...n]=e,a=this.get(i,!0);return n.length===0?!r&&qe.isScalar(a)?a.value:a:qe.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!qe.isPair(r))return!1;let i=r.value;return i==null||e&&qe.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[r,...i]=e;if(i.length===0)return this.has(r);let n=this.get(r,!0);return qe.isCollection(n)?n.hasIn(i):!1}setIn(e,r){let[i,...n]=e;if(n.length===0)this.set(i,r);else{let a=this.get(i,!0);if(qe.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,ls(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Mn.Collection=us;Mn.collectionFromPath=ls;Mn.isEmptyPath=Ku});var li=k(Wn=>{"use strict";var fg=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function ds(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var hg=(t,e,r)=>t.endsWith(`
6
+ `)?ds(r,e):r.includes(`
7
7
  `)?`
8
- `+us(r,e):(t.endsWith(" ")?"":" ")+r;Vn.indentComment=us;Vn.lineComment=dg;Vn.stringifyComment=ug});var Yu=k(ui=>{"use strict";var pg="flow",ds="block",Wn="quoted";function fg(t,e,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return t;n<a&&(a=0);let c=Math.max(1+a,1+n-e.length);if(t.length<=c)return t;let l=[],d={},u=n-e.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):u=n-i);let p,f,m=!1,h=-1,g=-1,v=-1;r===ds&&(h=Ku(t,h,e.length),h!==-1&&(u=h+c));for(let b;b=t[h+=1];){if(r===Wn&&b==="\\"){switch(g=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}v=h}if(b===`
9
- `)r===ds&&(h=Ku(t,h,e.length)),u=h+e.length+c,p=void 0;else{if(b===" "&&f&&f!==" "&&f!==`
8
+ `+ds(r,e):(t.endsWith(" ")?"":" ")+r;Wn.indentComment=ds;Wn.lineComment=hg;Wn.stringifyComment=fg});var Xu=k(ui=>{"use strict";var mg="flow",ps="block",zn="quoted";function vg(t,e,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return t;n<a&&(a=0);let c=Math.max(1+a,1+n-e.length);if(t.length<=c)return t;let l=[],d={},u=n-e.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):u=n-i);let p,f,m=!1,h=-1,g=-1,v=-1;r===ps&&(h=Yu(t,h,e.length),h!==-1&&(u=h+c));for(let b;b=t[h+=1];){if(r===zn&&b==="\\"){switch(g=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}v=h}if(b===`
9
+ `)r===ps&&(h=Yu(t,h,e.length)),u=h+e.length+c,p=void 0;else{if(b===" "&&f&&f!==" "&&f!==`
10
10
  `&&f!==" "){let y=t[h+1];y&&y!==" "&&y!==`
11
- `&&y!==" "&&(p=h)}if(h>=u)if(p)l.push(p),u=p+c,p=void 0;else if(r===Wn){for(;f===" "||f===" ";)f=b,b=t[h+=1],m=!0;let y=h>v+1?h-2:g-1;if(d[y])return t;l.push(y),d[y]=!0,u=y+c,p=void 0}else m=!0}f=b}if(m&&s&&s(),l.length===0)return t;o&&o();let N=t.slice(0,l[0]);for(let b=0;b<l.length;++b){let y=l[b],E=l[b+1]||t.length;y===0?N=`
12
- ${e}${t.slice(0,E)}`:(r===Wn&&d[y]&&(N+=`${t[y]}\\`),N+=`
13
- ${e}${t.slice(y+1,E)}`)}return N}function Ku(t,e,r){let i=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+r)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
- `);i=e,n=e+1,a=t[n]}return i}ui.FOLD_BLOCK=ds;ui.FOLD_FLOW=pg;ui.FOLD_QUOTED=Wn;ui.foldFlowLines=fg});var pi=k(Xu=>{"use strict";var Ce=V(),wt=Yu(),Gn=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Jn=t=>/^(%|---|\.\.\.)/m.test(t);function hg(t,e,r){if(!e||e<0)return!1;let i=e-r,n=t.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
- `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function di(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(Jn(t)?" ":""),o="",s=0;for(let c=0,l=r[c];l;l=r[++c])if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n"&&(o+=r.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(r[c+1]){case"u":{o+=r.slice(s,c);let d=r.substr(c+2,4);switch(d){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:d.substr(0,2)==="00"?o+="\\x"+d.substr(2):o+=r.substr(c,6)}c+=5,s=c+1}break;case"n":if(i||r[c+2]==='"'||r.length<n)c+=1;else{for(o+=r.slice(s,c)+`
11
+ `&&y!==" "&&(p=h)}if(h>=u)if(p)l.push(p),u=p+c,p=void 0;else if(r===zn){for(;f===" "||f===" ";)f=b,b=t[h+=1],m=!0;let y=h>v+1?h-2:g-1;if(d[y])return t;l.push(y),d[y]=!0,u=y+c,p=void 0}else m=!0}f=b}if(m&&s&&s(),l.length===0)return t;o&&o();let N=t.slice(0,l[0]);for(let b=0;b<l.length;++b){let y=l[b],E=l[b+1]||t.length;y===0?N=`
12
+ ${e}${t.slice(0,E)}`:(r===zn&&d[y]&&(N+=`${t[y]}\\`),N+=`
13
+ ${e}${t.slice(y+1,E)}`)}return N}function Yu(t,e,r){let i=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+r)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
+ `);i=e,n=e+1,a=t[n]}return i}ui.FOLD_BLOCK=ps;ui.FOLD_FLOW=mg;ui.FOLD_QUOTED=zn;ui.foldFlowLines=vg});var pi=k(Qu=>{"use strict";var Ce=V(),wt=Xu(),Jn=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Un=t=>/^(%|---|\.\.\.)/m.test(t);function gg(t,e,r){if(!e||e<0)return!1;let i=e-r,n=t.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
+ `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function di(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(Un(t)?" ":""),o="",s=0;for(let c=0,l=r[c];l;l=r[++c])if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n"&&(o+=r.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(r[c+1]){case"u":{o+=r.slice(s,c);let d=r.substr(c+2,4);switch(d){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:d.substr(0,2)==="00"?o+="\\x"+d.substr(2):o+=r.substr(c,6)}c+=5,s=c+1}break;case"n":if(i||r[c+2]==='"'||r.length<n)c+=1;else{for(o+=r.slice(s,c)+`
16
16
 
17
17
  `;r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"';)o+=`
18
- `,c+=2;o+=a,r[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+r.slice(s):r,i?o:wt.foldFlowLines(o,a,wt.FOLD_QUOTED,Gn(e,!1))}function ps(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(t))return di(t,e);let r=e.indent||(Jn(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${r}`)+"'";return e.implicitKey?i:wt.foldFlowLines(i,r,wt.FOLD_FLOW,Gn(e,!1))}function Nr(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=di;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=ps:a&&!n?i=di:i=r?ps:di}return i(t,e)}var fs;try{fs=new RegExp(`(^|(?<!
18
+ `,c+=2;o+=a,r[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+r.slice(s):r,i?o:wt.foldFlowLines(o,a,wt.FOLD_QUOTED,Jn(e,!1))}function fs(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(t))return di(t,e);let r=e.indent||(Un(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${r}`)+"'";return e.implicitKey?i:wt.foldFlowLines(i,r,wt.FOLD_FLOW,Jn(e,!1))}function Nr(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=di;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=fs:a&&!n?i=di:i=r?fs:di}return i(t,e)}var hs;try{hs=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{fs=/\n+(?!\n|$)/g}function zn({comment:t,type:e,value:r},i,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=i.options;if(!o||/\n[\t ]+$/.test(r))return Nr(r,i);let l=i.indent||(i.forceBlockIndent||Jn(r)?" ":""),d=o==="literal"?!0:o==="folded"||e===Ce.Scalar.BLOCK_FOLDED?!1:e===Ce.Scalar.BLOCK_LITERAL?!0:!hg(r,c,l.length);if(!r)return d?`|
23
+ |$)`,"g")}catch{hs=/\n+(?!\n|$)/g}function Gn({comment:t,type:e,value:r},i,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=i.options;if(!o||/\n[\t ]+$/.test(r))return Nr(r,i);let l=i.indent||(i.forceBlockIndent||Un(r)?" ":""),d=o==="literal"?!0:o==="folded"||e===Ce.Scalar.BLOCK_FOLDED?!1:e===Ce.Scalar.BLOCK_LITERAL?!0:!gg(r,c,l.length);if(!r)return d?`|
24
24
  `:`>
25
25
  `;let u,p;for(p=r.length;p>0;--p){let E=r[p-1];if(E!==`
26
26
  `&&E!==" "&&E!==" ")break}let f=r.substring(p),m=f.indexOf(`
27
27
  `);m===-1?u="-":r===f||m!==f.length-1?(u="+",a&&a()):u="",f&&(r=r.slice(0,-f.length),f[f.length-1]===`
28
- `&&(f=f.slice(0,-1)),f=f.replace(fs,`$&${l}`));let h=!1,g,v=-1;for(g=0;g<r.length;++g){let E=r[g];if(E===" ")h=!0;else if(E===`
28
+ `&&(f=f.slice(0,-1)),f=f.replace(hs,`$&${l}`));let h=!1,g,v=-1;for(g=0;g<r.length;++g){let E=r[g];if(E===" ")h=!0;else if(E===`
29
29
  `)v=g;else break}let N=r.substring(0,v<g?v+1:g);N&&(r=r.substring(N.length),N=N.replace(/\n+/g,`$&${l}`));let y=(h?l?"2":"1":"")+u;if(t&&(y+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!d){let E=r.replace(/\n+/g,`
30
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),w=!1,_=Gn(i,!0);o!=="folded"&&e!==Ce.Scalar.BLOCK_FOLDED&&(_.onOverflow=()=>{w=!0});let S=wt.foldFlowLines(`${N}${E}${f}`,l,wt.FOLD_BLOCK,_);if(!w)return`>${y}
30
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),w=!1,_=Jn(i,!0);o!=="folded"&&e!==Ce.Scalar.BLOCK_FOLDED&&(_.onOverflow=()=>{w=!0});let S=wt.foldFlowLines(`${N}${E}${f}`,l,wt.FOLD_BLOCK,_);if(!w)return`>${y}
31
31
  ${l}${S}`}return r=r.replace(/\n+/g,`$&${l}`),`|${y}
32
- ${l}${N}${r}${f}`}function mg(t,e,r,i){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:d}=e;if(s&&a.includes(`
32
+ ${l}${N}${r}${f}`}function wg(t,e,r,i){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:d}=e;if(s&&a.includes(`
33
33
  `)||d&&/[[\]{},]/.test(a))return Nr(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||d||!a.includes(`
34
- `)?Nr(a,e):zn(t,e,r,i);if(!s&&!d&&n!==Ce.Scalar.PLAIN&&a.includes(`
35
- `))return zn(t,e,r,i);if(Jn(a)){if(c==="")return e.forceBlockIndent=!0,zn(t,e,r,i);if(s&&c===l)return Nr(a,e)}let u=a.replace(/\n+/g,`$&
36
- ${c}`);if(o){let p=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:f,tags:m}=e.doc.schema;if(m.some(p)||f?.some(p))return Nr(a,e)}return s?u:wt.foldFlowLines(u,c,wt.FOLD_FLOW,Gn(e,!1))}function vg(t,e,r,i){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==Ce.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Ce.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case Ce.Scalar.BLOCK_FOLDED:case Ce.Scalar.BLOCK_LITERAL:return n||a?Nr(o.value,e):zn(o,e,r,i);case Ce.Scalar.QUOTE_DOUBLE:return di(o.value,e);case Ce.Scalar.QUOTE_SINGLE:return ps(o.value,e);case Ce.Scalar.PLAIN:return mg(o,e,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:d,defaultStringType:u}=e.options,p=n&&d||u;if(l=c(p),l===null)throw new Error(`Unsupported default string type ${p}`)}return l}Xu.stringifyString=vg});var fi=k(hs=>{"use strict";var gg=Bn(),yt=A(),wg=li(),yg=pi();function Ng(t,e){let r=Object.assign({blockQuote:!0,commentString:wg.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:t,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function bg(t,e){if(e.tag){let n=t.filter(a=>a.tag===e.tag);if(n.length>0)return n.find(a=>a.format===e.format)??n[0]}let r,i;if(yt.isScalar(e)){i=e.value;let n=t.filter(a=>a.identify?.(i));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}r=n.find(a=>a.format===e.format)??n.find(a=>!a.format)}else i=e,r=t.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return r}function kg(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(yt.isScalar(t)||yt.isCollection(t))&&t.anchor;a&&gg.anchorIsValid(a)&&(r.add(a),n.push(`&${a}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function Sg(t,e,r,i){if(yt.isPair(t))return t.toString(e,r,i);if(yt.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let n,a=yt.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=bg(e.doc.schema.tags,a));let o=kg(a,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,e,r,i):yt.isScalar(a)?yg.stringifyString(a,e,r,i):a.toString(e,r,i);return o?yt.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${e.indent}${s}`:s}hs.createStringifyContext=Ng;hs.stringify=Sg});var td=k(ed=>{"use strict";var rt=A(),Qu=V(),Zu=fi(),hi=li();function Eg({key:t,value:e},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:u}}=r,p=rt.isNode(t)&&t.comment||null;if(u){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(rt.isCollection(t)||!rt.isNode(t)&&typeof t=="object"){let _="With simple keys, collection cannot be used as a key value";throw new Error(_)}}let f=!u&&(!t||p&&e==null&&!r.inFlow||rt.isCollection(t)||(rt.isScalar(t)?t.type===Qu.Scalar.BLOCK_FOLDED||t.type===Qu.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!f&&(u||!a),indent:s+c});let m=!1,h=!1,g=Zu.stringify(t,r,()=>m=!0,()=>h=!0);if(!f&&!r.inFlow&&g.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");f=!0}if(r.inFlow){if(a||e==null)return m&&i&&i(),g===""?"?":f?`? ${g}`:g}else if(a&&!u||e==null&&f)return g=`? ${g}`,p&&!m?g+=hi.lineComment(g,r.indent,l(p)):h&&n&&n(),g;m&&(p=null),f?(p&&(g+=hi.lineComment(g,r.indent,l(p))),g=`? ${g}
38
- ${s}:`):(g=`${g}:`,p&&(g+=hi.lineComment(g,r.indent,l(p))));let v,N,b;rt.isNode(e)?(v=!!e.spaceBefore,N=e.commentBefore,b=e.comment):(v=!1,N=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!f&&!p&&rt.isScalar(e)&&(r.indentAtStart=g.length+1),h=!1,!d&&c.length>=2&&!r.inFlow&&!f&&rt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let y=!1,E=Zu.stringify(e,r,()=>y=!0,()=>h=!0),w=" ";if(p||v||N){if(w=v?`
34
+ `)?Nr(a,e):Gn(t,e,r,i);if(!s&&!d&&n!==Ce.Scalar.PLAIN&&a.includes(`
35
+ `))return Gn(t,e,r,i);if(Un(a)){if(c==="")return e.forceBlockIndent=!0,Gn(t,e,r,i);if(s&&c===l)return Nr(a,e)}let u=a.replace(/\n+/g,`$&
36
+ ${c}`);if(o){let p=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:f,tags:m}=e.doc.schema;if(m.some(p)||f?.some(p))return Nr(a,e)}return s?u:wt.foldFlowLines(u,c,wt.FOLD_FLOW,Jn(e,!1))}function yg(t,e,r,i){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==Ce.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Ce.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case Ce.Scalar.BLOCK_FOLDED:case Ce.Scalar.BLOCK_LITERAL:return n||a?Nr(o.value,e):Gn(o,e,r,i);case Ce.Scalar.QUOTE_DOUBLE:return di(o.value,e);case Ce.Scalar.QUOTE_SINGLE:return fs(o.value,e);case Ce.Scalar.PLAIN:return wg(o,e,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:d,defaultStringType:u}=e.options,p=n&&d||u;if(l=c(p),l===null)throw new Error(`Unsupported default string type ${p}`)}return l}Qu.stringifyString=yg});var fi=k(ms=>{"use strict";var Ng=Ln(),yt=A(),bg=li(),kg=pi();function Sg(t,e){let r=Object.assign({blockQuote:!0,commentString:bg.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:t,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function Eg(t,e){if(e.tag){let n=t.filter(a=>a.tag===e.tag);if(n.length>0)return n.find(a=>a.format===e.format)??n[0]}let r,i;if(yt.isScalar(e)){i=e.value;let n=t.filter(a=>a.identify?.(i));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}r=n.find(a=>a.format===e.format)??n.find(a=>!a.format)}else i=e,r=t.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return r}function xg(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(yt.isScalar(t)||yt.isCollection(t))&&t.anchor;a&&Ng.anchorIsValid(a)&&(r.add(a),n.push(`&${a}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function Cg(t,e,r,i){if(yt.isPair(t))return t.toString(e,r,i);if(yt.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let n,a=yt.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Eg(e.doc.schema.tags,a));let o=xg(a,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,e,r,i):yt.isScalar(a)?kg.stringifyString(a,e,r,i):a.toString(e,r,i);return o?yt.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${e.indent}${s}`:s}ms.createStringifyContext=Sg;ms.stringify=Cg});var rd=k(td=>{"use strict";var rt=A(),Zu=V(),ed=fi(),hi=li();function Rg({key:t,value:e},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:u}}=r,p=rt.isNode(t)&&t.comment||null;if(u){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(rt.isCollection(t)||!rt.isNode(t)&&typeof t=="object"){let _="With simple keys, collection cannot be used as a key value";throw new Error(_)}}let f=!u&&(!t||p&&e==null&&!r.inFlow||rt.isCollection(t)||(rt.isScalar(t)?t.type===Zu.Scalar.BLOCK_FOLDED||t.type===Zu.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!f&&(u||!a),indent:s+c});let m=!1,h=!1,g=ed.stringify(t,r,()=>m=!0,()=>h=!0);if(!f&&!r.inFlow&&g.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");f=!0}if(r.inFlow){if(a||e==null)return m&&i&&i(),g===""?"?":f?`? ${g}`:g}else if(a&&!u||e==null&&f)return g=`? ${g}`,p&&!m?g+=hi.lineComment(g,r.indent,l(p)):h&&n&&n(),g;m&&(p=null),f?(p&&(g+=hi.lineComment(g,r.indent,l(p))),g=`? ${g}
38
+ ${s}:`):(g=`${g}:`,p&&(g+=hi.lineComment(g,r.indent,l(p))));let v,N,b;rt.isNode(e)?(v=!!e.spaceBefore,N=e.commentBefore,b=e.comment):(v=!1,N=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!f&&!p&&rt.isScalar(e)&&(r.indentAtStart=g.length+1),h=!1,!d&&c.length>=2&&!r.inFlow&&!f&&rt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let y=!1,E=ed.stringify(e,r,()=>y=!0,()=>h=!0),w=" ";if(p||v||N){if(w=v?`
39
39
  `:"",N){let _=l(N);w+=`
40
40
  ${hi.indentComment(_,r.indent)}`}E===""&&!r.inFlow?w===`
41
41
  `&&b&&(w=`
@@ -44,34 +44,34 @@ ${hi.indentComment(_,r.indent)}`}E===""&&!r.inFlow?w===`
44
44
  ${r.indent}`}else if(!f&&rt.isCollection(e)){let _=E[0],S=E.indexOf(`
45
45
  `),T=S!==-1,Q=r.inFlow??e.flow??e.items.length===0;if(T||!Q){let xe=!1;if(T&&(_==="&"||_==="!")){let q=E.indexOf(" ");_==="&"&&q!==-1&&q<S&&E[q+1]==="!"&&(q=E.indexOf(" ",q+1)),(q===-1||S<q)&&(xe=!0)}xe||(w=`
46
46
  ${r.indent}`)}}else(E===""||E[0]===`
47
- `)&&(w="");return g+=w+E,r.inFlow?y&&i&&i():b&&!y?g+=hi.lineComment(g,r.indent,l(b)):h&&n&&n(),g}ed.stringifyPair=Eg});var vs=k(ms=>{"use strict";var rd=jn("process");function xg(t,...e){t==="debug"&&console.log(...e)}function Cg(t,e){(t==="debug"||t==="warn")&&(typeof rd.emitWarning=="function"?rd.emitWarning(e):console.warn(e))}ms.debug=xg;ms.warn=Cg});var Qn=k(Xn=>{"use strict";var Yn=A(),id=V(),Un="<<",Kn={identify:t=>t===Un||typeof t=="symbol"&&t.description===Un,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new id.Scalar(Symbol(Un)),{addToJSMap:nd}),stringify:()=>Un},Rg=(t,e)=>(Kn.identify(e)||Yn.isScalar(e)&&(!e.type||e.type===id.Scalar.PLAIN)&&Kn.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===Kn.tag&&r.default);function nd(t,e,r){let i=ad(t,r);if(Yn.isSeq(i))for(let n of i.items)gs(t,e,n);else if(Array.isArray(i))for(let n of i)gs(t,e,n);else gs(t,e,i)}function gs(t,e,r){let i=ad(t,r);if(!Yn.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,t,Map);for(let[a,o]of n)e instanceof Map?e.has(a)||e.set(a,o):e instanceof Set?e.add(a):Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function ad(t,e){return t&&Yn.isAlias(e)?e.resolve(t.doc,t):e}Xn.addMergeToJSMap=nd;Xn.isMergeKey=Rg;Xn.merge=Kn});var ys=k(cd=>{"use strict";var Pg=vs(),od=Qn(),_g=fi(),sd=A(),ws=vt();function Ag(t,e,{key:r,value:i}){if(sd.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(od.isMergeKey(t,r))od.addMergeToJSMap(t,e,i);else{let n=ws.toJS(r,"",t);if(e instanceof Map)e.set(n,ws.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=Ig(r,n,t),o=ws.toJS(i,a,t);a in e?Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[a]=o}}return e}function Ig(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(sd.isNode(t)&&r?.doc){let i=_g.createStringifyContext(r.doc,{});i.anchors=new Set;for(let a of r.anchors.keys())i.anchors.add(a.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=t.toString(i);if(!r.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Pg.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(e)}cd.addPairToJSMap=Ag});var Nt=k(Ns=>{"use strict";var ld=ci(),Tg=td(),jg=ys(),Zn=A();function $g(t,e,r){let i=ld.createNode(t,void 0,r),n=ld.createNode(e,void 0,r);return new ea(i,n)}var ea=class t{constructor(e,r=null){Object.defineProperty(this,Zn.NODE_TYPE,{value:Zn.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return Zn.isNode(r)&&(r=r.clone(e)),Zn.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return jg.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?Tg.stringifyPair(this,e,r,i):JSON.stringify(this)}};Ns.Pair=ea;Ns.createPair=$g});var bs=k(dd=>{"use strict";var Gt=A(),ud=fi(),ta=li();function Og(t,e,r){return(e.inFlow??t.flow?Dg:Hg)(t,e,r)}function Hg({comment:t,items:e},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,d=Object.assign({},r,{indent:a,type:null}),u=!1,p=[];for(let m=0;m<e.length;++m){let h=e[m],g=null;if(Gt.isNode(h))!u&&h.spaceBefore&&p.push(""),ra(r,p,h.commentBefore,u),h.comment&&(g=h.comment);else if(Gt.isPair(h)){let N=Gt.isNode(h.key)?h.key:null;N&&(!u&&N.spaceBefore&&p.push(""),ra(r,p,N.commentBefore,u))}u=!1;let v=ud.stringify(h,d,()=>g=null,()=>u=!0);g&&(v+=ta.lineComment(v,a,l(g))),u&&g&&(u=!1),p.push(i+v)}let f;if(p.length===0)f=n.start+n.end;else{f=p[0];for(let m=1;m<p.length;++m){let h=p[m];f+=h?`
47
+ `)&&(w="");return g+=w+E,r.inFlow?y&&i&&i():b&&!y?g+=hi.lineComment(g,r.indent,l(b)):h&&n&&n(),g}td.stringifyPair=Rg});var gs=k(vs=>{"use strict";var id=$n("process");function Pg(t,...e){t==="debug"&&console.log(...e)}function _g(t,e){(t==="debug"||t==="warn")&&(typeof id.emitWarning=="function"?id.emitWarning(e):console.warn(e))}vs.debug=Pg;vs.warn=_g});var Zn=k(Qn=>{"use strict";var Xn=A(),nd=V(),Kn="<<",Yn={identify:t=>t===Kn||typeof t=="symbol"&&t.description===Kn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new nd.Scalar(Symbol(Kn)),{addToJSMap:ad}),stringify:()=>Kn},Ag=(t,e)=>(Yn.identify(e)||Xn.isScalar(e)&&(!e.type||e.type===nd.Scalar.PLAIN)&&Yn.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===Yn.tag&&r.default);function ad(t,e,r){let i=od(t,r);if(Xn.isSeq(i))for(let n of i.items)ws(t,e,n);else if(Array.isArray(i))for(let n of i)ws(t,e,n);else ws(t,e,i)}function ws(t,e,r){let i=od(t,r);if(!Xn.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,t,Map);for(let[a,o]of n)e instanceof Map?e.has(a)||e.set(a,o):e instanceof Set?e.add(a):Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function od(t,e){return t&&Xn.isAlias(e)?e.resolve(t.doc,t):e}Qn.addMergeToJSMap=ad;Qn.isMergeKey=Ag;Qn.merge=Yn});var Ns=k(ld=>{"use strict";var Ig=gs(),sd=Zn(),Tg=fi(),cd=A(),ys=vt();function jg(t,e,{key:r,value:i}){if(cd.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(sd.isMergeKey(t,r))sd.addMergeToJSMap(t,e,i);else{let n=ys.toJS(r,"",t);if(e instanceof Map)e.set(n,ys.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=$g(r,n,t),o=ys.toJS(i,a,t);a in e?Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[a]=o}}return e}function $g(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(cd.isNode(t)&&r?.doc){let i=Tg.createStringifyContext(r.doc,{});i.anchors=new Set;for(let a of r.anchors.keys())i.anchors.add(a.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=t.toString(i);if(!r.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Ig.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(e)}ld.addPairToJSMap=jg});var Nt=k(bs=>{"use strict";var ud=ci(),Og=rd(),Hg=Ns(),ea=A();function Dg(t,e,r){let i=ud.createNode(t,void 0,r),n=ud.createNode(e,void 0,r);return new ta(i,n)}var ta=class t{constructor(e,r=null){Object.defineProperty(this,ea.NODE_TYPE,{value:ea.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return ea.isNode(r)&&(r=r.clone(e)),ea.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return Hg.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?Og.stringifyPair(this,e,r,i):JSON.stringify(this)}};bs.Pair=ta;bs.createPair=Dg});var ks=k(pd=>{"use strict";var Gt=A(),dd=fi(),ra=li();function Bg(t,e,r){return(e.inFlow??t.flow?Fg:Lg)(t,e,r)}function Lg({comment:t,items:e},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,d=Object.assign({},r,{indent:a,type:null}),u=!1,p=[];for(let m=0;m<e.length;++m){let h=e[m],g=null;if(Gt.isNode(h))!u&&h.spaceBefore&&p.push(""),ia(r,p,h.commentBefore,u),h.comment&&(g=h.comment);else if(Gt.isPair(h)){let N=Gt.isNode(h.key)?h.key:null;N&&(!u&&N.spaceBefore&&p.push(""),ia(r,p,N.commentBefore,u))}u=!1;let v=dd.stringify(h,d,()=>g=null,()=>u=!0);g&&(v+=ra.lineComment(v,a,l(g))),u&&g&&(u=!1),p.push(i+v)}let f;if(p.length===0)f=n.start+n.end;else{f=p[0];for(let m=1;m<p.length;++m){let h=p[m];f+=h?`
48
48
  ${c}${h}`:`
49
49
  `}}return t?(f+=`
50
- `+ta.indentComment(l(t),c),s&&s()):u&&o&&o(),f}function Dg({items:t},e,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;i+=a;let c=Object.assign({},e,{indent:i,inFlow:!0,type:null}),l=!1,d=0,u=[];for(let m=0;m<t.length;++m){let h=t[m],g=null;if(Gt.isNode(h))h.spaceBefore&&u.push(""),ra(e,u,h.commentBefore,!1),h.comment&&(g=h.comment);else if(Gt.isPair(h)){let N=Gt.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&u.push(""),ra(e,u,N.commentBefore,!1),N.comment&&(l=!0));let b=Gt.isNode(h.value)?h.value:null;b?(b.comment&&(g=b.comment),b.commentBefore&&(l=!0)):h.value==null&&N?.comment&&(g=N.comment)}g&&(l=!0);let v=ud.stringify(h,c,()=>g=null);l||(l=u.length>d||v.includes(`
51
- `)),m<t.length-1?v+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((N,b)=>N+b.length+2,2)+(v.length+2)>e.options.lineWidth)),l&&(v+=",")),g&&(v+=ta.lineComment(v,i,s(g))),u.push(v),d=u.length}let{start:p,end:f}=r;if(u.length===0)return p+f;if(!l){let m=u.reduce((h,g)=>h+g.length+2,2);l=e.options.lineWidth>0&&m>e.options.lineWidth}if(l){let m=p;for(let h of u)m+=h?`
50
+ `+ra.indentComment(l(t),c),s&&s()):u&&o&&o(),f}function Fg({items:t},e,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;i+=a;let c=Object.assign({},e,{indent:i,inFlow:!0,type:null}),l=!1,d=0,u=[];for(let m=0;m<t.length;++m){let h=t[m],g=null;if(Gt.isNode(h))h.spaceBefore&&u.push(""),ia(e,u,h.commentBefore,!1),h.comment&&(g=h.comment);else if(Gt.isPair(h)){let N=Gt.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&u.push(""),ia(e,u,N.commentBefore,!1),N.comment&&(l=!0));let b=Gt.isNode(h.value)?h.value:null;b?(b.comment&&(g=b.comment),b.commentBefore&&(l=!0)):h.value==null&&N?.comment&&(g=N.comment)}g&&(l=!0);let v=dd.stringify(h,c,()=>g=null);l||(l=u.length>d||v.includes(`
51
+ `)),m<t.length-1?v+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((N,b)=>N+b.length+2,2)+(v.length+2)>e.options.lineWidth)),l&&(v+=",")),g&&(v+=ra.lineComment(v,i,s(g))),u.push(v),d=u.length}let{start:p,end:f}=r;if(u.length===0)return p+f;if(!l){let m=u.reduce((h,g)=>h+g.length+2,2);l=e.options.lineWidth>0&&m>e.options.lineWidth}if(l){let m=p;for(let h of u)m+=h?`
52
52
  ${a}${n}${h}`:`
53
53
  `;return`${m}
54
- ${n}${f}`}else return`${p}${o}${u.join(" ")}${o}${f}`}function ra({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=ta.indentComment(e(i),t);r.push(a.trimStart())}}dd.stringifyCollection=Og});var kt=k(Ss=>{"use strict";var Bg=bs(),Lg=ys(),Fg=Mn(),bt=A(),ia=Nt(),qg=V();function mi(t,e){let r=bt.isScalar(e)?e.value:e;for(let i of t)if(bt.isPair(i)&&(i.key===e||i.key===r||bt.isScalar(i.key)&&i.key.value===r))return i}var ks=class extends Fg.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(bt.MAP,e),this.items=[]}static from(e,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(e),s=(c,l)=>{if(typeof a=="function")l=a.call(r,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(ia.createPair(c,l,i))};if(r instanceof Map)for(let[c,l]of r)s(c,l);else if(r&&typeof r=="object")for(let c of Object.keys(r))s(c,r[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,r){let i;bt.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new ia.Pair(e,e?.value):i=new ia.Pair(e.key,e.value);let n=mi(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);bt.isScalar(n.value)&&qg.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(a){let o=this.items.findIndex(s=>a(i,s)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){let r=mi(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=mi(this.items,e)?.value;return(!r&&bt.isScalar(n)?n.value:n)??void 0}has(e){return!!mi(this.items,e)}set(e,r){this.add(new ia.Pair(e,r),!0)}toJSON(e,r,i){let n=i?new i:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(n);for(let a of this.items)Lg.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!bt.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Bg.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};Ss.YAMLMap=ks;Ss.findPair=mi});var br=k(fd=>{"use strict";var Mg=A(),pd=kt(),Vg={collection:"map",default:!0,nodeClass:pd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Mg.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>pd.YAMLMap.from(t,e,r)};fd.map=Vg});var St=k(hd=>{"use strict";var Wg=ci(),zg=bs(),Gg=Mn(),aa=A(),Jg=V(),Ug=vt(),Es=class extends Gg.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(aa.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=na(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=na(e);if(typeof i!="number")return;let n=this.items[i];return!r&&aa.isScalar(n)?n.value:n}has(e){let r=na(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=na(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];aa.isScalar(n)&&Jg.isScalarValue(r)?n.value=r:this.items[i]=r}toJSON(e,r){let i=[];r?.onCreate&&r.onCreate(i);let n=0;for(let a of this.items)i.push(Ug.toJS(a,String(n++),r));return i}toString(e,r,i){return e?zg.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:r}):JSON.stringify(this)}static from(e,r,i){let{replacer:n}=i,a=new this(e);if(r&&Symbol.iterator in Object(r)){let o=0;for(let s of r){if(typeof n=="function"){let c=r instanceof Set?s:String(o++);s=n.call(r,c,s)}a.items.push(Wg.createNode(s,void 0,i))}}return a}};function na(t){let e=aa.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}hd.YAMLSeq=Es});var kr=k(vd=>{"use strict";var Kg=A(),md=St(),Yg={collection:"seq",default:!0,nodeClass:md.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Kg.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>md.YAMLSeq.from(t,e,r)};vd.seq=Yg});var vi=k(gd=>{"use strict";var Xg=pi(),Qg={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,r,i){return e=Object.assign({actualString:!0},e),Xg.stringifyString(t,e,r,i)}};gd.string=Qg});var oa=k(Nd=>{"use strict";var wd=V(),yd={identify:t=>t==null,createNode:()=>new wd.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new wd.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&yd.test.test(t)?t:e.options.nullStr};Nd.nullTag=yd});var xs=k(kd=>{"use strict";var Zg=V(),bd={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Zg.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&bd.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};kd.boolTag=bd});var Sr=k(Sd=>{"use strict";function ew({format:t,minFractionDigits:e,tag:r,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(i,-0)?"-0":JSON.stringify(i);if(!t&&e&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=e-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Sd.stringifyNumber=ew});var Rs=k(sa=>{"use strict";var tw=V(),Cs=Sr(),rw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Cs.stringifyNumber},iw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Cs.stringifyNumber(t)}},nw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new tw.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:Cs.stringifyNumber};sa.float=nw;sa.floatExp=iw;sa.floatNaN=rw});var _s=k(la=>{"use strict";var Ed=Sr(),ca=t=>typeof t=="bigint"||Number.isInteger(t),Ps=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function xd(t,e,r){let{value:i}=t;return ca(i)&&i>=0?r+i.toString(e):Ed.stringifyNumber(t)}var aw={identify:t=>ca(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>Ps(t,2,8,r),stringify:t=>xd(t,8,"0o")},ow={identify:ca,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>Ps(t,0,10,r),stringify:Ed.stringifyNumber},sw={identify:t=>ca(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>Ps(t,2,16,r),stringify:t=>xd(t,16,"0x")};la.int=ow;la.intHex=sw;la.intOct=aw});var Rd=k(Cd=>{"use strict";var cw=br(),lw=oa(),uw=kr(),dw=vi(),pw=xs(),As=Rs(),Is=_s(),fw=[cw.map,uw.seq,dw.string,lw.nullTag,pw.boolTag,Is.intOct,Is.int,Is.intHex,As.floatNaN,As.floatExp,As.float];Cd.schema=fw});var Ad=k(_d=>{"use strict";var hw=V(),mw=br(),vw=kr();function Pd(t){return typeof t=="bigint"||Number.isInteger(t)}var ua=({value:t})=>JSON.stringify(t),gw=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ua},{identify:t=>t==null,createNode:()=>new hw.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ua},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:ua},{identify:Pd,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:r})=>r?BigInt(t):parseInt(t,10),stringify:({value:t})=>Pd(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:ua}],ww={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},yw=[mw.map,vw.seq].concat(gw,ww);_d.schema=yw});var js=k(Id=>{"use strict";var gi=jn("buffer"),Ts=V(),Nw=pi(),bw={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof gi.Buffer=="function")return gi.Buffer.from(t,"base64");if(typeof atob=="function"){let r=atob(t.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof gi.Buffer=="function")s=o instanceof gi.Buffer?o.toString("base64"):gi.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Ts.Scalar.BLOCK_LITERAL),e!==Ts.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),d=new Array(l);for(let u=0,p=0;u<l;++u,p+=c)d[u]=s.substr(p,c);s=d.join(e===Ts.Scalar.BLOCK_LITERAL?`
55
- `:" ")}return Nw.stringifyString({comment:t,type:e,value:s},i,n,a)}};Id.binary=bw});var fa=k(pa=>{"use strict";var da=A(),$s=Nt(),kw=V(),Sw=St();function Td(t,e){if(da.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!da.isPair(i)){if(da.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new $s.Pair(new kw.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
54
+ ${n}${f}`}else return`${p}${o}${u.join(" ")}${o}${f}`}function ia({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=ra.indentComment(e(i),t);r.push(a.trimStart())}}pd.stringifyCollection=Bg});var kt=k(Es=>{"use strict";var qg=ks(),Mg=Ns(),Vg=Vn(),bt=A(),na=Nt(),Wg=V();function mi(t,e){let r=bt.isScalar(e)?e.value:e;for(let i of t)if(bt.isPair(i)&&(i.key===e||i.key===r||bt.isScalar(i.key)&&i.key.value===r))return i}var Ss=class extends Vg.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(bt.MAP,e),this.items=[]}static from(e,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(e),s=(c,l)=>{if(typeof a=="function")l=a.call(r,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(na.createPair(c,l,i))};if(r instanceof Map)for(let[c,l]of r)s(c,l);else if(r&&typeof r=="object")for(let c of Object.keys(r))s(c,r[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,r){let i;bt.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new na.Pair(e,e?.value):i=new na.Pair(e.key,e.value);let n=mi(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);bt.isScalar(n.value)&&Wg.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(a){let o=this.items.findIndex(s=>a(i,s)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){let r=mi(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=mi(this.items,e)?.value;return(!r&&bt.isScalar(n)?n.value:n)??void 0}has(e){return!!mi(this.items,e)}set(e,r){this.add(new na.Pair(e,r),!0)}toJSON(e,r,i){let n=i?new i:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(n);for(let a of this.items)Mg.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!bt.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),qg.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};Es.YAMLMap=Ss;Es.findPair=mi});var br=k(hd=>{"use strict";var zg=A(),fd=kt(),Gg={collection:"map",default:!0,nodeClass:fd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return zg.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>fd.YAMLMap.from(t,e,r)};hd.map=Gg});var St=k(md=>{"use strict";var Jg=ci(),Ug=ks(),Kg=Vn(),oa=A(),Yg=V(),Xg=vt(),xs=class extends Kg.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(oa.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=aa(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=aa(e);if(typeof i!="number")return;let n=this.items[i];return!r&&oa.isScalar(n)?n.value:n}has(e){let r=aa(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=aa(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];oa.isScalar(n)&&Yg.isScalarValue(r)?n.value=r:this.items[i]=r}toJSON(e,r){let i=[];r?.onCreate&&r.onCreate(i);let n=0;for(let a of this.items)i.push(Xg.toJS(a,String(n++),r));return i}toString(e,r,i){return e?Ug.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:r}):JSON.stringify(this)}static from(e,r,i){let{replacer:n}=i,a=new this(e);if(r&&Symbol.iterator in Object(r)){let o=0;for(let s of r){if(typeof n=="function"){let c=r instanceof Set?s:String(o++);s=n.call(r,c,s)}a.items.push(Jg.createNode(s,void 0,i))}}return a}};function aa(t){let e=oa.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}md.YAMLSeq=xs});var kr=k(gd=>{"use strict";var Qg=A(),vd=St(),Zg={collection:"seq",default:!0,nodeClass:vd.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Qg.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>vd.YAMLSeq.from(t,e,r)};gd.seq=Zg});var vi=k(wd=>{"use strict";var ew=pi(),tw={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,r,i){return e=Object.assign({actualString:!0},e),ew.stringifyString(t,e,r,i)}};wd.string=tw});var sa=k(bd=>{"use strict";var yd=V(),Nd={identify:t=>t==null,createNode:()=>new yd.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new yd.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Nd.test.test(t)?t:e.options.nullStr};bd.nullTag=Nd});var Cs=k(Sd=>{"use strict";var rw=V(),kd={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new rw.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&kd.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};Sd.boolTag=kd});var Sr=k(Ed=>{"use strict";function iw({format:t,minFractionDigits:e,tag:r,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(i,-0)?"-0":JSON.stringify(i);if(!t&&e&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=e-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Ed.stringifyNumber=iw});var Ps=k(ca=>{"use strict";var nw=V(),Rs=Sr(),aw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Rs.stringifyNumber},ow={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Rs.stringifyNumber(t)}},sw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new nw.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:Rs.stringifyNumber};ca.float=sw;ca.floatExp=ow;ca.floatNaN=aw});var As=k(ua=>{"use strict";var xd=Sr(),la=t=>typeof t=="bigint"||Number.isInteger(t),_s=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function Cd(t,e,r){let{value:i}=t;return la(i)&&i>=0?r+i.toString(e):xd.stringifyNumber(t)}var cw={identify:t=>la(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>_s(t,2,8,r),stringify:t=>Cd(t,8,"0o")},lw={identify:la,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>_s(t,0,10,r),stringify:xd.stringifyNumber},uw={identify:t=>la(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>_s(t,2,16,r),stringify:t=>Cd(t,16,"0x")};ua.int=lw;ua.intHex=uw;ua.intOct=cw});var Pd=k(Rd=>{"use strict";var dw=br(),pw=sa(),fw=kr(),hw=vi(),mw=Cs(),Is=Ps(),Ts=As(),vw=[dw.map,fw.seq,hw.string,pw.nullTag,mw.boolTag,Ts.intOct,Ts.int,Ts.intHex,Is.floatNaN,Is.floatExp,Is.float];Rd.schema=vw});var Id=k(Ad=>{"use strict";var gw=V(),ww=br(),yw=kr();function _d(t){return typeof t=="bigint"||Number.isInteger(t)}var da=({value:t})=>JSON.stringify(t),Nw=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:da},{identify:t=>t==null,createNode:()=>new gw.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:da},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:da},{identify:_d,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:r})=>r?BigInt(t):parseInt(t,10),stringify:({value:t})=>_d(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:da}],bw={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},kw=[ww.map,yw.seq].concat(Nw,bw);Ad.schema=kw});var $s=k(Td=>{"use strict";var gi=$n("buffer"),js=V(),Sw=pi(),Ew={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof gi.Buffer=="function")return gi.Buffer.from(t,"base64");if(typeof atob=="function"){let r=atob(t.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof gi.Buffer=="function")s=o instanceof gi.Buffer?o.toString("base64"):gi.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=js.Scalar.BLOCK_LITERAL),e!==js.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),d=new Array(l);for(let u=0,p=0;u<l;++u,p+=c)d[u]=s.substr(p,c);s=d.join(e===js.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return Sw.stringifyString({comment:t,type:e,value:s},i,n,a)}};Td.binary=Ew});var ha=k(fa=>{"use strict";var pa=A(),Os=Nt(),xw=V(),Cw=St();function jd(t,e){if(pa.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!pa.isPair(i)){if(pa.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new Os.Pair(new xw.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
56
56
  ${n.key.commentBefore}`:i.commentBefore),i.comment){let a=n.value??n.key;a.comment=a.comment?`${i.comment}
57
- ${a.comment}`:i.comment}i=n}t.items[r]=da.isPair(i)?i:new $s.Pair(i)}}else e("Expected a sequence for this tag");return t}function jd(t,e,r){let{replacer:i}=r,n=new Sw.YAMLSeq(t);n.tag="tag:yaml.org,2002:pairs";let a=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof i=="function"&&(o=i.call(e,String(a++),o));let s,c;if(Array.isArray(o))if(o.length===2)s=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)s=l[0],c=o[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=o;n.items.push($s.createPair(s,c,r))}return n}var Ew={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Td,createNode:jd};pa.createPairs=jd;pa.pairs=Ew;pa.resolvePairs=Td});var Ds=k(Hs=>{"use strict";var $d=A(),Os=vt(),wi=kt(),xw=St(),Od=fa(),Jt=class t extends xw.YAMLSeq{constructor(){super(),this.add=wi.YAMLMap.prototype.add.bind(this),this.delete=wi.YAMLMap.prototype.delete.bind(this),this.get=wi.YAMLMap.prototype.get.bind(this),this.has=wi.YAMLMap.prototype.has.bind(this),this.set=wi.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if($d.isPair(n)?(a=Os.toJS(n.key,"",r),o=Os.toJS(n.value,a,r)):a=Os.toJS(n,"",r),i.has(a))throw new Error("Ordered maps must not include duplicate keys");i.set(a,o)}return i}static from(e,r,i){let n=Od.createPairs(e,r,i),a=new this;return a.items=n.items,a}};Jt.tag="tag:yaml.org,2002:omap";var Cw={collection:"seq",identify:t=>t instanceof Map,nodeClass:Jt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=Od.resolvePairs(t,e),i=[];for(let{key:n}of r.items)$d.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Jt,r)},createNode:(t,e,r)=>Jt.from(t,e,r)};Hs.YAMLOMap=Jt;Hs.omap=Cw});var Fd=k(Bs=>{"use strict";var Hd=V();function Dd({value:t,source:e},r){return e&&(t?Bd:Ld).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Bd={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Hd.Scalar(!0),stringify:Dd},Ld={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Hd.Scalar(!1),stringify:Dd};Bs.falseTag=Ld;Bs.trueTag=Bd});var qd=k(ha=>{"use strict";var Rw=V(),Ls=Sr(),Pw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ls.stringifyNumber},_w={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Ls.stringifyNumber(t)}},Aw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new Rw.Scalar(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(r!==-1){let i=t.substring(r+1).replace(/_/g,"");i[i.length-1]==="0"&&(e.minFractionDigits=i.length)}return e},stringify:Ls.stringifyNumber};ha.float=Aw;ha.floatExp=_w;ha.floatNaN=Pw});var Vd=k(Ni=>{"use strict";var Md=Sr(),yi=t=>typeof t=="bigint"||Number.isInteger(t);function ma(t,e,r,{intAsBigInt:i}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),i){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return n==="-"?BigInt(-1)*o:o}let a=parseInt(t,r);return n==="-"?-1*a:a}function Fs(t,e,r){let{value:i}=t;if(yi(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return Md.stringifyNumber(t)}var Iw={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>ma(t,2,2,r),stringify:t=>Fs(t,2,"0b")},Tw={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>ma(t,1,8,r),stringify:t=>Fs(t,8,"0")},jw={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>ma(t,0,10,r),stringify:Md.stringifyNumber},$w={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>ma(t,2,16,r),stringify:t=>Fs(t,16,"0x")};Ni.int=jw;Ni.intBin=Iw;Ni.intHex=$w;Ni.intOct=Tw});var Ms=k(qs=>{"use strict";var wa=A(),va=Nt(),ga=kt(),Ut=class t extends ga.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;wa.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new va.Pair(e.key,null):r=new va.Pair(e,null),ga.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=ga.findPair(this.items,e);return!r&&wa.isPair(i)?wa.isScalar(i.key)?i.key.value:i.key:i}set(e,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let i=ga.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new va.Pair(e))}toJSON(e,r){return super.toJSON(e,r,Set)}toString(e,r,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),r,i);throw new Error("Set items must all have null values")}static from(e,r,i){let{replacer:n}=i,a=new this(e);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),a.items.push(va.createPair(o,null,i));return a}};Ut.tag="tag:yaml.org,2002:set";var Ow={collection:"map",identify:t=>t instanceof Set,nodeClass:Ut,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>Ut.from(t,e,r),resolve(t,e){if(wa.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Ut,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};qs.YAMLSet=Ut;qs.set=Ow});var Ws=k(ya=>{"use strict";var Hw=Sr();function Vs(t,e){let r=t[0],i=r==="-"||r==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=i.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return r==="-"?n(-1)*a:a}function Wd(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Hw.stringifyNumber(t);let i="";e<0&&(i="-",e*=r(-1));let n=r(60),a=[e%n];return e<60?a.unshift(0):(e=(e-a[0])/n,a.unshift(e%n),e>=60&&(e=(e-a[0])/n,a.unshift(e))),i+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Dw={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>Vs(t,r),stringify:Wd},Bw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Vs(t,!1),stringify:Wd},zd={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(zd.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,a||0,o||0,s||0,c),d=e[8];if(d&&d!=="Z"){let u=Vs(d,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ya.floatTime=Bw;ya.intTime=Dw;ya.timestamp=zd});var Ud=k(Jd=>{"use strict";var Lw=br(),Fw=oa(),qw=kr(),Mw=vi(),Vw=js(),Gd=Fd(),zs=qd(),Na=Vd(),Ww=Qn(),zw=Ds(),Gw=fa(),Jw=Ms(),Gs=Ws(),Uw=[Lw.map,qw.seq,Mw.string,Fw.nullTag,Gd.trueTag,Gd.falseTag,Na.intBin,Na.intOct,Na.int,Na.intHex,zs.floatNaN,zs.floatExp,zs.float,Vw.binary,Ww.merge,zw.omap,Gw.pairs,Jw.set,Gs.intTime,Gs.floatTime,Gs.timestamp];Jd.schema=Uw});var np=k(Ks=>{"use strict";var Qd=br(),Kw=oa(),Zd=kr(),Yw=vi(),Xw=xs(),Js=Rs(),Us=_s(),Qw=Rd(),Zw=Ad(),ep=js(),bi=Qn(),tp=Ds(),rp=fa(),Kd=Ud(),ip=Ms(),ba=Ws(),Yd=new Map([["core",Qw.schema],["failsafe",[Qd.map,Zd.seq,Yw.string]],["json",Zw.schema],["yaml11",Kd.schema],["yaml-1.1",Kd.schema]]),Xd={binary:ep.binary,bool:Xw.boolTag,float:Js.float,floatExp:Js.floatExp,floatNaN:Js.floatNaN,floatTime:ba.floatTime,int:Us.int,intHex:Us.intHex,intOct:Us.intOct,intTime:ba.intTime,map:Qd.map,merge:bi.merge,null:Kw.nullTag,omap:tp.omap,pairs:rp.pairs,seq:Zd.seq,set:ip.set,timestamp:ba.timestamp},ey={"tag:yaml.org,2002:binary":ep.binary,"tag:yaml.org,2002:merge":bi.merge,"tag:yaml.org,2002:omap":tp.omap,"tag:yaml.org,2002:pairs":rp.pairs,"tag:yaml.org,2002:set":ip.set,"tag:yaml.org,2002:timestamp":ba.timestamp};function ty(t,e,r){let i=Yd.get(e);if(i&&!t)return r&&!i.includes(bi.merge)?i.concat(bi.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Yd.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${a} or define customTags array`)}if(Array.isArray(t))for(let a of t)n=n.concat(a);else typeof t=="function"&&(n=t(n.slice()));return r&&(n=n.concat(bi.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Xd[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Xd).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},[])}Ks.coreKnownTags=ey;Ks.getTags=ty});var Qs=k(ap=>{"use strict";var Ys=A(),ry=br(),iy=kr(),ny=vi(),ka=np(),ay=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Xs=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?ka.getTags(e,"compat"):e?ka.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?ka.coreKnownTags:{},this.tags=ka.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Ys.MAP,{value:ry.map}),Object.defineProperty(this,Ys.SCALAR,{value:ny.string}),Object.defineProperty(this,Ys.SEQ,{value:iy.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?ay:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};ap.Schema=Xs});var sp=k(op=>{"use strict";var oy=A(),Zs=fi(),ki=li();function sy(t,e){let r=[],i=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(r.push(c),i=!0):t.directives.docStart&&(i=!0)}i&&r.push("---");let n=Zs.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(ki.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(oy.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let d=a(t.contents.commentBefore);r.push(ki.indentComment(d,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=Zs.stringify(t.contents,n,()=>s=null,c);s&&(l+=ki.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(Zs.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
57
+ ${a.comment}`:i.comment}i=n}t.items[r]=pa.isPair(i)?i:new Os.Pair(i)}}else e("Expected a sequence for this tag");return t}function $d(t,e,r){let{replacer:i}=r,n=new Cw.YAMLSeq(t);n.tag="tag:yaml.org,2002:pairs";let a=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof i=="function"&&(o=i.call(e,String(a++),o));let s,c;if(Array.isArray(o))if(o.length===2)s=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)s=l[0],c=o[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=o;n.items.push(Os.createPair(s,c,r))}return n}var Rw={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:jd,createNode:$d};fa.createPairs=$d;fa.pairs=Rw;fa.resolvePairs=jd});var Bs=k(Ds=>{"use strict";var Od=A(),Hs=vt(),wi=kt(),Pw=St(),Hd=ha(),Jt=class t extends Pw.YAMLSeq{constructor(){super(),this.add=wi.YAMLMap.prototype.add.bind(this),this.delete=wi.YAMLMap.prototype.delete.bind(this),this.get=wi.YAMLMap.prototype.get.bind(this),this.has=wi.YAMLMap.prototype.has.bind(this),this.set=wi.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if(Od.isPair(n)?(a=Hs.toJS(n.key,"",r),o=Hs.toJS(n.value,a,r)):a=Hs.toJS(n,"",r),i.has(a))throw new Error("Ordered maps must not include duplicate keys");i.set(a,o)}return i}static from(e,r,i){let n=Hd.createPairs(e,r,i),a=new this;return a.items=n.items,a}};Jt.tag="tag:yaml.org,2002:omap";var _w={collection:"seq",identify:t=>t instanceof Map,nodeClass:Jt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=Hd.resolvePairs(t,e),i=[];for(let{key:n}of r.items)Od.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Jt,r)},createNode:(t,e,r)=>Jt.from(t,e,r)};Ds.YAMLOMap=Jt;Ds.omap=_w});var qd=k(Ls=>{"use strict";var Dd=V();function Bd({value:t,source:e},r){return e&&(t?Ld:Fd).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Ld={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Dd.Scalar(!0),stringify:Bd},Fd={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Dd.Scalar(!1),stringify:Bd};Ls.falseTag=Fd;Ls.trueTag=Ld});var Md=k(ma=>{"use strict";var Aw=V(),Fs=Sr(),Iw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Fs.stringifyNumber},Tw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Fs.stringifyNumber(t)}},jw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new Aw.Scalar(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(r!==-1){let i=t.substring(r+1).replace(/_/g,"");i[i.length-1]==="0"&&(e.minFractionDigits=i.length)}return e},stringify:Fs.stringifyNumber};ma.float=jw;ma.floatExp=Tw;ma.floatNaN=Iw});var Wd=k(Ni=>{"use strict";var Vd=Sr(),yi=t=>typeof t=="bigint"||Number.isInteger(t);function va(t,e,r,{intAsBigInt:i}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),i){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return n==="-"?BigInt(-1)*o:o}let a=parseInt(t,r);return n==="-"?-1*a:a}function qs(t,e,r){let{value:i}=t;if(yi(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return Vd.stringifyNumber(t)}var $w={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>va(t,2,2,r),stringify:t=>qs(t,2,"0b")},Ow={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>va(t,1,8,r),stringify:t=>qs(t,8,"0")},Hw={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>va(t,0,10,r),stringify:Vd.stringifyNumber},Dw={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>va(t,2,16,r),stringify:t=>qs(t,16,"0x")};Ni.int=Hw;Ni.intBin=$w;Ni.intHex=Dw;Ni.intOct=Ow});var Vs=k(Ms=>{"use strict";var ya=A(),ga=Nt(),wa=kt(),Ut=class t extends wa.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;ya.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new ga.Pair(e.key,null):r=new ga.Pair(e,null),wa.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=wa.findPair(this.items,e);return!r&&ya.isPair(i)?ya.isScalar(i.key)?i.key.value:i.key:i}set(e,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let i=wa.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new ga.Pair(e))}toJSON(e,r){return super.toJSON(e,r,Set)}toString(e,r,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),r,i);throw new Error("Set items must all have null values")}static from(e,r,i){let{replacer:n}=i,a=new this(e);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),a.items.push(ga.createPair(o,null,i));return a}};Ut.tag="tag:yaml.org,2002:set";var Bw={collection:"map",identify:t=>t instanceof Set,nodeClass:Ut,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>Ut.from(t,e,r),resolve(t,e){if(ya.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Ut,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Ms.YAMLSet=Ut;Ms.set=Bw});var zs=k(Na=>{"use strict";var Lw=Sr();function Ws(t,e){let r=t[0],i=r==="-"||r==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=i.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return r==="-"?n(-1)*a:a}function zd(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Lw.stringifyNumber(t);let i="";e<0&&(i="-",e*=r(-1));let n=r(60),a=[e%n];return e<60?a.unshift(0):(e=(e-a[0])/n,a.unshift(e%n),e>=60&&(e=(e-a[0])/n,a.unshift(e))),i+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Fw={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>Ws(t,r),stringify:zd},qw={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Ws(t,!1),stringify:zd},Gd={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Gd.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,a||0,o||0,s||0,c),d=e[8];if(d&&d!=="Z"){let u=Ws(d,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Na.floatTime=qw;Na.intTime=Fw;Na.timestamp=Gd});var Kd=k(Ud=>{"use strict";var Mw=br(),Vw=sa(),Ww=kr(),zw=vi(),Gw=$s(),Jd=qd(),Gs=Md(),ba=Wd(),Jw=Zn(),Uw=Bs(),Kw=ha(),Yw=Vs(),Js=zs(),Xw=[Mw.map,Ww.seq,zw.string,Vw.nullTag,Jd.trueTag,Jd.falseTag,ba.intBin,ba.intOct,ba.int,ba.intHex,Gs.floatNaN,Gs.floatExp,Gs.float,Gw.binary,Jw.merge,Uw.omap,Kw.pairs,Yw.set,Js.intTime,Js.floatTime,Js.timestamp];Ud.schema=Xw});var ap=k(Ys=>{"use strict";var Zd=br(),Qw=sa(),ep=kr(),Zw=vi(),ey=Cs(),Us=Ps(),Ks=As(),ty=Pd(),ry=Id(),tp=$s(),bi=Zn(),rp=Bs(),ip=ha(),Yd=Kd(),np=Vs(),ka=zs(),Xd=new Map([["core",ty.schema],["failsafe",[Zd.map,ep.seq,Zw.string]],["json",ry.schema],["yaml11",Yd.schema],["yaml-1.1",Yd.schema]]),Qd={binary:tp.binary,bool:ey.boolTag,float:Us.float,floatExp:Us.floatExp,floatNaN:Us.floatNaN,floatTime:ka.floatTime,int:Ks.int,intHex:Ks.intHex,intOct:Ks.intOct,intTime:ka.intTime,map:Zd.map,merge:bi.merge,null:Qw.nullTag,omap:rp.omap,pairs:ip.pairs,seq:ep.seq,set:np.set,timestamp:ka.timestamp},iy={"tag:yaml.org,2002:binary":tp.binary,"tag:yaml.org,2002:merge":bi.merge,"tag:yaml.org,2002:omap":rp.omap,"tag:yaml.org,2002:pairs":ip.pairs,"tag:yaml.org,2002:set":np.set,"tag:yaml.org,2002:timestamp":ka.timestamp};function ny(t,e,r){let i=Xd.get(e);if(i&&!t)return r&&!i.includes(bi.merge)?i.concat(bi.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Xd.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${a} or define customTags array`)}if(Array.isArray(t))for(let a of t)n=n.concat(a);else typeof t=="function"&&(n=t(n.slice()));return r&&(n=n.concat(bi.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Qd[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Qd).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}Ys.coreKnownTags=iy;Ys.getTags=ny});var Zs=k(op=>{"use strict";var Xs=A(),ay=br(),oy=kr(),sy=vi(),Sa=ap(),cy=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Qs=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Sa.getTags(e,"compat"):e?Sa.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Sa.coreKnownTags:{},this.tags=Sa.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Xs.MAP,{value:ay.map}),Object.defineProperty(this,Xs.SCALAR,{value:sy.string}),Object.defineProperty(this,Xs.SEQ,{value:oy.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?cy:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};op.Schema=Qs});var cp=k(sp=>{"use strict";var ly=A(),ec=fi(),ki=li();function uy(t,e){let r=[],i=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(r.push(c),i=!0):t.directives.docStart&&(i=!0)}i&&r.push("---");let n=ec.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(ki.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(ly.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let d=a(t.contents.commentBefore);r.push(ki.indentComment(d,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=ec.stringify(t.contents,n,()=>s=null,c);s&&(l+=ki.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(ec.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
58
  `)?(r.push("..."),r.push(ki.indentComment(c,""))):r.push(`... ${c}`)}else r.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&r[r.length-1]!==""&&r.push(""),r.push(ki.indentComment(a(c),"")))}return r.join(`
59
59
  `)+`
60
- `}op.stringifyDocument=sy});var Si=k(cp=>{"use strict";var cy=si(),Er=Mn(),ge=A(),ly=Nt(),uy=vt(),dy=Qs(),py=sp(),ec=Bn(),fy=ns(),hy=ci(),tc=is(),rc=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ge.NODE_TYPE,{value:ge.DOC});let n=null;typeof r=="function"||Array.isArray(r)?n=r:i===void 0&&r&&(i=r,r=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=a;let{version:o}=a;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new tc.Directives({version:o}),this.setSchema(o,i),this.contents=e===void 0?null:this.createNode(e,n,i)}clone(){let e=Object.create(t.prototype,{[ge.NODE_TYPE]:{value:ge.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=ge.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){xr(this.contents)&&this.contents.add(e)}addIn(e,r){xr(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=ec.anchorNames(this);e.anchor=!r||i.has(r)?ec.findNewAnchor(r||"a",i):r}return new cy.Alias(e.anchor)}createNode(e,r,i){let n;if(typeof r=="function")e=r.call({"":e},"",e),n=r;else if(Array.isArray(r)){let g=N=>typeof N=="number"||N instanceof String||N instanceof Number,v=r.filter(g).map(String);v.length>0&&(r=r.concat(v)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:d}=i??{},{onAnchor:u,setAnchors:p,sourceObjects:f}=ec.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:f},h=hy.createNode(e,d,m);return s&&ge.isCollection(h)&&(h.flow=!0),p(),h}createPair(e,r,i={}){let n=this.createNode(e,null,i),a=this.createNode(r,null,i);return new ly.Pair(n,a)}delete(e){return xr(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Er.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):xr(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return ge.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return Er.isEmptyPath(e)?!r&&ge.isScalar(this.contents)?this.contents.value:this.contents:ge.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return ge.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Er.isEmptyPath(e)?this.contents!==void 0:ge.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=Er.collectionFromPath(this.schema,[e],r):xr(this.contents)&&this.contents.set(e,r)}setIn(e,r){Er.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=Er.collectionFromPath(this.schema,Array.from(e),r):xr(this.contents)&&this.contents.setIn(e,r)}setSchema(e,r={}){typeof e=="number"&&(e=String(e));let i;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new tc.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new tc.Directives({version:e}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(i)this.schema=new dy.Schema(Object.assign(i,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:r,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=uy.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:d}of s.anchors.values())a(d,l);return typeof o=="function"?fy.applyReviver(o,{"":c},"",c):c}toJSON(e,r){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:r})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let r=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return py.stringifyDocument(this,e)}};function xr(t){if(ge.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}cp.Document=rc});var Ci=k(xi=>{"use strict";var Ei=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},ic=class extends Ei{constructor(e,r,i){super("YAMLParseError",e,r,i)}},nc=class extends Ei{constructor(e,r,i){super("YAMLWarning",e,r,i)}},my=(t,e)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>e.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[i-2],e.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
60
+ `}sp.stringifyDocument=uy});var Si=k(lp=>{"use strict";var dy=si(),Er=Vn(),ge=A(),py=Nt(),fy=vt(),hy=Zs(),my=cp(),tc=Ln(),vy=as(),gy=ci(),rc=ns(),ic=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ge.NODE_TYPE,{value:ge.DOC});let n=null;typeof r=="function"||Array.isArray(r)?n=r:i===void 0&&r&&(i=r,r=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=a;let{version:o}=a;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new rc.Directives({version:o}),this.setSchema(o,i),this.contents=e===void 0?null:this.createNode(e,n,i)}clone(){let e=Object.create(t.prototype,{[ge.NODE_TYPE]:{value:ge.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=ge.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){xr(this.contents)&&this.contents.add(e)}addIn(e,r){xr(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=tc.anchorNames(this);e.anchor=!r||i.has(r)?tc.findNewAnchor(r||"a",i):r}return new dy.Alias(e.anchor)}createNode(e,r,i){let n;if(typeof r=="function")e=r.call({"":e},"",e),n=r;else if(Array.isArray(r)){let g=N=>typeof N=="number"||N instanceof String||N instanceof Number,v=r.filter(g).map(String);v.length>0&&(r=r.concat(v)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:d}=i??{},{onAnchor:u,setAnchors:p,sourceObjects:f}=tc.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:f},h=gy.createNode(e,d,m);return s&&ge.isCollection(h)&&(h.flow=!0),p(),h}createPair(e,r,i={}){let n=this.createNode(e,null,i),a=this.createNode(r,null,i);return new py.Pair(n,a)}delete(e){return xr(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Er.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):xr(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return ge.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return Er.isEmptyPath(e)?!r&&ge.isScalar(this.contents)?this.contents.value:this.contents:ge.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return ge.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Er.isEmptyPath(e)?this.contents!==void 0:ge.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=Er.collectionFromPath(this.schema,[e],r):xr(this.contents)&&this.contents.set(e,r)}setIn(e,r){Er.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=Er.collectionFromPath(this.schema,Array.from(e),r):xr(this.contents)&&this.contents.setIn(e,r)}setSchema(e,r={}){typeof e=="number"&&(e=String(e));let i;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new rc.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new rc.Directives({version:e}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(i)this.schema=new hy.Schema(Object.assign(i,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:r,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=fy.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:d}of s.anchors.values())a(d,l);return typeof o=="function"?vy.applyReviver(o,{"":c},"",c):c}toJSON(e,r){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:r})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let r=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return my.stringifyDocument(this,e)}};function xr(t){if(ge.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}lp.Document=ic});var Ci=k(xi=>{"use strict";var Ei=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},nc=class extends Ei{constructor(e,r,i){super("YAMLParseError",e,r,i)}},ac=class extends Ei{constructor(e,r,i){super("YAMLWarning",e,r,i)}},wy=(t,e)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>e.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[i-2],e.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
61
61
  `),o=s+o}if(/[^ ]/.test(o)){let s=1,c=r.linePos[1];c?.line===i&&c.col>n&&(s=Math.max(1,Math.min(c.col-n,80-a)));let l=" ".repeat(a)+"^".repeat(s);r.message+=`:
62
62
 
63
63
  ${o}
64
64
  ${l}
65
- `}};xi.YAMLError=Ei;xi.YAMLParseError=ic;xi.YAMLWarning=nc;xi.prettifyError=my});var Ri=k(lp=>{"use strict";function vy(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,d=s,u="",p="",f=!1,m=!1,h=null,g=null,v=null,N=null,b=null,y=null,E=null;for(let S of t)switch(m&&(S.type!=="space"&&S.type!=="newline"&&S.type!=="comma"&&a(S.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(l&&S.type!=="comment"&&S.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),S.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&S.source.includes(" ")&&(h=S),d=!0;break;case"comment":{d||a(S,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let T=S.source.substring(1)||" ";u?u+=p+T:u=T,p="",l=!1;break}case"newline":l?u?u+=S.source:(!y||r!=="seq-item-ind")&&(c=!0):p+=S.source,l=!0,f=!0,(g||v)&&(N=S),d=!0;break;case"anchor":g&&a(S,"MULTIPLE_ANCHORS","A node can have at most one anchor"),S.source.endsWith(":")&&a(S.offset+S.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=S,E??(E=S.offset),l=!1,d=!1,m=!0;break;case"tag":{v&&a(S,"MULTIPLE_TAGS","A node can have at most one tag"),v=S,E??(E=S.offset),l=!1,d=!1,m=!0;break}case r:(g||v)&&a(S,"BAD_PROP_ORDER",`Anchors and tags must be after the ${S.source} indicator`),y&&a(S,"UNEXPECTED_TOKEN",`Unexpected ${S.source} in ${e??"collection"}`),y=S,l=r==="seq-item-ind"||r==="explicit-key-ind",d=!1;break;case"comma":if(e){b&&a(S,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=S,l=!1,d=!1;break}default:a(S,"UNEXPECTED_TOKEN",`Unexpected ${S.type} token`),l=!1,d=!1}let w=t[t.length-1],_=w?w.offset+w.source.length:n;return m&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:y,spaceBefore:c,comment:u,hasNewline:f,anchor:g,tag:v,newlineAfterProp:N,end:_,start:E??_}}lp.resolveProps=vy});var Sa=k(up=>{"use strict";function ac(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
66
- `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let r of e.start)if(r.type==="newline")return!0;if(e.sep){for(let r of e.sep)if(r.type==="newline")return!0}if(ac(e.key)||ac(e.value))return!0}return!1;default:return!0}}up.containsNewline=ac});var oc=k(dp=>{"use strict";var gy=Sa();function wy(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&gy.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}dp.flowIndentCheck=wy});var sc=k(fp=>{"use strict";var pp=A();function yy(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||pp.isScalar(a)&&pp.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}fp.mapIncludes=yy});var yp=k(wp=>{"use strict";var hp=Nt(),Ny=kt(),mp=Ri(),by=Sa(),vp=oc(),ky=sc(),gp="All mapping items must start at the same column";function Sy({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Ny.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let d of i.items){let{start:u,key:p,sep:f,value:m}=d,h=mp.resolveProps(u,{indicator:"explicit-key-ind",next:p??f?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),g=!h.found;if(g){if(p&&(p.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&n(c,"BAD_INDENT",gp)),!h.anchor&&!h.tag&&!f){l=h.end,h.comment&&(s.comment?s.comment+=`
67
- `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||by.containsNewline(p))&&n(p??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&n(c,"BAD_INDENT",gp);r.atKey=!0;let v=h.end,N=p?t(r,p,h,n):e(r,v,u,null,h,n);r.schema.compat&&vp.flowIndentCheck(i.indent,p,n),r.atKey=!1,ky.mapIncludes(r,s.items,N)&&n(v,"DUPLICATE_KEY","Map keys must be unique");let b=mp.resolveProps(f??[],{indicator:"map-value-ind",next:m,offset:N.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(c=b.end,b.found){g&&(m?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<b.found.offset-1024&&n(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let y=m?t(r,m,b,n):e(r,c,f,null,b,n);r.schema.compat&&vp.flowIndentCheck(i.indent,m,n),c=y.range[2];let E=new hp.Pair(N,y);r.options.keepSourceTokens&&(E.srcToken=d),s.items.push(E)}else{g&&n(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(N.comment?N.comment+=`
68
- `+b.comment:N.comment=b.comment);let y=new hp.Pair(N);r.options.keepSourceTokens&&(y.srcToken=d),s.items.push(y)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}wp.resolveBlockMap=Sy});var bp=k(Np=>{"use strict";var Ey=St(),xy=Ri(),Cy=oc();function Ry({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Ey.YAMLSeq,s=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let c=i.offset,l=null;for(let{start:d,value:u}of i.items){let p=xy.resolveProps(d,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||u)u?.type==="block-seq"?n(p.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=p.end,p.comment&&(s.comment=p.comment);continue}let f=u?t(r,u,p,n):e(r,p.end,d,null,p,n);r.schema.compat&&Cy.flowIndentCheck(i.indent,u,n),c=f.range[2],s.items.push(f)}return s.range=[i.offset,c,l??c],s}Np.resolveBlockSeq=Ry});var Cr=k(kp=>{"use strict";function Py(t,e,r,i){let n="";if(t){let a=!1,o="";for(let s of t){let{source:c,type:l}=s;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";n?n+=o+d:n=d,o="";break}case"newline":n&&(o+=c),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}kp.resolveEnd=Py});var Cp=k(xp=>{"use strict";var _y=A(),Ay=Nt(),Sp=kt(),Iy=St(),Ty=Cr(),Ep=Ri(),jy=Sa(),$y=sc(),cc="Block collections are not allowed within flow collections",lc=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Oy({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Sp.YAMLMap:Iy.YAMLSeq),l=new c(r.schema);l.flow=!0;let d=r.atRoot;d&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let v=i.items[g],{start:N,key:b,sep:y,value:E}=v,w=Ep.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:b??y?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!w.found){if(!w.anchor&&!w.tag&&!y&&!E){g===0&&w.comma?n(w.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):g<i.items.length-1&&n(w.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),w.comment&&(l.comment?l.comment+=`
69
- `+w.comment:l.comment=w.comment),u=w.end;continue}!o&&r.options.strict&&jy.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)w.comma&&n(w.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(w.comma||n(w.start,"MISSING_CHAR",`Missing , between ${s} items`),w.comment){let _="";e:for(let S of N)switch(S.type){case"comma":case"space":break;case"comment":_=S.source.substring(1);break e;default:break e}if(_){let S=l.items[l.items.length-1];_y.isPair(S)&&(S=S.value??S.key),S.comment?S.comment+=`
70
- `+_:S.comment=_,w.comment=w.comment.substring(_.length+1)}}if(!o&&!y&&!w.found){let _=E?t(r,E,w,n):e(r,w.end,y,null,w,n);l.items.push(_),u=_.range[2],lc(E)&&n(_.range,"BLOCK_IN_FLOW",cc)}else{r.atKey=!0;let _=w.end,S=b?t(r,b,w,n):e(r,_,N,null,w,n);lc(b)&&n(S.range,"BLOCK_IN_FLOW",cc),r.atKey=!1;let T=Ep.resolveProps(y??[],{flow:s,indicator:"map-value-ind",next:E,offset:S.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(T.found){if(!o&&!w.found&&r.options.strict){if(y)for(let q of y){if(q===T.found)break;if(q.type==="newline"){n(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}w.start<T.found.offset-1024&&n(T.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?n(E,"MISSING_CHAR",`Missing space after : in ${s}`):n(T.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let Q=E?t(r,E,T,n):T.found?e(r,T.end,y,null,T,n):null;Q?lc(E)&&n(Q.range,"BLOCK_IN_FLOW",cc):T.comment&&(S.comment?S.comment+=`
71
- `+T.comment:S.comment=T.comment);let xe=new Ay.Pair(S,Q);if(r.options.keepSourceTokens&&(xe.srcToken=v),o){let q=l;$y.mapIncludes(r,q.items,S)&&n(_,"DUPLICATE_KEY","Map keys must be unique"),q.items.push(xe)}else{let q=new Sp.YAMLMap(r.schema);q.flow=!0,q.items.push(xe);let ri=(Q??S).range;q.range=[S.range[0],ri[1],ri[2]],l.items.push(q)}u=Q?Q.range[2]:T.end}}let p=o?"}":"]",[f,...m]=i.end,h=u;if(f?.source===p)h=f.offset+f.source.length;else{let g=s[0].toUpperCase()+s.substring(1),v=d?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;n(u,d?"MISSING_CHAR":"BAD_INDENT",v),f&&f.source.length!==1&&m.unshift(f)}if(m.length>0){let g=Ty.resolveEnd(m,h,r.options.strict,n);g.comment&&(l.comment?l.comment+=`
72
- `+g.comment:l.comment=g.comment),l.range=[i.offset,h,g.offset]}else l.range=[i.offset,h,h];return l}xp.resolveFlowCollection=Oy});var Pp=k(Rp=>{"use strict";var Hy=A(),Dy=V(),By=kt(),Ly=St(),Fy=yp(),qy=bp(),My=Cp();function uc(t,e,r,i,n,a){let o=r.type==="block-map"?Fy.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?qy.resolveBlockSeq(t,e,r,i,a):My.resolveFlowCollection(t,e,r,i,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function Vy(t,e,r,i,n){let a=i.tag,o=a?e.directives.tagName(a.source,p=>n(a,"TAG_RESOLVE_FAILED",p)):null;if(r.type==="block-seq"){let{anchor:p,newlineAfterProp:f}=i,m=p&&a?p.offset>a.offset?p:a:p??a;m&&(!f||f.offset<m.offset)&&n(m,"MISSING_CHAR","Missing newline after block sequence props")}let s=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===By.YAMLMap.tagName&&s==="map"||o===Ly.YAMLSeq.tagName&&s==="seq")return uc(t,e,r,n,o);let c=e.schema.tags.find(p=>p.tag===o&&p.collection===s);if(!c){let p=e.schema.knownTags[o];if(p?.collection===s)e.schema.tags.push(Object.assign({},p,{default:!1})),c=p;else return p?n(a,"BAD_COLLECTION_TYPE",`${p.tag} used for ${s} collection, but expects ${p.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),uc(t,e,r,n,o)}let l=uc(t,e,r,n,o,c),d=c.resolve?.(l,p=>n(a,"TAG_RESOLVE_FAILED",p),e.options)??l,u=Hy.isNode(d)?d:new Dy.Scalar(d);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Rp.composeCollection=Vy});var pc=k(_p=>{"use strict";var dc=V();function Wy(t,e,r){let i=e.offset,n=zy(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?dc.Scalar.BLOCK_FOLDED:dc.Scalar.BLOCK_LITERAL,o=e.source?Gy(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
65
+ `}};xi.YAMLError=Ei;xi.YAMLParseError=nc;xi.YAMLWarning=ac;xi.prettifyError=wy});var Ri=k(up=>{"use strict";function yy(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,d=s,u="",p="",f=!1,m=!1,h=null,g=null,v=null,N=null,b=null,y=null,E=null;for(let S of t)switch(m&&(S.type!=="space"&&S.type!=="newline"&&S.type!=="comma"&&a(S.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(l&&S.type!=="comment"&&S.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),S.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&S.source.includes(" ")&&(h=S),d=!0;break;case"comment":{d||a(S,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let T=S.source.substring(1)||" ";u?u+=p+T:u=T,p="",l=!1;break}case"newline":l?u?u+=S.source:(!y||r!=="seq-item-ind")&&(c=!0):p+=S.source,l=!0,f=!0,(g||v)&&(N=S),d=!0;break;case"anchor":g&&a(S,"MULTIPLE_ANCHORS","A node can have at most one anchor"),S.source.endsWith(":")&&a(S.offset+S.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=S,E??(E=S.offset),l=!1,d=!1,m=!0;break;case"tag":{v&&a(S,"MULTIPLE_TAGS","A node can have at most one tag"),v=S,E??(E=S.offset),l=!1,d=!1,m=!0;break}case r:(g||v)&&a(S,"BAD_PROP_ORDER",`Anchors and tags must be after the ${S.source} indicator`),y&&a(S,"UNEXPECTED_TOKEN",`Unexpected ${S.source} in ${e??"collection"}`),y=S,l=r==="seq-item-ind"||r==="explicit-key-ind",d=!1;break;case"comma":if(e){b&&a(S,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=S,l=!1,d=!1;break}default:a(S,"UNEXPECTED_TOKEN",`Unexpected ${S.type} token`),l=!1,d=!1}let w=t[t.length-1],_=w?w.offset+w.source.length:n;return m&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:y,spaceBefore:c,comment:u,hasNewline:f,anchor:g,tag:v,newlineAfterProp:N,end:_,start:E??_}}up.resolveProps=yy});var Ea=k(dp=>{"use strict";function oc(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
66
+ `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let r of e.start)if(r.type==="newline")return!0;if(e.sep){for(let r of e.sep)if(r.type==="newline")return!0}if(oc(e.key)||oc(e.value))return!0}return!1;default:return!0}}dp.containsNewline=oc});var sc=k(pp=>{"use strict";var Ny=Ea();function by(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&Ny.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}pp.flowIndentCheck=by});var cc=k(hp=>{"use strict";var fp=A();function ky(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||fp.isScalar(a)&&fp.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}hp.mapIncludes=ky});var Np=k(yp=>{"use strict";var mp=Nt(),Sy=kt(),vp=Ri(),Ey=Ea(),gp=sc(),xy=cc(),wp="All mapping items must start at the same column";function Cy({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Sy.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let d of i.items){let{start:u,key:p,sep:f,value:m}=d,h=vp.resolveProps(u,{indicator:"explicit-key-ind",next:p??f?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),g=!h.found;if(g){if(p&&(p.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&n(c,"BAD_INDENT",wp)),!h.anchor&&!h.tag&&!f){l=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Ey.containsNewline(p))&&n(p??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&n(c,"BAD_INDENT",wp);r.atKey=!0;let v=h.end,N=p?t(r,p,h,n):e(r,v,u,null,h,n);r.schema.compat&&gp.flowIndentCheck(i.indent,p,n),r.atKey=!1,xy.mapIncludes(r,s.items,N)&&n(v,"DUPLICATE_KEY","Map keys must be unique");let b=vp.resolveProps(f??[],{indicator:"map-value-ind",next:m,offset:N.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(c=b.end,b.found){g&&(m?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<b.found.offset-1024&&n(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let y=m?t(r,m,b,n):e(r,c,f,null,b,n);r.schema.compat&&gp.flowIndentCheck(i.indent,m,n),c=y.range[2];let E=new mp.Pair(N,y);r.options.keepSourceTokens&&(E.srcToken=d),s.items.push(E)}else{g&&n(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(N.comment?N.comment+=`
68
+ `+b.comment:N.comment=b.comment);let y=new mp.Pair(N);r.options.keepSourceTokens&&(y.srcToken=d),s.items.push(y)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}yp.resolveBlockMap=Cy});var kp=k(bp=>{"use strict";var Ry=St(),Py=Ri(),_y=sc();function Ay({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Ry.YAMLSeq,s=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let c=i.offset,l=null;for(let{start:d,value:u}of i.items){let p=Py.resolveProps(d,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||u)u?.type==="block-seq"?n(p.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=p.end,p.comment&&(s.comment=p.comment);continue}let f=u?t(r,u,p,n):e(r,p.end,d,null,p,n);r.schema.compat&&_y.flowIndentCheck(i.indent,u,n),c=f.range[2],s.items.push(f)}return s.range=[i.offset,c,l??c],s}bp.resolveBlockSeq=Ay});var Cr=k(Sp=>{"use strict";function Iy(t,e,r,i){let n="";if(t){let a=!1,o="";for(let s of t){let{source:c,type:l}=s;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";n?n+=o+d:n=d,o="";break}case"newline":n&&(o+=c),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}Sp.resolveEnd=Iy});var Rp=k(Cp=>{"use strict";var Ty=A(),jy=Nt(),Ep=kt(),$y=St(),Oy=Cr(),xp=Ri(),Hy=Ea(),Dy=cc(),lc="Block collections are not allowed within flow collections",uc=t=>t&&(t.type==="block-map"||t.type==="block-seq");function By({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Ep.YAMLMap:$y.YAMLSeq),l=new c(r.schema);l.flow=!0;let d=r.atRoot;d&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let v=i.items[g],{start:N,key:b,sep:y,value:E}=v,w=xp.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:b??y?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!w.found){if(!w.anchor&&!w.tag&&!y&&!E){g===0&&w.comma?n(w.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):g<i.items.length-1&&n(w.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),w.comment&&(l.comment?l.comment+=`
69
+ `+w.comment:l.comment=w.comment),u=w.end;continue}!o&&r.options.strict&&Hy.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)w.comma&&n(w.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(w.comma||n(w.start,"MISSING_CHAR",`Missing , between ${s} items`),w.comment){let _="";e:for(let S of N)switch(S.type){case"comma":case"space":break;case"comment":_=S.source.substring(1);break e;default:break e}if(_){let S=l.items[l.items.length-1];Ty.isPair(S)&&(S=S.value??S.key),S.comment?S.comment+=`
70
+ `+_:S.comment=_,w.comment=w.comment.substring(_.length+1)}}if(!o&&!y&&!w.found){let _=E?t(r,E,w,n):e(r,w.end,y,null,w,n);l.items.push(_),u=_.range[2],uc(E)&&n(_.range,"BLOCK_IN_FLOW",lc)}else{r.atKey=!0;let _=w.end,S=b?t(r,b,w,n):e(r,_,N,null,w,n);uc(b)&&n(S.range,"BLOCK_IN_FLOW",lc),r.atKey=!1;let T=xp.resolveProps(y??[],{flow:s,indicator:"map-value-ind",next:E,offset:S.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(T.found){if(!o&&!w.found&&r.options.strict){if(y)for(let q of y){if(q===T.found)break;if(q.type==="newline"){n(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}w.start<T.found.offset-1024&&n(T.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?n(E,"MISSING_CHAR",`Missing space after : in ${s}`):n(T.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let Q=E?t(r,E,T,n):T.found?e(r,T.end,y,null,T,n):null;Q?uc(E)&&n(Q.range,"BLOCK_IN_FLOW",lc):T.comment&&(S.comment?S.comment+=`
71
+ `+T.comment:S.comment=T.comment);let xe=new jy.Pair(S,Q);if(r.options.keepSourceTokens&&(xe.srcToken=v),o){let q=l;Dy.mapIncludes(r,q.items,S)&&n(_,"DUPLICATE_KEY","Map keys must be unique"),q.items.push(xe)}else{let q=new Ep.YAMLMap(r.schema);q.flow=!0,q.items.push(xe);let ri=(Q??S).range;q.range=[S.range[0],ri[1],ri[2]],l.items.push(q)}u=Q?Q.range[2]:T.end}}let p=o?"}":"]",[f,...m]=i.end,h=u;if(f?.source===p)h=f.offset+f.source.length;else{let g=s[0].toUpperCase()+s.substring(1),v=d?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;n(u,d?"MISSING_CHAR":"BAD_INDENT",v),f&&f.source.length!==1&&m.unshift(f)}if(m.length>0){let g=Oy.resolveEnd(m,h,r.options.strict,n);g.comment&&(l.comment?l.comment+=`
72
+ `+g.comment:l.comment=g.comment),l.range=[i.offset,h,g.offset]}else l.range=[i.offset,h,h];return l}Cp.resolveFlowCollection=By});var _p=k(Pp=>{"use strict";var Ly=A(),Fy=V(),qy=kt(),My=St(),Vy=Np(),Wy=kp(),zy=Rp();function dc(t,e,r,i,n,a){let o=r.type==="block-map"?Vy.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?Wy.resolveBlockSeq(t,e,r,i,a):zy.resolveFlowCollection(t,e,r,i,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function Gy(t,e,r,i,n){let a=i.tag,o=a?e.directives.tagName(a.source,p=>n(a,"TAG_RESOLVE_FAILED",p)):null;if(r.type==="block-seq"){let{anchor:p,newlineAfterProp:f}=i,m=p&&a?p.offset>a.offset?p:a:p??a;m&&(!f||f.offset<m.offset)&&n(m,"MISSING_CHAR","Missing newline after block sequence props")}let s=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===qy.YAMLMap.tagName&&s==="map"||o===My.YAMLSeq.tagName&&s==="seq")return dc(t,e,r,n,o);let c=e.schema.tags.find(p=>p.tag===o&&p.collection===s);if(!c){let p=e.schema.knownTags[o];if(p?.collection===s)e.schema.tags.push(Object.assign({},p,{default:!1})),c=p;else return p?n(a,"BAD_COLLECTION_TYPE",`${p.tag} used for ${s} collection, but expects ${p.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),dc(t,e,r,n,o)}let l=dc(t,e,r,n,o,c),d=c.resolve?.(l,p=>n(a,"TAG_RESOLVE_FAILED",p),e.options)??l,u=Ly.isNode(d)?d:new Fy.Scalar(d);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Pp.composeCollection=Gy});var fc=k(Ap=>{"use strict";var pc=V();function Jy(t,e,r){let i=e.offset,n=Uy(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?pc.Scalar.BLOCK_FOLDED:pc.Scalar.BLOCK_LITERAL,o=e.source?Ky(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
73
  `.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return e.source&&(g+=e.source.length),{value:h,type:a,comment:n.comment,range:[i,g,g]}}let c=e.indent+n.indent,l=e.offset+n.length,d=0;for(let h=0;h<s;++h){let[g,v]=o[h];if(v===""||v==="\r")n.indent===0&&g.length>c&&(c=g.length);else{g.length<c&&r(l+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=g.length),d=h,c===0&&!t.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=g.length+v.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let u="",p="",f=!1;for(let h=0;h<d;++h)u+=o[h][0].slice(c)+`
74
- `;for(let h=d;h<s;++h){let[g,v]=o[h];l+=g.length+v.length+1;let N=v[v.length-1]==="\r";if(N&&(v=v.slice(0,-1)),v&&g.length<c){let y=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-v.length-(N?2:1),"BAD_INDENT",y),g=""}a===dc.Scalar.BLOCK_LITERAL?(u+=p+g.slice(c)+v,p=`
74
+ `;for(let h=d;h<s;++h){let[g,v]=o[h];l+=g.length+v.length+1;let N=v[v.length-1]==="\r";if(N&&(v=v.slice(0,-1)),v&&g.length<c){let y=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-v.length-(N?2:1),"BAD_INDENT",y),g=""}a===pc.Scalar.BLOCK_LITERAL?(u+=p+g.slice(c)+v,p=`
75
75
  `):g.length>c||v[0]===" "?(p===" "?p=`
76
76
  `:!f&&p===`
77
77
  `&&(p=`
@@ -84,65 +84,69 @@ ${l}
84
84
  `+o[h][0].slice(c);u[u.length-1]!==`
85
85
  `&&(u+=`
86
86
  `);break;default:u+=`
87
- `}let m=i+n.length+e.source.length;return{value:u,type:a,comment:n.comment,range:[i,m,m]}}function zy({offset:t,props:e},r,i){if(e[0].type!=="block-scalar-header")return i(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],a=n[0],o=0,s="",c=-1;for(let p=1;p<n.length;++p){let f=n[p];if(!s&&(f==="-"||f==="+"))s=f;else{let m=Number(f);!o&&m?o=m:c===-1&&(c=t+p)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,d="",u=n.length;for(let p=1;p<e.length;++p){let f=e[p];switch(f.type){case"space":l=!0;case"newline":u+=f.source.length;break;case"comment":r&&!l&&i(f,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=f.source.length,d=f.source.substring(1);break;case"error":i(f,"UNEXPECTED_TOKEN",f.message),u+=f.source.length;break;default:{let m=`Unexpected token in block scalar header: ${f.type}`;i(f,"UNEXPECTED_TOKEN",m);let h=f.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:d,length:u}}function Gy(t){let e=t.split(/\n( *)/),r=e[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}_p.resolveBlockScalar=Wy});var hc=k(Ip=>{"use strict";var fc=V(),Jy=Cr();function Uy(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(p,f,m)=>r(i+p,f,m);switch(n){case"scalar":s=fc.Scalar.PLAIN,c=Ky(a,l);break;case"single-quoted-scalar":s=fc.Scalar.QUOTE_SINGLE,c=Yy(a,l);break;case"double-quoted-scalar":s=fc.Scalar.QUOTE_DOUBLE,c=Xy(a,l);break;default:return r(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let d=i+a.length,u=Jy.resolveEnd(o,d,e,r);return{value:c,type:s,comment:u.comment,range:[i,d,u.offset]}}function Ky(t,e){let r="";switch(t[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${t[0]}`;break}case"@":case"`":{r=`reserved character ${t[0]}`;break}}return r&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),Ap(t)}function Yy(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Ap(t.slice(1,-1)).replace(/''/g,"'")}function Ap(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
+ `}let m=i+n.length+e.source.length;return{value:u,type:a,comment:n.comment,range:[i,m,m]}}function Uy({offset:t,props:e},r,i){if(e[0].type!=="block-scalar-header")return i(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],a=n[0],o=0,s="",c=-1;for(let p=1;p<n.length;++p){let f=n[p];if(!s&&(f==="-"||f==="+"))s=f;else{let m=Number(f);!o&&m?o=m:c===-1&&(c=t+p)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,d="",u=n.length;for(let p=1;p<e.length;++p){let f=e[p];switch(f.type){case"space":l=!0;case"newline":u+=f.source.length;break;case"comment":r&&!l&&i(f,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=f.source.length,d=f.source.substring(1);break;case"error":i(f,"UNEXPECTED_TOKEN",f.message),u+=f.source.length;break;default:{let m=`Unexpected token in block scalar header: ${f.type}`;i(f,"UNEXPECTED_TOKEN",m);let h=f.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:d,length:u}}function Ky(t){let e=t.split(/\n( *)/),r=e[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}Ap.resolveBlockScalar=Jy});var mc=k(Tp=>{"use strict";var hc=V(),Yy=Cr();function Xy(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(p,f,m)=>r(i+p,f,m);switch(n){case"scalar":s=hc.Scalar.PLAIN,c=Qy(a,l);break;case"single-quoted-scalar":s=hc.Scalar.QUOTE_SINGLE,c=Zy(a,l);break;case"double-quoted-scalar":s=hc.Scalar.QUOTE_DOUBLE,c=eN(a,l);break;default:return r(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let d=i+a.length,u=Yy.resolveEnd(o,d,e,r);return{value:c,type:s,comment:u.comment,range:[i,d,u.offset]}}function Qy(t,e){let r="";switch(t[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${t[0]}`;break}case"@":case"`":{r=`reserved character ${t[0]}`;break}}return r&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),Ip(t)}function Zy(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Ip(t.slice(1,-1)).replace(/''/g,"'")}function Ip(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
88
88
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
89
89
  `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=e.exec(t);if(!i)return t;let n=i[1],a=" ",o=e.lastIndex;for(r.lastIndex=o;i=r.exec(t);)i[1]===""?a===`
90
90
  `?n+=a:a=`
91
- `:(n+=a+i[1],a=" "),o=r.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,i=s.exec(t),n+a+(i?.[1]??"")}function Xy(t,e){let r="";for(let i=1;i<t.length-1;++i){let n=t[i];if(!(n==="\r"&&t[i+1]===`
91
+ `:(n+=a+i[1],a=" "),o=r.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,i=s.exec(t),n+a+(i?.[1]??"")}function eN(t,e){let r="";for(let i=1;i<t.length-1;++i){let n=t[i];if(!(n==="\r"&&t[i+1]===`
92
92
  `))if(n===`
93
- `){let{fold:a,offset:o}=Qy(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=Zy[a];if(o)r+=o;else if(a===`
93
+ `){let{fold:a,offset:o}=tN(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=rN[a];if(o)r+=o;else if(a===`
94
94
  `)for(a=t[i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="\r"&&t[i+1]===`
95
- `)for(a=t[++i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=eN(t,i+1,s,e),i+=s}else{let s=t.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=t[i+1];for(;o===" "||o===" ";)o=t[++i+1];o!==`
95
+ `)for(a=t[++i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=iN(t,i+1,s,e),i+=s}else{let s=t.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=t[i+1];for(;o===" "||o===" ";)o=t[++i+1];o!==`
96
96
  `&&!(o==="\r"&&t[i+2]===`
97
- `)&&(r+=i>a?t.slice(a,i+1):n)}else r+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function Qy(t,e){let r="",i=t[e+1];for(;(i===" "||i===" "||i===`
97
+ `)&&(r+=i>a?t.slice(a,i+1):n)}else r+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function tN(t,e){let r="",i=t[e+1];for(;(i===" "||i===" "||i===`
98
98
  `||i==="\r")&&!(i==="\r"&&t[e+2]!==`
99
99
  `);)i===`
100
100
  `&&(r+=`
101
- `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var Zy={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function eN(t,e,r,i){let n=t.substr(e,r),o=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=t.substr(e-2,r+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Ip.resolveFlowScalar=Uy});var $p=k(jp=>{"use strict";var Kt=A(),Tp=V(),tN=pc(),rN=hc();function iN(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?tN.resolveBlockScalar(t,e,i):rN.resolveFlowScalar(e,t.options.strict,i),c=r?t.directives.tagName(r.source,u=>i(r,"TAG_RESOLVE_FAILED",u)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Kt.SCALAR]:c?l=nN(t.schema,n,c,r,i):e.type==="scalar"?l=aN(t,n,e,i):l=t.schema[Kt.SCALAR];let d;try{let u=l.resolve(n,p=>i(r??e,"TAG_RESOLVE_FAILED",p),t.options);d=Kt.isScalar(u)?u:new Tp.Scalar(u)}catch(u){let p=u instanceof Error?u.message:String(u);i(r??e,"TAG_RESOLVE_FAILED",p),d=new Tp.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 nN(t,e,r,i,n){if(r==="!")return t[Kt.SCALAR];let a=[];for(let s of t.tags)if(!s.collection&&s.tag===r)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(e))return s;let o=t.knownTags[r];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),t[Kt.SCALAR])}function aN({atKey:t,directives:e,schema:r},i,n,a){let o=r.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(i))||r[Kt.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[Kt.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),d=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",d,!0)}}return o}jp.composeScalar=iN});var Hp=k(Op=>{"use strict";function oN(t,e,r){if(e){r??(r=e.length);for(let i=r-1;i>=0;--i){let n=e[i];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++i];n?.type==="space";)t+=n.source.length,n=e[++i];break}}return t}Op.emptyScalarPosition=oN});var Lp=k(vc=>{"use strict";var sN=si(),cN=A(),lN=Pp(),Dp=$p(),uN=Cr(),dN=Hp(),pN={composeNode:Bp,composeEmptyNode:mc};function Bp(t,e,r,i){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,d=!0;switch(e.type){case"alias":l=fN(t,e,i),(s||c)&&i(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=Dp.composeScalar(t,e,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=lN.composeCollection(pN,t,e,r,i),s&&(l.anchor=s.source.substring(1))}catch(u){let p=u instanceof Error?u.message:String(u);i(e,"RESOURCE_EXHAUSTION",p)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",u),d=!1}}return l??(l=mc(t,e.offset,void 0,null,r,i)),s&&l.anchor===""&&i(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!cN.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&i(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?l.comment=o:l.commentBefore=o),t.options.keepSourceTokens&&d&&(l.srcToken=e),l}function mc(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let d={type:"scalar",offset:dN.emptyScalarPosition(e,r,i),indent:-1,source:""},u=Dp.composeScalar(t,d,s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function fN({options:t},{offset:e,source:r,end:i},n){let a=new sN.Alias(r.substring(1));a.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(e+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+r.length,s=uN.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}vc.composeEmptyNode=mc;vc.composeNode=Bp});var Mp=k(qp=>{"use strict";var hN=Si(),Fp=Lp(),mN=Cr(),vN=Ri();function gN(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new hN.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=vN.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Fp.composeNode(l,n,d,o):Fp.composeEmptyNode(l,d.end,i,null,d,o);let u=c.contents.range[2],p=mN.resolveEnd(a,u,!1,o);return p.comment&&(c.comment=p.comment),c.range=[r,u,p.offset],c}qp.composeDoc=gN});var wc=k(zp=>{"use strict";var wN=jn("process"),yN=is(),NN=Si(),Pi=Ci(),Vp=A(),bN=Mp(),kN=Cr();function _i(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:r}=t;return[e,e+(typeof r=="string"?r.length:1)]}function Wp(t){let e="",r=!1,i=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":i?`
101
+ `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var rN={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function iN(t,e,r,i){let n=t.substr(e,r),o=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=t.substr(e-2,r+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Tp.resolveFlowScalar=Xy});var Op=k($p=>{"use strict";var Kt=A(),jp=V(),nN=fc(),aN=mc();function oN(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?nN.resolveBlockScalar(t,e,i):aN.resolveFlowScalar(e,t.options.strict,i),c=r?t.directives.tagName(r.source,u=>i(r,"TAG_RESOLVE_FAILED",u)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Kt.SCALAR]:c?l=sN(t.schema,n,c,r,i):e.type==="scalar"?l=cN(t,n,e,i):l=t.schema[Kt.SCALAR];let d;try{let u=l.resolve(n,p=>i(r??e,"TAG_RESOLVE_FAILED",p),t.options);d=Kt.isScalar(u)?u:new jp.Scalar(u)}catch(u){let p=u instanceof Error?u.message:String(u);i(r??e,"TAG_RESOLVE_FAILED",p),d=new jp.Scalar(n)}return d.range=s,d.source=n,a&&(d.type=a),c&&(d.tag=c),l.format&&(d.format=l.format),o&&(d.comment=o),d}function sN(t,e,r,i,n){if(r==="!")return t[Kt.SCALAR];let a=[];for(let s of t.tags)if(!s.collection&&s.tag===r)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(e))return s;let o=t.knownTags[r];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),t[Kt.SCALAR])}function cN({atKey:t,directives:e,schema:r},i,n,a){let o=r.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(i))||r[Kt.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[Kt.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),d=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",d,!0)}}return o}$p.composeScalar=oN});var Dp=k(Hp=>{"use strict";function lN(t,e,r){if(e){r??(r=e.length);for(let i=r-1;i>=0;--i){let n=e[i];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++i];n?.type==="space";)t+=n.source.length,n=e[++i];break}}return t}Hp.emptyScalarPosition=lN});var Fp=k(gc=>{"use strict";var uN=si(),dN=A(),pN=_p(),Bp=Op(),fN=Cr(),hN=Dp(),mN={composeNode:Lp,composeEmptyNode:vc};function Lp(t,e,r,i){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,d=!0;switch(e.type){case"alias":l=vN(t,e,i),(s||c)&&i(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=Bp.composeScalar(t,e,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=pN.composeCollection(mN,t,e,r,i),s&&(l.anchor=s.source.substring(1))}catch(u){let p=u instanceof Error?u.message:String(u);i(e,"RESOURCE_EXHAUSTION",p)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",u),d=!1}}return l??(l=vc(t,e.offset,void 0,null,r,i)),s&&l.anchor===""&&i(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!dN.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&i(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?l.comment=o:l.commentBefore=o),t.options.keepSourceTokens&&d&&(l.srcToken=e),l}function vc(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let d={type:"scalar",offset:hN.emptyScalarPosition(e,r,i),indent:-1,source:""},u=Bp.composeScalar(t,d,s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function vN({options:t},{offset:e,source:r,end:i},n){let a=new uN.Alias(r.substring(1));a.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(e+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+r.length,s=fN.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}gc.composeEmptyNode=vc;gc.composeNode=Lp});var Vp=k(Mp=>{"use strict";var gN=Si(),qp=Fp(),wN=Cr(),yN=Ri();function NN(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new gN.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=yN.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?qp.composeNode(l,n,d,o):qp.composeEmptyNode(l,d.end,i,null,d,o);let u=c.contents.range[2],p=wN.resolveEnd(a,u,!1,o);return p.comment&&(c.comment=p.comment),c.range=[r,u,p.offset],c}Mp.composeDoc=NN});var yc=k(Gp=>{"use strict";var bN=$n("process"),kN=ns(),SN=Si(),Pi=Ci(),Wp=A(),EN=Vp(),xN=Cr();function _i(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:r}=t;return[e,e+(typeof r=="string"?r.length:1)]}function zp(t){let e="",r=!1,i=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":i?`
103
103
 
104
104
  `:`
105
- `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:e,afterEmptyLine:i}}var gc=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=_i(r);a?this.warnings.push(new Pi.YAMLWarning(o,i,n)):this.errors.push(new Pi.YAMLParseError(o,i,n))},this.directives=new yN.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=Wp(this.prelude);if(i){let a=e.contents;if(r)e.comment=e.comment?`${e.comment}
106
- ${i}`:i;else if(n||e.directives.docStart||!a)e.commentBefore=i;else if(Vp.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Vp.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
105
+ `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:e,afterEmptyLine:i}}var wc=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=_i(r);a?this.warnings.push(new Pi.YAMLWarning(o,i,n)):this.errors.push(new Pi.YAMLParseError(o,i,n))},this.directives=new kN.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=zp(this.prelude);if(i){let a=e.contents;if(r)e.comment=e.comment?`${e.comment}
106
+ ${i}`:i;else if(n||e.directives.docStart||!a)e.commentBefore=i;else if(Wp.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Wp.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
107
107
  ${s}`:i}else{let o=a.commentBefore;a.commentBefore=o?`${i}
108
- ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)e.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)e.warnings.push(this.warnings[a])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Wp(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,r=!1,i=-1){for(let n of e)yield*this.next(n);yield*this.end(r,i)}*next(e){switch(wN.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=_i(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=bN.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let r=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,i=new Pi.YAMLParseError(_i(e),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new Pi.YAMLParseError(_i(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=kN.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
109
- ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new Pi.YAMLParseError(_i(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let i=Object.assign({_directives:this.directives},this.options),n=new NN.Document(void 0,i);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,r,r],this.decorate(n,!1),yield n}}};zp.Composer=gc});var Up=k(Ea=>{"use strict";var SN=pc(),EN=hc(),xN=Ci(),Gp=pi();function CN(t,e=!0,r){if(t){let i=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(s,a,o);else throw new xN.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return EN.resolveFlowScalar(t,e,i);case"block-scalar":return SN.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function RN(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=Gp.stringifyString({type:o,value:t},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:i,source:`
108
+ ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)e.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)e.warnings.push(this.warnings[a])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:zp(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,r=!1,i=-1){for(let n of e)yield*this.next(n);yield*this.end(r,i)}*next(e){switch(bN.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=_i(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=EN.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let r=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,i=new Pi.YAMLParseError(_i(e),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new Pi.YAMLParseError(_i(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=xN.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
109
+ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new Pi.YAMLParseError(_i(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let i=Object.assign({_directives:this.directives},this.options),n=new SN.Document(void 0,i);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,r,r],this.decorate(n,!1),yield n}}};Gp.Composer=wc});var Kp=k(xa=>{"use strict";var CN=fc(),RN=mc(),PN=Ci(),Jp=pi();function _N(t,e=!0,r){if(t){let i=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(s,a,o);else throw new PN.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return RN.resolveFlowScalar(t,e,i);case"block-scalar":return CN.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function AN(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=Jp.stringifyString({type:o,value:t},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:i,source:`
110
110
  `}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
111
111
  `),d=s.substring(0,l),u=s.substring(l+1)+`
112
- `,p=[{type:"block-scalar-header",offset:a,indent:i,source:d}];return Jp(p,c)||p.push({type:"newline",offset:-1,indent:i,source:`
113
- `}),{type:"block-scalar",offset:a,indent:i,props:p,source:u}}case'"':return{type:"double-quoted-scalar",offset:a,indent:i,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:i,source:s,end:c};default:return{type:"scalar",offset:a,indent:i,source:s,end:c}}}function PN(t,e,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in t?t.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Gp.stringifyString({type:o,value:e},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":_N(t,c);break;case'"':yc(t,c,"double-quoted-scalar");break;case"'":yc(t,c,"single-quoted-scalar");break;default:yc(t,c,"scalar")}}function _N(t,e){let r=e.indexOf(`
112
+ `,p=[{type:"block-scalar-header",offset:a,indent:i,source:d}];return Up(p,c)||p.push({type:"newline",offset:-1,indent:i,source:`
113
+ `}),{type:"block-scalar",offset:a,indent:i,props:p,source:u}}case'"':return{type:"double-quoted-scalar",offset:a,indent:i,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:i,source:s,end:c};default:return{type:"scalar",offset:a,indent:i,source:s,end:c}}}function IN(t,e,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in t?t.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Jp.stringifyString({type:o,value:e},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":TN(t,c);break;case'"':Nc(t,c,"double-quoted-scalar");break;case"'":Nc(t,c,"single-quoted-scalar");break;default:Nc(t,c,"scalar")}}function TN(t,e){let r=e.indexOf(`
114
114
  `),i=e.substring(0,r),n=e.substring(r+1)+`
115
- `;if(t.type==="block-scalar"){let a=t.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,t.source=n}else{let{offset:a}=t,o="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];Jp(s,"end"in t?t.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
- `});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:s,source:n})}}function Jp(t,e){if(e)for(let r of e)switch(r.type){case"space":case"comment":t.push(r);break;case"newline":return t.push(r),!0}return!1}function yc(t,e,r){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=r,t.source=e;break;case"block-scalar":{let i=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let a of i)a.offset+=n;delete t.props,Object.assign(t,{type:r,source:e,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
117
- `};delete t.items,Object.assign(t,{type:r,source:e,end:[n]});break}default:{let i="indent"in t?t.indent:-1,n="end"in t&&Array.isArray(t.end)?t.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(t))a!=="type"&&a!=="offset"&&delete t[a];Object.assign(t,{type:r,indent:i,source:e,end:n})}}}Ea.createScalarToken=RN;Ea.resolveAsScalar=CN;Ea.setScalarValue=PN});var Yp=k(Kp=>{"use strict";var AN=t=>"type"in t?Ca(t):xa(t);function Ca(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=Ca(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=xa(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=xa(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=xa(t);if(t.end)for(let r of t.end)e+=r.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let r of t.end)e+=r.source;return e}}}function xa({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Ca(e)),r)for(let a of r)n+=a.source;return i&&(n+=Ca(i)),n}Kp.stringify=AN});var ef=k(Zp=>{"use strict";var Nc=Symbol("break visit"),IN=Symbol("skip children"),Xp=Symbol("remove item");function Yt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Qp(Object.freeze([]),t,e)}Yt.BREAK=Nc;Yt.SKIP=IN;Yt.REMOVE=Xp;Yt.itemAtPath=(t,e)=>{let r=t;for(let[i,n]of e){let a=r?.[i];if(a&&"items"in a)r=a.items[n];else return}return r};Yt.parentCollection=(t,e)=>{let r=Yt.itemAtPath(t,e.slice(0,-1)),i=e[e.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Qp(t,e,r){let i=r(e,t);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=e[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=Qp(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===Nc)return Nc;s===Xp&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}Zp.visit=Yt});var Ra=k(le=>{"use strict";var bc=Up(),TN=Yp(),jN=ef(),kc="\uFEFF",Sc="",Ec="",xc="",$N=t=>!!t&&"items"in t,ON=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function HN(t){switch(t){case kc:return"<BOM>";case Sc:return"<DOC>";case Ec:return"<FLOW_END>";case xc:return"<SCALAR>";default:return JSON.stringify(t)}}function DN(t){switch(t){case kc:return"byte-order-mark";case Sc:return"doc-mode";case Ec:return"flow-error-end";case xc:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
+ `;if(t.type==="block-scalar"){let a=t.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,t.source=n}else{let{offset:a}=t,o="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];Up(s,"end"in t?t.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
+ `});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:s,source:n})}}function Up(t,e){if(e)for(let r of e)switch(r.type){case"space":case"comment":t.push(r);break;case"newline":return t.push(r),!0}return!1}function Nc(t,e,r){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=r,t.source=e;break;case"block-scalar":{let i=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let a of i)a.offset+=n;delete t.props,Object.assign(t,{type:r,source:e,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
117
+ `};delete t.items,Object.assign(t,{type:r,source:e,end:[n]});break}default:{let i="indent"in t?t.indent:-1,n="end"in t&&Array.isArray(t.end)?t.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(t))a!=="type"&&a!=="offset"&&delete t[a];Object.assign(t,{type:r,indent:i,source:e,end:n})}}}xa.createScalarToken=AN;xa.resolveAsScalar=_N;xa.setScalarValue=IN});var Xp=k(Yp=>{"use strict";var jN=t=>"type"in t?Ra(t):Ca(t);function Ra(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=Ra(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=Ca(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=Ca(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=Ca(t);if(t.end)for(let r of t.end)e+=r.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let r of t.end)e+=r.source;return e}}}function Ca({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Ra(e)),r)for(let a of r)n+=a.source;return i&&(n+=Ra(i)),n}Yp.stringify=jN});var tf=k(ef=>{"use strict";var bc=Symbol("break visit"),$N=Symbol("skip children"),Qp=Symbol("remove item");function Yt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Zp(Object.freeze([]),t,e)}Yt.BREAK=bc;Yt.SKIP=$N;Yt.REMOVE=Qp;Yt.itemAtPath=(t,e)=>{let r=t;for(let[i,n]of e){let a=r?.[i];if(a&&"items"in a)r=a.items[n];else return}return r};Yt.parentCollection=(t,e)=>{let r=Yt.itemAtPath(t,e.slice(0,-1)),i=e[e.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Zp(t,e,r){let i=r(e,t);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=e[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=Zp(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===bc)return bc;s===Qp&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}ef.visit=Yt});var Pa=k(le=>{"use strict";var kc=Kp(),ON=Xp(),HN=tf(),Sc="\uFEFF",Ec="",xc="",Cc="",DN=t=>!!t&&"items"in t,BN=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function LN(t){switch(t){case Sc:return"<BOM>";case Ec:return"<DOC>";case xc:return"<FLOW_END>";case Cc:return"<SCALAR>";default:return JSON.stringify(t)}}function FN(t){switch(t){case Sc:return"byte-order-mark";case Ec:return"doc-mode";case xc:return"flow-error-end";case Cc:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
118
118
  `:case`\r
119
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}le.createScalarToken=bc.createScalarToken;le.resolveAsScalar=bc.resolveAsScalar;le.setScalarValue=bc.setScalarValue;le.stringify=TN.stringify;le.visit=jN.visit;le.BOM=kc;le.DOCUMENT=Sc;le.FLOW_END=Ec;le.SCALAR=xc;le.isCollection=$N;le.isScalar=ON;le.prettyToken=HN;le.tokenType=DN});var Pc=k(rf=>{"use strict";var Ai=Ra();function Re(t){switch(t){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var tf=new Set("0123456789ABCDEFabcdef"),BN=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Pa=new Set(",[]{}"),LN=new Set(` ,[]{}
121
- \r `),Cc=t=>!t||LN.has(t),Rc=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
119
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}le.createScalarToken=kc.createScalarToken;le.resolveAsScalar=kc.resolveAsScalar;le.setScalarValue=kc.setScalarValue;le.stringify=ON.stringify;le.visit=HN.visit;le.BOM=Sc;le.DOCUMENT=Ec;le.FLOW_END=xc;le.SCALAR=Cc;le.isCollection=DN;le.isScalar=BN;le.prettyToken=LN;le.tokenType=FN});var _c=k(nf=>{"use strict";var Ai=Pa();function Re(t){switch(t){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var rf=new Set("0123456789ABCDEFabcdef"),qN=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),_a=new Set(",[]{}"),MN=new Set(` ,[]{}
121
+ \r `),Rc=t=>!t||MN.has(t),Pc=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
122
122
  `?!0:r==="\r"?this.buffer[e+1]===`
123
123
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let r=this.buffer[e];if(this.indentNext>0){let i=0;for(;r===" ";)r=this.buffer[++i+e];if(r==="\r"){let n=this.buffer[i+e+1];if(n===`
124
124
  `||!n&&!this.atEnd)return e+i+1}return r===`
125
125
  `||i>=this.indentNext||!r&&!this.atEnd?e+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&Re(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
126
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Ai.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let r=e.length,i=e.indexOf("#");for(;i!==-1;){let a=e[i-1];if(a===" "||a===" "){r=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let a=e[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-r),yield*this.pushNewline(),"stream"}return yield Ai.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&Re(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Re(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Re(r)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(e[r]){case"#":yield*this.pushCount(e.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Cc),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,i=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&Re(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Ai.FLOW_END,yield*this.parseLineStart();let a=0;for(;n[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Cc),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Re(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
126
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Ai.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let r=e.length,i=e.indexOf("#");for(;i!==-1;){let a=e[i-1];if(a===" "||a===" "){r=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let a=e[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-r),yield*this.pushNewline(),"stream"}return yield Ai.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&Re(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Re(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Re(r)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(e[r]){case"#":yield*this.pushCount(e.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Rc),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,i=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&Re(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Ai.FLOW_END,yield*this.parseLineStart();let a=0;for(;n[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Rc),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Re(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
127
127
  `,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=i.indexOf(`
128
128
  `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>Re(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
129
129
  `:e=a,r=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
130
130
  `)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(e+1);if(a===-1)break;e=this.buffer.indexOf(`
131
131
  `,a)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
132
132
  `;)i=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let a=e-1,o=this.buffer[a];o==="\r"&&(o=this.buffer[--a]);let s=a;for(;o===" ";)o=this.buffer[--a];if(o===`
133
- `&&a>=this.pos&&a+1+r>s)e=a;else break}while(!0);return yield Ai.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(Re(a)||e&&Pa.has(a))break;r=i}else if(Re(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
133
+ `&&a>=this.pos&&a+1+r>s)e=a;else break}while(!0);return yield Ai.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(Re(a)||e&&_a.has(a))break;r=i}else if(Re(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
134
134
  `?(i+=1,n=`
135
- `,a=this.buffer[i+1]):r=i),a==="#"||e&&Pa.has(a))break;if(n===`
136
- `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&Pa.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Ai.SCALAR,yield*this.pushToIndex(r+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,r){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Cc),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(Re(i)||r&&Pa.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,r=this.buffer[e];for(;!Re(r)&&r!==">";)r=this.buffer[++e];return yield*this.pushToIndex(r===">"?e+1:e,!1)}else{let e=this.pos+1,r=this.buffer[e];for(;r;)if(BN.has(r))r=this.buffer[++e];else if(r==="%"&&tf.has(this.buffer[e+1])&&tf.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
135
+ `,a=this.buffer[i+1]):r=i),a==="#"||e&&_a.has(a))break;if(n===`
136
+ `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&_a.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Ai.SCALAR,yield*this.pushToIndex(r+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,r){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Rc),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(Re(i)||r&&_a.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,r=this.buffer[e];for(;!Re(r)&&r!==">";)r=this.buffer[++e];return yield*this.pushToIndex(r===">"?e+1:e,!1)}else{let e=this.pos+1,r=this.buffer[e];for(;r;)if(qN.has(r))r=this.buffer[++e];else if(r==="%"&&rf.has(this.buffer[e+1])&&rf.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
137
137
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
138
- `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||e&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let r=this.pos,i=this.buffer[r];for(;!e(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};rf.Lexer=Rc});var Ac=k(nf=>{"use strict";var _c=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<e?r=a+1:i=a}if(this.lineStarts[r]===e)return{line:r+1,col:1};if(r===0)return{line:0,col:e};let n=this.lineStarts[r-1];return{line:r,col:e-n+1}}}};nf.LineCounter=_c});var Tc=k(lf=>{"use strict";var FN=jn("process"),af=Ra(),qN=Pc();function Et(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function of(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function cf(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function _a(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Rr(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function Aa(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let r=0;r<e.length;++r)t.push(e[r])}function sf(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Et(e.start,"explicit-key-ind")&&!Et(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,cf(e.value)?e.value.end?Aa(e.value.end,e.sep):e.value.end=e.sep:Aa(e.start,e.sep),delete e.sep)}var Ic=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new qN.Lexer,this.onNewLine=e}*parse(e,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(e,r))yield*this.next(i);r||(yield*this.end())}*next(e){if(this.source=e,FN.env.LOG_TOKENS&&console.log("|",af.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=af.tokenType(e);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let r=e??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let i=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in i?i.indent:0:r.type==="flow-collection"&&i.type==="document"&&(r.indent=0),r.type==="flow-collection"&&sf(r),i.type){case"document":i.value=r;break;case"block-scalar":i.props.push(r);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=r;else{Object.assign(n,{key:r,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:r}):n.value=r;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:r,sep:[]}):n.sep?n.value=r:Object.assign(n,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let n=r.items[r.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&of(n.start)===-1&&(r.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<r.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{of(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let r=_a(this.peek(2)),i=Rr(r),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
138
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||e&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let r=this.pos,i=this.buffer[r];for(;!e(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};nf.Lexer=Pc});var Ic=k(af=>{"use strict";var Ac=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<e?r=a+1:i=a}if(this.lineStarts[r]===e)return{line:r+1,col:1};if(r===0)return{line:0,col:e};let n=this.lineStarts[r-1];return{line:r,col:e-n+1}}}};af.LineCounter=Ac});var jc=k(uf=>{"use strict";var VN=$n("process"),of=Pa(),WN=_c();function Et(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function sf(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function lf(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Aa(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Rr(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function Ia(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let r=0;r<e.length;++r)t.push(e[r])}function cf(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Et(e.start,"explicit-key-ind")&&!Et(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,lf(e.value)?e.value.end?Ia(e.value.end,e.sep):e.value.end=e.sep:Ia(e.start,e.sep),delete e.sep)}var Tc=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new WN.Lexer,this.onNewLine=e}*parse(e,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(e,r))yield*this.next(i);r||(yield*this.end())}*next(e){if(this.source=e,VN.env.LOG_TOKENS&&console.log("|",of.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=of.tokenType(e);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let r=e??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let i=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in i?i.indent:0:r.type==="flow-collection"&&i.type==="document"&&(r.indent=0),r.type==="flow-collection"&&cf(r),i.type){case"document":i.value=r;break;case"block-scalar":i.props.push(r);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=r;else{Object.assign(n,{key:r,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:r}):n.value=r;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:r,sep:[]}):n.sep?n.value=r:Object.assign(n,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let n=r.items[r.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&sf(n.start)===-1&&(r.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<r.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{sf(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let r=Aa(this.peek(2)),i=Rr(r),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
139
139
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
140
- `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Aa(n,r.start),n.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,n=i&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&r.sep&&!r.value){let o=[];for(let s=0;s<r.sep.length;++s){let c=r.sep[s];switch(c.type){case"newline":o.push(s);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||r.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):n||r.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Et(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(cf(r.key)&&!Et(r.sep,"newline")){let o=Rr(r.start),s=r.key,c=r.sep;c.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?r.sep=r.sep.concat(a,this.sourceToken):r.sep.push(this.sourceToken);else if(Et(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Rr(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||n?e.items.push({start:a,key:null,sep:[this.sourceToken]}):Et(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||r.value?(e.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!Et(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&e.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Aa(n,r.start),n.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=e.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;r.value||Et(r.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>e.indent){let i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let r=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?e.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!r||r.value?e.items.push({start:[],key:n,sep:[]}):r.sep?this.stack.push(n):Object.assign(r,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=_a(i),a=Rr(n);sf(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
140
+ `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ia(n,r.start),n.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,n=i&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&r.sep&&!r.value){let o=[];for(let s=0;s<r.sep.length;++s){let c=r.sep[s];switch(c.type){case"newline":o.push(s);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||r.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):n||r.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Et(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(lf(r.key)&&!Et(r.sep,"newline")){let o=Rr(r.start),s=r.key,c=r.sep;c.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?r.sep=r.sep.concat(a,this.sourceToken):r.sep.push(this.sourceToken);else if(Et(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Rr(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||n?e.items.push({start:a,key:null,sep:[this.sourceToken]}):Et(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||r.value?(e.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!Et(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&e.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ia(n,r.start),n.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=e.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;r.value||Et(r.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>e.indent){let i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let r=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?e.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!r||r.value?e.items.push({start:[],key:n,sep:[]}):r.sep?this.stack.push(n):Object.assign(r,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=Aa(i),a=Rr(n);cf(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
141
141
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
142
- `,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=_a(e),i=Rr(r);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=_a(e),i=Rr(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};lf.Parser=Ic});var hf=k(Ti=>{"use strict";var uf=wc(),MN=Si(),Ii=Ci(),VN=vs(),WN=A(),zN=Ac(),df=Tc();function pf(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new zN.LineCounter||null,prettyErrors:e}}function GN(t,e={}){let{lineCounter:r,prettyErrors:i}=pf(e),n=new df.Parser(r?.addNewLine),a=new uf.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(Ii.prettifyError(t,r)),s.warnings.forEach(Ii.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function ff(t,e={}){let{lineCounter:r,prettyErrors:i}=pf(e),n=new df.Parser(r?.addNewLine),a=new uf.Composer(e),o=null;for(let s of a.compose(n.parse(t),!0,t.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new Ii.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(Ii.prettifyError(t,r)),o.warnings.forEach(Ii.prettifyError(t,r))),o}function JN(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=ff(t,r);if(!n)return null;if(n.warnings.forEach(a=>VN.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},r))}function UN(t,e,r){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=r??e??{};if(!n)return}return WN.isDocument(t)&&!i?t.toString(r):new MN.Document(t,i,r).toString(r)}Ti.parse=JN;Ti.parseAllDocuments=GN;Ti.parseDocument=ff;Ti.stringify=UN});var Me=k(j=>{"use strict";var KN=wc(),YN=Si(),XN=Qs(),jc=Ci(),QN=si(),xt=A(),ZN=Nt(),eb=V(),tb=kt(),rb=St(),ib=Ra(),nb=Pc(),ab=Ac(),ob=Tc(),Ia=hf(),mf=ii();j.Composer=KN.Composer;j.Document=YN.Document;j.Schema=XN.Schema;j.YAMLError=jc.YAMLError;j.YAMLParseError=jc.YAMLParseError;j.YAMLWarning=jc.YAMLWarning;j.Alias=QN.Alias;j.isAlias=xt.isAlias;j.isCollection=xt.isCollection;j.isDocument=xt.isDocument;j.isMap=xt.isMap;j.isNode=xt.isNode;j.isPair=xt.isPair;j.isScalar=xt.isScalar;j.isSeq=xt.isSeq;j.Pair=ZN.Pair;j.Scalar=eb.Scalar;j.YAMLMap=tb.YAMLMap;j.YAMLSeq=rb.YAMLSeq;j.CST=ib;j.Lexer=nb.Lexer;j.LineCounter=ab.LineCounter;j.Parser=ob.Parser;j.parse=Ia.parse;j.parseAllDocuments=Ia.parseAllDocuments;j.parseDocument=Ia.parseDocument;j.stringify=Ia.stringify;j.visit=mf.visit;j.visitAsync=mf.visitAsync});import{AsyncLocalStorage as sb}from"node:async_hooks";import{performance as vf}from"node:perf_hooks";function gf(t=0){cb+=1,lb+=t;let e=ub.getStore();e&&(e.gitCommands+=1,e.gitDurationMs+=t)}function ji(t){let e=vf.now();try{return t()}finally{gf(vf.now()-e)}}var cb,lb,ub,Pr=x(()=>{"use strict";cb=0,lb=0,ub=new sb});var b_,$i=x(()=>{"use strict";b_=["$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 x_,_r=x(()=>{"use strict";Pr();$i();x_=8*1024*1024});function yb(t){return t.toLowerCase().startsWith(".env")}function Bi(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>yb(i))?"environment-file":r.some(i=>wb.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>gb.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var gb,wb,Li=x(()=>{"use strict";gb=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),wb=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"])});function Pt(t){return t!==0&&t!==0n&&t!=="0"}function nt(t,e){return Pt(t.dev)&&Pt(e.dev)&&Pt(t.ino)&&Pt(e.ino)}function B(t,e){let r=Pt(t.dev)&&Pt(e.dev);if(r&&t.dev!==e.dev)return!1;let i=Pt(t.ino)&&Pt(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var Fi=x(()=>{"use strict"});var Ve=x(()=>{"use strict";Fi()});import{createHash as Nb}from"node:crypto";import{promises as Pe}from"node:fs";import we from"node:path";import{TextDecoder as bb}from"node:util";function $c(t,e){let r=we.relative(t,e);return r===""||!we.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${we.sep}`)}function kb(t){let e=we.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||we.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let r=t.toLowerCase(),i=Bi(t);if(i||r==="runtime"||r.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${i??"native-runtime"}): ${t}`);return t}function Sb(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Eb(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function ja(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return nt(r,i)?B(r,i):B(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Ef(t){let e=await Pe.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await Pe.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function xb(t,e){let r=we.resolve(t),i=we.resolve(e);if(!$c(r,i))throw new Error("Native artifact path is outside its root");let n=[await Ef(r)],a=r;for(let o of we.relative(r,i).split(we.sep).filter(Boolean)){a=we.join(a,o);let s=await Ef(a);if(!$c(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function xf(t){for(let e of t){let r=await Pe.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Eb(e,r)||await Pe.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function L(t){let e=kb(t.ref),r=t.maxBytes===null?null:Sb(t.maxBytes??Cf),i=we.resolve(t.root,...e.split("/")),n=await xb(t.root,we.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await Pe.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);let o=await Pe.realpath(i);if(!$c(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await Pe.open(i,"r");try{let[c,l,d]=await Promise.all([s.stat(),Pe.lstat(i),Pe.realpath(i)]);if(await xf(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||d!==o||!ja(a,c)||!ja(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let u=[],p=0,f=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let b=r===null?f.length:r+1-p,y=await s.read(f,0,Math.min(f.length,b),null);if(y.bytesRead===0)break;if(p+=y.bytesRead,r!==null&&p>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);u.push(Buffer.from(f.subarray(0,y.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[m,h,g]=await Promise.all([s.stat(),Pe.lstat(i),Pe.realpath(i)]);if(await xf(n),!h.isFile()||h.isSymbolicLink()||g!==o||!ja(c,m)||!ja(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let v=Buffer.concat(u,p),N;try{N=new bb("utf-8",{fatal:!0}).decode(v)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:b})}return{ref:e,size:p,hash:t.includeHash===!1?null:Nb("sha256").update(v).digest("hex"),text:N}}finally{await s.close()}}var Cf,ue=x(()=>{"use strict";Li();Ve();Cf=1024*1024});import{promises as Hc}from"node:fs";async function Dc(t,e){let r;for(let i=0;i<=Oc.length;i+=1)try{return await t()}catch(n){r=n;let a=n.code;if(i===Oc.length||!Cb.has(a??""))throw n;await new Promise(o=>setTimeout(o,Oc[i]))}throw r}async function Bc(t,e){await Dc(()=>Hc.rename(t,e),`rename ${e}`)}async function Lc(t){await Dc(()=>Hc.unlink(t),`unlink ${t}`)}async function Fc(t,e){await Dc(()=>Hc.link(t,e),`link ${e}`)}var Cb,Oc,qc=x(()=>{"use strict";Cb=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),Oc=[50,100,200]});import{randomUUID as Rb}from"crypto";import{promises as re}from"fs";import _e from"path";function $a(t,e){let r=_e.relative(t,e);return r===""||!_e.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${_e.sep}`)}function Pb(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Oa(t,e){return B({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function _b(t,e){return Oa(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Rf(t){let e=await re.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await re.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Ar(t){for(let e of t){let r=await re.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Pb(e,r)||await re.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Ab(t,e,r){let[i,n]=await Promise.all([re.lstat(t),re.realpath(t),r?Ar(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Oa(i,e)||r&&!$a(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function Ib(t,e){let r=_e.resolve(t),i=_e.resolve(e);if(!$a(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Rf(r)],a=_e.relative(r,i).split(_e.sep).filter(Boolean),o=r;for(let s of a){await Ar(n),o=_e.join(o,s);try{await re.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Rf(o);if(!$a(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await Ar(n),n}async function Tb(t){let e;try{e=await re.open(t,"r"),await e.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await e?.close()}}async function jb(t,e,r={}){let i=_e.dirname(t),n=r.containedRoot?await Ib(r.containedRoot,i):null;n||await re.mkdir(i,{recursive:!0});let a=_e.join(i,`.${_e.basename(t)}.${Rb()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await re.open(a,"wx"),s=await o.stat(),n){let[l,d]=await Promise.all([re.lstat(a),re.realpath(a)]);if(await Ar(n),!l.isFile()||l.isSymbolicLink()||!Oa(s,l)||!$a(n[0].realPath,d))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof e=="string"?await o.writeFile(e,"utf8"):await o.writeFile(e),await o.sync(),c=await o.stat(),!Oa(s,c))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await r.afterTemporaryClose?.(),!c)throw new Error("Native atomic write temporary file was not written");if(c=await Ab(a,c,n),await r.beforeCommit?.(),n){await Ar(n);let l=await re.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!_b(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await Fc(a,t),await Lc(a)):await Bc(a,t),await Tb(i)}catch(l){if(await o?.close(),!n)await re.rm(a,{force:!0});else try{await Ar(n),await re.rm(a,{force:!0})}catch{}throw l}}async function We(t,e,r={}){await jb(t,e,r)}async function ie(t,e,r={}){await We(t,JSON.stringify(e,null,2)+`
143
- `,r)}var H=x(()=>{"use strict";qc();Ve()});function Db(t,e){return Mc[t][e]}function Ha(t,e={}){let r=["outcome","scope","nonGoals","acceptanceExamples"];return e.compact||r.push("constraints","decisions","openQuestions","verificationExpectations"),r.map(i=>`# ${Db(t,i)}
144
- `).join(`
145
- `)}var Mc,$b,Ob,Hb,Pf,Zt=x(()=>{"use strict";Mc={en:{outcome:"Outcome",scope:"Scope",nonGoals:"Non-goals",acceptanceExamples:"Acceptance examples",constraints:"Constraints and invariants",decisions:"Decisions",openQuestions:"Open questions",verificationExpectations:"Verification expectations"},"zh-CN":{outcome:"目标",scope:"范围",nonGoals:"非目标",acceptanceExamples:"验收示例",constraints:"约束与不变量",decisions:"决策",openQuestions:"待解决问题",verificationExpectations:"验证预期"}},$b={en:{verification:"Verification",currentResult:"Current result",acceptance:"Acceptance",checks:"Checks",blockers:"Blockers",risks:"Risks and skipped work",previousIterations:"Previous iterations",conclusion:"Conclusion"},"zh-CN":{verification:"验证",currentResult:"当前结果",acceptance:"验收",checks:"检查",blockers:"阻塞项",risks:"风险与跳过的工作",previousIterations:"之前的迭代",conclusion:"结论"}},Ob={en:{acceptanceEvidence:"Acceptance evidence",commandsAndResults:"Commands and results",skippedChecks:"Skipped checks",specConsistency:"Spec consistency",knownLimitationsAndRisks:"Known limitations and risks",conclusion:"Conclusion"},"zh-CN":{acceptanceEvidence:"验收证据",commandsAndResults:"命令与结果",skippedChecks:"跳过的检查",specConsistency:"规格一致性",knownLimitationsAndRisks:"已知限制与风险",conclusion:"结论"}},Hb=new Map,Pf=new Map;for(let t of Object.keys(Mc)){for(let[e,r]of Object.entries(Mc[t]))Hb.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries($b[t]))Pf.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Ob[t]))Pf.set(r.toLocaleLowerCase("en-US"),e)}});import _t from"path";function Mb(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||_t.posix.isAbsolute(r)||_t.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be a project-relative path`);if(r===".")return[];let i=r.replaceAll("\\","/").split("/");if(i.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(i.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return i}function er(t){let e=Mb(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Hf(t,e="docs"){let r=t??e;if(r!=="legacy"&&r!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return r}function Fa(t,e,r=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim().replaceAll("\\","/");if(i.length===0||_t.posix.isAbsolute(i)||_t.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be relative to its declared path base`);let n=i.split("/");if(n.some(a=>a===".."))throw new Error(`${e} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!r&&/[*?]/u.test(i))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function at(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Df(t,e,r){let i=t??e;if(i!=="en"&&i!=="zh-CN")throw new Error(`${r} must be en or zh-CN`);return i}function qa(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>Ba)throw new Error(`${e} exceeds ${Ba} characters`);let r=0;for(let i=0;i<t.length;i+=1)t[i]==="?"?r+=1:t[i]==="*"&&(r+=1,t[i+1]==="*"&&(i+=1));if(r>La)throw new Error(`${e} contains more than ${La} wildcard tokens`);return t}function jf(t,e,r){if(t===void 0)return[...r];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(i=>qa(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function qi(t,e,r){let i=t??e;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${r} must be a positive integer`);return i}function $f(t,e,r){let i=qi(t,e,r);if(i>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${r} is too large to convert to bytes safely`);return i}function Vb(t){if(t===void 0)return{...de,include:[...de.include],exclude:[...de.exclude]};let e=at(t,"native.snapshot");return{include:jf(e.include,"native.snapshot.include",de.include),exclude:jf(e.exclude,"native.snapshot.exclude",de.exclude),max_files:qi(e.max_files,de.max_files,"native.snapshot.max_files"),max_total_bytes:qi(e.max_total_bytes,de.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:qi(e.max_duration_ms,de.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:qi(e.max_selection_records,de.max_selection_records,"native.snapshot.max_selection_records")}}function Wb(t){if(t===void 0)return;let e=at(t,"native.pending_root_move"),r=e.id,i=e.from_artifact_root,n=e.to_artifact_root,a=e.stage;if(typeof r!="string"||!/^[a-f0-9-]{8,}$/u.test(r))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(e.cleanup!==void 0){let s=at(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,d=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof d!="string"||!/^[a-f0-9]{64}$/u.test(d))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:d}}return{id:r,fromArtifactRoot:er(i),toArtifactRoot:er(n),stage:a,...o?{cleanup:o}:{}}}function zb(t){if(t===void 0)return;let e=at(t,"native.finish");if(e.pull_request===void 0)return{};let r=at(e.pull_request,"native.finish.pull_request");if(r.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(r.command)||r.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(r.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=r.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(_t.posix.isAbsolute(i[0])||_t.win32.isAbsolute(i[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=r.timeout_ms??Bb;if(!Number.isSafeInteger(n)||n<1||n>Tf)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Tf}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function Gb(t,e={}){let r=at(t,"native"),i=r.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let n=r.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=r.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=r.max_verify_failures??Wc;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=r.document_writes??"allow";if(s!=="allow"&&s!=="revert")throw new Error("native.document_writes must be allow or revert");let c=Wb(r.pending_root_move),l=zb(r.finish);return{artifact_root:er(i),language:Df(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,...s==="revert"?{document_writes:s}:{},snapshot:Vb(r.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function Jb(t){let e=at(t,"classic"),r=e.context_compression??"off";if(r!=="off"&&r!=="beta")throw new Error("classic.context_compression must be off or beta");let i=e.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=e.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");let a=e.document_evidence??"neutral";if(a!=="neutral"&&a!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:Hf(e.artifact_layout),language:Df(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n,...a==="strict"?{document_evidence:a}:{}}}function Ub(t){let r=at(t,"hook").allow_paths??[];if(!Array.isArray(r))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(r.map((i,n)=>Fa(i,`hook.allow_paths[${n}]`)))]}}function Kb(t){if(t===void 0)return{...Da};let e=at(t,"memory"),r=e.learning??Da.learning,i=e.retrieval??Da.retrieval;if(typeof r!="boolean")throw new Error("memory.learning must be true or false");if(typeof i!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:r,retrieval:i}}function zc(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Yb(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||r.includes("\\")||r.includes("\0")||_t.posix.isAbsolute(r)||_t.win32.isAbsolute(r)||r.startsWith("~")||r.split("/").some(n=>n===""||n==="."||n===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!r.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(r.length>_f)throw new Error(`${e} exceeds ${_f} characters`);let i=0;for(let n=0;n<r.length;n+=1)r[n]==="?"?i+=1:r[n]==="*"&&(i+=1,r[n+1]==="*"&&(n+=1));if(i>Af)throw new Error(`${e} contains more than ${Af} wildcard tokens`);return r}function Xb(t){let e=zc(t,"knowledge.local"),r=e.include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");let i={include:[...new Set(r.map((n,a)=>Yb(n,`knowledge.local.include[${a}]`)))],max_file_mb:$f(e.max_file_mb,If.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:$f(e.max_total_mb,If.max_total_mb,"knowledge.local.max_total_mb")};if(i.max_file_mb>i.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return i}function Qb(t){if(typeof t!="string"||t.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(t)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let r=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=r==="localhost"||r==="127.0.0.1"||r==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function Zb(t){let e=zc(t,"knowledge.remote"),r=Qb(e.endpoint),i=e.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let n=e.scope;if(n!==void 0&&(typeof n!="string"||n.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let a=e.timeout_ms??5e3;if(typeof a!="number"||!Number.isSafeInteger(a)||a<100||a>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:r,...i===void 0?{}:{token_env:i},...n===void 0?{}:{scope:n},timeout_ms:a}}function ek(t){if(t===void 0)return{...Of};let e=zc(t,"knowledge"),r=e.provider??"local";if(r!=="local"&&r!=="remote")throw new Error("knowledge.provider must be local or remote");let i=e.local===void 0?void 0:Xb(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:Zb(e.remote);if(n===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:r,...i?{local:i}:{},remote:n}}function tk(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function rk(t,e,r,i,n,a,o,s){let c=t.schema!==void 0;if(!(c||t.default_workflow!==void 0||t.workflows!==void 0||!s.allowPartialProject&&t.native!==void 0)||s.allowPartialProject&&!c)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let d=t.workflows??[t.default_workflow];if(!Array.isArray(d)||d.length===0||d.some(p=>p!=="native"&&p!=="classic"))throw new Error("workflows must contain native and/or classic");let u=[...new Set(d)];if(!u.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(u.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:u,ambient_resume:o,...e?{hook:e}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function Vi(t,e={}){let r=(0,Vc.parseDocument)(t,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${r.errors[0].message}`);let i=r.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=i,a=tk(n.ambient_resume),o=n.hook===void 0?void 0:Ub(n.hook),s=Kb(n.memory),c=ek(n.knowledge),l=n.native===void 0?void 0:Gb(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),d=n.classic===void 0?void 0:Jb(n.classic),u=rk(n,o,s,c,l,d,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:u,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...d?{classic:d}:{}}}function Ma(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Da},knowledge:{...Of},native:{artifact_root:er(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Wc,snapshot:{...de,include:[...de.include],exclude:[...de.exclude]}}}}var Vc,Mi,Ba,La,_f,Af,Wc,Da,If,Of,Bb,Tf,Lb,Fb,qb,de,At=x(()=>{"use strict";Vc=et(Me(),1),Mi=Number.MAX_SAFE_INTEGER,Ba=1024,La=64,_f=1024,Af=64,Wc=5,Da={learning:!0,retrieval:!0},If={include:[],max_file_mb:1,max_total_mb:32},Of={provider:"local"},Bb=12e4,Tf=6e5,Lb=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".devin/skills/**",".dsh/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".omp/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],Fb=["**/.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"],qb=[...Lb,...Fb].sort((t,e)=>t.localeCompare(e,"en")),de={include:["**/*"],exclude:[...qb],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});import{constants as Va,promises as tr}from"fs";function Gc(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Bf(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function Wi(t){return{dev:t.dev,ino:t.ino,birthtime:Gc(t)}}function Wa(t,e){let r=Wi(t),i=Wi(e);return nt(r,i)?B(r,i):B(r,i)&&Gc(t)===Gc(e)&&Bf(t)===Bf(e)&&t.size===e.size}async function zi(t,e,r={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let i=r.label??"file",n=r.bigint===!0,a=await tr.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new ze("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new ze("too-large",`${i} exceeds ${e} bytes`);let o=await tr.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:Wi(a)});let s=process.platform==="win32"?Va.O_RDONLY:Va.O_RDONLY|Va.O_NOFOLLOW|Va.O_NONBLOCK,c;try{c=await tr.open(t,s)}catch(l){throw l.code==="ELOOP"?new ze("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,d,u]=await Promise.all([c.stat({bigint:n}),tr.lstat(t,{bigint:n}),tr.realpath(t)]);if(!l.isFile()||!d.isFile()||d.isSymbolicLink()||u!==o||!Wa(a,l)||!Wa(a,d))throw new ze("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:u,identity:Wi(l)}),await r.hooks?.afterOpen?.();let p=[],f=0,m=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let N=e+1-f,{bytesRead:b}=await c.read(m,0,Math.min(m.length,N),null);if(b===0)break;if(f+=b,f>e)throw new ze("too-large",`${i} exceeds ${e} bytes`);p.push(Buffer.from(m.subarray(0,b)))}await r.hooks?.beforeFinalCheck?.();let[h,g,v]=await Promise.all([c.stat({bigint:n}),tr.lstat(t,{bigint:n}),tr.realpath(t)]);if(!g.isFile()||g.isSymbolicLink()||v!==o||!Wa(a,h)||!Wa(a,g))throw new ze("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:v,identity:Wi(h)}),{bytes:Buffer.concat(p,f),stat:h,realPath:v}}finally{await c.close()}}var ze,Gi=x(()=>{"use strict";Fi();ze=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as za}from"fs";import It from"path";function ik(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Jc(t,e){let r=It.relative(t,e);return r===""||!It.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${It.sep}`)}async function Lf(t,e){let r=It.resolve(t),i=await za.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return za.realpath(r)}async function Ff(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=It.join(n,r[a]);let o;try{o=await za.lstat(n)}catch(d){if(ik(d))return{exists:!1,kind:"missing"};throw d}let s=It.relative(t,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${s}`);let c=a===r.length-1;if(!c&&!o.isDirectory())throw new Error(`${i.label} ancestor ${s} must be a real directory`);if(c&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let l=await za.realpath(n);if(!Jc(e,l))throw new Error(`${i.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function Ir(t,e,r){let i=Fa(e,r.label),n=It.resolve(t),a=await Lf(n,r.label),o=i.split("/"),s=It.resolve(n,...o);if(!Jc(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await Ff(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:c.exists,kind:c.kind}}async function Ge(t,e,r,i){let n=await Ir(t,e,{label:i.label,expected:"file"});if(!n.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let a=await Lf(n.projectRoot,i.label);return zi(n.target,r,{...i,verify:async(o,s)=>{if(!Jc(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await Ff(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var ot=x(()=>{"use strict";Gi();At()});import{createHash as nk}from"crypto";function ak(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Ga(t,e={}){return(await Ja(t,e)).document}async function ok(t){try{return(await Ge(t,Ji,Mi,{label:Ji})).bytes}catch(e){if(ak(e))return null;throw e}}function sk(t){return t?{exists:!0,sha256:nk("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Ja(t,e={}){let r=await ok(t);return{document:r?Vi(r.toString("utf8"),e):null,identity:sk(r)}}async function Uc(t){return(await Ga(t))?.config??null}var Ji,Tr=x(()=>{"use strict";At();ot();Ji=".comet/config.yaml"});var jr=x(()=>{"use strict";qc();Fi()});var CA,Kc=x(()=>{"use strict";jr();Tr();ot();CA=16*1024});var Qc=x(()=>{"use strict";jr();At();Tr();ot();Kc()});import{existsSync as Mf,promises as rr}from"fs";import R from"path";import pk from"os";async function Zc(t){try{return await rr.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function hk(t){try{let e=await rr.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Or(t,e){let r=R.relative(t,e);return r===""||!R.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${R.sep}`)}async function $r(t){let e=[],r=t;for(;!await Zc(r);){let n=R.dirname(r);if(n===r)break;e.push(R.basename(r)),r=n}let i=await rr.realpath(r);return R.resolve(i,...e.reverse())}async function el(t){try{return(await rr.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Ka(t){let e=R.resolve(t);try{(await rr.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=R.resolve(pk.homedir());for(;;){if(!(e===i&&r!==i)){let o=R.join(e,...Ua.split("/")),s=e===r||await hk(o);if(await Zc(o)&&s)return e}if(await Zc(R.join(e,".git")))return e;let a=R.dirname(e);if(a===e)return r;e=a}}function Ya(t){return er(t)}async function mk(t,e){let r=Ya(e),i=R.resolve(t,...r.split("/")),n=await rr.realpath(t),a=await $r(i);if(!Or(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Je(t,e){let r=Ya(e),i=await mk(t,r),n=R.join(i,"comet");if(await el(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([$r(i),$r(n)]);if(!Or(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=R.resolve(t),c=R.join(s,".comet","runtime","native");if(await el(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,d]=await Promise.all([rr.realpath(s),$r(c)]);if(!Or(l,d))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(t,...Ua.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:R.join(n,"specs"),changesDir:R.join(n,"changes"),archiveDir:R.join(n,"archive"),runtimeDir:c,changesRuntimeDir:R.join(c,"changes"),locksDir:R.join(c,"locks"),transactionsDir:R.join(c,"transactions")}}function tl(t){if(!fk.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Ue(t,e){tl(e);let r=R.join(t.changesRuntimeDir,e);if(!J(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function vk(t,e){tl(e);let r=R.join(t.changesDir,e,"runtime");if(!J(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Z(t,e){let r=Ue(t,e);if(Mf(r))return r;let i=vk(t,e);return Mf(i)?i:r}function ir(t,e){tl(e);let r=R.join(t.changesDir,e),i=Z(t,e);return{artifactRoot:t.artifactRoot,nativeRoot:t.nativeRoot,changeDir:r,briefPath:R.join(r,"brief.md"),childrenPath:R.join(r,"children.yaml"),specsDir:R.join(r,"specs"),verificationPath:R.join(r,"verification.md"),statePath:R.join(r,"comet-state.yaml"),runtimeDir:i,runtimeStatePath:R.join(i,"state.json")}}function Ae(t,e){let r=R.resolve(e);if(J(t.runtimeDir,r))return t.runtimeDir;if(J(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function J(t,e){return Or(R.resolve(t),R.resolve(e))}async function M(t,e){let r=R.resolve(t),i=R.resolve(e);if(!Or(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await el(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([$r(r),$r(i)]);if(!Or(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}var Ua,fk,I=x(()=>{"use strict";At();Ua=".comet/config.yaml",fk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});function wk(t="docs",e="en"){return Ma(t,e)}async function pe(t){let e=(await Ga(t))?.config??null;return e?.native?e:null}async function Vf(t){let e=await Ka(t.startPath),r=await pe(e);if(!r&&t.allowMissingConfig===!1)throw new Error(`${Ua} was not found`);if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let i=t.explicitArtifactRoot?Ya(t.explicitArtifactRoot):void 0;if(r&&i&&i!==r.native.artifact_root)throw new Error(`Configured Native artifact root is ${r.native.artifact_root}; refusing conflicting root ${i}`);let n=r??wk(i??"docs"),a=await Je(e,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}var Xa,ve=x(()=>{"use strict";At();Tr();Qc();H();I();Xa=qa});import{createHash as yk,randomUUID as UA}from"node:crypto";var Nk,YA,Wf=x(()=>{"use strict";_r();Nk=`using System;
142
+ `,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Aa(e),i=Rr(r);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=Aa(e),i=Rr(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};uf.Parser=Tc});var mf=k(Ti=>{"use strict";var df=yc(),zN=Si(),Ii=Ci(),GN=gs(),JN=A(),UN=Ic(),pf=jc();function ff(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new UN.LineCounter||null,prettyErrors:e}}function KN(t,e={}){let{lineCounter:r,prettyErrors:i}=ff(e),n=new pf.Parser(r?.addNewLine),a=new df.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(Ii.prettifyError(t,r)),s.warnings.forEach(Ii.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function hf(t,e={}){let{lineCounter:r,prettyErrors:i}=ff(e),n=new pf.Parser(r?.addNewLine),a=new df.Composer(e),o=null;for(let s of a.compose(n.parse(t),!0,t.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new Ii.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(Ii.prettifyError(t,r)),o.warnings.forEach(Ii.prettifyError(t,r))),o}function YN(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=hf(t,r);if(!n)return null;if(n.warnings.forEach(a=>GN.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},r))}function XN(t,e,r){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=r??e??{};if(!n)return}return JN.isDocument(t)&&!i?t.toString(r):new zN.Document(t,i,r).toString(r)}Ti.parse=YN;Ti.parseAllDocuments=KN;Ti.parseDocument=hf;Ti.stringify=XN});var Me=k(j=>{"use strict";var QN=yc(),ZN=Si(),eb=Zs(),$c=Ci(),tb=si(),xt=A(),rb=Nt(),ib=V(),nb=kt(),ab=St(),ob=Pa(),sb=_c(),cb=Ic(),lb=jc(),Ta=mf(),vf=ii();j.Composer=QN.Composer;j.Document=ZN.Document;j.Schema=eb.Schema;j.YAMLError=$c.YAMLError;j.YAMLParseError=$c.YAMLParseError;j.YAMLWarning=$c.YAMLWarning;j.Alias=tb.Alias;j.isAlias=xt.isAlias;j.isCollection=xt.isCollection;j.isDocument=xt.isDocument;j.isMap=xt.isMap;j.isNode=xt.isNode;j.isPair=xt.isPair;j.isScalar=xt.isScalar;j.isSeq=xt.isSeq;j.Pair=rb.Pair;j.Scalar=ib.Scalar;j.YAMLMap=nb.YAMLMap;j.YAMLSeq=ab.YAMLSeq;j.CST=ob;j.Lexer=sb.Lexer;j.LineCounter=cb.LineCounter;j.Parser=lb.Parser;j.parse=Ta.parse;j.parseAllDocuments=Ta.parseAllDocuments;j.parseDocument=Ta.parseDocument;j.stringify=Ta.stringify;j.visit=vf.visit;j.visitAsync=vf.visitAsync});import{AsyncLocalStorage as ub}from"node:async_hooks";import{performance as gf}from"node:perf_hooks";function wf(t=0){db+=1,pb+=t;let e=fb.getStore();e&&(e.gitCommands+=1,e.gitDurationMs+=t)}function ji(t){let e=gf.now();try{return t()}finally{wf(gf.now()-e)}}var db,pb,fb,Pr=x(()=>{"use strict";db=0,pb=0,fb=new ub});var R_,$i=x(()=>{"use strict";R_=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ")});var I_,_r=x(()=>{"use strict";Pr();$i();I_=8*1024*1024});function kb(t){return t.toLowerCase().startsWith(".env")}function Bi(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>kb(i))?"environment-file":r.some(i=>bb.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>Nb.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var Nb,bb,Li=x(()=>{"use strict";Nb=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),bb=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"])});function Pt(t){return t!==0&&t!==0n&&t!=="0"}function nt(t,e){return Pt(t.dev)&&Pt(e.dev)&&Pt(t.ino)&&Pt(e.ino)}function B(t,e){let r=Pt(t.dev)&&Pt(e.dev);if(r&&t.dev!==e.dev)return!1;let i=Pt(t.ino)&&Pt(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var Fi=x(()=>{"use strict"});var Ve=x(()=>{"use strict";Fi()});import{createHash as Sb}from"node:crypto";import{promises as Pe}from"node:fs";import we from"node:path";import{TextDecoder as Eb}from"node:util";function Oc(t,e){let r=we.relative(t,e);return r===""||!we.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${we.sep}`)}function xb(t){let e=we.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||we.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let r=t.toLowerCase(),i=Bi(t);if(i||r==="runtime"||r.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${i??"native-runtime"}): ${t}`);return t}function Cb(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Rb(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function $a(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return nt(r,i)?B(r,i):B(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function xf(t){let e=await Pe.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await Pe.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Pb(t,e){let r=we.resolve(t),i=we.resolve(e);if(!Oc(r,i))throw new Error("Native artifact path is outside its root");let n=[await xf(r)],a=r;for(let o of we.relative(r,i).split(we.sep).filter(Boolean)){a=we.join(a,o);let s=await xf(a);if(!Oc(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Cf(t){for(let e of t){let r=await Pe.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Rb(e,r)||await Pe.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function L(t){let e=xb(t.ref),r=t.maxBytes===null?null:Cb(t.maxBytes??Rf),i=we.resolve(t.root,...e.split("/")),n=await Pb(t.root,we.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await Pe.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);let o=await Pe.realpath(i);if(!Oc(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await Pe.open(i,"r");try{let[c,l,d]=await Promise.all([s.stat(),Pe.lstat(i),Pe.realpath(i)]);if(await Cf(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||d!==o||!$a(a,c)||!$a(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let u=[],p=0,f=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let b=r===null?f.length:r+1-p,y=await s.read(f,0,Math.min(f.length,b),null);if(y.bytesRead===0)break;if(p+=y.bytesRead,r!==null&&p>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);u.push(Buffer.from(f.subarray(0,y.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[m,h,g]=await Promise.all([s.stat(),Pe.lstat(i),Pe.realpath(i)]);if(await Cf(n),!h.isFile()||h.isSymbolicLink()||g!==o||!$a(c,m)||!$a(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let v=Buffer.concat(u,p),N;try{N=new Eb("utf-8",{fatal:!0}).decode(v)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:b})}return{ref:e,size:p,hash:t.includeHash===!1?null:Sb("sha256").update(v).digest("hex"),text:N}}finally{await s.close()}}var Rf,ue=x(()=>{"use strict";Li();Ve();Rf=1024*1024});import{promises as Dc}from"node:fs";async function Bc(t,e){let r;for(let i=0;i<=Hc.length;i+=1)try{return await t()}catch(n){r=n;let a=n.code;if(i===Hc.length||!_b.has(a??""))throw n;await new Promise(o=>setTimeout(o,Hc[i]))}throw r}async function Lc(t,e){await Bc(()=>Dc.rename(t,e),`rename ${e}`)}async function Fc(t){await Bc(()=>Dc.unlink(t),`unlink ${t}`)}async function qc(t,e){await Bc(()=>Dc.link(t,e),`link ${e}`)}var _b,Hc,Mc=x(()=>{"use strict";_b=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),Hc=[50,100,200]});import{randomUUID as Ab}from"crypto";import{promises as re}from"fs";import _e from"path";function Oa(t,e){let r=_e.relative(t,e);return r===""||!_e.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${_e.sep}`)}function Ib(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Ha(t,e){return B({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function Tb(t,e){return Ha(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Pf(t){let e=await re.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await re.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Ar(t){for(let e of t){let r=await re.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Ib(e,r)||await re.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function jb(t,e,r){let[i,n]=await Promise.all([re.lstat(t),re.realpath(t),r?Ar(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Ha(i,e)||r&&!Oa(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function $b(t,e){let r=_e.resolve(t),i=_e.resolve(e);if(!Oa(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Pf(r)],a=_e.relative(r,i).split(_e.sep).filter(Boolean),o=r;for(let s of a){await Ar(n),o=_e.join(o,s);try{await re.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Pf(o);if(!Oa(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await Ar(n),n}async function Ob(t){let e;try{e=await re.open(t,"r"),await e.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await e?.close()}}async function Hb(t,e,r={}){let i=_e.dirname(t),n=r.containedRoot?await $b(r.containedRoot,i):null;n||await re.mkdir(i,{recursive:!0});let a=_e.join(i,`.${_e.basename(t)}.${Ab()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await re.open(a,"wx"),s=await o.stat(),n){let[l,d]=await Promise.all([re.lstat(a),re.realpath(a)]);if(await Ar(n),!l.isFile()||l.isSymbolicLink()||!Ha(s,l)||!Oa(n[0].realPath,d))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof e=="string"?await o.writeFile(e,"utf8"):await o.writeFile(e),await o.sync(),c=await o.stat(),!Ha(s,c))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await r.afterTemporaryClose?.(),!c)throw new Error("Native atomic write temporary file was not written");if(c=await jb(a,c,n),await r.beforeCommit?.(),n){await Ar(n);let l=await re.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!Tb(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await qc(a,t),await Fc(a)):await Lc(a,t),await Ob(i)}catch(l){if(await o?.close(),!n)await re.rm(a,{force:!0});else try{await Ar(n),await re.rm(a,{force:!0})}catch{}throw l}}async function We(t,e,r={}){await Hb(t,e,r)}async function ie(t,e,r={}){await We(t,JSON.stringify(e,null,2)+`
143
+ `,r)}var H=x(()=>{"use strict";Mc();Ve()});function Af(t,e){return Vc[t][e]}function Mb(t){return qi[t].section}function Vb(t,e){return qi[t].subsections[e]}function Da(t,e={}){let r=["outcome","scope","nonGoals","acceptanceExamples"];return e.compact||r.push("constraints","decisions","openQuestions","verificationExpectations"),r.map(i=>{if(i!=="scope")return`# ${Af(t,i)}
144
+ `;let n=[`# ${Af(t,i)}
145
+ `];n.push(`## ${Mb(t)}
146
+ `);for(let a of If)n.push(`### ${Vb(t,a)}
147
+ `);return n.join(`
148
+ `)}).join(`
149
+ `)}var If,Vc,Db,Bb,Lb,_f,Fb,qb,qi,Zt=x(()=>{"use strict";If=["created","modified","deleted","notCreated"],Vc={en:{outcome:"Outcome",scope:"Scope",nonGoals:"Non-goals",acceptanceExamples:"Acceptance examples",constraints:"Constraints and invariants",decisions:"Decisions",openQuestions:"Open questions",verificationExpectations:"Verification expectations"},"zh-CN":{outcome:"目标",scope:"范围",nonGoals:"非目标",acceptanceExamples:"验收示例",constraints:"约束与不变量",decisions:"决策",openQuestions:"待解决问题",verificationExpectations:"验证预期"}},Db={en:{verification:"Verification",currentResult:"Current result",acceptance:"Acceptance",checks:"Checks",blockers:"Blockers",risks:"Risks and skipped work",previousIterations:"Previous iterations",conclusion:"Conclusion"},"zh-CN":{verification:"验证",currentResult:"当前结果",acceptance:"验收",checks:"检查",blockers:"阻塞项",risks:"风险与跳过的工作",previousIterations:"之前的迭代",conclusion:"结论"}},Bb={en:{acceptanceEvidence:"Acceptance evidence",commandsAndResults:"Commands and results",skippedChecks:"Skipped checks",specConsistency:"Spec consistency",knownLimitationsAndRisks:"Known limitations and risks",conclusion:"Conclusion"},"zh-CN":{acceptanceEvidence:"验收证据",commandsAndResults:"命令与结果",skippedChecks:"跳过的检查",specConsistency:"规格一致性",knownLimitationsAndRisks:"已知限制与风险",conclusion:"结论"}},Lb=new Map,_f=new Map,Fb=new Set,qb=new Map,qi={en:{section:"Directory structure",subsections:{created:"Created",modified:"Modified",deleted:"Deleted",notCreated:"Not created"}},"zh-CN":{section:"目录结构",subsections:{created:"新建",modified:"修改",deleted:"删除",notCreated:"明确不建"}}};for(let t of Object.keys(Vc)){for(let[e,r]of Object.entries(Vc[t]))Lb.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Db[t]))_f.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Bb[t]))_f.set(r.toLocaleLowerCase("en-US"),e)}for(let t of Object.keys(qi)){Fb.add(qi[t].section.toLocaleLowerCase("en-US"));for(let[e,r]of Object.entries(qi[t].subsections))qb.set(r.toLocaleLowerCase("en-US"),e)}});import _t from"path";function Ub(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||_t.posix.isAbsolute(r)||_t.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be a project-relative path`);if(r===".")return[];let i=r.replaceAll("\\","/").split("/");if(i.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(i.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return i}function er(t){let e=Ub(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Lf(t,e="docs"){let r=t??e;if(r!=="legacy"&&r!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return r}function qa(t,e,r=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim().replaceAll("\\","/");if(i.length===0||_t.posix.isAbsolute(i)||_t.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be relative to its declared path base`);let n=i.split("/");if(n.some(a=>a===".."))throw new Error(`${e} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!r&&/[*?]/u.test(i))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function at(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ff(t,e,r){let i=t??e;if(i!=="en"&&i!=="zh-CN")throw new Error(`${r} must be en or zh-CN`);return i}function Ma(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>La)throw new Error(`${e} exceeds ${La} characters`);let r=0;for(let i=0;i<t.length;i+=1)t[i]==="?"?r+=1:t[i]==="*"&&(r+=1,t[i+1]==="*"&&(i+=1));if(r>Fa)throw new Error(`${e} contains more than ${Fa} wildcard tokens`);return t}function Hf(t,e,r){if(t===void 0)return[...r];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(i=>Ma(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function Mi(t,e,r){let i=t??e;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${r} must be a positive integer`);return i}function Df(t,e,r){let i=Mi(t,e,r);if(i>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${r} is too large to convert to bytes safely`);return i}function Kb(t){if(t===void 0)return{...de,include:[...de.include],exclude:[...de.exclude]};let e=at(t,"native.snapshot");return{include:Hf(e.include,"native.snapshot.include",de.include),exclude:Hf(e.exclude,"native.snapshot.exclude",de.exclude),max_files:Mi(e.max_files,de.max_files,"native.snapshot.max_files"),max_total_bytes:Mi(e.max_total_bytes,de.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Mi(e.max_duration_ms,de.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:Mi(e.max_selection_records,de.max_selection_records,"native.snapshot.max_selection_records")}}function Yb(t){if(t===void 0)return;let e=at(t,"native.pending_root_move"),r=e.id,i=e.from_artifact_root,n=e.to_artifact_root,a=e.stage;if(typeof r!="string"||!/^[a-f0-9-]{8,}$/u.test(r))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(e.cleanup!==void 0){let s=at(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,d=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof d!="string"||!/^[a-f0-9]{64}$/u.test(d))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:d}}return{id:r,fromArtifactRoot:er(i),toArtifactRoot:er(n),stage:a,...o?{cleanup:o}:{}}}function Xb(t){if(t===void 0)return;let e=at(t,"native.finish");if(e.pull_request===void 0)return{};let r=at(e.pull_request,"native.finish.pull_request");if(r.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(r.command)||r.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(r.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=r.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(_t.posix.isAbsolute(i[0])||_t.win32.isAbsolute(i[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=r.timeout_ms??Wb;if(!Number.isSafeInteger(n)||n<1||n>Of)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Of}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function Qb(t,e={}){let r=at(t,"native"),i=r.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let n=r.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=r.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=r.max_verify_failures??zc;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=r.document_writes??"allow";if(s!=="allow"&&s!=="revert")throw new Error("native.document_writes must be allow or revert");let c=Yb(r.pending_root_move),l=Xb(r.finish);return{artifact_root:er(i),language:Ff(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,...s==="revert"?{document_writes:s}:{},snapshot:Kb(r.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function Zb(t){let e=at(t,"classic"),r=e.context_compression??"off";if(r!=="off"&&r!=="beta")throw new Error("classic.context_compression must be off or beta");let i=e.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=e.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");let a=e.document_evidence??"neutral";if(a!=="neutral"&&a!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:Lf(e.artifact_layout),language:Ff(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n,...a==="strict"?{document_evidence:a}:{}}}function ek(t){let r=at(t,"hook").allow_paths??[];if(!Array.isArray(r))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(r.map((i,n)=>qa(i,`hook.allow_paths[${n}]`)))]}}function tk(t){if(t===void 0)return{...Ba};let e=at(t,"memory"),r=e.learning??Ba.learning,i=e.retrieval??Ba.retrieval;if(typeof r!="boolean")throw new Error("memory.learning must be true or false");if(typeof i!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:r,retrieval:i}}function Gc(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function rk(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||r.includes("\\")||r.includes("\0")||_t.posix.isAbsolute(r)||_t.win32.isAbsolute(r)||r.startsWith("~")||r.split("/").some(n=>n===""||n==="."||n===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!r.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(r.length>Tf)throw new Error(`${e} exceeds ${Tf} characters`);let i=0;for(let n=0;n<r.length;n+=1)r[n]==="?"?i+=1:r[n]==="*"&&(i+=1,r[n+1]==="*"&&(n+=1));if(i>jf)throw new Error(`${e} contains more than ${jf} wildcard tokens`);return r}function ik(t){let e=Gc(t,"knowledge.local"),r=e.include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");let i={include:[...new Set(r.map((n,a)=>rk(n,`knowledge.local.include[${a}]`)))],max_file_mb:Df(e.max_file_mb,$f.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Df(e.max_total_mb,$f.max_total_mb,"knowledge.local.max_total_mb")};if(i.max_file_mb>i.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return i}function nk(t){if(typeof t!="string"||t.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(t)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let r=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=r==="localhost"||r==="127.0.0.1"||r==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function ak(t){let e=Gc(t,"knowledge.remote"),r=nk(e.endpoint),i=e.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let n=e.scope;if(n!==void 0&&(typeof n!="string"||n.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let a=e.timeout_ms??5e3;if(typeof a!="number"||!Number.isSafeInteger(a)||a<100||a>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:r,...i===void 0?{}:{token_env:i},...n===void 0?{}:{scope:n},timeout_ms:a}}function ok(t){if(t===void 0)return{...Bf};let e=Gc(t,"knowledge"),r=e.provider??"local";if(r!=="local"&&r!=="remote")throw new Error("knowledge.provider must be local or remote");let i=e.local===void 0?void 0:ik(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:ak(e.remote);if(n===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:r,...i?{local:i}:{},remote:n}}function sk(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function ck(t,e,r,i,n,a,o,s){let c=t.schema!==void 0;if(!(c||t.default_workflow!==void 0||t.workflows!==void 0||!s.allowPartialProject&&t.native!==void 0)||s.allowPartialProject&&!c)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let d=t.workflows??[t.default_workflow];if(!Array.isArray(d)||d.length===0||d.some(p=>p!=="native"&&p!=="classic"))throw new Error("workflows must contain native and/or classic");let u=[...new Set(d)];if(!u.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(u.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:u,ambient_resume:o,...e?{hook:e}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function Wi(t,e={}){let r=(0,Wc.parseDocument)(t,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${r.errors[0].message}`);let i=r.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=i,a=sk(n.ambient_resume),o=n.hook===void 0?void 0:ek(n.hook),s=tk(n.memory),c=ok(n.knowledge),l=n.native===void 0?void 0:Qb(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),d=n.classic===void 0?void 0:Zb(n.classic),u=ck(n,o,s,c,l,d,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:u,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...d?{classic:d}:{}}}function Va(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Ba},knowledge:{...Bf},native:{artifact_root:er(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:zc,snapshot:{...de,include:[...de.include],exclude:[...de.exclude]}}}}var Wc,Vi,La,Fa,Tf,jf,zc,Ba,$f,Bf,Wb,Of,zb,Gb,Jb,de,At=x(()=>{"use strict";Wc=et(Me(),1),Vi=Number.MAX_SAFE_INTEGER,La=1024,Fa=64,Tf=1024,jf=64,zc=5,Ba={learning:!0,retrieval:!0},$f={include:[],max_file_mb:1,max_total_mb:32},Bf={provider:"local"},Wb=12e4,Of=6e5,zb=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".devin/skills/**",".dsh/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".omp/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],Gb=["**/.idea/**","**/.vscode/**",".codex/skills/**","**/node_modules/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.svelte-kit/**","**/.vite/**","**/.parcel-cache/**","**/.turbo/**","**/.nx/cache/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.nyc_output/**","**/target/**","**/.gradle/**","**/.cxx/**","**/.externalNativeBuild/**","**/captures/**","**/__pycache__/**","**/.pytest_cache/**","**/.mypy_cache/**","**/.ruff_cache/**","**/.tox/**","**/.nox/**","**/.venv/**","**/venv/**","**/obj/**","**/CMakeFiles/**","**/cmake-build-*/**","**/.cache/**","**/tmp/**","**/temp/**","**/logs/**","**/*.tsbuildinfo","**/*.log","**/.DS_Store","**/Thumbs.db"],Jb=[...zb,...Gb].sort((t,e)=>t.localeCompare(e,"en")),de={include:["**/*"],exclude:[...Jb],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});import{constants as Wa,promises as tr}from"fs";function Jc(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function qf(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function zi(t){return{dev:t.dev,ino:t.ino,birthtime:Jc(t)}}function za(t,e){let r=zi(t),i=zi(e);return nt(r,i)?B(r,i):B(r,i)&&Jc(t)===Jc(e)&&qf(t)===qf(e)&&t.size===e.size}async function Gi(t,e,r={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let i=r.label??"file",n=r.bigint===!0,a=await tr.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new ze("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new ze("too-large",`${i} exceeds ${e} bytes`);let o=await tr.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:zi(a)});let s=process.platform==="win32"?Wa.O_RDONLY:Wa.O_RDONLY|Wa.O_NOFOLLOW|Wa.O_NONBLOCK,c;try{c=await tr.open(t,s)}catch(l){throw l.code==="ELOOP"?new ze("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,d,u]=await Promise.all([c.stat({bigint:n}),tr.lstat(t,{bigint:n}),tr.realpath(t)]);if(!l.isFile()||!d.isFile()||d.isSymbolicLink()||u!==o||!za(a,l)||!za(a,d))throw new ze("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:u,identity:zi(l)}),await r.hooks?.afterOpen?.();let p=[],f=0,m=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let N=e+1-f,{bytesRead:b}=await c.read(m,0,Math.min(m.length,N),null);if(b===0)break;if(f+=b,f>e)throw new ze("too-large",`${i} exceeds ${e} bytes`);p.push(Buffer.from(m.subarray(0,b)))}await r.hooks?.beforeFinalCheck?.();let[h,g,v]=await Promise.all([c.stat({bigint:n}),tr.lstat(t,{bigint:n}),tr.realpath(t)]);if(!g.isFile()||g.isSymbolicLink()||v!==o||!za(a,h)||!za(a,g))throw new ze("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:v,identity:zi(h)}),{bytes:Buffer.concat(p,f),stat:h,realPath:v}}finally{await c.close()}}var ze,Ji=x(()=>{"use strict";Fi();ze=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Ga}from"fs";import It from"path";function lk(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Uc(t,e){let r=It.relative(t,e);return r===""||!It.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${It.sep}`)}async function Mf(t,e){let r=It.resolve(t),i=await Ga.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Ga.realpath(r)}async function Vf(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=It.join(n,r[a]);let o;try{o=await Ga.lstat(n)}catch(d){if(lk(d))return{exists:!1,kind:"missing"};throw d}let s=It.relative(t,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${s}`);let c=a===r.length-1;if(!c&&!o.isDirectory())throw new Error(`${i.label} ancestor ${s} must be a real directory`);if(c&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let l=await Ga.realpath(n);if(!Uc(e,l))throw new Error(`${i.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function Ir(t,e,r){let i=qa(e,r.label),n=It.resolve(t),a=await Mf(n,r.label),o=i.split("/"),s=It.resolve(n,...o);if(!Uc(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await Vf(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:c.exists,kind:c.kind}}async function Ge(t,e,r,i){let n=await Ir(t,e,{label:i.label,expected:"file"});if(!n.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let a=await Mf(n.projectRoot,i.label);return Gi(n.target,r,{...i,verify:async(o,s)=>{if(!Uc(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await Vf(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var ot=x(()=>{"use strict";Ji();At()});import{createHash as uk}from"crypto";function dk(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Ja(t,e={}){return(await Ua(t,e)).document}async function pk(t){try{return(await Ge(t,Ui,Vi,{label:Ui})).bytes}catch(e){if(dk(e))return null;throw e}}function fk(t){return t?{exists:!0,sha256:uk("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Ua(t,e={}){let r=await pk(t);return{document:r?Wi(r.toString("utf8"),e):null,identity:fk(r)}}async function Kc(t){return(await Ja(t))?.config??null}var Ui,Tr=x(()=>{"use strict";At();ot();Ui=".comet/config.yaml"});var jr=x(()=>{"use strict";Mc();Fi()});var TA,Yc=x(()=>{"use strict";jr();Tr();ot();TA=16*1024});var Zc=x(()=>{"use strict";jr();At();Tr();ot();Yc()});import{existsSync as zf,promises as rr}from"fs";import R from"path";import wk from"os";async function el(t){try{return await rr.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Nk(t){try{let e=await rr.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Or(t,e){let r=R.relative(t,e);return r===""||!R.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${R.sep}`)}async function $r(t){let e=[],r=t;for(;!await el(r);){let n=R.dirname(r);if(n===r)break;e.push(R.basename(r)),r=n}let i=await rr.realpath(r);return R.resolve(i,...e.reverse())}async function tl(t){try{return(await rr.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Ya(t){let e=R.resolve(t);try{(await rr.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=R.resolve(wk.homedir());for(;;){if(!(e===i&&r!==i)){let o=R.join(e,...Ka.split("/")),s=e===r||await Nk(o);if(await el(o)&&s)return e}if(await el(R.join(e,".git")))return e;let a=R.dirname(e);if(a===e)return r;e=a}}function Xa(t){return er(t)}async function bk(t,e){let r=Xa(e),i=R.resolve(t,...r.split("/")),n=await rr.realpath(t),a=await $r(i);if(!Or(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Je(t,e){let r=Xa(e),i=await bk(t,r),n=R.join(i,"comet");if(await tl(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([$r(i),$r(n)]);if(!Or(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=R.resolve(t),c=R.join(s,".comet","runtime","native");if(await tl(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,d]=await Promise.all([rr.realpath(s),$r(c)]);if(!Or(l,d))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(t,...Ka.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:R.join(n,"specs"),changesDir:R.join(n,"changes"),archiveDir:R.join(n,"archive"),runtimeDir:c,changesRuntimeDir:R.join(c,"changes"),locksDir:R.join(c,"locks"),transactionsDir:R.join(c,"transactions")}}function rl(t){if(!yk.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Ue(t,e){rl(e);let r=R.join(t.changesRuntimeDir,e);if(!J(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function kk(t,e){rl(e);let r=R.join(t.changesDir,e,"runtime");if(!J(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Z(t,e){let r=Ue(t,e);if(zf(r))return r;let i=kk(t,e);return zf(i)?i:r}function ir(t,e){rl(e);let r=R.join(t.changesDir,e),i=Z(t,e);return{artifactRoot:t.artifactRoot,nativeRoot:t.nativeRoot,changeDir:r,briefPath:R.join(r,"brief.md"),childrenPath:R.join(r,"children.yaml"),specsDir:R.join(r,"specs"),verificationPath:R.join(r,"verification.md"),statePath:R.join(r,"comet-state.yaml"),runtimeDir:i,runtimeStatePath:R.join(i,"state.json")}}function Ae(t,e){let r=R.resolve(e);if(J(t.runtimeDir,r))return t.runtimeDir;if(J(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function J(t,e){return Or(R.resolve(t),R.resolve(e))}async function M(t,e){let r=R.resolve(t),i=R.resolve(e);if(!Or(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await tl(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([$r(r),$r(i)]);if(!Or(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}var Ka,yk,I=x(()=>{"use strict";At();Ka=".comet/config.yaml",yk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});function Ek(t="docs",e="en"){return Va(t,e)}async function pe(t){let e=(await Ja(t))?.config??null;return e?.native?e:null}async function Gf(t){let e=await Ya(t.startPath),r=await pe(e);if(!r&&t.allowMissingConfig===!1)throw new Error(`${Ka} was not found`);if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let i=t.explicitArtifactRoot?Xa(t.explicitArtifactRoot):void 0;if(r&&i&&i!==r.native.artifact_root)throw new Error(`Configured Native artifact root is ${r.native.artifact_root}; refusing conflicting root ${i}`);let n=r??Ek(i??"docs"),a=await Je(e,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}var Qa,ve=x(()=>{"use strict";At();Tr();Zc();H();I();Qa=Ma});import{createHash as xk,randomUUID as eI}from"node:crypto";var Ck,rI,Jf=x(()=>{"use strict";_r();Ck=`using System;
146
150
  using System.Runtime.InteropServices;
147
151
  class CometProcessIdentity {
148
152
  [DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
@@ -155,20 +159,20 @@ class CometProcessIdentity {
155
159
  Console.WriteLine(DateTime.FromFileTimeUtc(creation).Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); return 0;
156
160
  } finally { CloseHandle(handle); }
157
161
  }
158
- }`,YA=yk("sha256").update(Nk).digest("hex")});var Qa=x(()=>{"use strict";_r();Wf()});import{AsyncLocalStorage as kk}from"async_hooks";var sI,cI,lI,Ki=x(()=>{"use strict";Gi();Qa();I();Ve();sI=16*1024,cI=900*1e3,lI=new kk});var Gf,rl=x(()=>{"use strict";Gf=et(Me(),1)});var st,Tt,jt,Yi=x(()=>{"use strict";st="comet.native.v3",Tt="comet.native.v2",jt="comet.native.v1"});import Sk from"node:path";function Zi(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Yf(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function nr(t){if(!Kf.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Xf(t){if(!Kf.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Qf(t,e){if(t.length===0||Sk.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function Ik(t,e){let r=Zi(t,`spec_changes[${e}]`);if(Yf(r,Ck,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(Xf(r.capability),r.operation!=="create"&&r.operation!=="replace"&&r.operation!=="remove")throw new Error(`Invalid spec operation for ${r.capability}`);let i=r.source,n=r.base_hash;if(i!==void 0&&typeof i!="string")throw new Error(`Spec source for ${r.capability} must be a string`);if(typeof i=="string"&&Qf(i,`Spec source for ${r.capability}`),r.operation==="create"){if(!i)throw new Error(`Create spec ${r.capability} requires source`);if(n!==null)throw new Error(`Create spec ${r.capability} requires null base_hash`)}else if(r.operation==="replace"){if(!i)throw new Error(`Replace spec ${r.capability} requires source`);if(typeof n!="string"||!nl.test(n))throw new Error(`Replace spec ${r.capability} requires a SHA-256 base_hash`)}else{if(i!==void 0)throw new Error(`Remove spec ${r.capability} forbids source`);if(typeof n!="string"||!nl.test(n))throw new Error(`Remove spec ${r.capability} requires a SHA-256 base_hash`)}return{capability:r.capability,operation:r.operation,...typeof i=="string"?{source:i}:{},base_hash:n}}function Tk(t){return/^\d{4}-\d{2}-\d{2}$/u.test(t)?new Date(`${t}T00:00:00.000Z`).toISOString().slice(0,10)===t:!1}function al(t,e){if(Yf(t,e,lt),typeof t.name!="string")throw new Error("Native change name is required");if(nr(t.name),t.language!=="en"&&t.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof t.phase!="string"||!Rk.has(t.phase))throw new Error("Native change phase is invalid");if(t.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(t.approval!==null&&!Pk.has(t.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native spec_changes must be an array");let r=t.spec_changes.map(Ik),i=r.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(i.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(i)].join(", ")}`);if(typeof t.verification_result!="string"||!_k.has(t.verification_result))throw new Error("Native verification_result is invalid");if(t.verification_report!==null&&typeof t.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof t.verification_report=="string"&&Qf(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!Tk(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:r,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function en(t){let e=Zi(t,lt);if(e.schema!==jt)throw new Error(`Expected ${jt}`);return{schema:jt,...al(e,Ek)}}function Qi(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function il(t,e,r){if(t===null)return null;let i=typeof t=="string"?Ak.exec(t):null;if(!i||i[1]!==r)throw new Error(`${e} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return t}function jk(t){if(t==null)return null;if(typeof t!="string"||!nl.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function $k(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function tn(t){let e=Zi(t,lt);if(e.schema!==Tt)throw new Error(`Expected ${Tt}`);if(Qi(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Tt} minimum_runtime_version must be 2`);return{schema:Tt,minimum_runtime_version:2,revision:Qi(e.revision,"Native v2 revision"),...al(e,Uf)}}function Hr(t){let e=Zi(t,lt);if(e.schema!==st){if(e.schema===jt||e.schema===Tt){let o=e.schema===jt?en(e):tn(e);throw new Xi(o.name,o.schema)}throw new Ke(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=Qi(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Ke(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=Qi(e.revision,"Native revision"),n=al(e,xk),a=jk(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:st,minimum_runtime_version:3,revision:i,verification_protocol:$k(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:il(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:il(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:il(e.partial_allowance,"Native partial_allowance","allowances")}}function ol(t){let e=Zi(t,lt);if(e.schema===jt){let n=en(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${st}`}}if(e.schema===Tt){let n=tn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${st}`}}if(e.schema!==st){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new Ke(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=Qi(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new Ke(e.schema,r).message};let i=Hr(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}var Jf,Ek,Uf,xk,Ck,Rk,Pk,_k,lt,nl,Kf,Ak,Xi,Ke,Za=x(()=>{"use strict";Yi();Jf=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],Ek=new Set(Jf),Uf=new Set([...Jf,"minimum_runtime_version","revision"]),xk=new Set([...Uf,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),Ck=new Set(["capability","operation","source","base_hash"]),Rk=new Set(["shape","build","verify","archive"]),Pk=new Set(["implicit","confirmed"]),_k=new Set(["pending","pass","fail"]),lt="comet-state.yaml",nl=/^[a-f0-9]{64}$/u,Kf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Ak=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Xi=class extends Error{constructor(r,i){super(`Native change ${r} uses ${i}; run comet native doctor ${r} --repair before mutating it`);this.change=r;this.schema=i;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},Ke=class extends Error{constructor(r,i){super(r!==st||i===null?`Unsupported Native change schema ${r} for runtime protocol ${3}`:`Native change ${r} requires runtime protocol ${i}; current protocol is ${3}`);this.schema=r;this.minimumRuntimeVersion=i;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"}});import{createHash as Ok}from"crypto";function Ie(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function Hk(t,e){e.has(t)&&Ie("cyclic structures are not supported"),e.add(t);try{let r=Object.keys(t);for(let i=0;i<t.length;i+=1)Object.prototype.hasOwnProperty.call(t,i)||Ie("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&Ie("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&Ie("symbol properties are not supported"),`[${t.map(i=>sl(i,e)).join(",")}]`}finally{e.delete(t)}}function Dk(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&Ie("only plain objects are supported"),e.has(t)&&Ie("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&Ie("symbol properties are not supported"),e.add(t);try{let i=Object.getOwnPropertyDescriptors(t);return`{${Object.keys(t).sort().map(o=>{let s=i[o];return(!s||!("value"in s))&&Ie("accessor properties are not supported"),`${JSON.stringify(o)}:${sl(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function sl(t,e){if(t===null)return"null";switch(typeof t){case"boolean":return t?"true":"false";case"string":return JSON.stringify(t);case"number":return Number.isFinite(t)||Ie("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?Hk(t,e):Dk(t,e);case"bigint":case"function":case"symbol":case"undefined":return Ie(`${typeof t} values are not supported`)}return Ie("unsupported value type")}function cl(t){return sl(t,new Set)}function O(t,e){if(t.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(t))throw new TypeError("Canonical hash tag must not contain a line break");return Ok("sha256").update(`${t}
159
- ${cl(e)}`).digest("hex")}var F=x(()=>{"use strict"});var NI,Zf,rn=x(()=>{"use strict";Zt();F();NI=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Zf=Object.freeze({maxCriteria:1024})});var ll=x(()=>{"use strict";rn()});function ul(t,e,r,i=""){let n=Object.keys(t),a=e.filter(s=>!Object.hasOwn(t,s)),o=n.filter(s=>!e.includes(s));if(a.length||o.length)throw new nn({code:"invalid-fields",path:i,context:r,missingFields:a,unknownFields:o,expectedFields:[...e]})}var nn,eo=x(()=>{"use strict";nn=class extends Error{issues;constructor(e){let r=[e.missingFields.length?`missing: ${e.missingFields.join(", ")}`:"",e.unknownFields.length?`unknown: ${e.unknownFields.join(", ")}`:""].filter(Boolean).join("; ");super(`${e.context} fields are invalid at ${e.path||"/"} (${r})`),this.name="NativeInputValidationError",this.issues=[e]}}});function dl(t,e){if(typeof t!="string"||!t.trim()||t.length>4e3||/^<[^>]+>$/u.test(t.trim()))throw new Error(`${e} must contain a concrete statement of at most 4000 characters`);return t.trim()}function pl(t){if(!Array.isArray(t))throw new Error("Native Builder acceptance_review must be an array");return t.map((e,r)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native Builder acceptance review entry must be an object");let i=e,n=`Native Builder acceptance_review[${r}]`;ul(i,["id","status","evidence","note"],n,`/acceptance_review/${r}`);let a=i.status;if(!["implemented-with-evidence","implemented-no-evidence","not-implemented","known-fail"].includes(a))throw new Error(`${n}.status is invalid`);if(!Array.isArray(i.evidence))throw new Error(`${n}.evidence must be an array`);return{id:dl(i.id,`${n}.id`),status:a,evidence:i.evidence.map(o=>dl(o,`${n}.evidence`)),note:dl(i.note,`${n}.note`)}})}function fl(t,e){if(!e)throw new Dr(t.map(({id:c})=>c),[]);let r=new Set(t.map(({id:c})=>c)),i=e.map(({id:c})=>c),n=new Set(i);if(n.size!==i.length)throw new Error("Native Builder acceptance_review contains duplicate IDs");let a=i.filter(c=>!r.has(c));if(a.length)throw new Error(`Native Builder acceptance_review contains unknown IDs: ${a.join(", ")}`);let o=t.filter(({id:c})=>!n.has(c)).map(({id:c})=>c),s=e.filter(c=>c.status!=="implemented-with-evidence"||c.evidence.length===0).map(({id:c})=>c);if(o.length||s.length)throw new Dr(o,s)}var Dr,to=x(()=>{"use strict";eo();Dr=class extends Error{constructor(r,i){super(`Native Builder handoff is incomplete${r.length?`; missing: ${r.join(", ")}`:""}${i.length?`; not ready: ${i.join(", ")}`:""}. Complete acceptance_review for every requirement and its evidence before Verify`);this.missingIds=r;this.incompleteIds=i}missingIds;incompleteIds}});function hl(){return{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}}}var Br,ro,eh,an=x(()=>{"use strict";Br="comet.native.v4",ro="comet.native.local-execution.v4",eh=["multi-session","single-session"]});var yl={};Tv(yl,{NativePortableStateVersionConflictError:()=>on,appendNativePortableHistory:()=>sn,compareAndSwapNativePortableState:()=>ih,createNativePortableState:()=>rh,parseNativePortableState:()=>fe,readNativePortableState:()=>$t,writeNativePortableState:()=>wl});import{promises as qk}from"node:fs";function ne(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ae(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function U(t,e,r){if(typeof t!="string"||!r?.empty&&t.length===0)throw new Error(`${e} must be ${r?.empty?"a string":"a non-empty string"}`);return t}function vl(t,e){return t===null?null:U(t,e)}function gl(t,e){let r=U(t,e);if(!zk.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function Lr(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function D(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function Jk(t,e){return t===null?null:D(t,e,Number.MIN_SAFE_INTEGER)}function W(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Ye(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function oo(t,e){return Ye(t,e,(r,i)=>U(r,`${e}[${i}]`))}function ar(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Fr(t,e){let r=U(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function no(t,e,r=!1){let i=U(t,e);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return i}function ye(t,e){let r=ne(t,e);return ae(r,new Set(["text","truncated"]),e),{text:U(r.text,`${e}.text`,{empty:!0}),truncated:Lr(r.truncated,`${e}.truncated`)}}function Uk(t,e){let r=`Native spec_changes[${e}]`,i=ne(t,r);ae(i,new Set(["capability","operation","source","delta_source","base_hash"]),r);let n=U(i.capability,`${r}.capability`);if(!Vk.test(n))throw new Error(`${r}.capability is invalid`);let a=W(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:no(i.source,`${r}.source`),s=i.delta_source===void 0?void 0:no(i.delta_source,`${r}.delta_source`),c=i.base_hash===void 0?void 0:i.base_hash===null?null:gl(i.base_hash,`${r}.base_hash`);if(a==="remove"&&o!==null)throw new Error(`${r} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${r} ${a} requires a source`);if(s!==void 0&&a==="remove")throw new Error(`${r} remove cannot contain delta_source`);if(s!==void 0&&c==null)throw new Error(`${r} delta_source requires a non-null base_hash`);if(c!==void 0&&s===void 0&&a!=="remove")throw new Error(`${r} base_hash requires delta_source for non-remove specs`);return{capability:n,operation:a,source:o,...s===void 0?{}:{delta_source:s},...c===void 0?{}:{base_hash:c}}}function Kk(t){let e="Native workspace",r=ne(t,e);ae(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=W(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=vl(r.change_branch,`${e}.change_branch`),a=vl(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:W(r.finish,["merge","push","pull-request","keep"],`${e}.finish`);if(i==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(i==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(i!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:i,change_branch:n,target_branch:a,finish:o}}function Yk(t){let e="Native loop",r=ne(t,e);ae(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","stop_reason","execution_failure_count","previous_unresolved_ids","next_action"]),e);let i=oo(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);ar(i,`${e}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:W(r.stop_reason,["budget","stalled"],`${e}.stop_reason`);return{stage:W(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:D(r.goal_cycle,`${e}.goal_cycle`,1),iteration:D(r.iteration,`${e}.iteration`),attempt:D(r.attempt,`${e}.attempt`),retry_epoch:D(r.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:D(r.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:D(r.no_progress_count,`${e}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:D(r.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:i,next_action:vl(r.next_action,`${e}.next_action`)}}function Xk(t,e){let r=`Native acceptance[${e}]`,i=ne(t,r);ae(i,new Set(["id","source","text","result","reason"]),r);let n=U(i.id,`${r}.id`);if(!Wk.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:no(i.source,`${r}.source`),text:U(i.text,`${r}.text`),result:W(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:ye(i.reason,`${r}.reason`)}}function Qk(t,e){let r=`Native builder_handoff.checks[${e}]`,i=ne(t,r);return ae(i,new Set(["name","result","note"]),r),{name:ye(i.name,`${r}.name`),result:W(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:ye(i.note,`${r}.note`)}}function Zk(t){let e="Native builder_handoff",r=ne(t,e);ae(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","acceptance_review","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),e);let i=oo(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);ar(i,`${e}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:ne(r.review,`${e}.review`);return n&&ae(n,new Set(["status","summary","reviewer_execution_ref"]),`${e}.review`),{candidate_id:U(r.candidate_id,`${e}.candidate_id`),identity_provider:U(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:U(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:D(r.iteration,`${e}.iteration`,1),summary:ye(r.summary,`${e}.summary`),addressed_acceptance_ids:i,...r.acceptance_review===void 0?{}:{acceptance_review:pl(r.acceptance_review)},checks:Ye(r.checks,`${e}.checks`,Qk),checks_truncated:Lr(r.checks_truncated,`${e}.checks_truncated`),known_limits:Ye(r.known_limits,`${e}.known_limits`,(a,o)=>ye(a,`${e}.known_limits[${o}]`)),known_limits_truncated:Lr(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:W(n.status,["passed"],`${e}.review.status`),summary:ye(n.summary,`${e}.review.summary`),reviewer_execution_ref:U(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:Fr(r.submitted_at,`${e}.submitted_at`)}}function eS(t,e){let r=`Native blockers[${e}]`,i=ne(t,r);ae(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=oo(i.acceptance_ids,`${r}.acceptance_ids`);return ar(n,`${r}.acceptance_ids`),{owner:W(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:ye(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:W(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function tS(t,e){let r=`Native verification.checks[${e}]`,i=ne(t,r);return ae(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:U(i.id,`${r}.id`),name:ye(i.name,`${r}.name`),argv_display:Ye(i.argv_display,`${r}.argv_display`,(n,a)=>ye(n,`${r}.argv_display[${a}]`)),argv_truncated:Lr(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:no(i.cwd_ref,`${r}.cwd_ref`,!0),status:W(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:Jk(i.exit_code,`${r}.exit_code`),duration_ms:D(i.duration_ms,`${r}.duration_ms`)}}function rS(t){let e="Native verification",r=ne(t,e);ae(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let i=Ye(r.checks,`${e}.checks`,tS);ar(i.map(a=>a.id),`${e}.checks IDs`);let n=U(r.identity_provider,`${e}.identity_provider`);return{candidate_id:U(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:U(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:D(r.iteration,`${e}.iteration`,1),attempt:D(r.attempt,`${e}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":W(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:W(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:ye(r.summary,`${e}.summary`),risks:Ye(r.risks,`${e}.risks`,(a,o)=>ye(a,`${e}.risks[${o}]`)),risks_truncated:Lr(r.risks_truncated,`${e}.risks_truncated`),completed_at:Fr(r.completed_at,`${e}.completed_at`)}}function th(t,e){let r=`Native history[${e}]`,i=ne(t,r);ae(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=oo(i.unresolved_ids,`${r}.unresolved_ids`);return ar(n,`${r}.unresolved_ids`),{goal_cycle:D(i.goal_cycle,`${r}.goal_cycle`,1),iteration:D(i.iteration,`${r}.iteration`),attempt:D(i.attempt,`${r}.attempt`),outcome:W(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:ye(i.summary,`${r}.summary`),completed_at:Fr(i.completed_at,`${r}.completed_at`)}}function iS(t){let e="Native history_overflow.outcome_counts",r=ne(t,e),i=["pass","fail","blocked","execution-error","recovery"];return ae(r,new Set(i),e),{pass:D(r.pass,`${e}.pass`),fail:D(r.fail,`${e}.fail`),blocked:D(r.blocked,`${e}.blocked`),"execution-error":D(r["execution-error"],`${e}.execution-error`),recovery:D(r.recovery,`${e}.recovery`)}}function nS(t){let e="Native history_overflow",r=ne(t,e);ae(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let i=D(r.dropped_entries,`${e}.dropped_entries`),n=r.first_dropped_at===null?null:Fr(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:Fr(r.last_dropped_at,`${e}.last_dropped_at`);if(i===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(i>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=iS(r.outcome_counts);if(Object.values(o).reduce((c,l)=>c+l,0)!==i)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:i,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function aS(t){let e=new Set(t.acceptance.map(r=>r.id));for(let r of t.loop.previous_unresolved_ids)if(!e.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);t.builder_handoff?.acceptance_review&&fl(t.acceptance,t.builder_handoff.acceptance_review);for(let r of t.blockers)for(let i of r.acceptance_ids)if(!e.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(t.builder_handoff){if(!(t.builder_handoff.iteration===t.loop.iteration||t.phase==="build"&&t.loop.stage==="repairing"&&t.builder_handoff.iteration===t.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(t.builder_handoff.review?.reviewer_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(t.verification){if(!t.builder_handoff)throw new Error("Native verification requires a builder handoff");if(t.verification.candidate_id!==t.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(t.verification.identity_provider!==t.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(t.verification.assurance)!==(t.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(t.verification.assurance==="semantic-verification-unavailable"&&t.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(t.verification.assurance==="user-confirmed-degraded"&&t.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(t.verification.verifier_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=t.verification.iteration===t.loop.iteration&&t.verification.attempt===t.loop.attempt,n=t.phase==="build"&&t.loop.stage==="repairing"&&t.verification.iteration===t.loop.iteration-1&&t.verification.iteration===t.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function oS(t){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[t.phase].has(t.loop.stage))throw new Error(`Native loop stage ${t.loop.stage} is invalid for phase ${t.phase}`);let r=t.status==="await-user"?"await-user":t.status==="blocked"?"blocked":t.status==="done"?"done":null;if(r!==null&&t.loop.stage!==r)throw new Error(`Native status ${t.status} requires loop stage ${r}`);if(t.status==="active"&&["await-user","blocked","done"].includes(t.loop.stage))throw new Error(`Native active status cannot use loop stage ${t.loop.stage}`);if(t.archived!==(t.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(t.archived&&t.phase!=="archive")throw new Error("Native archived state must be in Archive");if(t.verification_result==="pass"){if(t.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(t.acceptance.some(i=>i.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(t.verification.checks.some(i=>i.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(t.verification?.assurance==="semantic-verification-unavailable"&&(t.phase!=="verify"||t.status!=="await-user"||t.verification_result!=="blocked"||t.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(t.verification_report!==null&&t.verification===null)throw new Error("Native verification report requires persisted verification")}function fe(t){let e=ne(t,"Native portable state");if(ae(e,Gk,"Native portable state"),e.schema!==Br)throw new Error(`Native portable state schema must be ${Br}`);let r=U(e.name,"Native state name");if(!Mk.test(r))throw new Error("Native state name is invalid");if(e.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let i=Ye(e.spec_changes,"Native spec_changes",Uk);ar(i.map(s=>s.capability),"Native spec change capabilities");let n=Ye(e.acceptance,"Native acceptance",Xk);ar(n.map(s=>s.id),"Native acceptance IDs");let a=Ye(e.history,"Native history",th);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Br,name:r,language:W(e.language,["en","zh-CN"],"Native state language"),phase:W(e.phase,["shape","build","verify","archive"],"Native state phase"),status:W(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:D(e.state_version,"Native state_version",1),brief:"brief.md",...e.document_constraints_version===void 0?{}:e.document_constraints_version===1||e.document_constraints_version===2?{document_constraints_version:e.document_constraints_version}:(()=>{throw new Error("Native document_constraints_version must be 1 or 2")})(),...e.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:gl(e.shape_confirmation_hash,"Native Shape confirmation hash")},...e.children_contract_hash===void 0?{}:{children_contract_hash:gl(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:W(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:Kk(e.workspace),loop:Yk(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Zk(e.builder_handoff),blockers:Ye(e.blockers,"Native blockers",eS),verification:e.verification===null?null:rS(e.verification),history:a,history_overflow:nS(e.history_overflow),verification_result:W(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:W(e.verification_report,["verification.md"],"Native verification_report"),archived:Lr(e.archived,"Native archived"),created_at:Fr(e.created_at,"Native created_at")};return aS(o),oS(o),o}function rh(t){let e=t.createdAt instanceof Date?t.createdAt.toISOString():t.createdAt??new Date().toISOString();return fe({schema:Br,name:t.name,language:t.language,phase:"shape",status:"active",state_version:1,brief:"brief.md",spec_changes:[],workspace:t.workspace??{isolation:"current",change_branch:null,target_branch:null,finish:null},loop:{stage:"shape",goal_cycle:1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:t.nextAction??null},acceptance:[],builder_handoff:null,blockers:[],verification:null,history:[],history_overflow:hl(),verification_result:"pending",verification_report:null,archived:!1,created_at:e})}function sn(t,e){let r=fe(t),i=th(e,r.history.length),n=[...r.history,i],a={...r.history_overflow,outcome_counts:{...r.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return fe({...r,history:n,history_overflow:a})}function sS(t,e){let r=(0,ao.parseDocument)(t,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`${e} is invalid YAML: ${r.errors[0].message}`);return r.toJS({mapAsMap:!1})}async function $t(t){let e=await qk.readFile(t,"utf8");return fe(sS(e,"Native portable state"))}async function wl(t,e,r={}){let i=fe(e);await We(t,(0,ao.stringify)(i),r)}async function cS(t,e){let r=io.get(t)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);io.set(t,a),await r;try{return await e()}finally{i(),io.get(t)===a&&io.delete(t)}}async function ih(t){return cS(t.file,async()=>{let e=D(t.expectedStateVersion,"Native expected state version",1),r=fe(t.next);if(r.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await $t(t.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==e)throw new on(e,i.state_version);return await wl(t.file,r,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await $t(t.file);if(n.state_version!==e)throw new on(e,n.state_version)}}),r})}var ao,Mk,Vk,Wk,zk,Gk,on,io,Te=x(()=>{"use strict";to();ao=et(Me(),1);H();an();Mk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Vk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Wk=/^A[1-9][0-9]*$/u,zk=/^[a-f0-9]{64}$/u,Gk=new Set(["schema","name","language","phase","status","state_version","brief","document_constraints_version","shape_confirmation_hash","children_contract_hash","coordination_mode","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),on=class extends Error{constructor(r,i){super(`Native state version conflict: expected ${r}, got ${i}`);this.expectedStateVersion=r;this.actualStateVersion=i;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};io=new Map});var or=x(()=>{"use strict"});var nh=x(()=>{"use strict";Za();ll();Te();or();an();Yi()});var ah,GI,JI,Nl=x(()=>{"use strict";ue();rl();nh();ah="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",GI=new RegExp(`^portable-archive-(${ah})\\.json$`,"u"),JI=new RegExp(`^portable-migration-(${ah})\\.json$`,"u")});import{createHash as dS}from"node:crypto";import{constants as so,promises as je}from"node:fs";import $e from"node:path";import{TextDecoder as pS}from"node:util";function lo(t,e){let r=$e.relative(t,e);return r===""||!$e.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${$e.sep}`)}function fS(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function hS(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function mS(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function co(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function bl(t,e){let r=await je.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await je.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function oh(t,e,r){let i=$e.resolve(t),n=$e.resolve(e);if(!lo(i,n))throw new Error(`${r} is outside its managed root`);let a=[await bl(i,r)],o=i;for(let s of $e.relative(i,n).split($e.sep).filter(Boolean)){await Ot(a,r),o=$e.join(o,s);let c=await bl(o,r);if(!lo(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await Ot(a,r),a}async function Ot(t,e){for(let r of t){let i=await je.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!hS(r,i)||await je.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function vS(t,e,r){let i=[],n=0,a=Buffer.allocUnsafe(e===null?64*1024:Math.min(64*1024,e+1));for(;;){let o=e===null?a.length:e+1-n,{bytesRead:s}=await t.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,e!==null&&n>e)throw new Error(`${r} exceeds ${e} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function ln(t){let e=t.maxBytes===null?null:fS(t.maxBytes),r=$e.resolve(t.file),i=await oh(t.root,$e.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(d=>bl($e.resolve(d),t.label)));await t.hooks?.afterParentChainCaptured?.(),await Ot(i,t.label);let a=await je.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(e!==null&&a.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let o=mS(a),s=await je.realpath(r);if(!lo(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(d=>lo(d.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?so.O_RDONLY:so.O_RDONLY|so.O_NOFOLLOW|so.O_NONBLOCK,l=await je.open(r,c);try{let d=await l.stat();await t.hooks?.afterOpen?.();let[u,p]=await Promise.all([je.lstat(r),je.realpath(r)]);if(await Ot(i,t.label),await Ot(n,t.label),!d.isFile()||!u.isFile()||u.isSymbolicLink()||p!==s||!co(o,d)||!co(o,u))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let f=await vS(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[m,h,g]=await Promise.all([l.stat(),je.lstat(r),je.realpath(r)]);if(await Ot(i,t.label),await Ot(n,t.label),!h.isFile()||h.isSymbolicLink()||g!==s||!co(o,m)||!co(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:f,hash:dS("sha256").update(f).digest("hex"),size:f.length}}finally{await l.close()}}async function sh(t){let e=await ln(t),r;try{r=new pS("utf-8",{fatal:!0}).decode(e.bytes)}catch(i){throw new Error(`${t.label} is not valid UTF-8`,{cause:i})}return{...e,text:r}}async function un(t){let e=await oh(t.root,t.directory,t.label);return{verify:()=>Ot(e,t.label)}}var Ne=x(()=>{"use strict";H();Ve()});import{TextDecoder as wS}from"util";var lT,uo=x(()=>{"use strict";H();I();Ne();lT=new wS("utf-8",{fatal:!0})});var K=x(()=>{"use strict";ve();Ki();Nl();uo()});import{createHash as NS}from"crypto";function he(t){return NS("sha256").update(t).digest("hex")}var Oe=x(()=>{"use strict"});import El from"path";function po(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}function FS(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function qS(t,e){return he(`comet.native.snapshot-policy.v1
160
- ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function Sl(t,e,r){let i=new Set(e),n=[...e];for(;n.length>0;){if(r&&!r())return null;let a=n.pop(),o=t[a];o&&(o.kind==="star"||o.kind==="globstar"||o.kind==="globstar-slash")&&!i.has(a+1)&&(i.add(a+1),n.push(a+1))}return i}function MS(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function ph(t){let e=Xa(t,"Native snapshot pattern"),r=[];for(let i=0;i<e.length;i+=1){let n=e[i];n==="*"&&e[i+1]==="*"?(i+=1,e[i+1]==="/"?(i+=1,r.push({kind:"globstar-slash"})):r.push({kind:"globstar"})):n==="*"?r.push({kind:"star"}):n==="?"?r.push({kind:"question"}):r.push({kind:"literal",value:n})}return(i,n)=>{let a=n?MS(n):void 0;if(a&&!a())return!1;let o=Sl(r,new Set([0]),a);if(o===null)return!1;for(let s of i){if(a&&!a())return!1;let c=new Set;for(let l of o){if(a&&!a())return!1;let d=r[l];d&&(d.kind==="literal"&&d.value===s||d.kind==="question"&&s!=="/"?c.add(l+1):d.kind==="star"&&s!=="/"||d.kind==="globstar"?c.add(l):d.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(o=Sl(r,c,a),o===null||o.size===0)return!1}return Sl(r,o,a)?.has(r.length)??!1}}function VS(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>Xa(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>Xa(n,"exclude")))].sort((n,a)=>n.localeCompare(a,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let i=qS(e,r);if("hash"in t&&t.hash!==i)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:r,hash:i},includeMatchers:e.map(ph),excludeMatchers:r.map(ph),excludedDirectoryPrefixes:r.flatMap(n=>{if(!n.endsWith("/**"))return[];let a=n.slice(0,-3);return/[*?]/u.test(a)?[]:[a]}).sort((n,a)=>n.localeCompare(a,"en"))}}function be(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ke(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function Mr(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Xe(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function mh(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let r=El.posix.normalize(t);if(r!==t||El.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function WS(t,e){let r=be(t,`Native snapshot entry ${e}`);ke(r,jS,`Native snapshot entry ${e}`);let i=mh(r.path,`Native snapshot entry ${e} path`);if(typeof r.hash!="string"||!fo.test(r.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(r.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:i,hash:r.hash,size:Xe(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!LS.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function zS(t,e){let r=be(t,`Native snapshot omission ${e}`);if(ke(r,$S,`Native snapshot omission ${e}`),!DS.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!BS.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:mh(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:Xe(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function GS(t){let e=be(t,"Native snapshot omission overflow");if(ke(e,OS,"Native snapshot omission overflow"),typeof e.hash!="string"||!fo.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let r=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==r)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:r,hash:e.hash,count:Mr(e.count,"Native snapshot omission overflow count")}}function qr(t,e){let r=be(t,e);if(ke(r,AS,e),typeof r.hash!="string"||!fo.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let i=Xe(r.recordCount,`${e} recordCount`),n=Xe(r.storedRecordCount,`${e} storedRecordCount`),a=Xe(r.stdoutBytes,`${e} stdoutBytes`);if(n>i||!r.overflow&&n!==i)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,recordCount:i,storedRecordCount:n,stdoutBytes:a,overflow:r.overflow}}function fh(t){let e=be(t,"Native Git selection evidence");if(ke(e,_S,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let r=qr(e.stageBefore,"Native Git selection stageBefore"),i=qr(e.combined,"Native Git selection combined"),n=qr(e.stageAfter,"Native Git selection stageAfter"),a=qr(e.finalStageBefore,"Native Git selection finalStageBefore"),o=qr(e.finalCombined,"Native Git selection finalCombined"),s=qr(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(u=>u.overflow),l=!po(r,n)||!po(n,a)||!po(i,o)||!po(a,s),d=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==d)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:d,stageBefore:r,combined:i,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function hh(t,e){let r=be(t,e);if(ke(r,TS,e),typeof r.hash!="string"||!fo.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean"||typeof r.unstable!="boolean")throw new Error(`${e} flags are invalid`);let i=Xe(r.visitedNodeCount,`${e} visitedNodeCount`),n=Xe(r.recordCount,`${e} recordCount`),a=Xe(r.storedRecordCount,`${e} storedRecordCount`),o=Xe(r.encodedBytes,`${e} encodedBytes`);if(a>n||!r.overflow&&a!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,visitedNodeCount:i,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:r.overflow,unstable:r.unstable}}function JS(t){let e=be(t,"Native physical selection evidence");if(ke(e,IS,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let r=hh(e.before,"Native physical selection before"),i=hh(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!FS(r,i);if(!n&&!a)throw new Error("Native physical selection evidence must describe an exceptional selection");let o=n&&a?"overflow-and-changed":n?"overflow":"changed";if(e.status!==o)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:o,before:r,after:i}}function vh(t){let e=be(t,"Native content snapshot manifest");if(ke(e,ES,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!HS.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let w=be(e.capture,"Native content snapshot capture");if(ke(w,RS,"Native content snapshot capture"),w.provider!=="git"&&w.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let _=w.gitSelection===void 0?void 0:fh(w.gitSelection),S=w.physicalSelection===void 0?void 0:JS(w.physicalSelection),T=null;if(w.projection!==void 0){let Q=be(w.projection,"Native content snapshot projection");if(ke(Q,PS,"Native content snapshot projection"),Q.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");T={provider:"git",...Q.selection===void 0?{}:{selection:fh(Q.selection)}}}if(w.provider==="git"){if(S||T)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",..._?{gitSelection:_}:{}}}else{if(_)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(S&&T)throw new Error("Native physical-tree capture cannot combine selection and projection");r=T?{provider:"physical-tree",projection:T}:{provider:"physical-tree",...S?{physicalSelection:S}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let i=be(e.limits,"Native content snapshot limits");ke(i,xS,"Native content snapshot limits");let n={maxFiles:Mr(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Mr(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Mr(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Mr(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:Mr(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let w=be(e.policy,"Native snapshot policy");if(ke(w,CS,"Native snapshot policy"),w.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(w.include)||!Array.isArray(w.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=VS({include:w.include,exclude:w.exclude,hash:w.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let o=e.entries.map(WS),s=e.omitted.map(zS),c=Xe(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:GS(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(w=>w.size>n.maxFileBytes)||o.reduce((w,_)=>w+_.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(w=>w.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>kS||c<s.length)throw new Error("Native content snapshot omission count is invalid");let d=c-s.length;if(d===0&&l||d>0&&l?.count!==d)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let u=s.filter(w=>w.reason==="git-enumeration-limit"),p=s.filter(w=>w.reason==="git-selection-changed");for(let w of[...u,...p])if(w.path!=="."||w.size!==null||w.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(u.length>1||p.length>1)throw new Error("Native Git selection omissions must not be duplicated");let f=r?.provider==="git"?r.gitSelection:r?.projection?.selection,m=f?.status==="overflow"||f?.status==="overflow-and-changed",h=f?.status==="changed"||f?.status==="overflow-and-changed";if(m!==(u.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(h!==(p.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let g=s.filter(w=>w.reason==="physical-enumeration-limit"),v=s.filter(w=>w.reason==="physical-selection-changed");for(let w of[...g,...v])if(w.path!=="."||w.size!==null||w.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(g.length>1||v.length>1)throw new Error("Native physical selection omissions must not be duplicated");let N=r?.physicalSelection,b=N?.status==="overflow"||N?.status==="overflow-and-changed",y=N?.status==="changed"||N?.status==="overflow-and-changed";if(b!==(g.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(y!==(v.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");return{schema:"comet.native.content-snapshot.v1",origin:e.origin,...r?{capture:r}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}}}function US(t,e){if(!SS.test(e))throw new Error(`Invalid Native change name: ${e}`);return El.join(Z(t,e),"baseline-manifest.json")}async function xl(t,e){let r=US(t,e),i=Ae(t,r);await M(i,r);try{let n=await sh({root:i,file:r,maxBytes:null,label:"Native baseline snapshot manifest"});return vh(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var jT,kS,SS,ES,xS,CS,RS,PS,_S,AS,IS,TS,jS,$S,OS,HS,DS,BS,fo,LS,$T,OT,HT,DT,BT,Vr=x(()=>{"use strict";Pr();H();ve();Oe();Ve();I();Ne();Li();jT={maxFiles:1e4,maxFileBytes:1024*1024*1024,maxTotalBytes:1024*1024*1024,maxManifestBytes:1024*1024*1024},kS=1e3,SS=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,ES=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),xS=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),CS=new Set(["schema","include","exclude","hash"]),RS=new Set(["provider","gitSelection","physicalSelection","projection"]),PS=new Set(["provider","selection"]),_S=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),AS=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),IS=new Set(["schema","status","before","after"]),TS=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),jS=new Set(["path","hash","size","type","gitObjectId"]),$S=new Set(["path","size","type","reason"]),OS=new Set(["ref","hash","count"]),HS=new Set(["change-created","legacy-migration","explicit"]),DS=new Set(["file","directory","other"]),BS=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),fo=/^[a-f0-9]{64}$/u,LS=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,$T=64*1024,OT=64*1024,HT={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},DT={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};BT=(1n<<256n)-1n});import{execFileSync as xE}from"node:child_process";function PE(t,e){try{return ji(()=>xE("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:CE,maxBuffer:RE,windowsHide:!0}))}catch(r){let i=typeof r.stderr=="string"?r.stderr.trim():Buffer.isBuffer(r.stderr)?r.stderr.toString("utf8").trim():"";throw new Ol(t,e,i)}}function me(t,e){return PE(t,e).trim()}var CE,RE,Ol,Se=x(()=>{"use strict";Pr();CE=3e4,RE=8*1024*1024,Ol=class extends Error{constructor(r,i,n){super(`git ${i.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=r;this.args=i;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr}});import{promises as _E}from"node:fs";import AE from"node:path";function No(t,e,r=""){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object${r}`);return t}function yo(t,e,r){let i=Object.keys(t).filter(a=>!e.has(a)),n=[...e].filter(a=>!(a in t));if(i.length>0||n.length>0){let a=[...n.length>0?[`missing ${n.join(", ")}`]:[],...i.length>0?[`unexpected ${i.join(", ")}`]:[],`expected ${[...e].join(", ")}`];throw new Error(`${r} fields are invalid: ${a.join("; ")}`)}}function Ph(t,e){if(!Array.isArray(t)||!t.every(r=>typeof r=="string"))throw new Error(`${e} must be an array of strings`);return[...new Set(t)].sort((r,i)=>r.localeCompare(i,"en"))}function HE(t){let e=new Map(t.map(a=>[a.name,a])),r=new Set,i=new Set,n=a=>{if(!i.has(a)){if(r.has(a))throw new Error(`Native children dependency cycle includes ${a}`);r.add(a);for(let o of e.get(a).depends_on)n(o);r.delete(a),i.add(a)}};for(let a of t)n(a.name)}function _h(t,e,r=e){let i=new Set(e);for(let o of t){let s=o.covers.filter(c=>!i.has(c));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(t.flatMap(o=>o.covers)),a=r.filter(o=>!n.has(o));if(a.length>0)throw new Error(`Native children do not cover parent acceptance: ${a.join(", ")}`)}function jh(t,e,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(t.schema===Dl&&t.acceptance_index){let n=r.requiredAcceptanceIds??e??[],a=r.allowedAcceptanceIds??n,o=Object.keys(t.acceptance_index);i.missing=n.filter(l=>!(l in t.acceptance_index)),i.extra=o.filter(l=>!a.includes(l));let s=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of o){let d=s.get(l),u=t.acceptance_index[l];d&&u&&(u.source!==d.source||u.text!==d.text)&&i.mismatched.push(l)}let c=new Set(o);for(let l of t.children)i.unknownCovers.push(...l.covers.filter(d=>!c.has(d)));return i.uncovered=o.filter(l=>!Ah(t.children,l)),Ih(i)?i:null}if(t.schema===sr&&e){let n=new Set(e);for(let a of t.children)i.unknownCovers.push(...a.covers.filter(o=>!n.has(o)));return i.uncovered=e.filter(a=>!Ah(t.children,a)),Ih(i)?i:null}return null}function Ah(t,e){return t.some(r=>r.covers.includes(e))}function Ih(t){return t.missing.length>0||t.extra.length>0||t.mismatched.length>0||t.uncovered.length>0||t.unknownCovers.length>0}function Dt(t){let e=new Set(t.acceptance.map(({id:n})=>n)),r=new Set(t.acceptance.filter(({source:n})=>n===t.brief).map(({id:n})=>n)),i=new Set(r);for(let n of t.history.filter(({outcome:a})=>a==="fail"))for(let a of n.unresolved_ids)e.has(a)&&i.add(a);if(t.loop.stage==="repairing"&&t.verification_result==="fail"){let n=[...t.history].reverse().find(({outcome:a})=>a==="fail");for(let a of n?.unresolved_ids??[])r.add(a)}return{acceptanceCatalog:t.acceptance,requiredAcceptanceIds:[...r],allowedAcceptanceIds:[...i]}}function DE(t){let e=No(t,"Native children acceptance_index",' keyed by acceptance ID, for example A1: { source: brief.md, text: "Full acceptance text" }'),r={};for(let[i,n]of Object.entries(e)){let a=No(n,`Native children acceptance_index.${i}`);if(yo(a,new Set(["source","text"]),`Native children acceptance_index.${i}`),typeof a.source!="string"||a.source.length===0)throw new Error(`Native children acceptance_index.${i}.source must be a non-empty string`);if(typeof a.text!="string"||a.text.length===0)throw new Error(`Native children acceptance_index.${i}.text must be a non-empty string`);r[i]={source:a.source,text:a.text}}return r}function BE(t,e,r){let i=r.requiredAcceptanceIds??e??[],n=r.allowedAcceptanceIds??i,a=Object.keys(t),o=i.filter(l=>!(l in t)),s=a.filter(l=>!n.includes(l));if(o.length>0||s.length>0)throw new Error(`Native children acceptance_index must match the required acceptance: missing ${o.join(", ")||"none"}; extra ${s.join(", ")||"none"}`);let c=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of a){let d=c.get(l);if(!d)continue;let u=t[l];if(u.source!==d.source||u.text!==d.text){let p=["source","text"].filter(f=>u[f]!==d[f]);throw new Error(`Native children acceptance_index.${l} does not match the acceptance catalog: copy ${p.join(", ")} exactly from the current acceptance catalog`)}}}function $h(t,e,r={}){let i=(0,Th.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=No(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==sr&&a!==Ht)throw yo(n,Rh,"Native children contract"),new Error(`Native children schema must be ${sr} or ${Ht}`);let o=a===sr?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(yo(n,o==="indexed-v2"?TE:Rh,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let c=n.children.map((p,f)=>{let m=No(p,`Native child ${f}`);if(yo(m,o==="indexed-v2"?OE:o==="summary-v2"?$E:jE,`Native ${s} child fields (child ${f})`),typeof m.name!="string"||!IE.test(m.name))throw new Error(`Native child ${f} name is invalid`);let h=o==="summary-v2";if(h){if(typeof m.summary!="string"||m.summary.trim().length===0)throw new Error(`Native child ${m.name} summary must be a non-empty string`);if(m.summary.length>2e3)throw new Error(`Native child ${m.name} summary exceeds 2000 characters`)}return{name:m.name,summary:h?m.summary:null,depends_on:Ph(m.depends_on,`Native child ${m.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?Ph(m.covers,`Native child ${m.name} covers`):[]}}),l=c.map(({name:p})=>p);if(new Set(l).size!==l.length)throw new Error("Native child names must be unique");let d=new Set(l);for(let p of c){let f=p.depends_on.filter(m=>!d.has(m));if(f.length>0)throw new Error(`Native child ${p.name} depends on unknown child: ${f.join(", ")}`)}HE(c);let u=r.policy==="advisory";if(a===Dl){if(o==="indexed-v2"){let p=DE(n.acceptance_index);u||BE(p,e,r);let f=Object.keys(p);return u||_h(c,f,f),{schema:Ht,acceptance_index:p,children:c}}return{schema:Ht,children:c}}return e&&!u&&_h(c,e),{schema:sr,children:c}}async function dt(t){let e=AE.join(t.changeDir,Hl);try{await _E.lstat(e)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await L({root:t.changeDir,ref:Hl}),i=t.policy==="advisory",n=i?{...t.validation,policy:"advisory"}:t.validation??{},a=$h(r.text,t.acceptanceIds,n);return{contract:a,hash:r.hash,size:r.size,drift:i?jh(a,t.acceptanceIds,t.validation??{}):null}}var Th,Hl,sr,Ht,Dl,IE,Rh,TE,jE,$E,OE,bo=x(()=>{"use strict";Th=et(Me(),1);ue();Hl="children.yaml",sr="comet.native.children.v1",Ht="comet.native.children.v2",Dl=Ht,IE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Rh=new Set(["schema","children"]),TE=new Set(["schema","acceptance_index","children"]),jE=new Set(["name","depends_on","covers"]),$E=new Set(["name","summary","depends_on"]),OE=new Set(["name","depends_on","covers"])});var hn=x(()=>{"use strict"});var ko=x(()=>{"use strict";eo();hn()});function pt(t,e){if(!FE.test(t))throw new Error(`${e} must be a Git commit`)}function Bl(t,e){t.history.push({...e,at:new Date().toISOString()}),t.history.length>256&&t.history.splice(0,t.history.length-256)}function Eo(t){pt(t.targetCommit,"Native Supervisor target commit");let e=new Set(t.contract.children.map(({name:i})=>i)),r=t.contract.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.depends_on],status:i.depends_on.length===0?"ready":"pending",baseCommit:null,candidateCommit:null,verifiedCommit:null,integrationCommit:null,verification:null,checks:[],blocker:null,projectRoot:null,task:null,acceptanceScope:Ll(t.contract,i.name),contractHash:O("comet.native.supervisor-contract.v1",t.contract),builderFailureCount:0}));for(let i of r)for(let n of i.dependsOn)if(!e.has(n))throw new Error(`Native Supervisor child ${i.name} depends on unknown child ${n}`);return{schema:mn,stateVersion:1,parent:t.parent,integration:{branch:t.integrationBranch,worktree:t.integrationWorktree,targetBranch:t.targetBranch,targetCommit:t.targetCommit,headCommit:t.targetCommit},children:r,history:[],finalVerification:{status:"pending",summary:null}}}function Ll(t,e){let r=t.children.find(i=>i.name===e);return r.covers.length>0?r.covers.map(i=>({id:i,source:t.acceptance_index?.[i]?.source??"brief.md",text:t.acceptance_index?.[i]?.text??i})):[{id:`child:${e}`,source:"children.yaml",text:r.summary??e}]}function xo(t){let e=t.children.every(i=>i.acceptanceScope&&i.acceptanceScope.length>0&&(!i.task||i.task.acceptance&&i.task.acceptance.length>0)),r=t.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.dependsOn],covers:i.acceptanceScope?.map(({id:n})=>n)??[],status:(i.status==="ready"||i.status==="active")&&i.blocker&&[...t.history].reverse().find(n=>n.child===i.name)?.kind==="task-blocked"?"blocked":i.status,phase:null,projectRoot:i.projectRoot??i.task?.projectRoot??null,message:e?i.blocker:"Supervisor acceptance scope is unavailable; restore children.yaml and confirm Shape before continuing",builderFailureCount:i.builderFailureCount??0}));return{contractHash:null,supervisorStateVersion:t.stateVersion,confirmed:e,parentBranch:t.integration.branch,children:r,readyChildren:e?r.filter(({status:i})=>i==="ready").map(({name:i})=>i):[],allDone:e&&r.every(({status:i})=>i==="integrated"||i==="archived")}}var FE,mn,So,cr=x(()=>{"use strict";F();ko();FE=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;mn="comet.native.supervisor.v2",So=3});import vn from"node:path";import{promises as Hh}from"node:fs";function Fl(t,e){return vn.join(Ue(t,e),"supervisor")}function Co(t,e){return vn.join(Fl(t,e),"state.json")}function Dh(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native Supervisor state must be an object");let e=t;if(e.schema!==mn)throw new Error(`Native Supervisor state schema must be ${mn}`);if(!Number.isSafeInteger(e.stateVersion)||typeof e.stateVersion!="number"||e.stateVersion<1)throw new Error("Native Supervisor state version is invalid");if(typeof e.parent!="string"||!e.parent)throw new Error("Native Supervisor state parent is invalid");if(!e.integration||typeof e.integration!="object")throw new Error("Native Supervisor integration state is missing");for(let[n,a]of Object.entries(e.integration))if(n!=="checkExecution"&&(typeof a!="string"||a.length===0))throw new Error(`Native Supervisor integration field ${n} is invalid`);if(pt(e.integration.targetCommit,"Native Supervisor target commit"),pt(e.integration.headCommit,"Native Supervisor integration head commit"),e.integration.checkExecution){let n=e.integration.checkExecution;if(!n.operationId||!n.key||!n.child||!["running","completed","interrupted"].includes(n.status)||!Number.isSafeInteger(n.ownerPid)||n.ownerPid<=0)throw new Error("Native Supervisor integration check execution is invalid");pt(n.candidateCommit,"Native Supervisor integration candidate commit"),pt(n.integrationCommit,"Native Supervisor integration check commit"),Oh(n.checkStates,"Native Supervisor integration")}if(!Array.isArray(e.children))throw new Error("Native Supervisor children are invalid");if(!Array.isArray(e.history))throw new Error("Native Supervisor history is invalid");if(!e.finalVerification||!["pending","passed","failed","incomplete"].includes(e.finalVerification.status)||e.finalVerification.summary!==null&&typeof e.finalVerification.summary!="string")throw new Error("Native Supervisor final verification is invalid");if(e.finalVerification.layers){let n=e.finalVerification.layers;if(!["complete","incomplete"].includes(n.childVerification)||!["complete","incomplete"].includes(n.parentIntegration)||!Array.isArray(n.parentChecks)||!n.parentChecks.every(a=>typeof a=="string")||!Array.isArray(n.notRerun)||!n.notRerun.every(a=>typeof a=="string")||!Array.isArray(n.incomplete)||!n.incomplete.every(a=>typeof a=="string"))throw new Error("Native Supervisor final verification layers are invalid")}for(let n of e.history)if(!n||typeof n!="object"||typeof n.kind!="string"||typeof n.summary!="string"||typeof n.at!="string"||n.child!==null&&typeof n.child!="string"||n.runId!==null&&typeof n.runId!="string")throw new Error("Native Supervisor history event is invalid");let r=new Set,i=new Set;for(let n of e.children){if(!n||typeof n!="object"||typeof n.name!="string")throw new Error("Native Supervisor child state is invalid");if(r.has(n.name))throw new Error(`Native Supervisor child ${n.name} is duplicated`);if(r.add(n.name),!Array.isArray(n.dependsOn)||!n.dependsOn.every(a=>typeof a=="string"))throw new Error(`Native Supervisor child ${n.name} dependencies are invalid`);if(typeof n.summary!="string"&&n.summary!==null)throw new Error(`Native Supervisor child ${n.name} summary is invalid`);if(n.builderFailureCount!==void 0&&(!Number.isSafeInteger(n.builderFailureCount)||n.builderFailureCount<0))throw new Error(`Native Supervisor child ${n.name} Builder failure count is invalid`);if(n.projectRoot!==void 0&&n.projectRoot!==null&&(typeof n.projectRoot!="string"||n.projectRoot.length===0))throw new Error(`Native Supervisor child ${n.name} projectRoot is invalid`);for(let[a,o]of[["base",n.baseCommit],["candidate",n.candidateCommit],["verified",n.verifiedCommit],["integration",n.integrationCommit]])o!==null&&pt(o,`Native Supervisor child ${n.name} ${a} commit`);if(!Array.isArray(n.checks)||!Array.isArray(n.verification?.checks??[]))throw new Error(`Native Supervisor child ${n.name} evidence is invalid`);if(n.task!==null){if(!n.task||typeof n.task!="object")throw new Error(`Native Supervisor child ${n.name} task is invalid`);if(!["builder","verifier"].includes(n.task.role)||n.task.child!==n.name||typeof n.task.projectRoot!="string"||n.task.projectRoot.length===0||typeof n.task.runId!="string"||n.task.runId.length===0)throw new Error(`Native Supervisor child ${n.name} task identity is invalid`);if(pt(n.task.baseCommit,`Native Supervisor child ${n.name} task base commit`),i.has(n.task.runId))throw new Error(`Native Supervisor task runId ${n.task.runId} is duplicated`);if(i.add(n.task.runId),n.task.role==="verifier"&&n.task.baseCommit!==n.candidateCommit)throw new Error(`Native Supervisor child ${n.name} verifier base commit is invalid`);if(n.task.projectRoot!==n.projectRoot)throw new Error(`Native Supervisor child ${n.name} task projectRoot is invalid`);if(n.task.checkExecution&&Oh(n.task.checkExecution.checkStates,`Native Supervisor child ${n.name}`),n.task.role==="builder"&&n.status!=="active"||n.task.role==="verifier"&&!["active","needs-reverify"].includes(n.status))throw new Error(`Native Supervisor child ${n.name} task status is invalid`)}}}async function He(t,e,r={}){try{let i=await Hh.readFile(Co(t,e),"utf8"),n=JSON.parse(i);if(Dh(n),n.children.some(o=>!o.acceptanceScope||o.task&&!o.task.acceptance))try{let o=t;if(!o.changesDir)throw new Error("Native Supervisor upgrade requires full project paths to recover confirmed acceptance");let{readNativePortableState:s}=await Promise.resolve().then(()=>(Te(),yl)),c=await s(vn.join(o.changesDir,e,"comet-state.yaml")),l=await dt({changeDir:vn.join(o.changesDir,e),acceptanceIds:c.acceptance.map(({id:d})=>d),validation:Dt(c)});if(!l)throw new Error("Native Supervisor upgrade requires the confirmed children contract");for(let d of n.children)l.contract.children.some(({name:u})=>u===d.name)&&(d.acceptanceScope=Ll(l.contract,d.name),d.contractHash=O("comet.native.supervisor-contract.v1",l.contract),d.task&&(d.task.acceptance=structuredClone(d.acceptanceScope),d.task.contractHash=d.contractHash,d.task.verificationBoundary="child-scope-parent-reverifies-all",d.task.checksReason="not-run"))}catch(o){if(!r.diagnostics)throw o}let a=t;if(a.changesDir)try{let{readNativePortableState:o}=await Promise.resolve().then(()=>(Te(),yl)),s=await o(vn.join(a.changesDir,e,"comet-state.yaml"));s.workspace.change_branch&&(n.integration.targetBranch=s.workspace.change_branch)}catch(o){if(o.code!=="ENOENT")throw o}return n}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Bt(t,e){Dh(e),await Hh.mkdir(t.changesRuntimeDir,{recursive:!0}),await ie(Co(t,e.parent),e,{containedRoot:t.changesRuntimeDir})}function Oh(t,e){if(t===void 0)return;if(!Array.isArray(t)||t.length===0)throw new Error(`${e} check states are invalid`);let r=new Set;for(let i of t){if(!i||typeof i.id!="string"||!i.id||r.has(i.id)||typeof i.name!="string"||!["planned","running","passed","failed","interrupted"].includes(i.status)||typeof i.repeatable!="boolean"||!Number.isSafeInteger(i.executionCount)||i.executionCount<0||!Array.isArray(i.argvDisplay)||!i.argvDisplay.every(n=>typeof n=="string")||typeof i.cwdRef!="string"||!Number.isSafeInteger(i.durationMs)||i.durationMs<0||i.exitCode!==null&&!Number.isSafeInteger(i.exitCode)||i.signal!==null&&typeof i.signal!="string"||typeof i.timedOut!="boolean"||i.startedAt!==null&&typeof i.startedAt!="string"||i.completedAt!==null&&typeof i.completedAt!="string"||i.logRef!==null&&typeof i.logRef!="string")throw new Error(`${e} check state is invalid`);r.add(i.id)}}var Lt=x(()=>{"use strict";H();F();bo();I();cr()});var ql=x(()=>{"use strict"});var Ft=x(()=>{"use strict"});import{accessSync as L0,constants as F0,createWriteStream as q0,existsSync as M0,promises as V0,statSync as VE}from"node:fs";import lr from"node:path";function WE(t,e){let r=lr.relative(t,e);return r===""||!lr.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${lr.sep}`)}function Bh(t,e){if(e.length===0||e.includes("\\")||lr.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||lr.posix.normalize(e)!==e)throw new Error("Native check cwd must be a normalized project-relative ref");let r=lr.resolve(t),i=lr.resolve(r,...e.split("/"));if(!WE(r,i))throw new Error("Native check cwd escaped the project root");let n;try{n=VE(i)}catch(a){throw new Error(`Native check cwd does not exist: ${e}`,{cause:a})}if(!n.isDirectory())throw new Error(`Native check cwd is not a directory: ${e}`);return i}var Ro=x(()=>{"use strict";$i();ql();Ft()});var Lh=x(()=>{"use strict";Se();Ro();F()});var Po=x(()=>{"use strict";Se();H()});var Gh,ur=x(()=>{"use strict";F();Vr();Gh=1024*1024});var Io=x(()=>{"use strict";F();Ft();Li();ur()});var Rm,MC,VC,WC,TL,zC,jL,du=x(()=>{"use strict";F();Rm="scoped-text-safety",MC=1,VC=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),WC="comet.native.checker-policy.v1",TL=O(WC,{policy:Rm,version:MC,limits:VC,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),zC=["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"],jL=new Set(zC)});var En=x(()=>{"use strict";F();du();Ft()});var GC,YL,Vt=x(()=>{"use strict";H();I();Ve();ur();Io();En();GC=Gh,YL=3*GC});var Tl=et(Me(),1);import{promises as kE}from"fs";import Wr from"path";Pr();_r();import{execFileSync as fb}from"child_process";import hb from"fs";import Xt from"path";import{AsyncLocalStorage as Nf}from"node:async_hooks";$i();var Qt=new Nf,bf=new Nf;function kf(t){return Qt.getStore()?t():Qt.run(new Map,t)}function mb(t){let e=Qt.getStore();for(let r of t)e?.set(Ct(r.root),t);return t}function Oi(t,e){return ji(()=>fb("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim())}function Hi(t,e){return Ct(t)===Ct(e)}function Ct(t){let e=Xt.resolve(t);try{let r=hb.realpathSync.native(e);return process.platform==="win32"?r.toLowerCase():r}catch{return process.platform==="win32"?e.toLowerCase():e}}function G(t){try{let e=bf.getStore()?.get(Ct(t)),r=Qt.getStore()?.get(e??Ct(t));if(r){let c=Di(e??t,r);if(c)return c;if(r.length===0)return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}let i=Xt.resolve(Oi(t,["rev-parse","--show-toplevel"])),n=Qt.getStore()?.get(Ct(i))??Sf(t),a=Di(i,n);if(Qt.getStore()&&a)return a;let o=n[0]?.root??i,s=null;try{s=Oi(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Hi(i,o),currentWorktreeRoot:i,primaryWorktreeRoot:o,currentBranch:s}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function Ta(t){try{let e=Qt.getStore()?.get(bf.getStore()?.get(Ct(t))??Ct(t));return e?e.map(r=>({...r})):(Oi(t,["rev-parse","--is-inside-work-tree"]),Sf(t))}catch{return[]}}function Sf(t){let e=vb(Oi(t,["worktree","list","--porcelain","-z"]));return mb(e),e.map(r=>({...r}))}function vb(t){let e=t.split("\0"),r=[],i=null;for(let n of e)n.startsWith("worktree ")?(i&&r.push(i),i={root:Xt.resolve(n.slice(9)),branch:null,detached:!1}):i&&n.startsWith("branch refs/heads/")?i.branch=n.slice(18):i&&n==="detached"&&(i.detached=!0);return i&&r.push(i),r}function Rt(t){return Ta(t).map(e=>e.root)}function Di(t,e){let r=e.find(a=>Hi(Xt.resolve(a.root),Xt.resolve(t)));if(!r)return null;let i=Xt.resolve(e[0].root),n=Xt.resolve(r.root);return{isGitWorktree:!0,isSecondaryWorktree:!Hi(i,n),currentWorktreeRoot:n,primaryWorktreeRoot:i,currentBranch:r.branch}}function it(t,e){try{let r=Oi(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(r)?r:null}catch{return null}}ue();H();Zt();ve();K();I();Ne();Vr();K();I();jr();At();var eE=et(Me(),1);jr();At();ot();ot();Tr();Qc();jr();ot();var ej=4*1024*1024;import{AsyncLocalStorage as tE}from"node:async_hooks";var rE=new tE;function iE(){let t=rE.getStore();return t?.active?t:null}function nE(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function gh(t,e){return(...r)=>{let i=iE();if(i===null)return e(...r);let n=nE(`async:${t}`,r),a=i.entries.get(n);if(a)return a.value;let o=e(...r).catch(s=>{throw i.entries.get(n)?.value===o&&i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}Tr();var oj=gh("hookWritePolicy",async t=>(await Uc(t))?.hook??{allow_paths:[]});Gi();var aE=16*1024;Kc();Fi();var c$=Number.MAX_SAFE_INTEGER;H();Ve();var b$={runStateBytes:Number.MAX_SAFE_INTEGER,trajectoryBytes:Number.MAX_SAFE_INTEGER,trajectoryEvents:4096,trajectoryEventBytes:Number.MAX_SAFE_INTEGER,checkpointBytes:Number.MAX_SAFE_INTEGER,pendingActionBytes:Number.MAX_SAFE_INTEGER,contextBytes:Number.MAX_SAFE_INTEGER,artifactsBytes:Number.MAX_SAFE_INTEGER};import{createHash as pE}from"node:crypto";import{promises as ho}from"node:fs";import ut from"node:path";H();ue();K();I();var dn=/^[a-f0-9]{64}$/u,wh=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,fE=16*1024,Pl=process.platform;function kh(t,e){let r=ut.relative(t,e);return ut.isAbsolute(r)||r===".."||r.startsWith(`..${ut.sep}`)?null:r.replaceAll("\\","/")||"."}function Sh(t){return Array.from(t).some(e=>{let r=e.codePointAt(0)??0;return r<=31||r===127})}function Eh(t,e){if(t.length===0||Sh(t)||t.includes("\\")||ut.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let r=ut.posix.normalize(t);if(r!==t||r===".."||r.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return r}function _l(t,e){return pE("sha256").update(`${t}
161
- ${e}`).digest("hex")}async function yh(t,e){let r=await ho.realpath(e),i=await ho.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=Pl==="win32"?ut.normalize(r).toLowerCase():r;return _l(t,`${n}
162
+ }`,rI=xk("sha256").update(Ck).digest("hex")});var Za=x(()=>{"use strict";_r();Jf()});import{AsyncLocalStorage as Pk}from"async_hooks";var fI,hI,mI,Yi=x(()=>{"use strict";Ji();Za();I();Ve();fI=16*1024,hI=900*1e3,mI=new Pk});var Kf,il=x(()=>{"use strict";Kf=et(Me(),1)});var st,Tt,jt,Xi=x(()=>{"use strict";st="comet.native.v3",Tt="comet.native.v2",jt="comet.native.v1"});import _k from"node:path";function en(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Zf(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function nr(t){if(!Qf.test(t))throw new Error(`Invalid Native change name: ${t}`)}function eh(t){if(!Qf.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function th(t,e){if(t.length===0||_k.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function Dk(t,e){let r=en(t,`spec_changes[${e}]`);if(Zf(r,Tk,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(eh(r.capability),r.operation!=="create"&&r.operation!=="replace"&&r.operation!=="remove")throw new Error(`Invalid spec operation for ${r.capability}`);let i=r.source,n=r.base_hash;if(i!==void 0&&typeof i!="string")throw new Error(`Spec source for ${r.capability} must be a string`);if(typeof i=="string"&&th(i,`Spec source for ${r.capability}`),r.operation==="create"){if(!i)throw new Error(`Create spec ${r.capability} requires source`);if(n!==null)throw new Error(`Create spec ${r.capability} requires null base_hash`)}else if(r.operation==="replace"){if(!i)throw new Error(`Replace spec ${r.capability} requires source`);if(typeof n!="string"||!al.test(n))throw new Error(`Replace spec ${r.capability} requires a SHA-256 base_hash`)}else{if(i!==void 0)throw new Error(`Remove spec ${r.capability} forbids source`);if(typeof n!="string"||!al.test(n))throw new Error(`Remove spec ${r.capability} requires a SHA-256 base_hash`)}return{capability:r.capability,operation:r.operation,...typeof i=="string"?{source:i}:{},base_hash:n}}function Bk(t){return/^\d{4}-\d{2}-\d{2}$/u.test(t)?new Date(`${t}T00:00:00.000Z`).toISOString().slice(0,10)===t:!1}function ol(t,e){if(Zf(t,e,lt),typeof t.name!="string")throw new Error("Native change name is required");if(nr(t.name),t.language!=="en"&&t.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof t.phase!="string"||!jk.has(t.phase))throw new Error("Native change phase is invalid");if(t.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(t.approval!==null&&!$k.has(t.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native spec_changes must be an array");let r=t.spec_changes.map(Dk),i=r.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(i.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(i)].join(", ")}`);if(typeof t.verification_result!="string"||!Ok.has(t.verification_result))throw new Error("Native verification_result is invalid");if(t.verification_report!==null&&typeof t.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof t.verification_report=="string"&&th(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!Bk(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:r,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function tn(t){let e=en(t,lt);if(e.schema!==jt)throw new Error(`Expected ${jt}`);return{schema:jt,...ol(e,Ak)}}function Zi(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function nl(t,e,r){if(t===null)return null;let i=typeof t=="string"?Hk.exec(t):null;if(!i||i[1]!==r)throw new Error(`${e} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return t}function Lk(t){if(t==null)return null;if(typeof t!="string"||!al.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function Fk(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function rn(t){let e=en(t,lt);if(e.schema!==Tt)throw new Error(`Expected ${Tt}`);if(Zi(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Tt} minimum_runtime_version must be 2`);return{schema:Tt,minimum_runtime_version:2,revision:Zi(e.revision,"Native v2 revision"),...ol(e,Xf)}}function Hr(t){let e=en(t,lt);if(e.schema!==st){if(e.schema===jt||e.schema===Tt){let o=e.schema===jt?tn(e):rn(e);throw new Qi(o.name,o.schema)}throw new Ke(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=Zi(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Ke(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=Zi(e.revision,"Native revision"),n=ol(e,Ik),a=Lk(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:st,minimum_runtime_version:3,revision:i,verification_protocol:Fk(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:nl(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:nl(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:nl(e.partial_allowance,"Native partial_allowance","allowances")}}function sl(t){let e=en(t,lt);if(e.schema===jt){let n=tn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${st}`}}if(e.schema===Tt){let n=rn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${st}`}}if(e.schema!==st){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new Ke(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=Zi(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new Ke(e.schema,r).message};let i=Hr(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}var Yf,Ak,Xf,Ik,Tk,jk,$k,Ok,lt,al,Qf,Hk,Qi,Ke,eo=x(()=>{"use strict";Xi();Yf=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],Ak=new Set(Yf),Xf=new Set([...Yf,"minimum_runtime_version","revision"]),Ik=new Set([...Xf,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),Tk=new Set(["capability","operation","source","base_hash"]),jk=new Set(["shape","build","verify","archive"]),$k=new Set(["implicit","confirmed"]),Ok=new Set(["pending","pass","fail"]),lt="comet-state.yaml",al=/^[a-f0-9]{64}$/u,Qf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Hk=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Qi=class extends Error{constructor(r,i){super(`Native change ${r} uses ${i}; run comet native doctor ${r} --repair before mutating it`);this.change=r;this.schema=i;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},Ke=class extends Error{constructor(r,i){super(r!==st||i===null?`Unsupported Native change schema ${r} for runtime protocol ${3}`:`Native change ${r} requires runtime protocol ${i}; current protocol is ${3}`);this.schema=r;this.minimumRuntimeVersion=i;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"}});import{createHash as qk}from"crypto";function Ie(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function Mk(t,e){e.has(t)&&Ie("cyclic structures are not supported"),e.add(t);try{let r=Object.keys(t);for(let i=0;i<t.length;i+=1)Object.prototype.hasOwnProperty.call(t,i)||Ie("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&Ie("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&Ie("symbol properties are not supported"),`[${t.map(i=>cl(i,e)).join(",")}]`}finally{e.delete(t)}}function Vk(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&Ie("only plain objects are supported"),e.has(t)&&Ie("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&Ie("symbol properties are not supported"),e.add(t);try{let i=Object.getOwnPropertyDescriptors(t);return`{${Object.keys(t).sort().map(o=>{let s=i[o];return(!s||!("value"in s))&&Ie("accessor properties are not supported"),`${JSON.stringify(o)}:${cl(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function cl(t,e){if(t===null)return"null";switch(typeof t){case"boolean":return t?"true":"false";case"string":return JSON.stringify(t);case"number":return Number.isFinite(t)||Ie("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?Mk(t,e):Vk(t,e);case"bigint":case"function":case"symbol":case"undefined":return Ie(`${typeof t} values are not supported`)}return Ie("unsupported value type")}function ll(t){return cl(t,new Set)}function O(t,e){if(t.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(t))throw new TypeError("Canonical hash tag must not contain a line break");return qk("sha256").update(`${t}
163
+ ${ll(e)}`).digest("hex")}var F=x(()=>{"use strict"});var CI,rh,nn=x(()=>{"use strict";Zt();F();CI=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),rh=Object.freeze({maxCriteria:1024})});var ul=x(()=>{"use strict";nn()});function dl(t,e,r,i=""){let n=Object.keys(t),a=e.filter(s=>!Object.hasOwn(t,s)),o=n.filter(s=>!e.includes(s));if(a.length||o.length)throw new an({code:"invalid-fields",path:i,context:r,missingFields:a,unknownFields:o,expectedFields:[...e]})}var an,to=x(()=>{"use strict";an=class extends Error{issues;constructor(e){let r=[e.missingFields.length?`missing: ${e.missingFields.join(", ")}`:"",e.unknownFields.length?`unknown: ${e.unknownFields.join(", ")}`:""].filter(Boolean).join("; ");super(`${e.context} fields are invalid at ${e.path||"/"} (${r})`),this.name="NativeInputValidationError",this.issues=[e]}}});function pl(t,e){if(typeof t!="string"||!t.trim()||t.length>4e3||/^<[^>]+>$/u.test(t.trim()))throw new Error(`${e} must contain a concrete statement of at most 4000 characters`);return t.trim()}function fl(t){if(!Array.isArray(t))throw new Error("Native Builder acceptance_review must be an array");return t.map((e,r)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native Builder acceptance review entry must be an object");let i=e,n=`Native Builder acceptance_review[${r}]`;dl(i,["id","status","evidence","note"],n,`/acceptance_review/${r}`);let a=i.status;if(!["implemented-with-evidence","implemented-no-evidence","not-implemented","known-fail"].includes(a))throw new Error(`${n}.status is invalid`);if(!Array.isArray(i.evidence))throw new Error(`${n}.evidence must be an array`);return{id:pl(i.id,`${n}.id`),status:a,evidence:i.evidence.map(o=>pl(o,`${n}.evidence`)),note:pl(i.note,`${n}.note`)}})}function hl(t,e){if(!e)throw new Dr(t.map(({id:c})=>c),[]);let r=new Set(t.map(({id:c})=>c)),i=e.map(({id:c})=>c),n=new Set(i);if(n.size!==i.length)throw new Error("Native Builder acceptance_review contains duplicate IDs");let a=i.filter(c=>!r.has(c));if(a.length)throw new Error(`Native Builder acceptance_review contains unknown IDs: ${a.join(", ")}`);let o=t.filter(({id:c})=>!n.has(c)).map(({id:c})=>c),s=e.filter(c=>c.status!=="implemented-with-evidence"||c.evidence.length===0).map(({id:c})=>c);if(o.length||s.length)throw new Dr(o,s)}var Dr,ro=x(()=>{"use strict";to();Dr=class extends Error{constructor(r,i){super(`Native Builder handoff is incomplete${r.length?`; missing: ${r.join(", ")}`:""}${i.length?`; not ready: ${i.join(", ")}`:""}. Complete acceptance_review for every requirement and its evidence before Verify`);this.missingIds=r;this.incompleteIds=i}missingIds;incompleteIds}});function ml(){return{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}}}var Br,io,ih,on=x(()=>{"use strict";Br="comet.native.v4",io="comet.native.local-execution.v4",ih=["multi-session","single-session"]});var Nl={};Ov(Nl,{NativePortableStateVersionConflictError:()=>sn,appendNativePortableHistory:()=>cn,compareAndSwapNativePortableState:()=>oh,createNativePortableState:()=>ah,parseNativePortableState:()=>fe,readNativePortableState:()=>$t,writeNativePortableState:()=>yl});import{promises as Jk}from"node:fs";function ne(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ae(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function U(t,e,r){if(typeof t!="string"||!r?.empty&&t.length===0)throw new Error(`${e} must be ${r?.empty?"a string":"a non-empty string"}`);return t}function gl(t,e){return t===null?null:U(t,e)}function wl(t,e){let r=U(t,e);if(!Xk.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function Lr(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function D(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function Zk(t,e){return t===null?null:D(t,e,Number.MIN_SAFE_INTEGER)}function W(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Ye(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function so(t,e){return Ye(t,e,(r,i)=>U(r,`${e}[${i}]`))}function ar(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Fr(t,e){let r=U(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function ao(t,e,r=!1){let i=U(t,e);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return i}function ye(t,e){let r=ne(t,e);return ae(r,new Set(["text","truncated"]),e),{text:U(r.text,`${e}.text`,{empty:!0}),truncated:Lr(r.truncated,`${e}.truncated`)}}function eS(t,e){let r=`Native spec_changes[${e}]`,i=ne(t,r);ae(i,new Set(["capability","operation","source","delta_source","base_hash"]),r);let n=U(i.capability,`${r}.capability`);if(!Kk.test(n))throw new Error(`${r}.capability is invalid`);let a=W(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:ao(i.source,`${r}.source`),s=i.delta_source===void 0?void 0:ao(i.delta_source,`${r}.delta_source`),c=i.base_hash===void 0?void 0:i.base_hash===null?null:wl(i.base_hash,`${r}.base_hash`);if(a==="remove"&&o!==null)throw new Error(`${r} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${r} ${a} requires a source`);if(s!==void 0&&a==="remove")throw new Error(`${r} remove cannot contain delta_source`);if(s!==void 0&&c==null)throw new Error(`${r} delta_source requires a non-null base_hash`);if(c!==void 0&&s===void 0&&a!=="remove")throw new Error(`${r} base_hash requires delta_source for non-remove specs`);return{capability:n,operation:a,source:o,...s===void 0?{}:{delta_source:s},...c===void 0?{}:{base_hash:c}}}function tS(t){let e="Native workspace",r=ne(t,e);ae(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=W(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=gl(r.change_branch,`${e}.change_branch`),a=gl(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:W(r.finish,["merge","push","pull-request","keep"],`${e}.finish`);if(i==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(i==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(i!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:i,change_branch:n,target_branch:a,finish:o}}function rS(t){let e="Native loop",r=ne(t,e);ae(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","stop_reason","execution_failure_count","previous_unresolved_ids","next_action"]),e);let i=so(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);ar(i,`${e}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:W(r.stop_reason,["budget","stalled"],`${e}.stop_reason`);return{stage:W(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:D(r.goal_cycle,`${e}.goal_cycle`,1),iteration:D(r.iteration,`${e}.iteration`),attempt:D(r.attempt,`${e}.attempt`),retry_epoch:D(r.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:D(r.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:D(r.no_progress_count,`${e}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:D(r.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:i,next_action:gl(r.next_action,`${e}.next_action`)}}function iS(t,e){let r=`Native acceptance[${e}]`,i=ne(t,r);ae(i,new Set(["id","source","text","result","reason"]),r);let n=U(i.id,`${r}.id`);if(!Yk.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:ao(i.source,`${r}.source`),text:U(i.text,`${r}.text`),result:W(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:ye(i.reason,`${r}.reason`)}}function nS(t,e){let r=`Native builder_handoff.checks[${e}]`,i=ne(t,r);return ae(i,new Set(["name","result","note"]),r),{name:ye(i.name,`${r}.name`),result:W(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:ye(i.note,`${r}.note`)}}function aS(t){let e="Native builder_handoff",r=ne(t,e);ae(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","acceptance_review","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),e);let i=so(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);ar(i,`${e}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:ne(r.review,`${e}.review`);return n&&ae(n,new Set(["status","summary","reviewer_execution_ref"]),`${e}.review`),{candidate_id:U(r.candidate_id,`${e}.candidate_id`),identity_provider:U(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:U(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:D(r.iteration,`${e}.iteration`,1),summary:ye(r.summary,`${e}.summary`),addressed_acceptance_ids:i,...r.acceptance_review===void 0?{}:{acceptance_review:fl(r.acceptance_review)},checks:Ye(r.checks,`${e}.checks`,nS),checks_truncated:Lr(r.checks_truncated,`${e}.checks_truncated`),known_limits:Ye(r.known_limits,`${e}.known_limits`,(a,o)=>ye(a,`${e}.known_limits[${o}]`)),known_limits_truncated:Lr(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:W(n.status,["passed"],`${e}.review.status`),summary:ye(n.summary,`${e}.review.summary`),reviewer_execution_ref:U(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:Fr(r.submitted_at,`${e}.submitted_at`)}}function oS(t,e){let r=`Native blockers[${e}]`,i=ne(t,r);ae(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=so(i.acceptance_ids,`${r}.acceptance_ids`);return ar(n,`${r}.acceptance_ids`),{owner:W(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:ye(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:W(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function sS(t,e){let r=`Native verification.checks[${e}]`,i=ne(t,r);return ae(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:U(i.id,`${r}.id`),name:ye(i.name,`${r}.name`),argv_display:Ye(i.argv_display,`${r}.argv_display`,(n,a)=>ye(n,`${r}.argv_display[${a}]`)),argv_truncated:Lr(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:ao(i.cwd_ref,`${r}.cwd_ref`,!0),status:W(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:Zk(i.exit_code,`${r}.exit_code`),duration_ms:D(i.duration_ms,`${r}.duration_ms`)}}function cS(t){let e="Native verification",r=ne(t,e);ae(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let i=Ye(r.checks,`${e}.checks`,sS);ar(i.map(a=>a.id),`${e}.checks IDs`);let n=U(r.identity_provider,`${e}.identity_provider`);return{candidate_id:U(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:U(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:D(r.iteration,`${e}.iteration`,1),attempt:D(r.attempt,`${e}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":W(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:W(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:ye(r.summary,`${e}.summary`),risks:Ye(r.risks,`${e}.risks`,(a,o)=>ye(a,`${e}.risks[${o}]`)),risks_truncated:Lr(r.risks_truncated,`${e}.risks_truncated`),completed_at:Fr(r.completed_at,`${e}.completed_at`)}}function nh(t,e){let r=`Native history[${e}]`,i=ne(t,r);ae(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=so(i.unresolved_ids,`${r}.unresolved_ids`);return ar(n,`${r}.unresolved_ids`),{goal_cycle:D(i.goal_cycle,`${r}.goal_cycle`,1),iteration:D(i.iteration,`${r}.iteration`),attempt:D(i.attempt,`${r}.attempt`),outcome:W(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:ye(i.summary,`${r}.summary`),completed_at:Fr(i.completed_at,`${r}.completed_at`)}}function lS(t){let e="Native history_overflow.outcome_counts",r=ne(t,e),i=["pass","fail","blocked","execution-error","recovery"];return ae(r,new Set(i),e),{pass:D(r.pass,`${e}.pass`),fail:D(r.fail,`${e}.fail`),blocked:D(r.blocked,`${e}.blocked`),"execution-error":D(r["execution-error"],`${e}.execution-error`),recovery:D(r.recovery,`${e}.recovery`)}}function uS(t){let e="Native history_overflow",r=ne(t,e);ae(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let i=D(r.dropped_entries,`${e}.dropped_entries`),n=r.first_dropped_at===null?null:Fr(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:Fr(r.last_dropped_at,`${e}.last_dropped_at`);if(i===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(i>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=lS(r.outcome_counts);if(Object.values(o).reduce((c,l)=>c+l,0)!==i)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:i,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function dS(t){let e=new Set(t.acceptance.map(r=>r.id));for(let r of t.loop.previous_unresolved_ids)if(!e.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);t.builder_handoff?.acceptance_review&&hl(t.acceptance,t.builder_handoff.acceptance_review);for(let r of t.blockers)for(let i of r.acceptance_ids)if(!e.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(t.builder_handoff){if(!(t.builder_handoff.iteration===t.loop.iteration||t.phase==="build"&&t.loop.stage==="repairing"&&t.builder_handoff.iteration===t.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(t.builder_handoff.review?.reviewer_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(t.verification){if(!t.builder_handoff)throw new Error("Native verification requires a builder handoff");if(t.verification.candidate_id!==t.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(t.verification.identity_provider!==t.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(t.verification.assurance)!==(t.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(t.verification.assurance==="semantic-verification-unavailable"&&t.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(t.verification.assurance==="user-confirmed-degraded"&&t.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(t.verification.verifier_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=t.verification.iteration===t.loop.iteration&&t.verification.attempt===t.loop.attempt,n=t.phase==="build"&&t.loop.stage==="repairing"&&t.verification.iteration===t.loop.iteration-1&&t.verification.iteration===t.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function pS(t){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[t.phase].has(t.loop.stage))throw new Error(`Native loop stage ${t.loop.stage} is invalid for phase ${t.phase}`);let r=t.status==="await-user"?"await-user":t.status==="blocked"?"blocked":t.status==="done"?"done":null;if(r!==null&&t.loop.stage!==r)throw new Error(`Native status ${t.status} requires loop stage ${r}`);if(t.status==="active"&&["await-user","blocked","done"].includes(t.loop.stage))throw new Error(`Native active status cannot use loop stage ${t.loop.stage}`);if(t.archived!==(t.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(t.archived&&t.phase!=="archive")throw new Error("Native archived state must be in Archive");if(t.verification_result==="pass"){if(t.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(t.acceptance.some(i=>i.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(t.verification.checks.some(i=>i.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(t.verification?.assurance==="semantic-verification-unavailable"&&(t.phase!=="verify"||t.status!=="await-user"||t.verification_result!=="blocked"||t.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(t.verification_report!==null&&t.verification===null)throw new Error("Native verification report requires persisted verification")}function fe(t){let e=ne(t,"Native portable state");if(ae(e,Qk,"Native portable state"),e.schema!==Br)throw new Error(`Native portable state schema must be ${Br}`);let r=U(e.name,"Native state name");if(!Uk.test(r))throw new Error("Native state name is invalid");if(e.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let i=Ye(e.spec_changes,"Native spec_changes",eS);ar(i.map(s=>s.capability),"Native spec change capabilities");let n=Ye(e.acceptance,"Native acceptance",iS);ar(n.map(s=>s.id),"Native acceptance IDs");let a=Ye(e.history,"Native history",nh);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Br,name:r,language:W(e.language,["en","zh-CN"],"Native state language"),phase:W(e.phase,["shape","build","verify","archive"],"Native state phase"),status:W(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:D(e.state_version,"Native state_version",1),brief:"brief.md",...e.document_constraints_version===void 0?{}:e.document_constraints_version===1||e.document_constraints_version===2||e.document_constraints_version===3?{document_constraints_version:e.document_constraints_version}:(()=>{throw new Error("Native document_constraints_version must be 1, 2, or 3")})(),...e.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:wl(e.shape_confirmation_hash,"Native Shape confirmation hash")},...e.children_contract_hash===void 0?{}:{children_contract_hash:wl(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:W(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:tS(e.workspace),loop:rS(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:aS(e.builder_handoff),blockers:Ye(e.blockers,"Native blockers",oS),verification:e.verification===null?null:cS(e.verification),history:a,history_overflow:uS(e.history_overflow),verification_result:W(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:W(e.verification_report,["verification.md"],"Native verification_report"),archived:Lr(e.archived,"Native archived"),created_at:Fr(e.created_at,"Native created_at")};return dS(o),pS(o),o}function ah(t){let e=t.createdAt instanceof Date?t.createdAt.toISOString():t.createdAt??new Date().toISOString();return fe({schema:Br,name:t.name,language:t.language,phase:"shape",status:"active",state_version:1,brief:"brief.md",spec_changes:[],workspace:t.workspace??{isolation:"current",change_branch:null,target_branch:null,finish:null},loop:{stage:"shape",goal_cycle:1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:t.nextAction??null},acceptance:[],builder_handoff:null,blockers:[],verification:null,history:[],history_overflow:ml(),verification_result:"pending",verification_report:null,archived:!1,created_at:e})}function cn(t,e){let r=fe(t),i=nh(e,r.history.length),n=[...r.history,i],a={...r.history_overflow,outcome_counts:{...r.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return fe({...r,history:n,history_overflow:a})}function fS(t,e){let r=(0,oo.parseDocument)(t,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`${e} is invalid YAML: ${r.errors[0].message}`);return r.toJS({mapAsMap:!1})}async function $t(t){let e=await Jk.readFile(t,"utf8");return fe(fS(e,"Native portable state"))}async function yl(t,e,r={}){let i=fe(e);await We(t,(0,oo.stringify)(i),r)}async function hS(t,e){let r=no.get(t)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);no.set(t,a),await r;try{return await e()}finally{i(),no.get(t)===a&&no.delete(t)}}async function oh(t){return hS(t.file,async()=>{let e=D(t.expectedStateVersion,"Native expected state version",1),r=fe(t.next);if(r.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await $t(t.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==e)throw new sn(e,i.state_version);return await yl(t.file,r,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await $t(t.file);if(n.state_version!==e)throw new sn(e,n.state_version)}}),r})}var oo,Uk,Kk,Yk,Xk,Qk,sn,no,Te=x(()=>{"use strict";ro();oo=et(Me(),1);H();on();Uk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Kk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Yk=/^A[1-9][0-9]*$/u,Xk=/^[a-f0-9]{64}$/u,Qk=new Set(["schema","name","language","phase","status","state_version","brief","document_constraints_version","shape_confirmation_hash","children_contract_hash","coordination_mode","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),sn=class extends Error{constructor(r,i){super(`Native state version conflict: expected ${r}, got ${i}`);this.expectedStateVersion=r;this.actualStateVersion=i;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};no=new Map});var or=x(()=>{"use strict"});var sh=x(()=>{"use strict";eo();ul();Te();or();on();Xi()});var ch,QI,ZI,bl=x(()=>{"use strict";ue();il();sh();ch="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",QI=new RegExp(`^portable-archive-(${ch})\\.json$`,"u"),ZI=new RegExp(`^portable-migration-(${ch})\\.json$`,"u")});import{createHash as gS}from"node:crypto";import{constants as co,promises as je}from"node:fs";import $e from"node:path";import{TextDecoder as wS}from"node:util";function uo(t,e){let r=$e.relative(t,e);return r===""||!$e.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${$e.sep}`)}function yS(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function NS(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function bS(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function lo(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function kl(t,e){let r=await je.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await je.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function lh(t,e,r){let i=$e.resolve(t),n=$e.resolve(e);if(!uo(i,n))throw new Error(`${r} is outside its managed root`);let a=[await kl(i,r)],o=i;for(let s of $e.relative(i,n).split($e.sep).filter(Boolean)){await Ot(a,r),o=$e.join(o,s);let c=await kl(o,r);if(!uo(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await Ot(a,r),a}async function Ot(t,e){for(let r of t){let i=await je.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!NS(r,i)||await je.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function kS(t,e,r){let i=[],n=0,a=Buffer.allocUnsafe(e===null?64*1024:Math.min(64*1024,e+1));for(;;){let o=e===null?a.length:e+1-n,{bytesRead:s}=await t.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,e!==null&&n>e)throw new Error(`${r} exceeds ${e} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function un(t){let e=t.maxBytes===null?null:yS(t.maxBytes),r=$e.resolve(t.file),i=await lh(t.root,$e.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(d=>kl($e.resolve(d),t.label)));await t.hooks?.afterParentChainCaptured?.(),await Ot(i,t.label);let a=await je.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(e!==null&&a.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let o=bS(a),s=await je.realpath(r);if(!uo(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(d=>uo(d.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?co.O_RDONLY:co.O_RDONLY|co.O_NOFOLLOW|co.O_NONBLOCK,l=await je.open(r,c);try{let d=await l.stat();await t.hooks?.afterOpen?.();let[u,p]=await Promise.all([je.lstat(r),je.realpath(r)]);if(await Ot(i,t.label),await Ot(n,t.label),!d.isFile()||!u.isFile()||u.isSymbolicLink()||p!==s||!lo(o,d)||!lo(o,u))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let f=await kS(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[m,h,g]=await Promise.all([l.stat(),je.lstat(r),je.realpath(r)]);if(await Ot(i,t.label),await Ot(n,t.label),!h.isFile()||h.isSymbolicLink()||g!==s||!lo(o,m)||!lo(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:f,hash:gS("sha256").update(f).digest("hex"),size:f.length}}finally{await l.close()}}async function uh(t){let e=await un(t),r;try{r=new wS("utf-8",{fatal:!0}).decode(e.bytes)}catch(i){throw new Error(`${t.label} is not valid UTF-8`,{cause:i})}return{...e,text:r}}async function dn(t){let e=await lh(t.root,t.directory,t.label);return{verify:()=>Ot(e,t.label)}}var Ne=x(()=>{"use strict";H();Ve()});import{TextDecoder as ES}from"util";var mT,po=x(()=>{"use strict";H();I();Ne();mT=new ES("utf-8",{fatal:!0})});var K=x(()=>{"use strict";ve();Yi();bl();po()});import{createHash as CS}from"crypto";function he(t){return CS("sha256").update(t).digest("hex")}var Oe=x(()=>{"use strict"});import xl from"path";function fo(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}function GS(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function JS(t,e){return he(`comet.native.snapshot-policy.v1
164
+ ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function El(t,e,r){let i=new Set(e),n=[...e];for(;n.length>0;){if(r&&!r())return null;let a=n.pop(),o=t[a];o&&(o.kind==="star"||o.kind==="globstar"||o.kind==="globstar-slash")&&!i.has(a+1)&&(i.add(a+1),n.push(a+1))}return i}function US(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function mh(t){let e=Qa(t,"Native snapshot pattern"),r=[];for(let i=0;i<e.length;i+=1){let n=e[i];n==="*"&&e[i+1]==="*"?(i+=1,e[i+1]==="/"?(i+=1,r.push({kind:"globstar-slash"})):r.push({kind:"globstar"})):n==="*"?r.push({kind:"star"}):n==="?"?r.push({kind:"question"}):r.push({kind:"literal",value:n})}return(i,n)=>{let a=n?US(n):void 0;if(a&&!a())return!1;let o=El(r,new Set([0]),a);if(o===null)return!1;for(let s of i){if(a&&!a())return!1;let c=new Set;for(let l of o){if(a&&!a())return!1;let d=r[l];d&&(d.kind==="literal"&&d.value===s||d.kind==="question"&&s!=="/"?c.add(l+1):d.kind==="star"&&s!=="/"||d.kind==="globstar"?c.add(l):d.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(o=El(r,c,a),o===null||o.size===0)return!1}return El(r,o,a)?.has(r.length)??!1}}function KS(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>Qa(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>Qa(n,"exclude")))].sort((n,a)=>n.localeCompare(a,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let i=JS(e,r);if("hash"in t&&t.hash!==i)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:r,hash:i},includeMatchers:e.map(mh),excludeMatchers:r.map(mh),excludedDirectoryPrefixes:r.flatMap(n=>{if(!n.endsWith("/**"))return[];let a=n.slice(0,-3);return/[*?]/u.test(a)?[]:[a]}).sort((n,a)=>n.localeCompare(a,"en"))}}function be(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ke(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function Mr(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Xe(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function wh(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let r=xl.posix.normalize(t);if(r!==t||xl.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function YS(t,e){let r=be(t,`Native snapshot entry ${e}`);ke(r,LS,`Native snapshot entry ${e}`);let i=wh(r.path,`Native snapshot entry ${e} path`);if(typeof r.hash!="string"||!ho.test(r.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(r.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:i,hash:r.hash,size:Xe(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!zS.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function XS(t,e){let r=be(t,`Native snapshot omission ${e}`);if(ke(r,FS,`Native snapshot omission ${e}`),!VS.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!WS.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:wh(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:Xe(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function QS(t){let e=be(t,"Native snapshot omission overflow");if(ke(e,qS,"Native snapshot omission overflow"),typeof e.hash!="string"||!ho.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let r=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==r)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:r,hash:e.hash,count:Mr(e.count,"Native snapshot omission overflow count")}}function qr(t,e){let r=be(t,e);if(ke(r,HS,e),typeof r.hash!="string"||!ho.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let i=Xe(r.recordCount,`${e} recordCount`),n=Xe(r.storedRecordCount,`${e} storedRecordCount`),a=Xe(r.stdoutBytes,`${e} stdoutBytes`);if(n>i||!r.overflow&&n!==i)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,recordCount:i,storedRecordCount:n,stdoutBytes:a,overflow:r.overflow}}function vh(t){let e=be(t,"Native Git selection evidence");if(ke(e,OS,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let r=qr(e.stageBefore,"Native Git selection stageBefore"),i=qr(e.combined,"Native Git selection combined"),n=qr(e.stageAfter,"Native Git selection stageAfter"),a=qr(e.finalStageBefore,"Native Git selection finalStageBefore"),o=qr(e.finalCombined,"Native Git selection finalCombined"),s=qr(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(u=>u.overflow),l=!fo(r,n)||!fo(n,a)||!fo(i,o)||!fo(a,s),d=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==d)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:d,stageBefore:r,combined:i,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function gh(t,e){let r=be(t,e);if(ke(r,BS,e),typeof r.hash!="string"||!ho.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean"||typeof r.unstable!="boolean")throw new Error(`${e} flags are invalid`);let i=Xe(r.visitedNodeCount,`${e} visitedNodeCount`),n=Xe(r.recordCount,`${e} recordCount`),a=Xe(r.storedRecordCount,`${e} storedRecordCount`),o=Xe(r.encodedBytes,`${e} encodedBytes`);if(a>n||!r.overflow&&a!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,visitedNodeCount:i,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:r.overflow,unstable:r.unstable}}function ZS(t){let e=be(t,"Native physical selection evidence");if(ke(e,DS,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let r=gh(e.before,"Native physical selection before"),i=gh(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!GS(r,i);if(!n&&!a)throw new Error("Native physical selection evidence must describe an exceptional selection");let o=n&&a?"overflow-and-changed":n?"overflow":"changed";if(e.status!==o)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:o,before:r,after:i}}function yh(t){let e=be(t,"Native content snapshot manifest");if(ke(e,AS,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!MS.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let w=be(e.capture,"Native content snapshot capture");if(ke(w,jS,"Native content snapshot capture"),w.provider!=="git"&&w.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let _=w.gitSelection===void 0?void 0:vh(w.gitSelection),S=w.physicalSelection===void 0?void 0:ZS(w.physicalSelection),T=null;if(w.projection!==void 0){let Q=be(w.projection,"Native content snapshot projection");if(ke(Q,$S,"Native content snapshot projection"),Q.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");T={provider:"git",...Q.selection===void 0?{}:{selection:vh(Q.selection)}}}if(w.provider==="git"){if(S||T)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",..._?{gitSelection:_}:{}}}else{if(_)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(S&&T)throw new Error("Native physical-tree capture cannot combine selection and projection");r=T?{provider:"physical-tree",projection:T}:{provider:"physical-tree",...S?{physicalSelection:S}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let i=be(e.limits,"Native content snapshot limits");ke(i,IS,"Native content snapshot limits");let n={maxFiles:Mr(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Mr(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Mr(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Mr(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:Mr(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let w=be(e.policy,"Native snapshot policy");if(ke(w,TS,"Native snapshot policy"),w.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(w.include)||!Array.isArray(w.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=KS({include:w.include,exclude:w.exclude,hash:w.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let o=e.entries.map(YS),s=e.omitted.map(XS),c=Xe(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:QS(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(w=>w.size>n.maxFileBytes)||o.reduce((w,_)=>w+_.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(w=>w.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>PS||c<s.length)throw new Error("Native content snapshot omission count is invalid");let d=c-s.length;if(d===0&&l||d>0&&l?.count!==d)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let u=s.filter(w=>w.reason==="git-enumeration-limit"),p=s.filter(w=>w.reason==="git-selection-changed");for(let w of[...u,...p])if(w.path!=="."||w.size!==null||w.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(u.length>1||p.length>1)throw new Error("Native Git selection omissions must not be duplicated");let f=r?.provider==="git"?r.gitSelection:r?.projection?.selection,m=f?.status==="overflow"||f?.status==="overflow-and-changed",h=f?.status==="changed"||f?.status==="overflow-and-changed";if(m!==(u.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(h!==(p.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let g=s.filter(w=>w.reason==="physical-enumeration-limit"),v=s.filter(w=>w.reason==="physical-selection-changed");for(let w of[...g,...v])if(w.path!=="."||w.size!==null||w.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(g.length>1||v.length>1)throw new Error("Native physical selection omissions must not be duplicated");let N=r?.physicalSelection,b=N?.status==="overflow"||N?.status==="overflow-and-changed",y=N?.status==="changed"||N?.status==="overflow-and-changed";if(b!==(g.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(y!==(v.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");return{schema:"comet.native.content-snapshot.v1",origin:e.origin,...r?{capture:r}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}}}function eE(t,e){if(!_S.test(e))throw new Error(`Invalid Native change name: ${e}`);return xl.join(Z(t,e),"baseline-manifest.json")}async function Cl(t,e){let r=eE(t,e),i=Ae(t,r);await M(i,r);try{let n=await uh({root:i,file:r,maxBytes:null,label:"Native baseline snapshot manifest"});return yh(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var LT,PS,_S,AS,IS,TS,jS,$S,OS,HS,DS,BS,LS,FS,qS,MS,VS,WS,ho,zS,FT,qT,MT,VT,WT,Vr=x(()=>{"use strict";Pr();H();ve();Oe();Ve();I();Ne();Li();LT={maxFiles:1e4,maxFileBytes:1024*1024*1024,maxTotalBytes:1024*1024*1024,maxManifestBytes:1024*1024*1024},PS=1e3,_S=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,AS=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),IS=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),TS=new Set(["schema","include","exclude","hash"]),jS=new Set(["provider","gitSelection","physicalSelection","projection"]),$S=new Set(["provider","selection"]),OS=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),HS=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),DS=new Set(["schema","status","before","after"]),BS=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),LS=new Set(["path","hash","size","type","gitObjectId"]),FS=new Set(["path","size","type","reason"]),qS=new Set(["ref","hash","count"]),MS=new Set(["change-created","legacy-migration","explicit"]),VS=new Set(["file","directory","other"]),WS=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),ho=/^[a-f0-9]{64}$/u,zS=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,FT=64*1024,qT=64*1024,MT={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},VT={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};WT=(1n<<256n)-1n});import{execFileSync as IE}from"node:child_process";function $E(t,e){try{return ji(()=>IE("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:TE,maxBuffer:jE,windowsHide:!0}))}catch(r){let i=typeof r.stderr=="string"?r.stderr.trim():Buffer.isBuffer(r.stderr)?r.stderr.toString("utf8").trim():"";throw new Hl(t,e,i)}}function me(t,e){return $E(t,e).trim()}var TE,jE,Hl,Se=x(()=>{"use strict";Pr();TE=3e4,jE=8*1024*1024,Hl=class extends Error{constructor(r,i,n){super(`git ${i.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=r;this.args=i;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr}});import{promises as OE}from"node:fs";import HE from"node:path";function bo(t,e,r=""){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object${r}`);return t}function No(t,e,r){let i=Object.keys(t).filter(a=>!e.has(a)),n=[...e].filter(a=>!(a in t));if(i.length>0||n.length>0){let a=[...n.length>0?[`missing ${n.join(", ")}`]:[],...i.length>0?[`unexpected ${i.join(", ")}`]:[],`expected ${[...e].join(", ")}`];throw new Error(`${r} fields are invalid: ${a.join("; ")}`)}}function Ih(t,e){if(!Array.isArray(t)||!t.every(r=>typeof r=="string"))throw new Error(`${e} must be an array of strings`);return[...new Set(t)].sort((r,i)=>r.localeCompare(i,"en"))}function ME(t){let e=new Map(t.map(a=>[a.name,a])),r=new Set,i=new Set,n=a=>{if(!i.has(a)){if(r.has(a))throw new Error(`Native children dependency cycle includes ${a}`);r.add(a);for(let o of e.get(a).depends_on)n(o);r.delete(a),i.add(a)}};for(let a of t)n(a.name)}function Th(t,e,r=e){let i=new Set(e);for(let o of t){let s=o.covers.filter(c=>!i.has(c));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(t.flatMap(o=>o.covers)),a=r.filter(o=>!n.has(o));if(a.length>0)throw new Error(`Native children do not cover parent acceptance: ${a.join(", ")}`)}function Hh(t,e,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(t.schema===Bl&&t.acceptance_index){let n=r.requiredAcceptanceIds??e??[],a=r.allowedAcceptanceIds??n,o=Object.keys(t.acceptance_index);i.missing=n.filter(l=>!(l in t.acceptance_index)),i.extra=o.filter(l=>!a.includes(l));let s=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of o){let d=s.get(l),u=t.acceptance_index[l];d&&u&&(u.source!==d.source||u.text!==d.text)&&i.mismatched.push(l)}let c=new Set(o);for(let l of t.children)i.unknownCovers.push(...l.covers.filter(d=>!c.has(d)));return i.uncovered=o.filter(l=>!jh(t.children,l)),$h(i)?i:null}if(t.schema===sr&&e){let n=new Set(e);for(let a of t.children)i.unknownCovers.push(...a.covers.filter(o=>!n.has(o)));return i.uncovered=e.filter(a=>!jh(t.children,a)),$h(i)?i:null}return null}function jh(t,e){return t.some(r=>r.covers.includes(e))}function $h(t){return t.missing.length>0||t.extra.length>0||t.mismatched.length>0||t.uncovered.length>0||t.unknownCovers.length>0}function Dt(t){let e=new Set(t.acceptance.map(({id:n})=>n)),r=new Set(t.acceptance.filter(({source:n})=>n===t.brief).map(({id:n})=>n)),i=new Set(r);for(let n of t.history.filter(({outcome:a})=>a==="fail"))for(let a of n.unresolved_ids)e.has(a)&&i.add(a);if(t.loop.stage==="repairing"&&t.verification_result==="fail"){let n=[...t.history].reverse().find(({outcome:a})=>a==="fail");for(let a of n?.unresolved_ids??[])r.add(a)}return{acceptanceCatalog:t.acceptance,requiredAcceptanceIds:[...r],allowedAcceptanceIds:[...i]}}function VE(t){let e=bo(t,"Native children acceptance_index",' keyed by acceptance ID, for example A1: { source: brief.md, text: "Full acceptance text" }'),r={};for(let[i,n]of Object.entries(e)){let a=bo(n,`Native children acceptance_index.${i}`);if(No(a,new Set(["source","text"]),`Native children acceptance_index.${i}`),typeof a.source!="string"||a.source.length===0)throw new Error(`Native children acceptance_index.${i}.source must be a non-empty string`);if(typeof a.text!="string"||a.text.length===0)throw new Error(`Native children acceptance_index.${i}.text must be a non-empty string`);r[i]={source:a.source,text:a.text}}return r}function WE(t,e,r){let i=r.requiredAcceptanceIds??e??[],n=r.allowedAcceptanceIds??i,a=Object.keys(t),o=i.filter(l=>!(l in t)),s=a.filter(l=>!n.includes(l));if(o.length>0||s.length>0)throw new Error(`Native children acceptance_index must match the required acceptance: missing ${o.join(", ")||"none"}; extra ${s.join(", ")||"none"}`);let c=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of a){let d=c.get(l);if(!d)continue;let u=t[l];if(u.source!==d.source||u.text!==d.text){let p=["source","text"].filter(f=>u[f]!==d[f]);throw new Error(`Native children acceptance_index.${l} does not match the acceptance catalog: copy ${p.join(", ")} exactly from the current acceptance catalog`)}}}function Dh(t,e,r={}){let i=(0,Oh.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=bo(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==sr&&a!==Ht)throw No(n,Ah,"Native children contract"),new Error(`Native children schema must be ${sr} or ${Ht}`);let o=a===sr?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(No(n,o==="indexed-v2"?BE:Ah,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let c=n.children.map((p,f)=>{let m=bo(p,`Native child ${f}`);if(No(m,o==="indexed-v2"?qE:o==="summary-v2"?FE:LE,`Native ${s} child fields (child ${f})`),typeof m.name!="string"||!DE.test(m.name))throw new Error(`Native child ${f} name is invalid`);let h=o==="summary-v2";if(h){if(typeof m.summary!="string"||m.summary.trim().length===0)throw new Error(`Native child ${m.name} summary must be a non-empty string`);if(m.summary.length>2e3)throw new Error(`Native child ${m.name} summary exceeds 2000 characters`)}return{name:m.name,summary:h?m.summary:null,depends_on:Ih(m.depends_on,`Native child ${m.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?Ih(m.covers,`Native child ${m.name} covers`):[]}}),l=c.map(({name:p})=>p);if(new Set(l).size!==l.length)throw new Error("Native child names must be unique");let d=new Set(l);for(let p of c){let f=p.depends_on.filter(m=>!d.has(m));if(f.length>0)throw new Error(`Native child ${p.name} depends on unknown child: ${f.join(", ")}`)}ME(c);let u=r.policy==="advisory";if(a===Bl){if(o==="indexed-v2"){let p=VE(n.acceptance_index);u||WE(p,e,r);let f=Object.keys(p);return u||Th(c,f,f),{schema:Ht,acceptance_index:p,children:c}}return{schema:Ht,children:c}}return e&&!u&&Th(c,e),{schema:sr,children:c}}async function dt(t){let e=HE.join(t.changeDir,Dl);try{await OE.lstat(e)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await L({root:t.changeDir,ref:Dl}),i=t.policy==="advisory",n=i?{...t.validation,policy:"advisory"}:t.validation??{},a=Dh(r.text,t.acceptanceIds,n);return{contract:a,hash:r.hash,size:r.size,drift:i?Hh(a,t.acceptanceIds,t.validation??{}):null}}var Oh,Dl,sr,Ht,Bl,DE,Ah,BE,LE,FE,qE,ko=x(()=>{"use strict";Oh=et(Me(),1);ue();Dl="children.yaml",sr="comet.native.children.v1",Ht="comet.native.children.v2",Bl=Ht,DE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Ah=new Set(["schema","children"]),BE=new Set(["schema","acceptance_index","children"]),LE=new Set(["name","depends_on","covers"]),FE=new Set(["name","summary","depends_on"]),qE=new Set(["name","depends_on","covers"])});var mn=x(()=>{"use strict"});var So=x(()=>{"use strict";to();mn()});function pt(t,e){if(!GE.test(t))throw new Error(`${e} must be a Git commit`)}function Ll(t,e){t.history.push({...e,at:new Date().toISOString()}),t.history.length>256&&t.history.splice(0,t.history.length-256)}function xo(t){pt(t.targetCommit,"Native Supervisor target commit");let e=new Set(t.contract.children.map(({name:i})=>i)),r=t.contract.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.depends_on],status:i.depends_on.length===0?"ready":"pending",baseCommit:null,candidateCommit:null,verifiedCommit:null,integrationCommit:null,verification:null,checks:[],blocker:null,projectRoot:null,task:null,acceptanceScope:Fl(t.contract,i.name),contractHash:O("comet.native.supervisor-contract.v1",t.contract),builderFailureCount:0}));for(let i of r)for(let n of i.dependsOn)if(!e.has(n))throw new Error(`Native Supervisor child ${i.name} depends on unknown child ${n}`);return{schema:vn,stateVersion:1,parent:t.parent,integration:{branch:t.integrationBranch,worktree:t.integrationWorktree,targetBranch:t.targetBranch,targetCommit:t.targetCommit,headCommit:t.targetCommit},children:r,history:[],finalVerification:{status:"pending",summary:null}}}function Fl(t,e){let r=t.children.find(i=>i.name===e);return r.covers.length>0?r.covers.map(i=>({id:i,source:t.acceptance_index?.[i]?.source??"brief.md",text:t.acceptance_index?.[i]?.text??i})):[{id:`child:${e}`,source:"children.yaml",text:r.summary??e}]}function Co(t){let e=t.children.every(i=>i.acceptanceScope&&i.acceptanceScope.length>0&&(!i.task||i.task.acceptance&&i.task.acceptance.length>0)),r=t.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.dependsOn],covers:i.acceptanceScope?.map(({id:n})=>n)??[],status:(i.status==="ready"||i.status==="active")&&i.blocker&&[...t.history].reverse().find(n=>n.child===i.name)?.kind==="task-blocked"?"blocked":i.status,phase:null,projectRoot:i.projectRoot??i.task?.projectRoot??null,message:e?i.blocker:"Supervisor acceptance scope is unavailable; restore children.yaml and confirm Shape before continuing",builderFailureCount:i.builderFailureCount??0}));return{contractHash:null,supervisorStateVersion:t.stateVersion,confirmed:e,parentBranch:t.integration.branch,children:r,readyChildren:e?r.filter(({status:i})=>i==="ready").map(({name:i})=>i):[],allDone:e&&r.every(({status:i})=>i==="integrated"||i==="archived")}}var GE,vn,Eo,cr=x(()=>{"use strict";F();So();GE=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;vn="comet.native.supervisor.v2",Eo=3});import gn from"node:path";import{promises as Lh}from"node:fs";function ql(t,e){return gn.join(Ue(t,e),"supervisor")}function Ro(t,e){return gn.join(ql(t,e),"state.json")}function Fh(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native Supervisor state must be an object");let e=t;if(e.schema!==vn)throw new Error(`Native Supervisor state schema must be ${vn}`);if(!Number.isSafeInteger(e.stateVersion)||typeof e.stateVersion!="number"||e.stateVersion<1)throw new Error("Native Supervisor state version is invalid");if(typeof e.parent!="string"||!e.parent)throw new Error("Native Supervisor state parent is invalid");if(!e.integration||typeof e.integration!="object")throw new Error("Native Supervisor integration state is missing");for(let[n,a]of Object.entries(e.integration))if(n!=="checkExecution"&&(typeof a!="string"||a.length===0))throw new Error(`Native Supervisor integration field ${n} is invalid`);if(pt(e.integration.targetCommit,"Native Supervisor target commit"),pt(e.integration.headCommit,"Native Supervisor integration head commit"),e.integration.checkExecution){let n=e.integration.checkExecution;if(!n.operationId||!n.key||!n.child||!["running","completed","interrupted"].includes(n.status)||!Number.isSafeInteger(n.ownerPid)||n.ownerPid<=0)throw new Error("Native Supervisor integration check execution is invalid");pt(n.candidateCommit,"Native Supervisor integration candidate commit"),pt(n.integrationCommit,"Native Supervisor integration check commit"),Bh(n.checkStates,"Native Supervisor integration")}if(!Array.isArray(e.children))throw new Error("Native Supervisor children are invalid");if(!Array.isArray(e.history))throw new Error("Native Supervisor history is invalid");if(!e.finalVerification||!["pending","passed","failed","incomplete"].includes(e.finalVerification.status)||e.finalVerification.summary!==null&&typeof e.finalVerification.summary!="string")throw new Error("Native Supervisor final verification is invalid");if(e.finalVerification.layers){let n=e.finalVerification.layers;if(!["complete","incomplete"].includes(n.childVerification)||!["complete","incomplete"].includes(n.parentIntegration)||!Array.isArray(n.parentChecks)||!n.parentChecks.every(a=>typeof a=="string")||!Array.isArray(n.notRerun)||!n.notRerun.every(a=>typeof a=="string")||!Array.isArray(n.incomplete)||!n.incomplete.every(a=>typeof a=="string"))throw new Error("Native Supervisor final verification layers are invalid")}for(let n of e.history)if(!n||typeof n!="object"||typeof n.kind!="string"||typeof n.summary!="string"||typeof n.at!="string"||n.child!==null&&typeof n.child!="string"||n.runId!==null&&typeof n.runId!="string")throw new Error("Native Supervisor history event is invalid");let r=new Set,i=new Set;for(let n of e.children){if(!n||typeof n!="object"||typeof n.name!="string")throw new Error("Native Supervisor child state is invalid");if(r.has(n.name))throw new Error(`Native Supervisor child ${n.name} is duplicated`);if(r.add(n.name),!Array.isArray(n.dependsOn)||!n.dependsOn.every(a=>typeof a=="string"))throw new Error(`Native Supervisor child ${n.name} dependencies are invalid`);if(typeof n.summary!="string"&&n.summary!==null)throw new Error(`Native Supervisor child ${n.name} summary is invalid`);if(n.builderFailureCount!==void 0&&(!Number.isSafeInteger(n.builderFailureCount)||n.builderFailureCount<0))throw new Error(`Native Supervisor child ${n.name} Builder failure count is invalid`);if(n.projectRoot!==void 0&&n.projectRoot!==null&&(typeof n.projectRoot!="string"||n.projectRoot.length===0))throw new Error(`Native Supervisor child ${n.name} projectRoot is invalid`);for(let[a,o]of[["base",n.baseCommit],["candidate",n.candidateCommit],["verified",n.verifiedCommit],["integration",n.integrationCommit]])o!==null&&pt(o,`Native Supervisor child ${n.name} ${a} commit`);if(!Array.isArray(n.checks)||!Array.isArray(n.verification?.checks??[]))throw new Error(`Native Supervisor child ${n.name} evidence is invalid`);if(n.task!==null){if(!n.task||typeof n.task!="object")throw new Error(`Native Supervisor child ${n.name} task is invalid`);if(!["builder","verifier"].includes(n.task.role)||n.task.child!==n.name||typeof n.task.projectRoot!="string"||n.task.projectRoot.length===0||typeof n.task.runId!="string"||n.task.runId.length===0)throw new Error(`Native Supervisor child ${n.name} task identity is invalid`);if(pt(n.task.baseCommit,`Native Supervisor child ${n.name} task base commit`),i.has(n.task.runId))throw new Error(`Native Supervisor task runId ${n.task.runId} is duplicated`);if(i.add(n.task.runId),n.task.role==="verifier"&&n.task.baseCommit!==n.candidateCommit)throw new Error(`Native Supervisor child ${n.name} verifier base commit is invalid`);if(n.task.projectRoot!==n.projectRoot)throw new Error(`Native Supervisor child ${n.name} task projectRoot is invalid`);if(n.task.checkExecution&&Bh(n.task.checkExecution.checkStates,`Native Supervisor child ${n.name}`),n.task.role==="builder"&&n.status!=="active"||n.task.role==="verifier"&&!["active","needs-reverify"].includes(n.status))throw new Error(`Native Supervisor child ${n.name} task status is invalid`)}}}async function He(t,e,r={}){try{let i=await Lh.readFile(Ro(t,e),"utf8"),n=JSON.parse(i);if(Fh(n),n.children.some(o=>!o.acceptanceScope||o.task&&!o.task.acceptance))try{let o=t;if(!o.changesDir)throw new Error("Native Supervisor upgrade requires full project paths to recover confirmed acceptance");let{readNativePortableState:s}=await Promise.resolve().then(()=>(Te(),Nl)),c=await s(gn.join(o.changesDir,e,"comet-state.yaml")),l=await dt({changeDir:gn.join(o.changesDir,e),acceptanceIds:c.acceptance.map(({id:d})=>d),validation:Dt(c)});if(!l)throw new Error("Native Supervisor upgrade requires the confirmed children contract");for(let d of n.children)l.contract.children.some(({name:u})=>u===d.name)&&(d.acceptanceScope=Fl(l.contract,d.name),d.contractHash=O("comet.native.supervisor-contract.v1",l.contract),d.task&&(d.task.acceptance=structuredClone(d.acceptanceScope),d.task.contractHash=d.contractHash,d.task.verificationBoundary="child-scope-parent-reverifies-all",d.task.checksReason="not-run"))}catch(o){if(!r.diagnostics)throw o}let a=t;if(a.changesDir)try{let{readNativePortableState:o}=await Promise.resolve().then(()=>(Te(),Nl)),s=await o(gn.join(a.changesDir,e,"comet-state.yaml"));s.workspace.change_branch&&(n.integration.targetBranch=s.workspace.change_branch)}catch(o){if(o.code!=="ENOENT")throw o}return n}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Bt(t,e){Fh(e),await Lh.mkdir(t.changesRuntimeDir,{recursive:!0}),await ie(Ro(t,e.parent),e,{containedRoot:t.changesRuntimeDir})}function Bh(t,e){if(t===void 0)return;if(!Array.isArray(t)||t.length===0)throw new Error(`${e} check states are invalid`);let r=new Set;for(let i of t){if(!i||typeof i.id!="string"||!i.id||r.has(i.id)||typeof i.name!="string"||!["planned","running","passed","failed","interrupted"].includes(i.status)||typeof i.repeatable!="boolean"||!Number.isSafeInteger(i.executionCount)||i.executionCount<0||!Array.isArray(i.argvDisplay)||!i.argvDisplay.every(n=>typeof n=="string")||typeof i.cwdRef!="string"||!Number.isSafeInteger(i.durationMs)||i.durationMs<0||i.exitCode!==null&&!Number.isSafeInteger(i.exitCode)||i.signal!==null&&typeof i.signal!="string"||typeof i.timedOut!="boolean"||i.startedAt!==null&&typeof i.startedAt!="string"||i.completedAt!==null&&typeof i.completedAt!="string"||i.logRef!==null&&typeof i.logRef!="string")throw new Error(`${e} check state is invalid`);r.add(i.id)}}var Lt=x(()=>{"use strict";H();F();ko();I();cr()});var Ml=x(()=>{"use strict"});var Ft=x(()=>{"use strict"});import{accessSync as z0,constants as G0,createWriteStream as J0,existsSync as U0,promises as K0,statSync as KE}from"node:fs";import lr from"node:path";function YE(t,e){let r=lr.relative(t,e);return r===""||!lr.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${lr.sep}`)}function qh(t,e){if(e.length===0||e.includes("\\")||lr.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||lr.posix.normalize(e)!==e)throw new Error("Native check cwd must be a normalized project-relative ref");let r=lr.resolve(t),i=lr.resolve(r,...e.split("/"));if(!YE(r,i))throw new Error("Native check cwd escaped the project root");let n;try{n=KE(i)}catch(a){throw new Error(`Native check cwd does not exist: ${e}`,{cause:a})}if(!n.isDirectory())throw new Error(`Native check cwd is not a directory: ${e}`);return i}var Po=x(()=>{"use strict";$i();Ml();Ft()});var Mh=x(()=>{"use strict";Se();Po();F()});var _o=x(()=>{"use strict";Se();H()});var Kh,ur=x(()=>{"use strict";F();Vr();Kh=1024*1024});var To=x(()=>{"use strict";F();Ft();Li();ur()});var Am,UC,KC,YC,qL,XC,ML,pu=x(()=>{"use strict";F();Am="scoped-text-safety",UC=1,KC=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),YC="comet.native.checker-policy.v1",qL=O(YC,{policy:Am,version:UC,limits:KC,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),XC=["contract-before-does-not-match-scope","implementation-before-does-not-match-scope","contract-changed-during-check","implementation-changed-during-check","contract-after-does-not-match-scope","implementation-after-does-not-match-scope"],ML=new Set(XC)});var xn=x(()=>{"use strict";F();pu();Ft()});var QC,aF,Vt=x(()=>{"use strict";H();I();Ve();ur();To();xn();QC=Kh,aF=3*QC});var jl=et(Me(),1);import{promises as PE}from"fs";import Wr from"path";Pr();_r();import{execFileSync as vb}from"child_process";import gb from"fs";import Xt from"path";import{AsyncLocalStorage as bf}from"node:async_hooks";$i();var Qt=new bf,kf=new bf;function Sf(t){return Qt.getStore()?t():Qt.run(new Map,t)}function wb(t){let e=Qt.getStore();for(let r of t)e?.set(Ct(r.root),t);return t}function Oi(t,e){return ji(()=>vb("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim())}function Hi(t,e){return Ct(t)===Ct(e)}function Ct(t){let e=Xt.resolve(t);try{let r=gb.realpathSync.native(e);return process.platform==="win32"?r.toLowerCase():r}catch{return process.platform==="win32"?e.toLowerCase():e}}function G(t){try{let e=kf.getStore()?.get(Ct(t)),r=Qt.getStore()?.get(e??Ct(t));if(r){let c=Di(e??t,r);if(c)return c;if(r.length===0)return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}let i=Xt.resolve(Oi(t,["rev-parse","--show-toplevel"])),n=Qt.getStore()?.get(Ct(i))??Ef(t),a=Di(i,n);if(Qt.getStore()&&a)return a;let o=n[0]?.root??i,s=null;try{s=Oi(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Hi(i,o),currentWorktreeRoot:i,primaryWorktreeRoot:o,currentBranch:s}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function ja(t){try{let e=Qt.getStore()?.get(kf.getStore()?.get(Ct(t))??Ct(t));return e?e.map(r=>({...r})):(Oi(t,["rev-parse","--is-inside-work-tree"]),Ef(t))}catch{return[]}}function Ef(t){let e=yb(Oi(t,["worktree","list","--porcelain","-z"]));return wb(e),e.map(r=>({...r}))}function yb(t){let e=t.split("\0"),r=[],i=null;for(let n of e)n.startsWith("worktree ")?(i&&r.push(i),i={root:Xt.resolve(n.slice(9)),branch:null,detached:!1}):i&&n.startsWith("branch refs/heads/")?i.branch=n.slice(18):i&&n==="detached"&&(i.detached=!0);return i&&r.push(i),r}function Rt(t){return ja(t).map(e=>e.root)}function Di(t,e){let r=e.find(a=>Hi(Xt.resolve(a.root),Xt.resolve(t)));if(!r)return null;let i=Xt.resolve(e[0].root),n=Xt.resolve(r.root);return{isGitWorktree:!0,isSecondaryWorktree:!Hi(i,n),currentWorktreeRoot:n,primaryWorktreeRoot:i,currentBranch:r.branch}}function it(t,e){try{let r=Oi(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(r)?r:null}catch{return null}}ue();H();Zt();ve();K();I();Ne();Vr();K();I();jr();At();var oE=et(Me(),1);jr();At();ot();ot();Tr();Zc();jr();ot();var oj=4*1024*1024;import{AsyncLocalStorage as sE}from"node:async_hooks";var cE=new sE;function lE(){let t=cE.getStore();return t?.active?t:null}function uE(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function Nh(t,e){return(...r)=>{let i=lE();if(i===null)return e(...r);let n=uE(`async:${t}`,r),a=i.entries.get(n);if(a)return a.value;let o=e(...r).catch(s=>{throw i.entries.get(n)?.value===o&&i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}Tr();var pj=Nh("hookWritePolicy",async t=>(await Kc(t))?.hook??{allow_paths:[]});Ji();var dE=16*1024;Yc();Fi();var h$=Number.MAX_SAFE_INTEGER;H();Ve();var R$={runStateBytes:Number.MAX_SAFE_INTEGER,trajectoryBytes:Number.MAX_SAFE_INTEGER,trajectoryEvents:4096,trajectoryEventBytes:Number.MAX_SAFE_INTEGER,checkpointBytes:Number.MAX_SAFE_INTEGER,pendingActionBytes:Number.MAX_SAFE_INTEGER,contextBytes:Number.MAX_SAFE_INTEGER,artifactsBytes:Number.MAX_SAFE_INTEGER};import{createHash as wE}from"node:crypto";import{promises as mo}from"node:fs";import ut from"node:path";H();ue();K();I();var pn=/^[a-f0-9]{64}$/u,bh=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,yE=16*1024,_l=process.platform;function xh(t,e){let r=ut.relative(t,e);return ut.isAbsolute(r)||r===".."||r.startsWith(`..${ut.sep}`)?null:r.replaceAll("\\","/")||"."}function Ch(t){return Array.from(t).some(e=>{let r=e.codePointAt(0)??0;return r<=31||r===127})}function Rh(t,e){if(t.length===0||Ch(t)||t.includes("\\")||ut.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let r=ut.posix.normalize(t);if(r!==t||r===".."||r.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return r}function Al(t,e){return wE("sha256").update(`${t}
165
+ ${e}`).digest("hex")}async function kh(t,e){let r=await mo.realpath(e),i=await mo.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=_l==="win32"?ut.normalize(r).toLowerCase():r;return Al(t,`${n}
162
166
  ${i.dev}
163
167
  ${i.ino}
164
- ${i.birthtimeMs}`)}async function Nh(t,e){let r=await ho.realpath(e),i=await ho.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=Pl==="win32"?ut.normalize(r).toLowerCase():r;return _l(t,n)}function hE(t){if(typeof t!="string")throw new Error("Native workspace capturedAt is invalid");let e=new Date(t);if(!Number.isFinite(e.getTime())||e.toISOString()!==t)throw new Error("Native workspace capturedAt is invalid");return t}function Rl(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||Sh(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function xh(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Rl(t.changeBranch,"Native workspace change branch"),Rl(t.targetBranch,"Native workspace target branch"),(t.isolation==="branch"||t.isolation==="worktree")&&(t.changeBranch===null||t.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function mE(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(e).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!wh.test(e.baseCommit)||typeof e.targetCommit!="string"||!wh.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");Rl(e.targetBranch,"Native workspace Git target branch")}function mo(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(e).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(e.schema!=="comet.native.workspace.v2"&&e.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(e.capturedRevision)||e.capturedRevision<1||typeof e.nativeRootRef!="string"||!dn.test(String(e.projectRootId))||!dn.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");hE(e.capturedAt),Eh(e.nativeRootRef,"Native workspace root ref");let n=e.projectRootPathId!==void 0,a=e.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!dn.test(String(e.projectRootPathId))||a&&!dn.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!dn.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&mE(e.git),e.schema==="comet.native.workspace.v2"){if(e.isolation!==void 0||e.changeBranch!==void 0||e.targetBranch!==void 0||e.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof e.isolation!="string"||e.changeBranch===void 0||e.targetBranch===void 0||e.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(xh(e),e.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(e.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function vE(t,e){return ut.join(Z(t,e),"workspace.json")}function gE(t,e){let r=vE(t,e),i=Ae(t,r),n=kh(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:Eh(n,"Native workspace file ref")}}async function wE(t,e){try{let r=gE(t,e),i=await L({root:r.root,ref:r.ref,maxBytes:fE});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Al(t,e){let r=G(t.projectRoot),i={projectRoot:ut.resolve(t.projectRoot),currentBranch:r.currentBranch,isSecondaryWorktree:r.isSecondaryWorktree};try{let n=await pn(t,e);if(n===null)return{...i,bindingState:"missing",isolation:null,changeBranch:null,targetBranch:null,finish:null};if(n.schema!=="comet.native.workspace.v3")return{...i,bindingState:"legacy",isolation:null,changeBranch:null,targetBranch:n.git?.targetBranch??null,finish:null};let a=await vo({paths:t,identity:n});return{...i,bindingState:a.state==="aligned"?"aligned":"drifted",isolation:n.isolation,changeBranch:n.changeBranch,targetBranch:n.targetBranch,finish:n.finish}}catch{return{...i,bindingState:"invalid",isolation:null,changeBranch:null,targetBranch:null,finish:null}}}async function yE(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=kh(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let r=G(t.paths.projectRoot),i=r.isGitWorktree?it(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??r.currentBranch,a=n==null?null:it(t.paths.projectRoot,n),o=i!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:i,targetBranch:n,targetCommit:a}:void 0,[s,c,l,d]=await Promise.all([yh("comet.native.workspace-project-root.v2",t.paths.projectRoot),yh("comet.native.workspace-native-root.v2",t.paths.nativeRoot),Nh("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),Nh("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),u=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&xh(t.binding);let p={capturedAt:u,capturedRevision:t.revision,nativeRootRef:e,projectRootId:s,nativeRootId:c,projectRootPathId:l,nativeRootPathId:d,...o?{git:o}:{},...t.sessionId?{sessionHash:_l("comet.native.workspace-session.v2",`${s}
168
+ ${i.birthtimeMs}`)}async function Sh(t,e){let r=await mo.realpath(e),i=await mo.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=_l==="win32"?ut.normalize(r).toLowerCase():r;return Al(t,n)}function NE(t){if(typeof t!="string")throw new Error("Native workspace capturedAt is invalid");let e=new Date(t);if(!Number.isFinite(e.getTime())||e.toISOString()!==t)throw new Error("Native workspace capturedAt is invalid");return t}function Pl(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||Ch(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function Ph(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Pl(t.changeBranch,"Native workspace change branch"),Pl(t.targetBranch,"Native workspace target branch"),(t.isolation==="branch"||t.isolation==="worktree")&&(t.changeBranch===null||t.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function bE(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(e).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!bh.test(e.baseCommit)||typeof e.targetCommit!="string"||!bh.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");Pl(e.targetBranch,"Native workspace Git target branch")}function vo(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(e).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(e.schema!=="comet.native.workspace.v2"&&e.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(e.capturedRevision)||e.capturedRevision<1||typeof e.nativeRootRef!="string"||!pn.test(String(e.projectRootId))||!pn.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");NE(e.capturedAt),Rh(e.nativeRootRef,"Native workspace root ref");let n=e.projectRootPathId!==void 0,a=e.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!pn.test(String(e.projectRootPathId))||a&&!pn.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!pn.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&bE(e.git),e.schema==="comet.native.workspace.v2"){if(e.isolation!==void 0||e.changeBranch!==void 0||e.targetBranch!==void 0||e.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof e.isolation!="string"||e.changeBranch===void 0||e.targetBranch===void 0||e.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(Ph(e),e.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(e.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function kE(t,e){return ut.join(Z(t,e),"workspace.json")}function SE(t,e){let r=kE(t,e),i=Ae(t,r),n=xh(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:Rh(n,"Native workspace file ref")}}async function EE(t,e){try{let r=SE(t,e),i=await L({root:r.root,ref:r.ref,maxBytes:yE});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Il(t,e){let r=G(t.projectRoot),i={projectRoot:ut.resolve(t.projectRoot),currentBranch:r.currentBranch,isSecondaryWorktree:r.isSecondaryWorktree};try{let n=await fn(t,e);if(n===null)return{...i,bindingState:"missing",isolation:null,changeBranch:null,targetBranch:null,finish:null};if(n.schema!=="comet.native.workspace.v3")return{...i,bindingState:"legacy",isolation:null,changeBranch:null,targetBranch:n.git?.targetBranch??null,finish:null};let a=await go({paths:t,identity:n});return{...i,bindingState:a.state==="aligned"?"aligned":"drifted",isolation:n.isolation,changeBranch:n.changeBranch,targetBranch:n.targetBranch,finish:n.finish}}catch{return{...i,bindingState:"invalid",isolation:null,changeBranch:null,targetBranch:null,finish:null}}}async function xE(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=xh(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let r=G(t.paths.projectRoot),i=r.isGitWorktree?it(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??r.currentBranch,a=n==null?null:it(t.paths.projectRoot,n),o=i!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:i,targetBranch:n,targetCommit:a}:void 0,[s,c,l,d]=await Promise.all([kh("comet.native.workspace-project-root.v2",t.paths.projectRoot),kh("comet.native.workspace-native-root.v2",t.paths.nativeRoot),Sh("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),Sh("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),u=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&Ph(t.binding);let p={capturedAt:u,capturedRevision:t.revision,nativeRootRef:e,projectRootId:s,nativeRootId:c,projectRootPathId:l,nativeRootPathId:d,...o?{git:o}:{},...t.sessionId?{sessionHash:Al("comet.native.workspace-session.v2",`${s}
165
169
  ${c}
166
- ${t.sessionId}`)}:{}},f=t.binding?{schema:"comet.native.workspace.v3",...p,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...p};return mo(f),f}async function pn(t,e){let r=await wE(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(mo(r),r)}async function Il(t){mo(t.identity);let e=await yE({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),r=[],i=[];return e.nativeRootRef!==t.identity.nativeRootRef&&r.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&r.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&r.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&r.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&r.push("native-root-legacy-identity")),Pl==="win32"&&r.length>0&&r.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?i.push("workspace-inspection-unavailable"):r.length>0&&i.push("workspace-root-changed"),{state:i.length===0?"aligned":i.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:i,driftComponents:r}}async function vo(t){if(mo(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await Il(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=G(t.paths.projectRoot);return t.identity.changeBranch===null?r.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:r.isGitWorktree?r.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${r.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!r.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}Yi();Za();Za();var go=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},fn=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},wo=class extends Error{constructor(r,i,n,a,o,s=null,c=null){super(`Native change ${r} baseline is incomplete (${i} omitted entr${i===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=r;this.omittedCount=i;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},l0=Ha("en");function oe(t,e){nr(e);let r=Wr.join(t.changesDir,e);if(!J(t.changesDir,r))throw new Error("Native change path escaped");return r}async function jl(t,e){let r=Z(t,e),i=Wr.join(r,"schema-migration.json");await M(J(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await kE.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function SE(t,e=Wr.dirname(t)){let r=Wr.relative(e,t).split(Wr.sep).join("/"),i=await L({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,Tl.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${t}: ${n.errors[0].message}`);return n.toJS()}async function $l(t,e){let r=Wr.join(oe(t,e),lt);await M(t.nativeRoot,r);let i=ol(await SE(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await jl(t,e)?{status:"migration-required",schema:i.schema,minimumRuntimeVersion:i.minimumRuntimeVersion,state:i.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(i.status==="current"&&i.state&&await EE(t,i.state),i)}async function EE(t,e){if(await xl(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}ue();var Wh=et(Me(),1);import{promises as nx}from"node:fs";import De from"node:path";Se();ue();F();ve();I();Te();bo();bo();cr();Lt();Se();Qa();H();F();Ro();K();I();Lh();cr();Lt();Po();Se();ve();Po();Ki();I();var _o=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};function Ml(t){if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t))throw new Error(`Invalid Native Supervisor parent name: ${t}`);return`comet/supervisor/${t}/integration`}import tx from"node:path";Se();ve();K();cr();Lt();async function Ao(t){let e=Ml(t.parent),r=it(t.paths.projectRoot,e);if(!r)return null;let i=it(t.paths.projectRoot,t.targetBranch);if(!i)return null;let n=Rt(t.paths.projectRoot).map(o=>tx.resolve(o)).find(o=>G(o).currentBranch===e);if(!n)return null;let a=Eo({parent:t.parent,targetBranch:t.targetBranch,targetCommit:i,integrationBranch:e,integrationWorktree:n,contract:t.contract});if(r!==i){for(let o of a.children)o.status=o.dependsOn.length===0?"blocked":"pending",o.blocker=o.status==="blocked"?"Supervisor Runtime was lost; portable Child verification evidence is required.":null;a.integration.headCommit=r}return Bl(a,{kind:"delivery-reconciled",child:null,runId:null,summary:"Supervisor state rebuilt from Git worktree facts"}),a}function Vl(t,e){let r=De.normalize(De.resolve(t)),i=De.normalize(De.resolve(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function ax(t){let e=/^#\s+(?:Decisions|决策)\s*$/imu.exec(t);if(!e||e.index===void 0)return null;let r=t.slice(e.index+e[0].length);return r.split(/^#\s+/mu,1)[0]??r}function ox(t){let e=ax(t);if(!e||!/Supervisor\s+Change/iu.test(e))return!1;let r=e.match(/^\s*[-*]\s+(?:Child\b|子任务\b|子 Change\b)/gimu),i=e.match(/\bChild\s+\d+\b/giu);return Math.max(r?.length??0,i?.length??0)>=2}async function Wl(t){try{let e=await L({root:t,ref:"brief.md",maxBytes:null,includeHash:!1});return ox(e.text)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function zl(t){return O("comet.native.parent-contract.v1",{acceptance:t.acceptance.map(({id:e,source:r,text:i})=>({id:e,source:r,text:i})),children:t.children})}async function sx(t){let e=Rt(t.projectRoot);e.some(i=>Vl(i,t.projectRoot))||e.push(t.projectRoot);let r=[];for(let i of[...new Set(e.map(n=>De.resolve(n)))]){let n=await pe(i);n&&r.push({projectRoot:i,paths:await Je(i,n.native.artifact_root),parent:Vl(i,t.projectRoot)})}return r.some(({parent:i})=>i)||r.push({projectRoot:t.projectRoot,paths:t,parent:!0}),r}async function cx(t,e){let r=De.join(t.paths.changesDir,e,"comet-state.yaml");try{return await $t(r)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function lx(t,e){let r;try{r=await nx.readdir(t.paths.archiveDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()||![...e].some(o=>n.name.endsWith(`-${o}`))))try{let o=De.join(t.paths.archiveDir,n.name,"comet-state.yaml"),s=await $t(o);e.has(s.name)&&i.push({file:o,state:s})}catch{}return i}function ux(t,e,r){let i=De.relative(t.projectRoot,e);if(!i||i===".."||i.startsWith(`..${De.sep}`))return null;let n=i.split(De.sep).join("/");try{let a=(0,Wh.parseDocument)(me(t.projectRoot,["show",`${r}:${n}`]),{uniqueKeys:!0});return a.errors.length>0?null:fe(a.toJS({mapAsMap:!1}))}catch{return null}}function dx(t,e,r){return t.workspace.isolation!=="worktree"||t.workspace.target_branch!==r||t.workspace.finish!==null&&t.workspace.finish!=="merge"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:`Native child ${t.name} must use a linked worktree targeting parent branch ${r??"(missing)"}`}:t.status==="blocked"||t.status==="await-user"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:t.blockers[0]?.reason.text??`Native child ${t.name} requires user resolution`}:{kind:"active",phase:t.phase,projectRoot:e.projectRoot,message:null}}function Vh(t,e){return t.status==="done"&&t.archived&&t.workspace.finish==="merge"&&t.workspace.target_branch===e}async function Gr(t){let e=De.join(t.paths.changesDir,t.state.name),r=await Wl(e),i=null,n;try{n=await dt({changeDir:e,validation:Dt(t.state),...t.state.acceptance.length>0?{acceptanceIds:t.state.acceptance.map(({id:v})=>v)}:{},policy:"advisory"})}catch(v){i=`Children contract cannot be read; restore children.yaml and confirm Shape: ${v.message}`,n=null}if(!n){let v=await He(t.paths,t.state.name,{diagnostics:!0});if(v){let N=xo(v);return{...N,...r?{coordinationChoiceRequired:!0}:{},confirmed:!1,readyChildren:[],allDone:!1,children:N.children.map(b=>({...b,message:i??"Children contract is missing; restore children.yaml and confirm Shape before continuing"}))}}if(i)throw new Error(i);return t.state.children_contract_hash?{...r?{coordinationChoiceRequired:!0}:{},contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:r?{coordinationChoiceRequired:!0,contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:null}let a=zl({acceptance:t.state.acceptance,children:n.contract}),o=t.state.workspace.change_branch,s=t.state.phase!=="shape"&&t.state.children_contract_hash===a&&!n.drift;if(n.contract.schema===Ht){let v=await He(t.paths,t.state.name,{diagnostics:!0});if(!v){let y=t.state.workspace.change_branch??t.state.workspace.target_branch;if(y){let E=await Ao({paths:t.paths,parent:t.state.name,targetBranch:y,contract:n.contract});E&&(v=E,await Bt(t.paths,E))}}if(v){let y=xo(v);return t.state.children_contract_hash!==a||n.drift?{...y,schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:!1,readyChildren:[],allDone:!1,children:y.children.map(E=>({...E,message:n.drift?"Children acceptance index is stale; Shape confirmation is required":"Supervisor child plan changed; Shape confirmation is required"}))}:{...y,schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s&&y.confirmed}}let N=new Map(n.contract.children.map(y=>[y.name,y])),b=n.contract.children.map(y=>({name:y.name,summary:y.summary,dependsOn:[...y.depends_on],covers:[],status:s&&y.depends_on.every(E=>n.contract.children.filter(({name:w})=>w!==y.name).every(({name:w})=>w!==E))?"ready":"pending",phase:null,projectRoot:null,message:s?null:"Parent Shape confirmation is required"}));for(let y of b){if(y.status!=="ready")continue;N.get(y.name).depends_on.length>0&&(y.status="pending")}return{schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s,parentBranch:o,children:b,readyChildren:b.filter(({status:y})=>y==="ready").map(({name:y})=>y),allDone:!1}}let c=await sx(t.paths),l=new Set(n.contract.children.map(({name:v})=>v)),d=new Map,u=new Map;for(let v of c){let N=v.parent&&o?`refs/heads/${o}`:"HEAD";for(let b of await lx(v,l)){let y={...b,source:v,committedState:ux(v,b.file,N)};d.set(b.state.name,[...d.get(b.state.name)??[],y])}for(let b of l){let y=await cx(v,b);y&&u.set(b,[...u.get(b)??[],{source:v,state:y}])}}let p=new Map;for(let v of n.contract.children){let N=(d.get(v.name)??[]).find(({source:E,committedState:w})=>E.parent&&w?.name===v.name&&Vh(w,o));if(N){p.set(v.name,{kind:"done",phase:N.state.phase,projectRoot:N.source.projectRoot,message:null});continue}let b=d.get(v.name)?.[0];if(b){p.set(v.name,{kind:"blocked",phase:b.state.phase,projectRoot:b.source.projectRoot,message:`Native child ${v.name} is archived but not merged into parent branch ${o??"(missing)"}`});continue}let y=u.get(v.name)??[];y.length>1?p.set(v.name,{kind:"blocked",phase:null,projectRoot:null,message:`Native child ${v.name} has multiple active workspace owners`}):y[0]&&p.set(v.name,dx(y[0].state,y[0].source,o))}let f=new Map(n.contract.children.map(v=>[v.name,v])),m=new Map,h=v=>{let N=m.get(v);if(N)return N;let b=f.get(v),E=b.depends_on.map(h).every(({status:xe})=>xe==="done"),w=p.get(v),_=w?.kind==="active"&&E?b.depends_on.filter(xe=>!(d.get(xe)??[]).some(({source:q,committedState:ri})=>Vl(q.projectRoot,w.projectRoot)&&ri?.name===xe&&Vh(ri,o))):[],S,T=w?.message??null;w?.kind==="done"?(S=E?"done":"blocked",E||(T=`Native child ${v} was merged before its dependencies`)):w?.kind==="active"?(S=E&&_.length===0?"active":"blocked",E?_.length>0&&(T=`Native child ${v} does not include merged dependencies: ${_.join(", ")}`):T=`Native child ${v} started before its dependencies merged`):w?.kind==="blocked"?S="blocked":(S=s&&E?"ready":"pending",s||(T="Parent Shape confirmation is required"));let Q={name:v,summary:b.summary,dependsOn:[...b.depends_on],covers:[...b.covers],status:S,phase:w?.phase??null,projectRoot:w?.projectRoot??null,message:T};return m.set(v,Q),Q},g=n.contract.children.map(({name:v})=>h(v));return{schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s,parentBranch:o,children:g,readyChildren:g.filter(({status:v})=>v==="ready").map(({name:v})=>v),allDone:g.every(({status:v})=>v==="done")}}import{promises as Xh}from"fs";import Qh from"path";Zt();ue();Oe();I();var px=["outcome","scope","nonGoals","acceptanceExamples"],HH=[...px,"constraints","decisions","openQuestions","verificationExpectations"];var gn=class extends Error{constructor(r,i,n){super(r);this.findings=i;this.change=n;this.name="NativeDocumentConstraintError"}findings;change};ue();H();Oe();I();Ne();Li();Ft();K();H();Oe();Ki();K();I();Ne();Ft();F();F();Io();ur();Oe();var Jh={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:[]},gx=he("comet-native-runtime:v3:scope-reopen"),gD=[{skillVersion:"3",skillHash:he("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:he("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:he("comet-native-runtime:v1")}];Oe();Oe();Yi();var Kh=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],YD=new Set(Kh),kx=new Set([...Kh,"minimum_runtime_version","revision"]),XD=new Set([...kx,"operation"]),Sx=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),QD=new Set([...Sx,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Oe();K();Ne();Ft();I();ue();rn();F();var mB={maxAcceptanceCriteria:Zf.maxCriteria};var Ul={maxSpecs:64};var Zh=Ul.maxSpecs*4;async function Cx(t,e){let r=Qh.join(oe(t,e),"specs"),i;try{i=await un({root:t.nativeRoot,directory:r,label:"Native proposed specs directory"})}catch(s){if(s.code==="ENOENT")return[];throw s}let n=[],a=0,o=await Xh.opendir(r);try{for await(let s of o){if(a+=1,a>Zh)throw new Error(`Native proposed specs directory exceeds ${Zh} entries`);if(s.isSymbolicLink())throw new Error(`Proposed spec capability must not be a symbolic link: ${s.name}`);if(!s.isDirectory())continue;nr(s.name);let c=Qh.join(r,s.name,"spec.md");await M(t.nativeRoot,c);let l;try{l=await Xh.lstat(c)}catch(d){if(d.code==="ENOENT")continue;throw d}if(l.isSymbolicLink()||!l.isFile())throw new Error(`Proposed spec must be a regular file: ${s.name}`);if(n.push(s.name),n.length>Ul.maxSpecs)throw new Error("Native proposed specs exceed the spec-count budget")}}finally{await o.close().catch(s=>{if(s.code!=="ERR_DIR_CLOSED")throw s})}return await i.verify(),n.sort()}async function tm(t,e){let r=oe(t,e),i={};for(let n of await Cx(t,e)){let a=await L({root:r,ref:`specs/${n}/spec.md`,maxBytes:null});i[n]=a.text}return i}an();cr();function Y(t,e,r){return t.language==="zh-CN"?r:e}function Rx(t,e,r,i){let n=a=>({required:!1,message:null,suggestedReply:null,agentInstruction:a});if(t.phase==="shape"&&t.status==="await-user"&&t.loop.next_action==="confirm-shape")return e?{required:!0,message:Y(t,"Shape is ready. Confirm the complete plan and choose A) Multi-session coordination (recommended), or B) Single-session progression in one reply.","Shape 已整理完成。请确认完整方案,并在同一次回复中选择 A)多会话协作(推荐),或 B)单会话推进。"),suggestedReply:Y(t,"Confirm the plan and use A","确认方案,按 A 开始"),agentInstruction:Y(t,"First present the target, scope, key decisions, acceptance criteria, non-goals, child responsibilities and dependencies, and both coordination choices. Execute the matching confirm-shape alternative only when the user explicitly accepts this complete Shape and chooses its mode. Choosing a mode alone, additions, or corrections are not full confirmation; retain that choice and ask only for the missing decision. Do not run --confirmed before full confirmation.","先展示目标、范围、关键决定、验收标准、非目标、各 Child 的职责与依赖,以及两种推进方式。只有用户明确同意当前完整 Shape 并选择推进方式后,才执行对应的 confirm-shape 选项。仅选择推进方式、补充或修改要求都不算完整确认;保留已选方式,只补问缺少的决定。完整确认前不要运行 --confirmed。")}:t.language==="zh-CN"?{required:!0,message:"Shape 已整理完成。请确认目标、范围、关键决定、验收标准和非目标是否准确;明确确认后才会进入 Build。",suggestedReply:"确认进入 Build",agentInstruction:"先用自然语言简要展示目标、范围、关键决定、验收标准和非目标,再转述 message 并等待用户明确确认。只有用户明确同意当前完整 Shape 时,才执行 commandAlternatives 中的 confirm-shape;补充或修改要求不算确认。不要展示机器状态或提前运行 --confirmed。"}:{required:!0,message:"Shape is ready. Confirm that the target, scope, key decisions, acceptance criteria, and non-goals are accurate; Build starts only after explicit confirmation.",suggestedReply:"Confirm and enter Build",agentInstruction:"First present a concise natural-language summary of the target, scope, key decisions, acceptance criteria, and non-goals. Then relay message and wait for explicit user confirmation. Run confirm-shape from commandAlternatives only when the user explicitly accepts the complete current Shape; additions or corrections are not confirmation. Do not expose machine state or run --confirmed early."};if(e&&t.phase==="shape"&&t.status==="active")return n(Y(t,"Complete the Shape documents and child plan, resolve blocking questions, then execute prepare-shape-confirmation. Its persisted response combines complete Shape confirmation and coordination choice in one user decision. If the user already chose only a mode, include that --coordination-mode when preparing and ask only for complete Shape confirmation afterward.","完成 Shape 文档和 Child 计划,解决阻塞问题后执行 prepare-shape-confirmation。持久化后的响应会让用户一次确认完整 Shape 并选择推进方式。如果用户已经仅选择了推进方式,准备时附上对应的 --coordination-mode,随后只确认完整 Shape。"));if(t.phase==="verify"&&t.status==="active"&&t.loop.stage==="verify-ready"&&t.loop.next_action!=="await-verifier-result")return n(Y(t,"The current candidate and completed checks are preserved. Continue with dispatch-verifier without asking the user to recover files, processes, or workflow state. If a brief status update is necessary, say only that verification is being retried and the code is unchanged.","当前候选和已经完成的检查都已保留。直接继续 dispatch-verifier,不要让用户恢复文件、进程或工作流状态。如果确实需要简短同步进度,只说明正在重新尝试验收且代码没有变化。"));if(t.phase==="verify"&&t.status==="active"&&t.loop.next_action==="await-verifier-result"){let a=i==="confirmed"?Y(t,"The Verifier has confirmed startup. Continue waiting on the same host task and use its actual progress.","Verifier 已确认启动。继续等待同一个宿主任务,并使用该任务的实际进度。"):Y(t,"Check whether the host accepted the startup call and locate the task for the current verifierExecutionRef. If the call has not been made, start the dispatched task once; if the host accepted it, check that same task and let the Verifier submit its startup receipt. A missing receipt alone does not prove failure. If local startup state is unavailable, recover the host task context before deciding whether startup is needed.","先核实宿主是否接受了启动调用,并找到当前 verifierExecutionRef 对应的任务。尚未调用时启动已派发的任务一次;宿主已接受时检查同一个任务,由 Verifier 提交启动回执。仅缺少回执不能证明执行失败。本地启动记录不可用时,先恢复宿主任务上下文,再判断是否需要启动。");return n(`${a} ${Y(t,"Keep the same dispatched Verifier while it is active. A wait-tool timeout is not an execution timeout: check task progress and continue waiting; do not cancel, interrupt, or spawn a replacement just because a wait returned without a result. Request progress without telling the Verifier to stop inspecting. Only after confirmed task failure, a host-reported execution timeout, loss, or termination without a usable result, immediately submit verifier-execution-error. Preserve completed evidence and explain the failure and changed recovery approach before retrying. Submit verifier-unavailable only when the current platform truly has no usable subagent capability. Forward the actual report, including risks and incomplete checks; never turn an uninspected candidate into pass. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","已派发的验收任务仍在运行时,继续使用同一个 Verifier。等待工具超时不等于执行超时:检查任务进度并继续等待,不得仅因一次等待没有结果就取消、中断或重新派发。询问进度时不要要求停止核查。仅在确认任务失败、宿主报告执行超时、任务丢失或结束后没有可用结果时,立即提交 verifier-execution-error;保留已完成证据,重试前说明失败原因及恢复方式的变化。只有当前平台确实没有可用的 subagent 能力时才提交 verifier-unavailable。忠实传递原始报告,包括风险和未完成检查;没有核查当前候选不能判定通过。不要让用户恢复文件或进程,也不要向用户展示 attempt、requestCheckRounds 等机器状态。")}`)}if(t.status==="blocked"&&t.blockers.some(({resolution_action:a})=>a==="retry-verifier"))return t.loop.retry_epoch>=3?t.language==="zh-CN"?{required:!0,message:"自动重试验收已连续多轮未能取得结果,验证环境很可能不可用。请人工检查验证环境(subagent 配额、平台任务队列、网络),或使用 doctor --repair 评估该 change 状态。",suggestedReply:"人工检查验证环境",agentInstruction:"只向用户转述 message,等待用户完成人工检查后再继续。不要自动重试验收。"}:{required:!0,message:"Automatic verification retries have failed across multiple rounds; the verification environment is likely unavailable. Inspect the environment manually (subagent quota, platform task queue, network), or use doctor --repair to assess the change state.",suggestedReply:"Inspect the verification environment",agentInstruction:"Relay message to the user and wait for a manual environment check before continuing. Do not retry verification automatically."}:t.language==="zh-CN"?{required:!0,message:"由于独立验收任务连续几次没有正常返回结果,本次验收已暂停。你的代码和已经完成的检查都已安全保留。回复“继续”即可重新尝试,不需要处理文件或进程。",suggestedReply:"继续",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户回复。不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification paused because the independent verification task repeatedly ended without a result. Your code and completed checks are safely preserved. Reply “Continue” to retry; you do not need to manage files or processes.",suggestedReply:"Continue",agentInstruction:"Relay only message and suggestedReply to the user, then wait for that reply. Do not expose internal attempts, counters, paths, or recovery steps."};if(t.phase==="verify"&&t.status==="await-user"&&t.verification?.assurance==="semantic-verification-unavailable")return t.language==="zh-CN"?{required:!0,message:"独立验收当前不可用,但你的代码和已经完成的检查都已安全保留。你可以直接重新尝试独立验收,也可以明确接受只有自动检查的结果。",suggestedReply:"重新尝试独立验收",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户选择。用户要求重试时执行 commandAlternatives 中的 retry-verifier;只有用户明确接受降级结果时才执行 confirm-verifier-unavailable。不要把“继续”视为接受降级结果,也不要要求用户处理文件、进程、服务或回调。"}:{required:!0,message:"Independent verification is currently unavailable, but your code and completed checks are safely preserved. You can retry independent verification directly or explicitly accept the automatic-check-only result.",suggestedReply:"Retry independent verification",agentInstruction:"Relay only message and suggestedReply, then wait for the user choice. If the user asks to retry, run retry-verifier from commandAlternatives; run confirm-verifier-unavailable only when the user explicitly accepts the degraded result. Do not treat “Continue” as accepting the degraded result, and do not ask the user to manage files, processes, services, or callbacks."};if(t.phase==="verify"&&t.status==="await-user"&&t.loop.next_action==="resolve-verifier-blocker")return t.language==="zh-CN"?{required:!0,message:"验证暂时无法下结论,因为缺少只有你能提供的信息,例如外部系统的真实行为或某个业务决定。你的代码和已经完成的检查都已安全保留。补充所需信息后可继续验证,也可以选择修改实现或调整需求。",suggestedReply:null,agentInstruction:"向用户转述 message,请用户补充缺失的信息,或在继续验证(resolve-verifier-blocker)、修改实现、调整需求之间明确选择,再执行 commandAlternatives 中对应的完整命令。不要把“继续”当作默认选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification cannot reach a verdict yet because information only you can provide is missing, such as the real behavior of an external system or a business decision. Your code and completed checks are safely preserved. Supply the missing information to resume verification, or choose to revise the implementation or the requirements.",suggestedReply:null,agentInstruction:"Relay message and ask the user to supply the missing information or explicitly choose between resuming verification (resolve-verifier-blocker), revising the implementation, and revising the requirements; run the matching commandAlternative afterwards. Do not treat “Continue” as a default choice, and do not expose internal rounds, counters, paths, or recovery steps."};if(t.phase==="verify"&&t.status==="await-user"&&t.loop.next_action==="await-user"){let o=(t.loop.stop_reason??(t.loop.no_progress_count>=3?"stalled":"budget"))==="stalled",s=o?"验证已连续三轮失败且未通过的验收场景一直没有减少,本次修改已暂停,以避免在同一个问题上反复循环。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。":"本次修改的验证失败次数已用完配置的预算,因此暂停等待你的决定,而不是自动重试。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。注意:预算不会重置,选择继续修复后,下一次验收失败会再次暂停。",c=o?"Verification has failed three times in a row without the unresolved scenarios shrinking, so this change is paused to avoid looping on the same problem. Your code and completed checks are safely preserved. You can have the Builder try a different repair approach, or go back and adjust the requirements.":"Verification for this change has used its configured failure budget, so it is paused for your decision instead of retrying automatically. Your code and completed checks are safely preserved. You can have the Builder continue with a different repair approach, or go back and adjust the requirements.";return t.language==="zh-CN"?{required:!0,message:s,suggestedReply:"继续修复",agentInstruction:"向用户转述 message 和 suggestedReply,等待用户在“继续修复实现”(revise-implementation)与“调整需求”(revise-requirements)之间明确选择,再执行 commandAlternatives 中对应的完整命令。选择继续修复时,要求 Builder 更换修复思路。不要替用户选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:c,suggestedReply:"Continue repairing",agentInstruction:"Relay message and suggestedReply, then wait for the user to explicitly choose between continuing the implementation (revise-implementation) and adjusting the requirements (revise-requirements); run the matching commandAlternative afterwards. When continuing, ask the Builder to change its repair approach. Do not choose for the user, and do not expose internal rounds, counters, paths, or recovery steps."}}if(t.phase==="verify"&&t.status==="await-user"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass")return{required:!0,message:Y(t,"The reported verification passed, but this platform cannot confirm an independent Verifier execution. Review the result and choose whether to accept it for Archive, revise the implementation, or revise the requirements."+(t.workspace.isolation!=="current"&&t.workspace.finish===null?" If accepting, also choose: keep the workspace, merge locally, push the branch, or push and create a PR. You may accept the result and defer the finish choice.":""),"当前验收报告已通过,但当前平台无法确认验收是否独立执行。请检查结果,并选择接受结果进入归档、继续修改实现,或调整需求。"+(t.workspace.isolation!=="current"&&t.workspace.finish===null?" 接受时可一起选择:保留工作区、本地合并、推送分支,或推送并创建 PR;也可以先接受结果,稍后再选择收尾方式。":"")),suggestedReply:Y(t,"Accept the result","接受结果"),agentInstruction:Y(t,"Summarize the result and verification evidence, relay the message, and wait for an explicit user decision. Only then execute the matching commandAlternative. Do not accept the result on the user’s behalf.","简要说明交付结果和验收证据,转述 message,并等待用户明确选择后再执行对应的 commandAlternative。不要替用户接受结果。")};if(t.phase==="build"&&t.status==="active"){let a=r?.children.some(({status:l})=>l==="blocked")??!1,o=r?.children.some(({status:l})=>l==="needs-reverify")??!1,s=r?.children.some(({status:l})=>l==="ready"||l==="active")??!1,c=r?.children.some(({status:l,builderFailureCount:d})=>l==="blocked"&&(d??0)>=So)??!1;return a&&!o&&!s&&!c?t.language==="zh-CN"?{required:!0,message:"Supervisor 子任务暂时无法启动,已暂停自动重试以避免流程循环。请先根据子任务 blocker 修复工作区、分支或依赖;修复完成后重新运行最新的 next 继续流程。代码和已有证据已保留。",suggestedReply:"修复 blocker 后继续",agentInstruction:"向用户说明子任务 blocker 和需要先完成的外部修复;不要反复执行 next,也不要创建替代任务。用户确认工作区或依赖已修复后,再重新读取 status 并执行最新 continuation。"}:{required:!0,message:"Supervisor child dispatch is paused because every remaining child is blocked. Automatic retries are stopped to avoid a loop. Resolve the recorded child blocker (workspace, branch, or dependency) first, then read the latest status and continue; code and completed evidence are preserved.",suggestedReply:"Resolve the blocker and continue",agentInstruction:"Explain the child blocker and the required external repair to the user. Do not repeatedly run next or spawn replacement tasks. After the user confirms the workspace or dependency is fixed, read status again and execute the latest continuation."}:n(Y(t,"Implement the complete confirmed brief and Spec scope, then review every acceptance ID with its implementation and evidence before handoff. Fill acceptance_review from this audit; derive remaining work from it. Do not submit a partial candidate just to obtain verification feedback. Run focused checks; a separate pre-review is optional. If review is useful, retain the same Reviewer for focused repair follow-ups. Submit the completed candidate for one complete independent verification and release completed helper tasks.","完成已确认的 brief 和 Spec 全部范围,交接前逐项核对所有验收 ID 的实现和证据,填写 acceptance_review,并由这份自查生成剩余工作。不得提交未完成的候选来试探验收反馈。开发期运行相关检查,额外预审为可选项;确需审查时,保留同一个 Reviewer 复核修复及受影响范围。全部完成后提交一次完整独立验收,及时释放已完成的辅助任务。"))}return n(Y(t,"Follow the continuation action. Unless required is true, continue without asking the user to handle internal workflow state, and do not present machine fields as a user-facing explanation.","按 continuation 执行下一步。除非 required 为 true,否则继续推进,不要让用户处理内部工作流状态,也不要把机器字段作为面向用户的说明。"))}function Px(t){let e=t.workspace.change_branch??"<change-branch>",r=t.workspace.target_branch??"<target-branch>";return t.language==="zh-CN"?{required:!0,message:`当前 change 位于 ${e},目标分支为 ${r}。请选择一次工作区收尾方式:A) 保留工作区;B) 本地合并;C) 推送分支;D) 推送并创建 PR;E) 暂不归档。选择 A-D 后 Runtime 会完成预检,检查通过后按所选方式归档;选择 E 将保留当前 change 等待稍后继续。`,suggestedReply:"回复 A、B、C、D 或 E",agentInstruction:"向用户展示五种收尾方式及实际影响,等待用户选择。选择 A-D 时执行对应 commandAlternatives 的完整命令,Runtime 会在归档前检查状态和证据;选择 E 时停止,不运行 Archive 命令。按用户的明确选择执行 finish。"}:{required:!0,message:`This change is on ${e} and targets ${r}. Choose one workspace finish: A) keep the workspace; B) merge locally; C) push the branch; D) push and create a PR; or E) defer Archive. For A-D, Runtime will run preflight and archive with the selected finish when the checks pass; E keeps the current change for later.`,suggestedReply:"Reply A, B, C, D, or E",agentInstruction:"Show all five finish choices and their actual effects, then wait. For A-D, execute the matching complete commandAlternative; Runtime checks state and evidence before archiving. For E, stop without running an Archive command. Use the finish explicitly selected by the user."}}function _x(t){return[...[{finish:"keep",name:"keep-workspace",description:["保留当前分支和目录;完成归档提交,不合并、不推送、不创建 PR。","Keep the current branch and directory; create the archive commit without merging, pushing, or creating a PR."]},{finish:"merge",name:"merge-locally",description:["完成归档提交,并把 change 分支本地合并到目标分支;不推送、不创建 PR。","Create the archive commit and merge the change branch locally into the target branch without pushing or creating a PR."]},{finish:"push",name:"push-branch",description:["完成归档提交并推送 change 分支;不合并到目标分支、不创建 PR。","Create the archive commit and push the change branch without merging into the target branch or creating a PR."]},{finish:"pull-request",name:"push-pull-request",description:["完成归档提交、推送 change 分支,并以目标分支为基础创建 PR。","Create the archive commit, push the change branch, and create a PR against the target branch."]}].map(({finish:i,name:n,description:a})=>({name:n,stateVersion:t.state_version,expectedAction:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed","--finish",i,"--expected-state-version",String(t.state_version)],requiredInputs:[],inputOptions:[],description:Y(t,a[1],a[0])})),{name:"defer-archive",stateVersion:t.state_version,expectedAction:"archive-preview",commandArgs:null,requiredInputs:[],inputOptions:[],description:Y(t,"Keep the current change and workspace without archiving; stop and resume later.","保留当前 change 和工作区,不执行归档;停止本次流程,稍后再继续。")}]}function am(t){return["comet","native","next",t.change,"--summary","<summary>",t.flag,"--expected-state-version",String(t.stateVersion),"--expected-action",t.action]}function pr(t,e){return{name:t,flag:e,valueKind:"text",required:!0,template:null}}function rm(){return{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}}function Ax(t,e){return{name:t,flag:e,valueKind:"confirmation",required:!0,template:null}}function im(t,e,r){return{name:t,flag:e,valueKind:"choice",required:!0,template:null,choices:[...r]}}function Ix(t){return t?.coordinationChoiceRequired===!0||t?.schema==="comet.native.children.v2"&&t.children.length>=2}function Tx(t){return["comet","native","next",t.change,"--summary","<summary>","--expected-state-version",String(t.stateVersion),"--expected-action","prepare-shape-confirmation"]}function Qe(t){return{name:t.name,stateVersion:t.stateVersion,expectedAction:t.expectedAction,commandArgs:am({change:t.change,stateVersion:t.stateVersion,action:t.expectedAction,flag:t.flag}),requiredInputs:["summary",t.confirmationInput],inputOptions:[pr("summary","--summary"),Ax(t.name,t.flag)]}}function nm(t,e){return e.some(i=>/^verification\.md is (?:missing|stale|invalid)$/u.test(i))?[{name:"repair-verification-report",stateVersion:t.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","doctor",t.name,"--repair"],requiredInputs:[],inputOptions:[],description:Y(t,"Rebuild the Runtime-managed verification report, then rerun the Archive dry-run.","重建由 Runtime 管理的 verification.md,然后重新运行 Archive 预检。")}]:[]}function jx(t){return/^verification\.md is (?:missing|stale|invalid)$/u.test(t)}function $o(t){return[Qe({name:"revise-implementation",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),Qe({name:"revise-requirements",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function $x(t){let e={"request-checks":"Choose when the Verifier needs additional Runtime checks.","final-result":"Choose when the Verifier has a result for every current scope ID.","verifier-execution-error":"Choose when a dispatched Verifier failed, was lost, or ended without a result.","verifier-unavailable":"Choose only when the platform has no usable independent Verifier capability."};return t.flatMap(r=>Array.isArray(r.template)?r.template.map(i=>{let n=i.response?.kind??i.kind;return{...r,name:n,required:!1,exclusiveGroup:"runner-input",description:e[n],template:i}}):[r])}function Jr(t,e,r={}){let i=Ix(e)&&t.coordination_mode===void 0,n=Rx(t,i,e,r.verifierStartup),a={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[],requiresUserDecision:n.required,userCommunication:n},o=s=>({kind:s,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...a,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:o("none")};if(t.status==="await-user")return t.phase==="shape"&&t.loop.next_action==="confirm-shape"?{...a,disposition:"await-user",action:"confirm-shape",commandArgs:null,requiredInputs:["summary","shared-understanding-confirmation",...i?["coordination-choice"]:[]],inputOptions:[pr("summary","--summary")],commandAlternatives:i?eh.map(s=>{let c=Qe({name:`confirm-shape-${s}`,change:t.name,stateVersion:t.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"});return{...c,commandArgs:[...c.commandArgs,"--coordination-mode",s],requiredInputs:[...c.requiredInputs,"coordination-choice"],inputOptions:[...c.inputOptions,im("coordination-mode","--coordination-mode",[s])]}}):[Qe({name:"confirm-shape",change:t.name,stateVersion:t.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"})],runnerAction:o("none")}:t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...a,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[...t.workspace.isolation!=="current"&&t.workspace.finish===null?["keep","merge","push","pull-request"].map(s=>{let c=Qe({name:`accept-result-${s}`,change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"});return{...c,commandArgs:[...c.commandArgs,"--finish",s]}}):[],Qe({name:"accept-result",change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...$o({change:t.name,stateVersion:t.state_version})],runnerAction:o("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...a,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[Qe({name:"retry-verifier",change:t.name,stateVersion:t.state_version,expectedAction:"retry-verifier",flag:"--retry-verifier",confirmationInput:"user-decision"}),Qe({name:"confirm-verifier-unavailable",change:t.name,stateVersion:t.state_version,expectedAction:"confirm-verifier-unavailable",flag:"--confirmed",confirmationInput:"user-decision"})],runnerAction:o("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...a,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[Qe({name:"resolve-verifier-blocker",change:t.name,stateVersion:t.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...$o({change:t.name,stateVersion:t.state_version})],runnerAction:o("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...a,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:$o({change:t.name,stateVersion:t.state_version}),runnerAction:o("none")}:{...a,disposition:"await-user",action:"none",commandArgs:null,commandAlternatives:$o({change:t.name,stateVersion:t.state_version}),userCommunication:{...a.userCommunication,required:!0,message:t.blockers.length>0?t.blockers.map(({reason:s})=>s).join("; "):a.userCommunication.message,suggestedReply:t.blockers.length>0?t.blockers[0]?.resolution_action??null:a.userCommunication.suggestedReply},requiredInputs:["resolve-blocker"],runnerAction:o("none")};if(t.status==="blocked"){let s=t.blockers.some(({resolution_action:c})=>c==="retry-verifier");return{...a,disposition:"blocked",action:s?"retry-verifier":"none",commandArgs:s?am({change:t.name,stateVersion:t.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:s?["summary"]:["repair-runtime"],inputOptions:s?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:o(s?"retry-verifier":"none")}}if(t.phase==="shape")return{...a,disposition:"continue",action:"prepare-shape-confirmation",commandArgs:Tx({change:t.name,stateVersion:t.state_version}),requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.phase==="build"){if(e){if(!e.confirmed)return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.loop.stage==="repairing"&&t.verification_result==="fail")return{...a,disposition:"continue",action:"repair",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["repair-child"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(e.allDone)return{...a,disposition:"continue",action:"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:t.acceptance.map(({id:m})=>m),acceptance_review:t.acceptance.map(({id:m})=>({id:m,status:"not-implemented",evidence:[],note:"<implementation and evidence summary>"})),checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[rm()],known_limits:[]}}],runnerAction:o("builder-handoff")};let s=e.children.find(({status:m})=>m==="verified");if(s){let m=r.supervisorIntegrationRetryIds;return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["supervisor-integration-checks"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-integrate",child:s.name,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}],...m&&m.length>0?{retry_check_ids:[...m]}:{}}}],runnerAction:o("none")}}let c=e.children.some(({status:m})=>m==="blocked"||m==="needs-reverify"),l=e.children.some(({status:m})=>m==="needs-reverify"),d=e.children.some(({status:m})=>m==="ready"||m==="active"),u=e.supervisorStateVersion===void 0?null:e.children.find(m=>m.status==="blocked"&&(m.builderFailureCount??0)>=So)??null,p=u===null?null:{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-retry-builder",child:u.name,stateVersion:e.supervisorStateVersion},description:Y(t,"Explicitly authorize one fresh Builder attempt after the Builder failure budget was exhausted.","Builder 失败预算已耗尽;明确授权后才能重新开始一次 Builder 尝试。")},f=c&&!l&&!d&&p===null;return{...a,disposition:f?"blocked":"continue",action:"advance-children",commandArgs:f?null:p!==null?["comet","native","next",t.name,"--runner-input","<temporary-json-file>"]:["comet","native","next",t.name,"--summary","<summary>",...t.coordination_mode==="single-session"?["--max-parallel","1"]:[]],requiredInputs:f?[]:p!==null?["supervisor-builder-retry-json-file"]:["ready-children"],inputOptions:f?[]:p!==null?[p]:[pr("summary","--summary")],runnerAction:o("none")}}return{...a,disposition:"continue",action:t.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:t.acceptance.map(({id:s})=>s),acceptance_review:t.acceptance.map(({id:s})=>{let c=t.builder_handoff?.acceptance_review?.find(l=>l.id===s);return c?{...c,evidence:[...c.evidence],...t.loop.previous_unresolved_ids.includes(s)?{status:"implemented-no-evidence",evidence:[],note:"<current repair and evidence summary>"}:{}}:{id:s,status:"not-implemented",evidence:[],note:"<implementation and evidence summary>"}}),checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[],known_limits:[]}}],runnerAction:o("builder-handoff")}}if(t.phase==="verify"){let s=t.loop.next_action==="await-verifier-result",c=!!t.children_contract_hash,l=rm();return!s&&r.retryCheckIds&&r.retryCheckIds.length>0?{...a,disposition:"continue",action:"retry-checks",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["retry-checks-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"retry-checks",check_ids:[...r.retryCheckIds]}}],runnerAction:o("retry-checks")}:{...a,userCommunication:!s&&c?{...a.userCommunication,agentInstruction:`${a.userCommunication.agentInstruction} ${Y(t,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:a.userCommunication,disposition:"continue",action:s?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[s?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:$x([{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:s?[{kind:"verifier-response",candidateId:t.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[l]}},{kind:"verifier-response",candidateId:t.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"final-result",result:{iteration:t.loop.iteration,attempt:t.loop.attempt,verdict:"blocked",acceptance:[{id:"<acceptance-id>",result:"blocked",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:r.verificationCheckPlans?r.verificationCheckPlans.map(d=>({...d,argv:[...d.argv]})):c?[l]:[]}}]),runnerAction:o(s?"await-verifier":"dispatch-verifier")}}if(t.phase==="archive"&&t.status==="active"&&t.loop.stage==="archive-ready"&&!t.archived){let s=r.archiveMode??"archive-ready",l=t.workspace.isolation!=="current"&&t.workspace.finish===null;if(s==="blocked")return{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],runnerAction:o("none")};if(s==="preview"){if(r.archiveBlockers&&r.archiveBlockers.length>0){let d=nm(t,r.archiveBlockers)[0];return d&&r.archiveBlockers.every(u=>jx(u))?{...a,disposition:"continue",action:"repair",commandArgs:d.commandArgs,requiredInputs:[],inputOptions:[],runnerAction:o("none")}:{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],commandAlternatives:nm(t,r.archiveBlockers),runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}return l?{...a,disposition:"await-user",action:"archive",commandArgs:null,requiredInputs:["workspace-finish"],inputOptions:[im("finish","--finish",["keep","merge","push","pull-request"])],commandAlternatives:[..._x(t)],userCommunication:Px(t),runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--dry-run"],requiredInputs:[],commandAlternatives:[Qe({name:"revise-requirements",change:t.name,stateVersion:t.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}Se();Qa();F();import ei from"node:path";Se();ot();H();var WB=8*1024*1024;Ro();to();Te();or();hn();ko();import{promises as Hx}from"node:fs";H();an();import om from"node:path";function wn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function yn(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function se(t,e,r=!1){if(typeof t!="string"||!r&&t.length===0)throw new Error(`${e} must be ${r?"a string":"a non-empty string"}`);return t}function Ur(t,e){return t===null?null:se(t,e)}function Kr(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function Dx(t,e){if(t===null)return null;if(!Number.isSafeInteger(t))throw new Error(`${e} must be null or a safe integer`);return t}function Bx(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function Yr(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Yl(t,e){if(t===null)return null;let r=se(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function Lx(t,e){let r=se(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function Xl(t,e){let r=se(t,e);if(!om.isAbsolute(r))throw new Error(`${e} must be absolute`);return om.resolve(r)}function Fx(t,e){let r=`Native local checks[${e}]`,i=wn(t,r);if(yn(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log","activeProcess","evidence","evidenceDigest"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((d,u)=>se(d,`${r}.argv[${u}]`,!0)),a=Yr(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=Yl(i.startedAt,`${r}.startedAt`),s=Yl(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let c=Kr(i.timeoutMs,`${r}.timeoutMs`);if(c<1)throw new Error(`${r}.timeoutMs must be positive`);let l;if(Object.hasOwn(i,"activeProcess"))if(i.activeProcess===null)l=null;else{let d=wn(i.activeProcess,`${r}.activeProcess`),u=Yr(d.status,["starting","running"],`${r}.activeProcess.status`);if(yn(d,new Set(["status","pid","identity"]),`${r}.activeProcess`),u==="starting"){if(Object.hasOwn(d,"pid")||Object.hasOwn(d,"identity"))throw new Error(`${r}.activeProcess starting state cannot contain process identity`);l={status:"starting"}}else l={status:"running",pid:Kr(d.pid,`${r}.activeProcess.pid`,1),...Object.hasOwn(d,"identity")?{identity:se(d.identity,`${r}.activeProcess.identity`)}:{}}}return{id:se(i.id,`${r}.id`),name:se(i.name,`${r}.name`),operationId:se(i.operationId,`${r}.operationId`),status:a,repeatable:Bx(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:Kr(i.executionCount,`${r}.executionCount`),argv:n,cwd:Xl(i.cwd,`${r}.cwd`),exitCode:Dx(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:se(i.log,`${r}.log`),...Object.hasOwn(i,"activeProcess")?{activeProcess:l}:{},...Object.hasOwn(i,"evidence")?{evidence:Yr(i.evidence,["runtime"],`${r}.evidence`)}:{},...Object.hasOwn(i,"evidenceDigest")?{evidenceDigest:se(i.evidenceDigest,`${r}.evidenceDigest`)}:{}}}function qx(t){let e="Native local execution state",r=wn(t,e);if(yn(r,new Set(["schema","change","basedOnStateVersion","candidateId","inputFingerprint","inputFingerprintGate","candidateInputFingerprintGate","workspace","execution","checks"]),e),r.schema!==ro)throw new Error(`Native local execution schema must be ${ro}`);let i=wn(r.workspace,"Native local workspace");yn(i,new Set(["projectRoot","worktreeRoot","branch","machineId"]),"Native local workspace");let n=null;if(r.execution!==null){let o=wn(r.execution,"Native local execution");yn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds","verifierStartedAt","ownerPid","ownerIdentity"]),"Native local execution");let s=Yl(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:se(o.operationId,"Native local execution.operationId"),stage:Yr(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Yr(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Ur(o.executionId,"Native local execution.executionId"),status:Yr(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Kr(o.requestCheckRounds,"Native local execution.requestCheckRounds"),...Object.hasOwn(o,"verifierStartedAt")?{verifierStartedAt:Lx(o.verifierStartedAt,"Native local execution.verifierStartedAt")}:{},...Object.hasOwn(o,"ownerPid")?{ownerPid:Kr(o.ownerPid,"Native local execution.ownerPid",1)}:{},...Object.hasOwn(o,"ownerIdentity")?{ownerIdentity:se(o.ownerIdentity,"Native local execution.ownerIdentity")}:{}}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(Fx);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:ro,change:se(r.change,"Native local change"),basedOnStateVersion:Kr(r.basedOnStateVersion,"Native local basedOnStateVersion",1),...Object.hasOwn(r,"candidateId")?{candidateId:Ur(r.candidateId,"Native local candidateId")}:{},...Object.hasOwn(r,"inputFingerprint")?{inputFingerprint:Ur(r.inputFingerprint,"Native local inputFingerprint")}:{},...Object.hasOwn(r,"inputFingerprintGate")?{inputFingerprintGate:Ur(r.inputFingerprintGate,"Native local inputFingerprintGate")}:{},...Object.hasOwn(r,"candidateInputFingerprintGate")?{candidateInputFingerprintGate:Ur(r.candidateInputFingerprintGate,"Native local candidateInputFingerprintGate")}:{},workspace:{projectRoot:Xl(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Xl(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Ur(i.branch,"Native local workspace.branch"),...Object.hasOwn(i,"machineId")?{machineId:se(i.machineId,"Native local workspace.machineId")}:{}},execution:n,checks:a}}async function Oo(t){let e;try{e=await Hx.readFile(t,"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}let r;try{r=JSON.parse(e)}catch(i){throw new Error(`Native local execution state is invalid JSON: ${i.message}`,{cause:i})}return qx(r)}function Ql(t,e){let r=e?.execution;if(!(t.phase!=="verify"||t.status!=="active"||t.loop.next_action!=="await-verifier-result"||t.builder_handoff?.candidate_id===void 0||t.builder_handoff?.candidate_id===null||e===null||e.change!==t.name||e.basedOnStateVersion!==t.state_version||e.candidateId!==t.builder_handoff.candidate_id||r==null||r.stage!=="verifying"||r.actor!=="verifier"||r.status!=="running"||r.executionId===null))return r.executionId}K();or();I();import{promises as Mx}from"node:fs";import Zl from"node:path";Se();Te();I();var sm=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,cm="comet-state.yaml",lm="state.json";function ft(t,e){if(!sm.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=Zl.join(t.changesDir,e);if(!J(t.changesDir,r))throw new Error("Native change path escaped");return r}function Ho(t,e){return Zl.join(ft(t,e),cm)}function qt(t,e){return Zl.join(Ue(t,e),lm)}async function Xr(t,e){try{let r=await Mx.readFile(Ho(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}async function Be(t,e){return $t(Ho(t,e))}async function Do(t){let e=await Be(t.paths,t.name),r=qt(t.paths,t.name);try{let i=await Oo(r);return i===null?{state:e,local:null,localStatus:"missing"}:i.change!==e.name||i.basedOnStateVersion!==e.state_version?{state:e,local:null,localStatus:"stale"}:{state:e,local:i,localStatus:"available"}}catch(i){return i.code==="ENOENT"?{state:e,local:null,localStatus:"missing"}:{state:e,local:null,localStatus:"invalid"}}}function iu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mr=iu();function gm(t){mr=t}var fr={exec:()=>null};function Qr(t){let e=[];return r=>{let i=Math.max(0,Math.min(3,r-1)),n=e[i];return n||(n=t(i),e[i]=n),n}}function P(t,e=""){let r=typeof t=="string"?t:t.source,i={replace:(n,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(te.caret,"$1"),r=r.replace(n,o),i},getRegex:()=>new RegExp(r,e)};return i}var Vx=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),te={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Qr(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Qr(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}>`))},Wx=/^(?:[ \t]*(?:\n|$))+/,zx=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Gx=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,kn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Jx=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,nu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,wm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ym=P(wm).replace(/bull/g,nu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ux=P(wm).replace(/bull/g,nu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),au=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Kx=/^[^\n]+/,ou=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Yx=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ou).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Xx=P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,nu).getRegex(),Mo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",su=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Qx=P("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",su).replace("tag",Mo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Nm=t=>P(au).replace("hr",kn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Mo).getRegex(),Zx=Nm(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),eC=Nm(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),tC=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",eC).getRegex(),cu={blockquote:tC,code:zx,def:Yx,fences:Gx,heading:Jx,hr:kn,html:Qx,lheading:ym,list:Xx,newline:Wx,paragraph:Zx,table:fr,text:Kx},um=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",kn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Mo).getRegex(),rC={...cu,lheading:Ux,table:um,paragraph:P(au).replace("hr",kn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",um).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Mo).getRegex()},iC={...cu,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",su).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:fr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(au).replace("hr",kn).replace("heading",` *#{1,6} *[^
167
- ]`).replace("lheading",ym).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},nC=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,aC=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,bm=/^( {2,}|\\)\n(?!\s*$)/,oC=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ht=/[\p{P}\p{S}]/u,Zr=/[\s\p{P}\p{S}]/u,Sn=/[^\s\p{P}\p{S}]/u,sC=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Zr).getRegex(),cC=/[\p{Pi}\p{Ps}"']/u,km=/(?!~)[\p{P}\p{S}]/u,lC=/(?!~)[\s\p{P}\p{S}]/u,uC=/(?:[^\s\p{P}\p{S}]|~)/u,dC=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Vx?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Sm=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,pC=P(Sm,"u").replace(/punct/g,ht).getRegex(),fC=P(Sm,"u").replace(/punct/g,km).getRegex(),hC=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,mC=P(hC,"u").replace(/openQuote/g,cC).replace(/punct/g,ht).getRegex(),Em="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",vC=P(Em,"gu").replace(/notPunctSpace/g,Sn).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),gC=P(Em,"gu").replace(/notPunctSpace/g,uC).replace(/punctSpace/g,lC).replace(/punct/g,km).getRegex(),wC="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",yC=P(wC,"gu").replace(/notPunctSpace/g,Sn).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),NC=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Sn).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),bC="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",kC=P(bC,"gu").replace(/notPunctSpace/g,Sn).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),SC=P(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ht).getRegex(),EC="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",xC=P(EC,"gu").replace(/notPunctSpace/g,Sn).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),CC=P(/\\(punct)/,"gu").replace(/punct/g,ht).getRegex(),RC=P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),PC=P(su).replace("(?:-->|$)","-->").getRegex(),_C=P("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",PC).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Lo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,AC=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Lo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),xm=P(/^!?\[(label)\]\[(ref)\]/).replace("label",Lo).replace("ref",ou).getRegex(),Cm=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",ou).getRegex(),IC=P("reflink|nolink(?!\\()","g").replace("reflink",xm).replace("nolink",Cm).getRegex(),dm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,lu={_backpedal:fr,anyPunctuation:CC,autolink:RC,blockSkip:dC,br:bm,code:aC,del:fr,delLDelim:fr,delRDelim:fr,emStrongLDelim:pC,emStrongRDelimAst:vC,emStrongRDelimUnd:NC,escape:nC,link:AC,nolink:Cm,punctuation:sC,reflink:xm,reflinkSearch:IC,tag:_C,text:oC,url:fr},TC={...lu,emStrongLDelim:mC,emStrongRDelimAst:yC,emStrongRDelimUnd:kC,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",Lo).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Lo).getRegex()},eu={...lu,emStrongRDelimAst:gC,emStrongLDelim:fC,delLDelim:SC,delRDelim:xC,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",dm).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",dm).getRegex()},jC={...eu,br:P(bm).replace("{2,}","*").getRegex(),text:P(eu.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Bo={normal:cu,gfm:rC,pedantic:iC},Nn={normal:lu,gfm:eu,breaks:jC,pedantic:TC},$C={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},pm=t=>$C[t];function Ze(t,e){if(e){if(te.escapeTest.test(t))return t.replace(te.escapeReplace,pm)}else if(te.escapeTestNoEncode.test(t))return t.replace(te.escapeReplaceNoEncode,pm);return t}function fm(t){try{t=encodeURI(t).replace(te.percentDecode,"%")}catch{return null}return t}function hm(t,e){let r=t.replace(te.findPipe,(a,o,s)=>{let c=!1,l=o;for(;--l>=0&&s[l]==="\\";)c=!c;return c?"|":" |"}),i=r.split(te.splitPipe),n=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(te.slashPipe,"|");return i}function Mt(t,e,r){let i=t.length;if(i===0)return"";let n=0;for(;n<i;){let a=t.charAt(i-n-1);if(a===e&&!r)n++;else if(a!==e&&r)n++;else break}return t.slice(0,i-n)}function mm(t){let e=t.split(`
170
+ ${t.sessionId}`)}:{}},f=t.binding?{schema:"comet.native.workspace.v3",...p,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...p};return vo(f),f}async function fn(t,e){let r=await EE(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(vo(r),r)}async function Tl(t){vo(t.identity);let e=await xE({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),r=[],i=[];return e.nativeRootRef!==t.identity.nativeRootRef&&r.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&r.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&r.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&r.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&r.push("native-root-legacy-identity")),_l==="win32"&&r.length>0&&r.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?i.push("workspace-inspection-unavailable"):r.length>0&&i.push("workspace-root-changed"),{state:i.length===0?"aligned":i.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:i,driftComponents:r}}async function go(t){if(vo(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await Tl(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=G(t.paths.projectRoot);return t.identity.changeBranch===null?r.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:r.isGitWorktree?r.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${r.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!r.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}Xi();eo();eo();var wo=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},hn=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},yo=class extends Error{constructor(r,i,n,a,o,s=null,c=null){super(`Native change ${r} baseline is incomplete (${i} omitted entr${i===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=r;this.omittedCount=i;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},m0=Da("en");function oe(t,e){nr(e);let r=Wr.join(t.changesDir,e);if(!J(t.changesDir,r))throw new Error("Native change path escaped");return r}async function $l(t,e){let r=Z(t,e),i=Wr.join(r,"schema-migration.json");await M(J(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await PE.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function _E(t,e=Wr.dirname(t)){let r=Wr.relative(e,t).split(Wr.sep).join("/"),i=await L({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,jl.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${t}: ${n.errors[0].message}`);return n.toJS()}async function Ol(t,e){let r=Wr.join(oe(t,e),lt);await M(t.nativeRoot,r);let i=sl(await _E(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await $l(t,e)?{status:"migration-required",schema:i.schema,minimumRuntimeVersion:i.minimumRuntimeVersion,state:i.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(i.status==="current"&&i.state&&await AE(t,i.state),i)}async function AE(t,e){if(await Cl(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}ue();var Jh=et(Me(),1);import{promises as ux}from"node:fs";import De from"node:path";Se();ue();F();ve();I();Te();ko();ko();cr();Lt();Se();Za();H();F();Po();K();I();Mh();cr();Lt();_o();Se();ve();_o();Yi();I();var Ao=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};function Vl(t){if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t))throw new Error(`Invalid Native Supervisor parent name: ${t}`);return`comet/supervisor/${t}/integration`}import sx from"node:path";Se();ve();K();cr();Lt();async function Io(t){let e=Vl(t.parent),r=it(t.paths.projectRoot,e);if(!r)return null;let i=it(t.paths.projectRoot,t.targetBranch);if(!i)return null;let n=Rt(t.paths.projectRoot).map(o=>sx.resolve(o)).find(o=>G(o).currentBranch===e);if(!n)return null;let a=xo({parent:t.parent,targetBranch:t.targetBranch,targetCommit:i,integrationBranch:e,integrationWorktree:n,contract:t.contract});if(r!==i){for(let o of a.children)o.status=o.dependsOn.length===0?"blocked":"pending",o.blocker=o.status==="blocked"?"Supervisor Runtime was lost; portable Child verification evidence is required.":null;a.integration.headCommit=r}return Ll(a,{kind:"delivery-reconciled",child:null,runId:null,summary:"Supervisor state rebuilt from Git worktree facts"}),a}function Wl(t,e){let r=De.normalize(De.resolve(t)),i=De.normalize(De.resolve(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function dx(t){let e=/^#\s+(?:Decisions|决策)\s*$/imu.exec(t);if(!e||e.index===void 0)return null;let r=t.slice(e.index+e[0].length);return r.split(/^#\s+/mu,1)[0]??r}function px(t){let e=dx(t);if(!e||!/Supervisor\s+Change/iu.test(e))return!1;let r=e.match(/^\s*[-*]\s+(?:Child\b|子任务\b|子 Change\b)/gimu),i=e.match(/\bChild\s+\d+\b/giu);return Math.max(r?.length??0,i?.length??0)>=2}async function zl(t){try{let e=await L({root:t,ref:"brief.md",maxBytes:null,includeHash:!1});return px(e.text)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Gl(t){return O("comet.native.parent-contract.v1",{acceptance:t.acceptance.map(({id:e,source:r,text:i})=>({id:e,source:r,text:i})),children:t.children})}async function fx(t){let e=Rt(t.projectRoot);e.some(i=>Wl(i,t.projectRoot))||e.push(t.projectRoot);let r=[];for(let i of[...new Set(e.map(n=>De.resolve(n)))]){let n=await pe(i);n&&r.push({projectRoot:i,paths:await Je(i,n.native.artifact_root),parent:Wl(i,t.projectRoot)})}return r.some(({parent:i})=>i)||r.push({projectRoot:t.projectRoot,paths:t,parent:!0}),r}async function hx(t,e){let r=De.join(t.paths.changesDir,e,"comet-state.yaml");try{return await $t(r)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function mx(t,e){let r;try{r=await ux.readdir(t.paths.archiveDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()||![...e].some(o=>n.name.endsWith(`-${o}`))))try{let o=De.join(t.paths.archiveDir,n.name,"comet-state.yaml"),s=await $t(o);e.has(s.name)&&i.push({file:o,state:s})}catch{}return i}function vx(t,e,r){let i=De.relative(t.projectRoot,e);if(!i||i===".."||i.startsWith(`..${De.sep}`))return null;let n=i.split(De.sep).join("/");try{let a=(0,Jh.parseDocument)(me(t.projectRoot,["show",`${r}:${n}`]),{uniqueKeys:!0});return a.errors.length>0?null:fe(a.toJS({mapAsMap:!1}))}catch{return null}}function gx(t,e,r){return t.workspace.isolation!=="worktree"||t.workspace.target_branch!==r||t.workspace.finish!==null&&t.workspace.finish!=="merge"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:`Native child ${t.name} must use a linked worktree targeting parent branch ${r??"(missing)"}`}:t.status==="blocked"||t.status==="await-user"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:t.blockers[0]?.reason.text??`Native child ${t.name} requires user resolution`}:{kind:"active",phase:t.phase,projectRoot:e.projectRoot,message:null}}function Gh(t,e){return t.status==="done"&&t.archived&&t.workspace.finish==="merge"&&t.workspace.target_branch===e}async function Gr(t){let e=De.join(t.paths.changesDir,t.state.name),r=await zl(e),i=null,n;try{n=await dt({changeDir:e,validation:Dt(t.state),...t.state.acceptance.length>0?{acceptanceIds:t.state.acceptance.map(({id:v})=>v)}:{},policy:"advisory"})}catch(v){i=`Children contract cannot be read; restore children.yaml and confirm Shape: ${v.message}`,n=null}if(!n){let v=await He(t.paths,t.state.name,{diagnostics:!0});if(v){let N=Co(v);return{...N,...r?{coordinationChoiceRequired:!0}:{},confirmed:!1,readyChildren:[],allDone:!1,children:N.children.map(b=>({...b,message:i??"Children contract is missing; restore children.yaml and confirm Shape before continuing"}))}}if(i)throw new Error(i);return t.state.children_contract_hash?{...r?{coordinationChoiceRequired:!0}:{},contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:r?{coordinationChoiceRequired:!0,contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:null}let a=Gl({acceptance:t.state.acceptance,children:n.contract}),o=t.state.workspace.change_branch,s=t.state.phase!=="shape"&&t.state.children_contract_hash===a&&!n.drift;if(n.contract.schema===Ht){let v=await He(t.paths,t.state.name,{diagnostics:!0});if(!v){let y=t.state.workspace.change_branch??t.state.workspace.target_branch;if(y){let E=await Io({paths:t.paths,parent:t.state.name,targetBranch:y,contract:n.contract});E&&(v=E,await Bt(t.paths,E))}}if(v){let y=Co(v);return t.state.children_contract_hash!==a||n.drift?{...y,schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:!1,readyChildren:[],allDone:!1,children:y.children.map(E=>({...E,message:n.drift?"Children acceptance index is stale; Shape confirmation is required":"Supervisor child plan changed; Shape confirmation is required"}))}:{...y,schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s&&y.confirmed}}let N=new Map(n.contract.children.map(y=>[y.name,y])),b=n.contract.children.map(y=>({name:y.name,summary:y.summary,dependsOn:[...y.depends_on],covers:[],status:s&&y.depends_on.every(E=>n.contract.children.filter(({name:w})=>w!==y.name).every(({name:w})=>w!==E))?"ready":"pending",phase:null,projectRoot:null,message:s?null:"Parent Shape confirmation is required"}));for(let y of b){if(y.status!=="ready")continue;N.get(y.name).depends_on.length>0&&(y.status="pending")}return{schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s,parentBranch:o,children:b,readyChildren:b.filter(({status:y})=>y==="ready").map(({name:y})=>y),allDone:!1}}let c=await fx(t.paths),l=new Set(n.contract.children.map(({name:v})=>v)),d=new Map,u=new Map;for(let v of c){let N=v.parent&&o?`refs/heads/${o}`:"HEAD";for(let b of await mx(v,l)){let y={...b,source:v,committedState:vx(v,b.file,N)};d.set(b.state.name,[...d.get(b.state.name)??[],y])}for(let b of l){let y=await hx(v,b);y&&u.set(b,[...u.get(b)??[],{source:v,state:y}])}}let p=new Map;for(let v of n.contract.children){let N=(d.get(v.name)??[]).find(({source:E,committedState:w})=>E.parent&&w?.name===v.name&&Gh(w,o));if(N){p.set(v.name,{kind:"done",phase:N.state.phase,projectRoot:N.source.projectRoot,message:null});continue}let b=d.get(v.name)?.[0];if(b){p.set(v.name,{kind:"blocked",phase:b.state.phase,projectRoot:b.source.projectRoot,message:`Native child ${v.name} is archived but not merged into parent branch ${o??"(missing)"}`});continue}let y=u.get(v.name)??[];y.length>1?p.set(v.name,{kind:"blocked",phase:null,projectRoot:null,message:`Native child ${v.name} has multiple active workspace owners`}):y[0]&&p.set(v.name,gx(y[0].state,y[0].source,o))}let f=new Map(n.contract.children.map(v=>[v.name,v])),m=new Map,h=v=>{let N=m.get(v);if(N)return N;let b=f.get(v),E=b.depends_on.map(h).every(({status:xe})=>xe==="done"),w=p.get(v),_=w?.kind==="active"&&E?b.depends_on.filter(xe=>!(d.get(xe)??[]).some(({source:q,committedState:ri})=>Wl(q.projectRoot,w.projectRoot)&&ri?.name===xe&&Gh(ri,o))):[],S,T=w?.message??null;w?.kind==="done"?(S=E?"done":"blocked",E||(T=`Native child ${v} was merged before its dependencies`)):w?.kind==="active"?(S=E&&_.length===0?"active":"blocked",E?_.length>0&&(T=`Native child ${v} does not include merged dependencies: ${_.join(", ")}`):T=`Native child ${v} started before its dependencies merged`):w?.kind==="blocked"?S="blocked":(S=s&&E?"ready":"pending",s||(T="Parent Shape confirmation is required"));let Q={name:v,summary:b.summary,dependsOn:[...b.depends_on],covers:[...b.covers],status:S,phase:w?.phase??null,projectRoot:w?.projectRoot??null,message:T};return m.set(v,Q),Q},g=n.contract.children.map(({name:v})=>h(v));return{schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s,parentBranch:o,children:g,readyChildren:g.filter(({status:v})=>v==="ready").map(({name:v})=>v),allDone:g.every(({status:v})=>v==="done")}}import{promises as em}from"fs";import tm from"path";Zt();ue();Oe();I();var wx=["outcome","scope","nonGoals","acceptanceExamples"],zH=[...wx,"constraints","decisions","openQuestions","verificationExpectations"];var wn=class extends Error{constructor(r,i,n){super(r);this.findings=i;this.change=n;this.name="NativeDocumentConstraintError"}findings;change};ue();H();Oe();I();Ne();Li();Ft();K();H();Oe();Yi();K();I();Ne();Ft();F();F();To();ur();Oe();var Yh={root:"/comet/native-runtime",packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-native-runtime",version:"3",description:"Comet-owned state runtime for the Native workflow."},goal:{statement:"Advance a Native change only after its current guard passes.",inputs:[],outputs:[],success:["The Native change and Run state agree on the next phase."]},orchestration:{mode:"deterministic",entry:"shape",steps:[{id:"shape",action:{type:"checkpoint"},next:"build"},{id:"build",action:{type:"checkpoint"},next:"verify"},{id:"verify",action:{type:"checkpoint"},next:"archive"},{id:"archive",action:{type:"checkpoint"}}]},skills:[],agents:[],tools:[]},guardrails:{allowedSkills:[],allowedAgents:[],allowedTools:[],maxIterations:Number.MAX_SAFE_INTEGER,maxRetriesPerAction:2,confirmationRequiredFor:[]},evals:[]},Sx=he("comet-native-runtime:v3:scope-reopen"),CD=[{skillVersion:"3",skillHash:he("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:he("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:he("comet-native-runtime:v1")}];Oe();Oe();Xi();var Qh=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],aB=new Set(Qh),Px=new Set([...Qh,"minimum_runtime_version","revision"]),oB=new Set([...Px,"operation"]),_x=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),sB=new Set([..._x,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Oe();K();Ne();Ft();I();ue();nn();F();var EB={maxAcceptanceCriteria:rh.maxCriteria};var Kl={maxSpecs:64};var rm=Kl.maxSpecs*4;async function Tx(t,e){let r=tm.join(oe(t,e),"specs"),i;try{i=await dn({root:t.nativeRoot,directory:r,label:"Native proposed specs directory"})}catch(s){if(s.code==="ENOENT")return[];throw s}let n=[],a=0,o=await em.opendir(r);try{for await(let s of o){if(a+=1,a>rm)throw new Error(`Native proposed specs directory exceeds ${rm} entries`);if(s.isSymbolicLink())throw new Error(`Proposed spec capability must not be a symbolic link: ${s.name}`);if(!s.isDirectory())continue;nr(s.name);let c=tm.join(r,s.name,"spec.md");await M(t.nativeRoot,c);let l;try{l=await em.lstat(c)}catch(d){if(d.code==="ENOENT")continue;throw d}if(l.isSymbolicLink()||!l.isFile())throw new Error(`Proposed spec must be a regular file: ${s.name}`);if(n.push(s.name),n.length>Kl.maxSpecs)throw new Error("Native proposed specs exceed the spec-count budget")}}finally{await o.close().catch(s=>{if(s.code!=="ERR_DIR_CLOSED")throw s})}return await i.verify(),n.sort()}async function nm(t,e){let r=oe(t,e),i={};for(let n of await Tx(t,e)){let a=await L({root:r,ref:`specs/${n}/spec.md`,maxBytes:null});i[n]=a.text}return i}on();cr();function Y(t,e,r){return t.language==="zh-CN"?r:e}function jx(t,e,r,i){let n=a=>({required:!1,message:null,suggestedReply:null,agentInstruction:a});if(t.phase==="shape"&&t.status==="await-user"&&t.loop.next_action==="confirm-shape")return e?{required:!0,message:Y(t,"Shape is ready. Confirm the complete plan and choose A) Multi-session coordination (recommended), or B) Single-session progression in one reply.","Shape 已整理完成。请确认完整方案,并在同一次回复中选择 A)多会话协作(推荐),或 B)单会话推进。"),suggestedReply:Y(t,"Confirm the plan and use A","确认方案,按 A 开始"),agentInstruction:Y(t,"First present the target, scope, key decisions, acceptance criteria, non-goals, child responsibilities and dependencies, and both coordination choices. Execute the matching confirm-shape alternative only when the user explicitly accepts this complete Shape and chooses its mode. Choosing a mode alone, additions, or corrections are not full confirmation; retain that choice and ask only for the missing decision. Do not run --confirmed before full confirmation.","先展示目标、范围、关键决定、验收标准、非目标、各 Child 的职责与依赖,以及两种推进方式。只有用户明确同意当前完整 Shape 并选择推进方式后,才执行对应的 confirm-shape 选项。仅选择推进方式、补充或修改要求都不算完整确认;保留已选方式,只补问缺少的决定。完整确认前不要运行 --confirmed。")}:t.language==="zh-CN"?{required:!0,message:"Shape 已整理完成。请确认目标、范围、关键决定、验收标准和非目标是否准确;明确确认后才会进入 Build。",suggestedReply:"确认进入 Build",agentInstruction:"先用自然语言简要展示目标、范围、关键决定、验收标准和非目标,再转述 message 并等待用户明确确认。只有用户明确同意当前完整 Shape 时,才执行 commandAlternatives 中的 confirm-shape;补充或修改要求不算确认。不要展示机器状态或提前运行 --confirmed。"}:{required:!0,message:"Shape is ready. Confirm that the target, scope, key decisions, acceptance criteria, and non-goals are accurate; Build starts only after explicit confirmation.",suggestedReply:"Confirm and enter Build",agentInstruction:"First present a concise natural-language summary of the target, scope, key decisions, acceptance criteria, and non-goals. Then relay message and wait for explicit user confirmation. Run confirm-shape from commandAlternatives only when the user explicitly accepts the complete current Shape; additions or corrections are not confirmation. Do not expose machine state or run --confirmed early."};if(e&&t.phase==="shape"&&t.status==="active")return n(Y(t,"Complete the Shape documents and child plan, resolve blocking questions, then execute prepare-shape-confirmation. Its persisted response combines complete Shape confirmation and coordination choice in one user decision. If the user already chose only a mode, include that --coordination-mode when preparing and ask only for complete Shape confirmation afterward.","完成 Shape 文档和 Child 计划,解决阻塞问题后执行 prepare-shape-confirmation。持久化后的响应会让用户一次确认完整 Shape 并选择推进方式。如果用户已经仅选择了推进方式,准备时附上对应的 --coordination-mode,随后只确认完整 Shape。"));if(t.phase==="verify"&&t.status==="active"&&t.loop.stage==="verify-ready"&&t.loop.next_action!=="await-verifier-result")return n(Y(t,"The current candidate and completed checks are preserved. Continue with dispatch-verifier without asking the user to recover files, processes, or workflow state. If a brief status update is necessary, say only that verification is being retried and the code is unchanged.","当前候选和已经完成的检查都已保留。直接继续 dispatch-verifier,不要让用户恢复文件、进程或工作流状态。如果确实需要简短同步进度,只说明正在重新尝试验收且代码没有变化。"));if(t.phase==="verify"&&t.status==="active"&&t.loop.next_action==="await-verifier-result"){let a=i==="confirmed"?Y(t,"The Verifier has confirmed startup. Continue waiting on the same host task and use its actual progress.","Verifier 已确认启动。继续等待同一个宿主任务,并使用该任务的实际进度。"):Y(t,"Check whether the host accepted the startup call and locate the task for the current verifierExecutionRef. If the call has not been made, start the dispatched task once; if the host accepted it, check that same task and let the Verifier submit its startup receipt. A missing receipt alone does not prove failure. If local startup state is unavailable, recover the host task context before deciding whether startup is needed.","先核实宿主是否接受了启动调用,并找到当前 verifierExecutionRef 对应的任务。尚未调用时启动已派发的任务一次;宿主已接受时检查同一个任务,由 Verifier 提交启动回执。仅缺少回执不能证明执行失败。本地启动记录不可用时,先恢复宿主任务上下文,再判断是否需要启动。");return n(`${a} ${Y(t,"Keep the same dispatched Verifier while it is active. A wait-tool timeout is not an execution timeout: check task progress and continue waiting; do not cancel, interrupt, or spawn a replacement just because a wait returned without a result. Request progress without telling the Verifier to stop inspecting. Only after confirmed task failure, a host-reported execution timeout, loss, or termination without a usable result, immediately submit verifier-execution-error. Preserve completed evidence and explain the failure and changed recovery approach before retrying. Submit verifier-unavailable only when the current platform truly has no usable subagent capability. Forward the actual report, including risks and incomplete checks; never turn an uninspected candidate into pass. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","已派发的验收任务仍在运行时,继续使用同一个 Verifier。等待工具超时不等于执行超时:检查任务进度并继续等待,不得仅因一次等待没有结果就取消、中断或重新派发。询问进度时不要要求停止核查。仅在确认任务失败、宿主报告执行超时、任务丢失或结束后没有可用结果时,立即提交 verifier-execution-error;保留已完成证据,重试前说明失败原因及恢复方式的变化。只有当前平台确实没有可用的 subagent 能力时才提交 verifier-unavailable。忠实传递原始报告,包括风险和未完成检查;没有核查当前候选不能判定通过。不要让用户恢复文件或进程,也不要向用户展示 attempt、requestCheckRounds 等机器状态。")}`)}if(t.status==="blocked"&&t.blockers.some(({resolution_action:a})=>a==="retry-verifier"))return t.loop.retry_epoch>=3?t.language==="zh-CN"?{required:!0,message:"自动重试验收已连续多轮未能取得结果,验证环境很可能不可用。请人工检查验证环境(subagent 配额、平台任务队列、网络),或使用 doctor --repair 评估该 change 状态。",suggestedReply:"人工检查验证环境",agentInstruction:"只向用户转述 message,等待用户完成人工检查后再继续。不要自动重试验收。"}:{required:!0,message:"Automatic verification retries have failed across multiple rounds; the verification environment is likely unavailable. Inspect the environment manually (subagent quota, platform task queue, network), or use doctor --repair to assess the change state.",suggestedReply:"Inspect the verification environment",agentInstruction:"Relay message to the user and wait for a manual environment check before continuing. Do not retry verification automatically."}:t.language==="zh-CN"?{required:!0,message:"由于独立验收任务连续几次没有正常返回结果,本次验收已暂停。你的代码和已经完成的检查都已安全保留。回复“继续”即可重新尝试,不需要处理文件或进程。",suggestedReply:"继续",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户回复。不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification paused because the independent verification task repeatedly ended without a result. Your code and completed checks are safely preserved. Reply “Continue” to retry; you do not need to manage files or processes.",suggestedReply:"Continue",agentInstruction:"Relay only message and suggestedReply to the user, then wait for that reply. Do not expose internal attempts, counters, paths, or recovery steps."};if(t.phase==="verify"&&t.status==="await-user"&&t.verification?.assurance==="semantic-verification-unavailable")return t.language==="zh-CN"?{required:!0,message:"独立验收当前不可用,但你的代码和已经完成的检查都已安全保留。你可以直接重新尝试独立验收,也可以明确接受只有自动检查的结果。",suggestedReply:"重新尝试独立验收",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户选择。用户要求重试时执行 commandAlternatives 中的 retry-verifier;只有用户明确接受降级结果时才执行 confirm-verifier-unavailable。不要把“继续”视为接受降级结果,也不要要求用户处理文件、进程、服务或回调。"}:{required:!0,message:"Independent verification is currently unavailable, but your code and completed checks are safely preserved. You can retry independent verification directly or explicitly accept the automatic-check-only result.",suggestedReply:"Retry independent verification",agentInstruction:"Relay only message and suggestedReply, then wait for the user choice. If the user asks to retry, run retry-verifier from commandAlternatives; run confirm-verifier-unavailable only when the user explicitly accepts the degraded result. Do not treat “Continue” as accepting the degraded result, and do not ask the user to manage files, processes, services, or callbacks."};if(t.phase==="verify"&&t.status==="await-user"&&t.loop.next_action==="resolve-verifier-blocker")return t.language==="zh-CN"?{required:!0,message:"验证暂时无法下结论,因为缺少只有你能提供的信息,例如外部系统的真实行为或某个业务决定。你的代码和已经完成的检查都已安全保留。补充所需信息后可继续验证,也可以选择修改实现或调整需求。",suggestedReply:null,agentInstruction:"向用户转述 message,请用户补充缺失的信息,或在继续验证(resolve-verifier-blocker)、修改实现、调整需求之间明确选择,再执行 commandAlternatives 中对应的完整命令。不要把“继续”当作默认选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification cannot reach a verdict yet because information only you can provide is missing, such as the real behavior of an external system or a business decision. Your code and completed checks are safely preserved. Supply the missing information to resume verification, or choose to revise the implementation or the requirements.",suggestedReply:null,agentInstruction:"Relay message and ask the user to supply the missing information or explicitly choose between resuming verification (resolve-verifier-blocker), revising the implementation, and revising the requirements; run the matching commandAlternative afterwards. Do not treat “Continue” as a default choice, and do not expose internal rounds, counters, paths, or recovery steps."};if(t.phase==="verify"&&t.status==="await-user"&&t.loop.next_action==="await-user"){let o=(t.loop.stop_reason??(t.loop.no_progress_count>=3?"stalled":"budget"))==="stalled",s=o?"验证已连续三轮失败且未通过的验收场景一直没有减少,本次修改已暂停,以避免在同一个问题上反复循环。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。":"本次修改的验证失败次数已用完配置的预算,因此暂停等待你的决定,而不是自动重试。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。注意:预算不会重置,选择继续修复后,下一次验收失败会再次暂停。",c=o?"Verification has failed three times in a row without the unresolved scenarios shrinking, so this change is paused to avoid looping on the same problem. Your code and completed checks are safely preserved. You can have the Builder try a different repair approach, or go back and adjust the requirements.":"Verification for this change has used its configured failure budget, so it is paused for your decision instead of retrying automatically. Your code and completed checks are safely preserved. You can have the Builder continue with a different repair approach, or go back and adjust the requirements.";return t.language==="zh-CN"?{required:!0,message:s,suggestedReply:"继续修复",agentInstruction:"向用户转述 message 和 suggestedReply,等待用户在“继续修复实现”(revise-implementation)与“调整需求”(revise-requirements)之间明确选择,再执行 commandAlternatives 中对应的完整命令。选择继续修复时,要求 Builder 更换修复思路。不要替用户选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:c,suggestedReply:"Continue repairing",agentInstruction:"Relay message and suggestedReply, then wait for the user to explicitly choose between continuing the implementation (revise-implementation) and adjusting the requirements (revise-requirements); run the matching commandAlternative afterwards. When continuing, ask the Builder to change its repair approach. Do not choose for the user, and do not expose internal rounds, counters, paths, or recovery steps."}}if(t.phase==="verify"&&t.status==="await-user"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass")return{required:!0,message:Y(t,"The reported verification passed, but this platform cannot confirm an independent Verifier execution. Review the result and choose whether to accept it for Archive, revise the implementation, or revise the requirements."+(t.workspace.isolation!=="current"&&t.workspace.finish===null?" If accepting, also choose: keep the workspace, merge locally, push the branch, or push and create a PR. You may accept the result and defer the finish choice.":""),"当前验收报告已通过,但当前平台无法确认验收是否独立执行。请检查结果,并选择接受结果进入归档、继续修改实现,或调整需求。"+(t.workspace.isolation!=="current"&&t.workspace.finish===null?" 接受时可一起选择:保留工作区、本地合并、推送分支,或推送并创建 PR;也可以先接受结果,稍后再选择收尾方式。":"")),suggestedReply:Y(t,"Accept the result","接受结果"),agentInstruction:Y(t,"Summarize the result and verification evidence, relay the message, and wait for an explicit user decision. Only then execute the matching commandAlternative. Do not accept the result on the user’s behalf.","简要说明交付结果和验收证据,转述 message,并等待用户明确选择后再执行对应的 commandAlternative。不要替用户接受结果。")};if(t.phase==="build"&&t.status==="active"){let a=r?.children.some(({status:l})=>l==="blocked")??!1,o=r?.children.some(({status:l})=>l==="needs-reverify")??!1,s=r?.children.some(({status:l})=>l==="ready"||l==="active")??!1,c=r?.children.some(({status:l,builderFailureCount:d})=>l==="blocked"&&(d??0)>=Eo)??!1;return a&&!o&&!s&&!c?t.language==="zh-CN"?{required:!0,message:"Supervisor 子任务暂时无法启动,已暂停自动重试以避免流程循环。请先根据子任务 blocker 修复工作区、分支或依赖;修复完成后重新运行最新的 next 继续流程。代码和已有证据已保留。",suggestedReply:"修复 blocker 后继续",agentInstruction:"向用户说明子任务 blocker 和需要先完成的外部修复;不要反复执行 next,也不要创建替代任务。用户确认工作区或依赖已修复后,再重新读取 status 并执行最新 continuation。"}:{required:!0,message:"Supervisor child dispatch is paused because every remaining child is blocked. Automatic retries are stopped to avoid a loop. Resolve the recorded child blocker (workspace, branch, or dependency) first, then read the latest status and continue; code and completed evidence are preserved.",suggestedReply:"Resolve the blocker and continue",agentInstruction:"Explain the child blocker and the required external repair to the user. Do not repeatedly run next or spawn replacement tasks. After the user confirms the workspace or dependency is fixed, read status again and execute the latest continuation."}:n(Y(t,"Implement the complete confirmed brief and Spec scope, then review every acceptance ID with its implementation and evidence before handoff. Fill acceptance_review from this audit; derive remaining work from it. Do not submit a partial candidate just to obtain verification feedback. Run focused checks; a separate pre-review is optional. If review is useful, retain the same Reviewer for focused repair follow-ups. Submit the completed candidate for one complete independent verification and release completed helper tasks.","完成已确认的 brief 和 Spec 全部范围,交接前逐项核对所有验收 ID 的实现和证据,填写 acceptance_review,并由这份自查生成剩余工作。不得提交未完成的候选来试探验收反馈。开发期运行相关检查,额外预审为可选项;确需审查时,保留同一个 Reviewer 复核修复及受影响范围。全部完成后提交一次完整独立验收,及时释放已完成的辅助任务。"))}return n(Y(t,"Follow the continuation action. Unless required is true, continue without asking the user to handle internal workflow state, and do not present machine fields as a user-facing explanation.","按 continuation 执行下一步。除非 required 为 true,否则继续推进,不要让用户处理内部工作流状态,也不要把机器字段作为面向用户的说明。"))}function $x(t){let e=t.workspace.change_branch??"<change-branch>",r=t.workspace.target_branch??"<target-branch>";return t.language==="zh-CN"?{required:!0,message:`当前 change 位于 ${e},目标分支为 ${r}。请选择一次工作区收尾方式:A) 保留工作区;B) 本地合并;C) 推送分支;D) 推送并创建 PR;E) 暂不归档。选择 A-D 后 Runtime 会完成预检,检查通过后按所选方式归档;选择 E 将保留当前 change 等待稍后继续。`,suggestedReply:"回复 A、B、C、D 或 E",agentInstruction:"向用户展示五种收尾方式及实际影响,等待用户选择。选择 A-D 时执行对应 commandAlternatives 的完整命令,Runtime 会在归档前检查状态和证据;选择 E 时停止,不运行 Archive 命令。按用户的明确选择执行 finish。"}:{required:!0,message:`This change is on ${e} and targets ${r}. Choose one workspace finish: A) keep the workspace; B) merge locally; C) push the branch; D) push and create a PR; or E) defer Archive. For A-D, Runtime will run preflight and archive with the selected finish when the checks pass; E keeps the current change for later.`,suggestedReply:"Reply A, B, C, D, or E",agentInstruction:"Show all five finish choices and their actual effects, then wait. For A-D, execute the matching complete commandAlternative; Runtime checks state and evidence before archiving. For E, stop without running an Archive command. Use the finish explicitly selected by the user."}}function Ox(t){return[...[{finish:"keep",name:"keep-workspace",description:["保留当前分支和目录;完成归档提交,不合并、不推送、不创建 PR。","Keep the current branch and directory; create the archive commit without merging, pushing, or creating a PR."]},{finish:"merge",name:"merge-locally",description:["完成归档提交,并把 change 分支本地合并到目标分支;不推送、不创建 PR。","Create the archive commit and merge the change branch locally into the target branch without pushing or creating a PR."]},{finish:"push",name:"push-branch",description:["完成归档提交并推送 change 分支;不合并到目标分支、不创建 PR。","Create the archive commit and push the change branch without merging into the target branch or creating a PR."]},{finish:"pull-request",name:"push-pull-request",description:["完成归档提交、推送 change 分支,并以目标分支为基础创建 PR。","Create the archive commit, push the change branch, and create a PR against the target branch."]}].map(({finish:i,name:n,description:a})=>({name:n,stateVersion:t.state_version,expectedAction:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed","--finish",i,"--expected-state-version",String(t.state_version)],requiredInputs:[],inputOptions:[],description:Y(t,a[1],a[0])})),{name:"defer-archive",stateVersion:t.state_version,expectedAction:"archive-preview",commandArgs:null,requiredInputs:[],inputOptions:[],description:Y(t,"Keep the current change and workspace without archiving; stop and resume later.","保留当前 change 和工作区,不执行归档;停止本次流程,稍后再继续。")}]}function cm(t){return["comet","native","next",t.change,"--summary","<summary>",t.flag,"--expected-state-version",String(t.stateVersion),"--expected-action",t.action]}function pr(t,e){return{name:t,flag:e,valueKind:"text",required:!0,template:null}}function am(){return{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}}function Hx(t,e){return{name:t,flag:e,valueKind:"confirmation",required:!0,template:null}}function om(t,e,r){return{name:t,flag:e,valueKind:"choice",required:!0,template:null,choices:[...r]}}function Dx(t){return t?.coordinationChoiceRequired===!0||t?.schema==="comet.native.children.v2"&&t.children.length>=2}function Bx(t){return["comet","native","next",t.change,"--summary","<summary>","--expected-state-version",String(t.stateVersion),"--expected-action","prepare-shape-confirmation"]}function Qe(t){return{name:t.name,stateVersion:t.stateVersion,expectedAction:t.expectedAction,commandArgs:cm({change:t.change,stateVersion:t.stateVersion,action:t.expectedAction,flag:t.flag}),requiredInputs:["summary",t.confirmationInput],inputOptions:[pr("summary","--summary"),Hx(t.name,t.flag)]}}function sm(t,e){return e.some(i=>/^verification\.md is (?:missing|stale|invalid)$/u.test(i))?[{name:"repair-verification-report",stateVersion:t.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","doctor",t.name,"--repair"],requiredInputs:[],inputOptions:[],description:Y(t,"Rebuild the Runtime-managed verification report, then rerun the Archive dry-run.","重建由 Runtime 管理的 verification.md,然后重新运行 Archive 预检。")}]:[]}function Lx(t){return/^verification\.md is (?:missing|stale|invalid)$/u.test(t)}function Oo(t){return[Qe({name:"revise-implementation",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),Qe({name:"revise-requirements",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function Fx(t){let e={"request-checks":"Choose when the Verifier needs additional Runtime checks.","final-result":"Choose when the Verifier has a result for every current scope ID.","verifier-execution-error":"Choose when a dispatched Verifier failed, was lost, or ended without a result.","verifier-unavailable":"Choose only when the platform has no usable independent Verifier capability."};return t.flatMap(r=>Array.isArray(r.template)?r.template.map(i=>{let n=i.response?.kind??i.kind;return{...r,name:n,required:!1,exclusiveGroup:"runner-input",description:e[n],template:i}}):[r])}function Jr(t,e,r={}){let i=Dx(e)&&t.coordination_mode===void 0,n=jx(t,i,e,r.verifierStartup),a={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[],requiresUserDecision:n.required,userCommunication:n},o=s=>({kind:s,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...a,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:o("none")};if(t.status==="await-user")return t.phase==="shape"&&t.loop.next_action==="confirm-shape"?{...a,disposition:"await-user",action:"confirm-shape",commandArgs:null,requiredInputs:["summary","shared-understanding-confirmation",...i?["coordination-choice"]:[]],inputOptions:[pr("summary","--summary")],commandAlternatives:i?ih.map(s=>{let c=Qe({name:`confirm-shape-${s}`,change:t.name,stateVersion:t.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"});return{...c,commandArgs:[...c.commandArgs,"--coordination-mode",s],requiredInputs:[...c.requiredInputs,"coordination-choice"],inputOptions:[...c.inputOptions,om("coordination-mode","--coordination-mode",[s])]}}):[Qe({name:"confirm-shape",change:t.name,stateVersion:t.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"})],runnerAction:o("none")}:t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...a,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[...t.workspace.isolation!=="current"&&t.workspace.finish===null?["keep","merge","push","pull-request"].map(s=>{let c=Qe({name:`accept-result-${s}`,change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"});return{...c,commandArgs:[...c.commandArgs,"--finish",s]}}):[],Qe({name:"accept-result",change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...Oo({change:t.name,stateVersion:t.state_version})],runnerAction:o("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...a,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[Qe({name:"retry-verifier",change:t.name,stateVersion:t.state_version,expectedAction:"retry-verifier",flag:"--retry-verifier",confirmationInput:"user-decision"}),Qe({name:"confirm-verifier-unavailable",change:t.name,stateVersion:t.state_version,expectedAction:"confirm-verifier-unavailable",flag:"--confirmed",confirmationInput:"user-decision"})],runnerAction:o("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...a,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[Qe({name:"resolve-verifier-blocker",change:t.name,stateVersion:t.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...Oo({change:t.name,stateVersion:t.state_version})],runnerAction:o("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...a,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:Oo({change:t.name,stateVersion:t.state_version}),runnerAction:o("none")}:{...a,disposition:"await-user",action:"none",commandArgs:null,commandAlternatives:Oo({change:t.name,stateVersion:t.state_version}),userCommunication:{...a.userCommunication,required:!0,message:t.blockers.length>0?t.blockers.map(({reason:s})=>s).join("; "):a.userCommunication.message,suggestedReply:t.blockers.length>0?t.blockers[0]?.resolution_action??null:a.userCommunication.suggestedReply},requiredInputs:["resolve-blocker"],runnerAction:o("none")};if(t.status==="blocked"){let s=t.blockers.some(({resolution_action:c})=>c==="retry-verifier");return{...a,disposition:"blocked",action:s?"retry-verifier":"none",commandArgs:s?cm({change:t.name,stateVersion:t.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:s?["summary"]:["repair-runtime"],inputOptions:s?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:o(s?"retry-verifier":"none")}}if(t.phase==="shape")return{...a,disposition:"continue",action:"prepare-shape-confirmation",commandArgs:Bx({change:t.name,stateVersion:t.state_version}),requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.phase==="build"){if(e){if(!e.confirmed)return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.loop.stage==="repairing"&&t.verification_result==="fail")return{...a,disposition:"continue",action:"repair",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["repair-child"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(e.allDone)return{...a,disposition:"continue",action:"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:t.acceptance.map(({id:m})=>m),acceptance_review:t.acceptance.map(({id:m})=>({id:m,status:"not-implemented",evidence:[],note:"<implementation and evidence summary>"})),checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[am()],known_limits:[]}}],runnerAction:o("builder-handoff")};let s=e.children.find(({status:m})=>m==="verified");if(s){let m=r.supervisorIntegrationRetryIds;return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["supervisor-integration-checks"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-integrate",child:s.name,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}],...m&&m.length>0?{retry_check_ids:[...m]}:{}}}],runnerAction:o("none")}}let c=e.children.some(({status:m})=>m==="blocked"||m==="needs-reverify"),l=e.children.some(({status:m})=>m==="needs-reverify"),d=e.children.some(({status:m})=>m==="ready"||m==="active"),u=e.supervisorStateVersion===void 0?null:e.children.find(m=>m.status==="blocked"&&(m.builderFailureCount??0)>=Eo)??null,p=u===null?null:{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-retry-builder",child:u.name,stateVersion:e.supervisorStateVersion},description:Y(t,"Explicitly authorize one fresh Builder attempt after the Builder failure budget was exhausted.","Builder 失败预算已耗尽;明确授权后才能重新开始一次 Builder 尝试。")},f=c&&!l&&!d&&p===null;return{...a,disposition:f?"blocked":"continue",action:"advance-children",commandArgs:f?null:p!==null?["comet","native","next",t.name,"--runner-input","<temporary-json-file>"]:["comet","native","next",t.name,"--summary","<summary>",...t.coordination_mode==="single-session"?["--max-parallel","1"]:[]],requiredInputs:f?[]:p!==null?["supervisor-builder-retry-json-file"]:["ready-children"],inputOptions:f?[]:p!==null?[p]:[pr("summary","--summary")],runnerAction:o("none")}}return{...a,disposition:"continue",action:t.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:t.acceptance.map(({id:s})=>s),acceptance_review:t.acceptance.map(({id:s})=>{let c=t.builder_handoff?.acceptance_review?.find(l=>l.id===s);return c?{...c,evidence:[...c.evidence],...t.loop.previous_unresolved_ids.includes(s)?{status:"implemented-no-evidence",evidence:[],note:"<current repair and evidence summary>"}:{}}:{id:s,status:"not-implemented",evidence:[],note:"<implementation and evidence summary>"}}),checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[],known_limits:[]}}],runnerAction:o("builder-handoff")}}if(t.phase==="verify"){let s=t.loop.next_action==="await-verifier-result",c=!!t.children_contract_hash,l=am();return!s&&r.retryCheckIds&&r.retryCheckIds.length>0?{...a,disposition:"continue",action:"retry-checks",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["retry-checks-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"retry-checks",check_ids:[...r.retryCheckIds]}}],runnerAction:o("retry-checks")}:{...a,userCommunication:!s&&c?{...a.userCommunication,agentInstruction:`${a.userCommunication.agentInstruction} ${Y(t,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:a.userCommunication,disposition:"continue",action:s?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[s?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:Fx([{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:s?[{kind:"verifier-response",candidateId:t.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[l]}},{kind:"verifier-response",candidateId:t.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"final-result",result:{iteration:t.loop.iteration,attempt:t.loop.attempt,verdict:"blocked",acceptance:[{id:"<acceptance-id>",result:"blocked",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:r.verificationCheckPlans?r.verificationCheckPlans.map(d=>({...d,argv:[...d.argv]})):c?[l]:[]}}]),runnerAction:o(s?"await-verifier":"dispatch-verifier")}}if(t.phase==="archive"&&t.status==="active"&&t.loop.stage==="archive-ready"&&!t.archived){let s=r.archiveMode??"archive-ready",l=t.workspace.isolation!=="current"&&t.workspace.finish===null;if(s==="blocked")return{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],runnerAction:o("none")};if(s==="preview"){if(r.archiveBlockers&&r.archiveBlockers.length>0){let d=sm(t,r.archiveBlockers)[0];return d&&r.archiveBlockers.every(u=>Lx(u))?{...a,disposition:"continue",action:"repair",commandArgs:d.commandArgs,requiredInputs:[],inputOptions:[],runnerAction:o("none")}:{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],commandAlternatives:sm(t,r.archiveBlockers),runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}return l?{...a,disposition:"await-user",action:"archive",commandArgs:null,requiredInputs:["workspace-finish"],inputOptions:[om("finish","--finish",["keep","merge","push","pull-request"])],commandAlternatives:[...Ox(t)],userCommunication:$x(t),runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--dry-run"],requiredInputs:[],commandAlternatives:[Qe({name:"revise-requirements",change:t.name,stateVersion:t.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}Se();Za();F();import ei from"node:path";Se();ot();H();var ZB=8*1024*1024;Po();ro();Te();or();mn();So();import{promises as Mx}from"node:fs";H();on();import lm from"node:path";function yn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Nn(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function se(t,e,r=!1){if(typeof t!="string"||!r&&t.length===0)throw new Error(`${e} must be ${r?"a string":"a non-empty string"}`);return t}function Ur(t,e){return t===null?null:se(t,e)}function Kr(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function Vx(t,e){if(t===null)return null;if(!Number.isSafeInteger(t))throw new Error(`${e} must be null or a safe integer`);return t}function Wx(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function Yr(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Xl(t,e){if(t===null)return null;let r=se(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function zx(t,e){let r=se(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function Ql(t,e){let r=se(t,e);if(!lm.isAbsolute(r))throw new Error(`${e} must be absolute`);return lm.resolve(r)}function Gx(t,e){let r=`Native local checks[${e}]`,i=yn(t,r);if(Nn(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log","activeProcess","evidence","evidenceDigest"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((d,u)=>se(d,`${r}.argv[${u}]`,!0)),a=Yr(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=Xl(i.startedAt,`${r}.startedAt`),s=Xl(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let c=Kr(i.timeoutMs,`${r}.timeoutMs`);if(c<1)throw new Error(`${r}.timeoutMs must be positive`);let l;if(Object.hasOwn(i,"activeProcess"))if(i.activeProcess===null)l=null;else{let d=yn(i.activeProcess,`${r}.activeProcess`),u=Yr(d.status,["starting","running"],`${r}.activeProcess.status`);if(Nn(d,new Set(["status","pid","identity"]),`${r}.activeProcess`),u==="starting"){if(Object.hasOwn(d,"pid")||Object.hasOwn(d,"identity"))throw new Error(`${r}.activeProcess starting state cannot contain process identity`);l={status:"starting"}}else l={status:"running",pid:Kr(d.pid,`${r}.activeProcess.pid`,1),...Object.hasOwn(d,"identity")?{identity:se(d.identity,`${r}.activeProcess.identity`)}:{}}}return{id:se(i.id,`${r}.id`),name:se(i.name,`${r}.name`),operationId:se(i.operationId,`${r}.operationId`),status:a,repeatable:Wx(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:Kr(i.executionCount,`${r}.executionCount`),argv:n,cwd:Ql(i.cwd,`${r}.cwd`),exitCode:Vx(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:se(i.log,`${r}.log`),...Object.hasOwn(i,"activeProcess")?{activeProcess:l}:{},...Object.hasOwn(i,"evidence")?{evidence:Yr(i.evidence,["runtime"],`${r}.evidence`)}:{},...Object.hasOwn(i,"evidenceDigest")?{evidenceDigest:se(i.evidenceDigest,`${r}.evidenceDigest`)}:{}}}function Jx(t){let e="Native local execution state",r=yn(t,e);if(Nn(r,new Set(["schema","change","basedOnStateVersion","candidateId","inputFingerprint","inputFingerprintGate","candidateInputFingerprintGate","workspace","execution","checks"]),e),r.schema!==io)throw new Error(`Native local execution schema must be ${io}`);let i=yn(r.workspace,"Native local workspace");Nn(i,new Set(["projectRoot","worktreeRoot","branch","machineId"]),"Native local workspace");let n=null;if(r.execution!==null){let o=yn(r.execution,"Native local execution");Nn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds","verifierStartedAt","ownerPid","ownerIdentity"]),"Native local execution");let s=Xl(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:se(o.operationId,"Native local execution.operationId"),stage:Yr(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Yr(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Ur(o.executionId,"Native local execution.executionId"),status:Yr(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Kr(o.requestCheckRounds,"Native local execution.requestCheckRounds"),...Object.hasOwn(o,"verifierStartedAt")?{verifierStartedAt:zx(o.verifierStartedAt,"Native local execution.verifierStartedAt")}:{},...Object.hasOwn(o,"ownerPid")?{ownerPid:Kr(o.ownerPid,"Native local execution.ownerPid",1)}:{},...Object.hasOwn(o,"ownerIdentity")?{ownerIdentity:se(o.ownerIdentity,"Native local execution.ownerIdentity")}:{}}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(Gx);if(new Set(a.map(o=>o.id)).size!==a.length)throw new Error("Native local check IDs must be unique");if(n&&a.some(o=>o.operationId!==n.operationId))throw new Error("Native local checks must belong to the current operation");return{schema:io,change:se(r.change,"Native local change"),basedOnStateVersion:Kr(r.basedOnStateVersion,"Native local basedOnStateVersion",1),...Object.hasOwn(r,"candidateId")?{candidateId:Ur(r.candidateId,"Native local candidateId")}:{},...Object.hasOwn(r,"inputFingerprint")?{inputFingerprint:Ur(r.inputFingerprint,"Native local inputFingerprint")}:{},...Object.hasOwn(r,"inputFingerprintGate")?{inputFingerprintGate:Ur(r.inputFingerprintGate,"Native local inputFingerprintGate")}:{},...Object.hasOwn(r,"candidateInputFingerprintGate")?{candidateInputFingerprintGate:Ur(r.candidateInputFingerprintGate,"Native local candidateInputFingerprintGate")}:{},workspace:{projectRoot:Ql(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Ql(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Ur(i.branch,"Native local workspace.branch"),...Object.hasOwn(i,"machineId")?{machineId:se(i.machineId,"Native local workspace.machineId")}:{}},execution:n,checks:a}}async function Ho(t){let e;try{e=await Mx.readFile(t,"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}let r;try{r=JSON.parse(e)}catch(i){throw new Error(`Native local execution state is invalid JSON: ${i.message}`,{cause:i})}return Jx(r)}function Zl(t,e){let r=e?.execution;if(!(t.phase!=="verify"||t.status!=="active"||t.loop.next_action!=="await-verifier-result"||t.builder_handoff?.candidate_id===void 0||t.builder_handoff?.candidate_id===null||e===null||e.change!==t.name||e.basedOnStateVersion!==t.state_version||e.candidateId!==t.builder_handoff.candidate_id||r==null||r.stage!=="verifying"||r.actor!=="verifier"||r.status!=="running"||r.executionId===null))return r.executionId}K();or();I();import{promises as Ux}from"node:fs";import eu from"node:path";Se();Te();I();var um=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,dm="comet-state.yaml",pm="state.json";function ft(t,e){if(!um.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=eu.join(t.changesDir,e);if(!J(t.changesDir,r))throw new Error("Native change path escaped");return r}function Do(t,e){return eu.join(ft(t,e),dm)}function qt(t,e){return eu.join(Ue(t,e),pm)}async function Xr(t,e){try{let r=await Ux.readFile(Do(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}async function Be(t,e){return $t(Do(t,e))}async function Bo(t){let e=await Be(t.paths,t.name),r=qt(t.paths,t.name);try{let i=await Ho(r);return i===null?{state:e,local:null,localStatus:"missing"}:i.change!==e.name||i.basedOnStateVersion!==e.state_version?{state:e,local:null,localStatus:"stale"}:{state:e,local:i,localStatus:"available"}}catch(i){return i.code==="ENOENT"?{state:e,local:null,localStatus:"missing"}:{state:e,local:null,localStatus:"invalid"}}}function nu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mr=nu();function Nm(t){mr=t}var fr={exec:()=>null};function Qr(t){let e=[];return r=>{let i=Math.max(0,Math.min(3,r-1)),n=e[i];return n||(n=t(i),e[i]=n),n}}function P(t,e=""){let r=typeof t=="string"?t:t.source,i={replace:(n,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(te.caret,"$1"),r=r.replace(n,o),i},getRegex:()=>new RegExp(r,e)};return i}var Kx=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),te={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Qr(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Qr(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}>`))},Yx=/^(?:[ \t]*(?:\n|$))+/,Xx=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Qx=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Zx=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,au=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,bm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,km=P(bm).replace(/bull/g,au).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),eC=P(bm).replace(/bull/g,au).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ou=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,tC=/^[^\n]+/,su=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,rC=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",su).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),iC=P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,au).getRegex(),Vo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",cu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,nC=P("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",cu).replace("tag",Vo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Sm=t=>P(ou).replace("hr",Sn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Vo).getRegex(),aC=Sm(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),oC=Sm(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),sC=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",oC).getRegex(),lu={blockquote:sC,code:Xx,def:rC,fences:Qx,heading:Zx,hr:Sn,html:nC,lheading:km,list:iC,newline:Yx,paragraph:aC,table:fr,text:tC},fm=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Sn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Vo).getRegex(),cC={...lu,lheading:eC,table:fm,paragraph:P(ou).replace("hr",Sn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",fm).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Vo).getRegex()},lC={...lu,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",cu).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:fr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(ou).replace("hr",Sn).replace("heading",` *#{1,6} *[^
171
+ ]`).replace("lheading",km).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},uC=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,dC=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Em=/^( {2,}|\\)\n(?!\s*$)/,pC=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ht=/[\p{P}\p{S}]/u,Zr=/[\s\p{P}\p{S}]/u,En=/[^\s\p{P}\p{S}]/u,fC=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Zr).getRegex(),hC=/[\p{Pi}\p{Ps}"']/u,xm=/(?!~)[\p{P}\p{S}]/u,mC=/(?!~)[\s\p{P}\p{S}]/u,vC=/(?:[^\s\p{P}\p{S}]|~)/u,gC=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Kx?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cm=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,wC=P(Cm,"u").replace(/punct/g,ht).getRegex(),yC=P(Cm,"u").replace(/punct/g,xm).getRegex(),NC=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,bC=P(NC,"u").replace(/openQuote/g,hC).replace(/punct/g,ht).getRegex(),Rm="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",kC=P(Rm,"gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),SC=P(Rm,"gu").replace(/notPunctSpace/g,vC).replace(/punctSpace/g,mC).replace(/punct/g,xm).getRegex(),EC="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",xC=P(EC,"gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),CC=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),RC="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",PC=P(RC,"gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),_C=P(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ht).getRegex(),AC="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",IC=P(AC,"gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),TC=P(/\\(punct)/,"gu").replace(/punct/g,ht).getRegex(),jC=P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),$C=P(cu).replace("(?:-->|$)","-->").getRegex(),OC=P("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",$C).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Fo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,HC=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Fo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Pm=P(/^!?\[(label)\]\[(ref)\]/).replace("label",Fo).replace("ref",su).getRegex(),_m=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",su).getRegex(),DC=P("reflink|nolink(?!\\()","g").replace("reflink",Pm).replace("nolink",_m).getRegex(),hm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,uu={_backpedal:fr,anyPunctuation:TC,autolink:jC,blockSkip:gC,br:Em,code:dC,del:fr,delLDelim:fr,delRDelim:fr,emStrongLDelim:wC,emStrongRDelimAst:kC,emStrongRDelimUnd:CC,escape:uC,link:HC,nolink:_m,punctuation:fC,reflink:Pm,reflinkSearch:DC,tag:OC,text:pC,url:fr},BC={...uu,emStrongLDelim:bC,emStrongRDelimAst:xC,emStrongRDelimUnd:PC,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",Fo).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Fo).getRegex()},tu={...uu,emStrongRDelimAst:SC,emStrongLDelim:yC,delLDelim:_C,delRDelim:IC,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",hm).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",hm).getRegex()},LC={...tu,br:P(Em).replace("{2,}","*").getRegex(),text:P(tu.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Lo={normal:lu,gfm:cC,pedantic:lC},bn={normal:uu,gfm:tu,breaks:LC,pedantic:BC},FC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},mm=t=>FC[t];function Ze(t,e){if(e){if(te.escapeTest.test(t))return t.replace(te.escapeReplace,mm)}else if(te.escapeTestNoEncode.test(t))return t.replace(te.escapeReplaceNoEncode,mm);return t}function vm(t){try{t=encodeURI(t).replace(te.percentDecode,"%")}catch{return null}return t}function gm(t,e){let r=t.replace(te.findPipe,(a,o,s)=>{let c=!1,l=o;for(;--l>=0&&s[l]==="\\";)c=!c;return c?"|":" |"}),i=r.split(te.splitPipe),n=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(te.slashPipe,"|");return i}function Mt(t,e,r){let i=t.length;if(i===0)return"";let n=0;for(;n<i;){let a=t.charAt(i-n-1);if(a===e&&!r)n++;else if(a!==e&&r)n++;else break}return t.slice(0,i-n)}function wm(t){let e=t.split(`
168
172
  `),r=e.length-1;for(;r>=0&&te.blankLine.test(e[r]);)r--;return e.length-r<=2?t:e.slice(0,r+1).join(`
169
- `)}function OC(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let i=0;i<t.length;i++)if(t[i]==="\\")i++;else if(t[i]===e[0])r++;else if(t[i]===e[1]&&(r--,r<0))return i;return r>0?-2:-1}function HC(t,e=0){let r=e,i="";for(let n of t)if(n===" "){let a=4-r%4;i+=" ".repeat(a),r+=a}else i+=n,r++;return i}function vm(t,e,r,i,n){let a=e.href,o=e.title||null,s=t[1].replace(n.other.outputLinkReplace,"$1"),c=t[0].charAt(0)==="!";i.state.inLink=!0;let l=i.state.linkEmitted,d=i.state.inRawBlock;i.state.linkEmitted=!1;let u=i.inlineTokens(s),p=i.state.linkEmitted;if(i.state.linkEmitted=l,i.state.inLink=!1,!c){if(p){i.state.inRawBlock=d;return}i.state.linkEmitted=!0}return{type:c?"image":"link",raw:r,href:a,title:o,text:s,tokens:u}}function DC(t,e,r){let i=t.match(r.other.indentCodeCompensation);if(i===null)return e;let n=i[1];return e.split(`
173
+ `)}function qC(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let i=0;i<t.length;i++)if(t[i]==="\\")i++;else if(t[i]===e[0])r++;else if(t[i]===e[1]&&(r--,r<0))return i;return r>0?-2:-1}function MC(t,e=0){let r=e,i="";for(let n of t)if(n===" "){let a=4-r%4;i+=" ".repeat(a),r+=a}else i+=n,r++;return i}function ym(t,e,r,i,n){let a=e.href,o=e.title||null,s=t[1].replace(n.other.outputLinkReplace,"$1"),c=t[0].charAt(0)==="!";i.state.inLink=!0;let l=i.state.linkEmitted,d=i.state.inRawBlock;i.state.linkEmitted=!1;let u=i.inlineTokens(s),p=i.state.linkEmitted;if(i.state.linkEmitted=l,i.state.inLink=!1,!c){if(p){i.state.inRawBlock=d;return}i.state.linkEmitted=!0}return{type:c?"image":"link",raw:r,href:a,title:o,text:s,tokens:u}}function VC(t,e,r){let i=t.match(r.other.indentCodeCompensation);if(i===null)return e;let n=i[1];return e.split(`
170
174
  `).map(a=>{let o=a.match(r.other.beginningSpace);if(o===null)return a;let[s]=o;return s.length>=n.length?a.slice(n.length):a}).join(`
171
- `)}var Fo=class{options;rules;lexer;constructor(t){this.options=t||mr}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let r=this.options.pedantic?e[0]:mm(e[0]),i=r.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:r,codeBlockStyle:"indented",text:i}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let r=e[0],i=DC(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let i=Mt(r,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(r=i.trim())}return{type:"heading",raw:Mt(e[0],`
175
+ `)}var qo=class{options;rules;lexer;constructor(t){this.options=t||mr}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let r=this.options.pedantic?e[0]:wm(e[0]),i=r.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:r,codeBlockStyle:"indented",text:i}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let r=e[0],i=VC(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let i=Mt(r,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(r=i.trim())}return{type:"heading",raw:Mt(e[0],`
172
176
  `),depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Mt(e[0],`
173
177
  `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let r=Mt(e[0],`
174
178
  `).split(`
@@ -182,19 +186,19 @@ ${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
182
186
  ${m}`,n=n.substring(0,n.length-f.text.length)+g.text;break}else if(p?.type==="list"){let f=p,m=f.raw+`
183
187
  `+r.join(`
184
188
  `),h=this.list(m);a[a.length-1]=h,i=i.substring(0,i.length-p.raw.length)+h.raw,n=n.substring(0,n.length-f.raw.length)+h.raw,r=m.substring(a.at(-1).raw.length).split(`
185
- `);continue}}return{type:"blockquote",raw:i,tokens:a,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let r=e[1].trim(),i=r.length>1,n={type:"list",raw:"",ordered:i,start:i?+r.slice(0,-1):"",loose:!1,items:[]};r=i?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=i?r:"[*+-]");let a=this.rules.other.listItemRegex(r),o=!1;for(;t;){let c=!1,l="",d="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;l=e[0],t=t.substring(l.length);let u=HC(e[2].split(`
189
+ `);continue}}return{type:"blockquote",raw:i,tokens:a,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let r=e[1].trim(),i=r.length>1,n={type:"list",raw:"",ordered:i,start:i?+r.slice(0,-1):"",loose:!1,items:[]};r=i?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=i?r:"[*+-]");let a=this.rules.other.listItemRegex(r),o=!1;for(;t;){let c=!1,l="",d="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;l=e[0],t=t.substring(l.length);let u=MC(e[2].split(`
186
190
  `,1)[0],e[1].length),p=t.split(`
187
191
  `,1)[0],f=!u.trim(),m=0;if(this.options.pedantic?(m=2,d=u.trimStart()):f?m=e[1].length+1:(m=u.search(this.rules.other.nonSpaceChar),m=m>4?1:m,d=u.slice(m),m+=e[1].length),f&&this.rules.other.blankLine.test(p)&&(l+=p+`
188
192
  `,t=t.substring(p.length+1),c=!0),!c){let h=this.rules.other.nextBulletRegex(m),g=this.rules.other.hrRegex(m),v=this.rules.other.fencesBeginRegex(m),N=this.rules.other.headingBeginRegex(m),b=this.rules.other.htmlBeginRegex(m),y=this.rules.other.blockquoteBeginRegex(m);for(;t;){let E=t.split(`
189
193
  `,1)[0],w;if(p=E,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),w=p):w=p.replace(this.rules.other.tabCharGlobal," "),v.test(p)||N.test(p)||b.test(p)||y.test(p)||h.test(p)||g.test(p))break;if(w.search(this.rules.other.nonSpaceChar)>=m||!p.trim())d+=`
190
194
  `+w.slice(m);else{if(f||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||v.test(u)||N.test(u)||g.test(u))break;d+=`
191
195
  `+p}f=!p.trim(),l+=E+`
192
- `,t=t.substring(E.length+1),u=w.slice(m)}}n.loose||(o?n.loose=!0:this.rules.other.doubleBlankLine.test(l)&&(o=!0)),n.items.push({type:"list_item",raw:l,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),n.raw+=l}let s=n.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let c of n.items)if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),!n.loose){let l=c.tokens.filter(u=>u.type==="space"),d=l.length>0&&l.some(u=>this.rules.other.anyLine.test(u.raw));n.loose=d}for(let c of n.items){let l=c.tokens[0];if(c.task&&(l?.type==="text"||l?.type==="paragraph")){c.text=c.text.replace(this.rules.other.listReplaceTask,""),l.raw=l.raw.replace(this.rules.other.listReplaceTask,""),l.text=l.text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}let d=this.rules.other.listTaskCheckbox.exec(c.raw);if(d){let u={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};c.checked=u.checked,n.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=u.raw+c.tokens[0].raw,c.tokens[0].text=u.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(u)):c.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):c.tokens.unshift(u)}}else c.task&&(c.task=!1)}if(n.loose)for(let c of n.items){c.loose=!0;for(let l of c.tokens)l.type==="text"&&(l.type="paragraph")}return n}}html(t){let e=this.rules.block.html.exec(t);if(e){let r=mm(e[0]);return{type:"html",block:!0,raw:r,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:r}}}def(t){let e=this.rules.block.def.exec(t);if(e){let r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:Mt(e[0],`
193
- `),href:i,title:n}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=hm(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
196
+ `,t=t.substring(E.length+1),u=w.slice(m)}}n.loose||(o?n.loose=!0:this.rules.other.doubleBlankLine.test(l)&&(o=!0)),n.items.push({type:"list_item",raw:l,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),n.raw+=l}let s=n.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let c of n.items)if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),!n.loose){let l=c.tokens.filter(u=>u.type==="space"),d=l.length>0&&l.some(u=>this.rules.other.anyLine.test(u.raw));n.loose=d}for(let c of n.items){let l=c.tokens[0];if(c.task&&(l?.type==="text"||l?.type==="paragraph")){c.text=c.text.replace(this.rules.other.listReplaceTask,""),l.raw=l.raw.replace(this.rules.other.listReplaceTask,""),l.text=l.text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}let d=this.rules.other.listTaskCheckbox.exec(c.raw);if(d){let u={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};c.checked=u.checked,n.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=u.raw+c.tokens[0].raw,c.tokens[0].text=u.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(u)):c.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):c.tokens.unshift(u)}}else c.task&&(c.task=!1)}if(n.loose)for(let c of n.items){c.loose=!0;for(let l of c.tokens)l.type==="text"&&(l.type="paragraph")}return n}}html(t){let e=this.rules.block.html.exec(t);if(e){let r=wm(e[0]);return{type:"html",block:!0,raw:r,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:r}}}def(t){let e=this.rules.block.def.exec(t);if(e){let r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:Mt(e[0],`
197
+ `),href:i,title:n}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=gm(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
194
198
  `):[],a={type:"table",raw:Mt(e[0],`
195
- `),header:[],align:[],rows:[]};if(r.length===i.length){for(let o of i)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<r.length;o++)a.header.push({text:r[o],tokens:this.lexer.inline(r[o]),header:!0,align:a.align[o]});for(let o of n)a.rows.push(hm(o,a.header.length).map((s,c)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:a.align[c]})));return a}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let r=e[1].trim();return{type:"heading",raw:Mt(e[0],`
199
+ `),header:[],align:[],rows:[]};if(r.length===i.length){for(let o of i)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<r.length;o++)a.header.push({text:r[o],tokens:this.lexer.inline(r[o]),header:!0,align:a.align[o]});for(let o of n)a.rows.push(gm(o,a.header.length).map((s,c)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:a.align[c]})));return a}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let r=e[1].trim();return{type:"heading",raw:Mt(e[0],`
196
200
  `),depth:e[2].charAt(0)==="="?1:2,text:r,tokens:this.lexer.inline(r)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let r=e[1].charAt(e[1].length-1)===`
197
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let a=Mt(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{let a=OC(e[2],"()");if(a===-2)return;if(a>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let i=e[2],n="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(i);a&&(i=a[1],n=a[3])}else n=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i=i.slice(1):i=i.slice(1,-1)),vm(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let i=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[i.toLowerCase()];if(!n){let a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return vm(r,n,r[0],this.lexer,this.rules)}}emStrong(t,e,r=""){let i=this.rules.inline.emStrongLDelim.exec(t);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!r||this.rules.inline.punctuation.exec(r))){let n=[...i[0]].length-1,a,o,s=n,c=0,l=i[0][0],d=r===l,u=l==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+n);(i=u.exec(e))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(o=[...a].length,i[3]||i[4]){s+=o;continue}else if(i[5]||i[6]){if(n%3&&!((n+o)%3)){c+=o;continue}if(d)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let p=[...i[0]][0].length,f=t.slice(0,n+i.index+p+o);if(Math.min(n,o)%2){let h=f.slice(1,-1);return{type:"em",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}let m=f.slice(2,-2);return{type:"strong",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(r),n=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return i&&n&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,r=""){let i=this.rules.inline.delLDelim.exec(t);if(i&&(!i[1]||!r||this.rules.inline.punctuation.exec(r))){let n=[...i[0]].length-1,a,o,s=n,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*t.length+n);(i=c.exec(e))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a||(o=[...a].length,o!==n))continue;if(i[3]||i[4]){s+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s);let l=[...i[0]][0].length,d=t.slice(0,n+i.index+l+o),u=d.slice(n,-n);return{type:"del",raw:d,text:u,tokens:this.lexer.inlineTokens(u)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let r,i;return e[2]==="@"?(r=e[1],i="mailto:"+r):(r=e[1],i=r),{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},Ee=class tu{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||mr,this.options.tokenizer=this.options.tokenizer||new Fo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let r={other:te,block:Bo.normal,inline:Nn.normal};this.options.pedantic?(r.block=Bo.pedantic,r.inline=Nn.pedantic):this.options.gfm&&(r.block=Bo.gfm,this.options.breaks?r.inline=Nn.breaks:r.inline=Nn.gfm),this.tokenizer.rules=r}static get rules(){return{block:Bo,inline:Nn}}static lex(e,r){return new tu(r).lex(e)}static lexInline(e,r){return new tu(r).inlineTokens(e)}lex(e){e=e.replace(te.carriageReturn,`
201
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let a=Mt(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{let a=qC(e[2],"()");if(a===-2)return;if(a>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let i=e[2],n="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(i);a&&(i=a[1],n=a[3])}else n=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i=i.slice(1):i=i.slice(1,-1)),ym(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let i=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[i.toLowerCase()];if(!n){let a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return ym(r,n,r[0],this.lexer,this.rules)}}emStrong(t,e,r=""){let i=this.rules.inline.emStrongLDelim.exec(t);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!r||this.rules.inline.punctuation.exec(r))){let n=[...i[0]].length-1,a,o,s=n,c=0,l=i[0][0],d=r===l,u=l==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+n);(i=u.exec(e))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(o=[...a].length,i[3]||i[4]){s+=o;continue}else if(i[5]||i[6]){if(n%3&&!((n+o)%3)){c+=o;continue}if(d)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let p=[...i[0]][0].length,f=t.slice(0,n+i.index+p+o);if(Math.min(n,o)%2){let h=f.slice(1,-1);return{type:"em",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}let m=f.slice(2,-2);return{type:"strong",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(r),n=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return i&&n&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,r=""){let i=this.rules.inline.delLDelim.exec(t);if(i&&(!i[1]||!r||this.rules.inline.punctuation.exec(r))){let n=[...i[0]].length-1,a,o,s=n,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*t.length+n);(i=c.exec(e))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a||(o=[...a].length,o!==n))continue;if(i[3]||i[4]){s+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s);let l=[...i[0]][0].length,d=t.slice(0,n+i.index+l+o),u=d.slice(n,-n);return{type:"del",raw:d,text:u,tokens:this.lexer.inlineTokens(u)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let r,i;return e[2]==="@"?(r=e[1],i="mailto:"+r):(r=e[1],i=r),{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},Ee=class ru{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||mr,this.options.tokenizer=this.options.tokenizer||new qo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let r={other:te,block:Lo.normal,inline:bn.normal};this.options.pedantic?(r.block=Lo.pedantic,r.inline=bn.pedantic):this.options.gfm&&(r.block=Lo.gfm,this.options.breaks?r.inline=bn.breaks:r.inline=bn.gfm),this.tokenizer.rules=r}static get rules(){return{block:Lo,inline:bn}}static lex(e,r){return new ru(r).lex(e)}static lexInline(e,r){return new ru(r).inlineTokens(e)}lex(e){e=e.replace(te.carriageReturn,`
198
202
  `),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let i=this.inlineQueue[r];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],i=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(te.tabCharGlobal," ").replace(te.spaceLine,""));let n=1/0;for(;e;){if(e.length<n)n=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let a;if(this.options.extensions?.block?.some(s=>(a=s.call({lexer:this},e,r))?(e=e.substring(a.raw.length),r.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let s=r.at(-1);a.raw.length===1&&s!==void 0?s.raw+=`
199
203
  `:r.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let s=r.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
200
204
  `)?"":`
@@ -208,7 +212,7 @@ ${m}`,n=n.substring(0,n.length-f.text.length)+g.text;break}else if(p?.type==="li
208
212
  `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(a),i=o.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let s=r.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
209
213
  `)?"":`
210
214
  `)+a.raw,s.text+=`
211
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}linkInText(e){if(!e.includes("["))return!1;let r=this.tokenizer.rules.inline.link;for(let i of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(r.test(i[0])&&e.charAt(i.index-1)!=="!")return!0;for(let i of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let n=i[0],a=n.lastIndexOf("[");if(!(n.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,n.slice(a+1,-1)))&&!(a>1&&this.linkInText(n.slice(1,a-1))))return!0}return!1}inlineTokens(e,r=[]){this.tokenizer.lexer=this;let i=e;if(this.tokens.links&&e.includes("[")){let s=this.tokenizer.rules.inline.reflinkSearch,c=l=>{let d=l.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,l.slice(d+1,-1)))return l;if(d>1&&l.charAt(0)!=="!"){let u=l.slice(1,d-1);if(this.linkInText(u))return"["+u.replace(s,c)+"]["+"a".repeat(l.length-d-2)+"]"}return"["+"a".repeat(l.length-2)+"]"};i=i.replace(s,c)}i=i.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),i=i.replace(this.tokenizer.rules.inline.blockSkip,(s,c,l)=>{let d=l?l.length:0;return s.slice(0,d)+"["+"a".repeat(s.length-d-2)+"]"}),i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let n=!1,a="",o=1/0;for(;e;){if(e.length<o)o=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}n||(a=""),n=!1;let s;if(this.options.extensions?.inline?.some(l=>(s=l.call({lexer:this},e,r))?(e=e.substring(s.raw.length),r.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let l=r.at(-1);s.type==="text"&&l?.type==="text"?(l.raw+=s.raw,l.text+=s.text):r.push(s);continue}if(s=this.tokenizer.emStrong(e,i,a)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.del(e,i,a)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),r.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),r.push(s);continue}let c=e;if(this.options.extensions?.startInline){let l=1/0,d=e.slice(1),u;this.options.extensions.startInline.forEach(p=>{u=p.call({lexer:this},d),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(c=e.substring(0,l+1))}if(s=this.tokenizer.inlineText(c)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(a=s.raw.slice(-1)),n=!0;let l=r.at(-1);l?.type==="text"?(l.raw+=s.raw,l.text+=s.text):r.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return r}infiniteLoopError(e){let r="Infinite loop on byte: "+e;if(this.options.silent)console.error(r);else throw new Error(r)}},qo=class{options;parser;constructor(t){this.options=t||mr}space(t){return""}code({text:t,lang:e,escaped:r}){let i=(e||"").match(te.notSpaceStart)?.[0],n=t.replace(te.endingNewline,"")+`
215
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}linkInText(e){if(!e.includes("["))return!1;let r=this.tokenizer.rules.inline.link;for(let i of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(r.test(i[0])&&e.charAt(i.index-1)!=="!")return!0;for(let i of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let n=i[0],a=n.lastIndexOf("[");if(!(n.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,n.slice(a+1,-1)))&&!(a>1&&this.linkInText(n.slice(1,a-1))))return!0}return!1}inlineTokens(e,r=[]){this.tokenizer.lexer=this;let i=e;if(this.tokens.links&&e.includes("[")){let s=this.tokenizer.rules.inline.reflinkSearch,c=l=>{let d=l.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,l.slice(d+1,-1)))return l;if(d>1&&l.charAt(0)!=="!"){let u=l.slice(1,d-1);if(this.linkInText(u))return"["+u.replace(s,c)+"]["+"a".repeat(l.length-d-2)+"]"}return"["+"a".repeat(l.length-2)+"]"};i=i.replace(s,c)}i=i.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),i=i.replace(this.tokenizer.rules.inline.blockSkip,(s,c,l)=>{let d=l?l.length:0;return s.slice(0,d)+"["+"a".repeat(s.length-d-2)+"]"}),i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let n=!1,a="",o=1/0;for(;e;){if(e.length<o)o=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}n||(a=""),n=!1;let s;if(this.options.extensions?.inline?.some(l=>(s=l.call({lexer:this},e,r))?(e=e.substring(s.raw.length),r.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let l=r.at(-1);s.type==="text"&&l?.type==="text"?(l.raw+=s.raw,l.text+=s.text):r.push(s);continue}if(s=this.tokenizer.emStrong(e,i,a)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.del(e,i,a)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),r.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),r.push(s);continue}let c=e;if(this.options.extensions?.startInline){let l=1/0,d=e.slice(1),u;this.options.extensions.startInline.forEach(p=>{u=p.call({lexer:this},d),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(c=e.substring(0,l+1))}if(s=this.tokenizer.inlineText(c)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(a=s.raw.slice(-1)),n=!0;let l=r.at(-1);l?.type==="text"?(l.raw+=s.raw,l.text+=s.text):r.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return r}infiniteLoopError(e){let r="Infinite loop on byte: "+e;if(this.options.silent)console.error(r);else throw new Error(r)}},Mo=class{options;parser;constructor(t){this.options=t||mr}space(t){return""}code({text:t,lang:e,escaped:r}){let i=(e||"").match(te.notSpaceStart)?.[0],n=t.replace(te.endingNewline,"")+`
212
216
  `;return i?'<pre><code class="language-'+Ze(i)+'">'+(r?n:Ze(n,!0))+`</code></pre>
213
217
  `:"<pre><code>"+(r?n:Ze(n,!0))+`</code></pre>
214
218
  `}blockquote({tokens:t}){return`<blockquote>
@@ -226,26 +230,26 @@ ${this.parser.parse(t)}</blockquote>
226
230
  `}tablerow({text:t}){return`<tr>
227
231
  ${t}</tr>
228
232
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>
229
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ze(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:r}){let i=this.parser.parseInline(r),n=fm(t);if(n===null)return i;t=n;let a='<a href="'+t+'"';return e&&(a+=' title="'+Ze(e)+'"'),a+=">"+i+"</a>",a}image({href:t,title:e,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let n=fm(t);if(n===null)return Ze(r);t=n;let a=`<img src="${t}" alt="${Ze(r)}"`;return e&&(a+=` title="${Ze(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ze(t.text)}},uu=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Le=class ru{options;renderer;textRenderer;constructor(e){this.options=e||mr,this.options.renderer=this.options.renderer||new qo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new uu}static parse(e,r){return new ru(r).parse(e)}static parseInline(e,r){return new ru(r).parseInline(e)}parse(e){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let n=e[i];if(this.options.extensions?.renderers?.[n.type]){let o=n,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){r+=s||"";continue}}let a=n;switch(a.type){case"space":{r+=this.renderer.space(a);break}case"hr":{r+=this.renderer.hr(a);break}case"heading":{r+=this.renderer.heading(a);break}case"code":{r+=this.renderer.code(a);break}case"table":{r+=this.renderer.table(a);break}case"blockquote":{r+=this.renderer.blockquote(a);break}case"list":{r+=this.renderer.list(a);break}case"checkbox":{r+=this.renderer.checkbox(a);break}case"html":{r+=this.renderer.html(a);break}case"def":{r+=this.renderer.def(a);break}case"paragraph":{r+=this.renderer.paragraph(a);break}case"text":{r+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(e,r=this.renderer){this.renderer.parser=this;let i="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions?.renderers?.[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(a.type)){i+=s||"";continue}}let o=a;switch(o.type){case"escape":{i+=r.text(o);break}case"html":{i+=r.html(o);break}case"link":{i+=r.link(o);break}case"image":{i+=r.image(o);break}case"checkbox":{i+=r.checkbox(o);break}case"strong":{i+=r.strong(o);break}case"em":{i+=r.em(o);break}case"codespan":{i+=r.codespan(o);break}case"br":{i+=r.br(o);break}case"del":{i+=r.del(o);break}case"text":{i+=r.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return i}},bn=class{options;block;constructor(t){this.options=t||mr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Ee.lex:Ee.lexInline}provideParser(t=this.block){return t?Le.parse:Le.parseInline}},BC=class{defaults=iu();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Le;Renderer=qo;TextRenderer=uu;Lexer=Ee;Tokenizer=Fo;Hooks=bn;constructor(...t){this.use(...t)}walkTokens(t,e){let r=[];for(let i of t)switch(r=r.concat(e.call(this,i)),i.type){case"table":{let n=i;for(let a of n.header)r=r.concat(this.walkTokens(a.tokens,e));for(let a of n.rows)for(let o of a)r=r.concat(this.walkTokens(o.tokens,e));break}case"list":{let n=i;r=r.concat(this.walkTokens(n.items,e));break}default:{let n=i;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(a=>{let o=n[a].flat(1/0);r=r.concat(this.walkTokens(o,e))}):n.tokens&&(r=r.concat(this.walkTokens(n.tokens,e)))}}return r}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let i={...r};if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let a=e.renderers[n.name];a?e.renderers[n.name]=function(...o){let s=n.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[n.level];a?a.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),i.extensions=e),r.renderer){let n=this.defaults.renderer||new qo(this.defaults);for(let a in r.renderer){if(!(a in n))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=r.renderer[o],c=n[o];n[o]=(...l)=>{let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d||""}}i.renderer=n}if(r.tokenizer){let n=this.defaults.tokenizer||new Fo(this.defaults);for(let a in r.tokenizer){if(!(a in n))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=r.tokenizer[o],c=n[o];n[o]=(...l)=>{let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d}}i.tokenizer=n}if(r.hooks){let n=this.defaults.hooks||new bn;for(let a in r.hooks){if(!(a in n))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=r.hooks[o],c=n[o];bn.passThroughHooks.has(a)?n[o]=l=>{if(this.defaults.async&&bn.passThroughHooksRespectAsync.has(a))return(async()=>{let u=await s.call(n,l);return c.call(n,u)})();let d=s.call(n,l);return c.call(n,d)}:n[o]=(...l)=>{if(this.defaults.async)return(async()=>{let u=await s.apply(n,l);return u===!1&&(u=await c.apply(n,l)),u})();let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d}}i.hooks=n}if(r.walkTokens){let n=this.defaults.walkTokens,a=r.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),n&&(s=s.concat(n.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ee.lex(t,e??this.defaults)}parser(t,e){return Le.parse(t,e??this.defaults)}parseMarkdown(t){return(e,r)=>{let i={...r},n={...this.defaults,...i},a=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=t),n.async)return(async()=>{let o=n.hooks?await n.hooks.preprocess(e):e,s=await(n.hooks?await n.hooks.provideLexer(t):t?Ee.lex:Ee.lexInline)(o,n),c=n.hooks?await n.hooks.processAllTokens(s):s;n.walkTokens&&await Promise.all(this.walkTokens(c,n.walkTokens));let l=await(n.hooks?await n.hooks.provideParser(t):t?Le.parse:Le.parseInline)(c,n);return n.hooks?await n.hooks.postprocess(l):l})().catch(a);try{n.hooks&&(e=n.hooks.preprocess(e));let o=(n.hooks?n.hooks.provideLexer(t):t?Ee.lex:Ee.lexInline)(e,n);n.hooks&&(o=n.hooks.processAllTokens(o)),n.walkTokens&&this.walkTokens(o,n.walkTokens);let s=(n.hooks?n.hooks.provideParser(t):t?Le.parse:Le.parseInline)(o,n);return n.hooks&&(s=n.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(t,e){return r=>{if(r.message+=`
230
- Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Ze(r.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(r);throw r}}},hr=new BC;function $(t,e){return hr.parse(t,e)}$.options=$.setOptions=function(t){return hr.setOptions(t),$.defaults=hr.defaults,gm($.defaults),$};$.getDefaults=iu;$.defaults=mr;function LC(...t){return hr.use(...t),$.defaults=hr.defaults,gm($.defaults),$}$.use=LC;$.walkTokens=function(t,e){return hr.walkTokens(t,e)};$.parseInline=hr.parseInline;$.Parser=Le;$.parser=Le.parse;$.Renderer=qo;$.TextRenderer=uu;$.Lexer=Ee;$.lexer=Ee.lex;$.Tokenizer=Fo;$.Hooks=bn;$.parse=$;var mL=$.options,vL=$.setOptions,gL=$.walkTokens,wL=$.parseInline;var yL=Le.parse,NL=Ee.lex;H();ue();F();K();ll();rl();Te();or();H();Zt();hn();I();Zt();Vt();ve();var _m=et(Me(),1);ot();var QL=new Set("a an and are as at be by for from in is it of on or that the this to with you your".split(" "));var nF=256*1024;Te();or();Lt();var YC=Ha("en",{compact:!0});function QC(t,e){let r=ei.relative(ei.resolve(t),ei.resolve(e));if(ei.isAbsolute(r)||r===".."||r.startsWith(`..${ei.sep}`))throw new Error("Native local check cwd escaped the project root");let i=r.length===0?".":r.split(ei.sep).join("/");return Bh(t,i),i}function fu(t,e=t.workspace.projectRoot){return t.checks.map(r=>{let[i,...n]=r.argv;if(!i)throw new Error(`Native local check ${r.id} has no executable`);return{id:r.id,name:r.name,executable:i,argv:n,cwdRef:QC(e,r.cwd),timeoutMs:r.timeoutMs,repeatable:r.repeatable}})}var yq=1024*1024*1024;ve();K();cr();Lt();Te();or();K();ko();hn();Lt();K();Lt();K();Nl();Gi();import An from"path";import{realpathSync as IR}from"fs";function $m(t,e){let r=d=>d!==null&&typeof d=="object"&&!Array.isArray(d)?d:{},i=r(t),n=r(i.entry),a=r(i.state??n.state??i),o=r(i.preparation??i.workspace??n.workspace),s=r(i.continuation??n.continuation),c=typeof o.projectRoot=="string"&&o.projectRoot!=="."?o.projectRoot:e??null,l=a.stateVersion??a.state_version;return{phase:typeof a.phase=="string"?a.phase:null,status:typeof a.status=="string"?a.status:null,stateVersion:typeof l=="number"?l:null,workspace:{cwd:c},continuation:Object.keys(s).length?{...s,cwd:c}:null}}var mt={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Om(t){return t?t.command?`${mt.next} ${t.command}`:t.ask_user?`${mt.next} ${t.ask_user}`:null:null}function Hm(t,e){let r=[t.summary],i=Om(t.next);return i&&r.push(i),t.user_message&&r.push("",mt.relay,t.user_message),e!==void 0&&r.push("",mt.details,JSON.stringify(e,null,2)),`${r.join(`
233
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ze(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:r}){let i=this.parser.parseInline(r),n=vm(t);if(n===null)return i;t=n;let a='<a href="'+t+'"';return e&&(a+=' title="'+Ze(e)+'"'),a+=">"+i+"</a>",a}image({href:t,title:e,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let n=vm(t);if(n===null)return Ze(r);t=n;let a=`<img src="${t}" alt="${Ze(r)}"`;return e&&(a+=` title="${Ze(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ze(t.text)}},du=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Le=class iu{options;renderer;textRenderer;constructor(e){this.options=e||mr,this.options.renderer=this.options.renderer||new Mo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new du}static parse(e,r){return new iu(r).parse(e)}static parseInline(e,r){return new iu(r).parseInline(e)}parse(e){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let n=e[i];if(this.options.extensions?.renderers?.[n.type]){let o=n,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){r+=s||"";continue}}let a=n;switch(a.type){case"space":{r+=this.renderer.space(a);break}case"hr":{r+=this.renderer.hr(a);break}case"heading":{r+=this.renderer.heading(a);break}case"code":{r+=this.renderer.code(a);break}case"table":{r+=this.renderer.table(a);break}case"blockquote":{r+=this.renderer.blockquote(a);break}case"list":{r+=this.renderer.list(a);break}case"checkbox":{r+=this.renderer.checkbox(a);break}case"html":{r+=this.renderer.html(a);break}case"def":{r+=this.renderer.def(a);break}case"paragraph":{r+=this.renderer.paragraph(a);break}case"text":{r+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(e,r=this.renderer){this.renderer.parser=this;let i="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions?.renderers?.[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(a.type)){i+=s||"";continue}}let o=a;switch(o.type){case"escape":{i+=r.text(o);break}case"html":{i+=r.html(o);break}case"link":{i+=r.link(o);break}case"image":{i+=r.image(o);break}case"checkbox":{i+=r.checkbox(o);break}case"strong":{i+=r.strong(o);break}case"em":{i+=r.em(o);break}case"codespan":{i+=r.codespan(o);break}case"br":{i+=r.br(o);break}case"del":{i+=r.del(o);break}case"text":{i+=r.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return i}},kn=class{options;block;constructor(t){this.options=t||mr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Ee.lex:Ee.lexInline}provideParser(t=this.block){return t?Le.parse:Le.parseInline}},WC=class{defaults=nu();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Le;Renderer=Mo;TextRenderer=du;Lexer=Ee;Tokenizer=qo;Hooks=kn;constructor(...t){this.use(...t)}walkTokens(t,e){let r=[];for(let i of t)switch(r=r.concat(e.call(this,i)),i.type){case"table":{let n=i;for(let a of n.header)r=r.concat(this.walkTokens(a.tokens,e));for(let a of n.rows)for(let o of a)r=r.concat(this.walkTokens(o.tokens,e));break}case"list":{let n=i;r=r.concat(this.walkTokens(n.items,e));break}default:{let n=i;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(a=>{let o=n[a].flat(1/0);r=r.concat(this.walkTokens(o,e))}):n.tokens&&(r=r.concat(this.walkTokens(n.tokens,e)))}}return r}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let i={...r};if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let a=e.renderers[n.name];a?e.renderers[n.name]=function(...o){let s=n.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[n.level];a?a.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),i.extensions=e),r.renderer){let n=this.defaults.renderer||new Mo(this.defaults);for(let a in r.renderer){if(!(a in n))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=r.renderer[o],c=n[o];n[o]=(...l)=>{let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d||""}}i.renderer=n}if(r.tokenizer){let n=this.defaults.tokenizer||new qo(this.defaults);for(let a in r.tokenizer){if(!(a in n))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=r.tokenizer[o],c=n[o];n[o]=(...l)=>{let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d}}i.tokenizer=n}if(r.hooks){let n=this.defaults.hooks||new kn;for(let a in r.hooks){if(!(a in n))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=r.hooks[o],c=n[o];kn.passThroughHooks.has(a)?n[o]=l=>{if(this.defaults.async&&kn.passThroughHooksRespectAsync.has(a))return(async()=>{let u=await s.call(n,l);return c.call(n,u)})();let d=s.call(n,l);return c.call(n,d)}:n[o]=(...l)=>{if(this.defaults.async)return(async()=>{let u=await s.apply(n,l);return u===!1&&(u=await c.apply(n,l)),u})();let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d}}i.hooks=n}if(r.walkTokens){let n=this.defaults.walkTokens,a=r.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),n&&(s=s.concat(n.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ee.lex(t,e??this.defaults)}parser(t,e){return Le.parse(t,e??this.defaults)}parseMarkdown(t){return(e,r)=>{let i={...r},n={...this.defaults,...i},a=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=t),n.async)return(async()=>{let o=n.hooks?await n.hooks.preprocess(e):e,s=await(n.hooks?await n.hooks.provideLexer(t):t?Ee.lex:Ee.lexInline)(o,n),c=n.hooks?await n.hooks.processAllTokens(s):s;n.walkTokens&&await Promise.all(this.walkTokens(c,n.walkTokens));let l=await(n.hooks?await n.hooks.provideParser(t):t?Le.parse:Le.parseInline)(c,n);return n.hooks?await n.hooks.postprocess(l):l})().catch(a);try{n.hooks&&(e=n.hooks.preprocess(e));let o=(n.hooks?n.hooks.provideLexer(t):t?Ee.lex:Ee.lexInline)(e,n);n.hooks&&(o=n.hooks.processAllTokens(o)),n.walkTokens&&this.walkTokens(o,n.walkTokens);let s=(n.hooks?n.hooks.provideParser(t):t?Le.parse:Le.parseInline)(o,n);return n.hooks&&(s=n.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(t,e){return r=>{if(r.message+=`
234
+ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Ze(r.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(r);throw r}}},hr=new WC;function $(t,e){return hr.parse(t,e)}$.options=$.setOptions=function(t){return hr.setOptions(t),$.defaults=hr.defaults,Nm($.defaults),$};$.getDefaults=nu;$.defaults=mr;function zC(...t){return hr.use(...t),$.defaults=hr.defaults,Nm($.defaults),$}$.use=zC;$.walkTokens=function(t,e){return hr.walkTokens(t,e)};$.parseInline=hr.parseInline;$.Parser=Le;$.parser=Le.parse;$.Renderer=Mo;$.TextRenderer=du;$.Lexer=Ee;$.lexer=Ee.lex;$.Tokenizer=qo;$.Hooks=kn;$.parse=$;var EL=$.options,xL=$.setOptions,CL=$.walkTokens,RL=$.parseInline;var PL=Le.parse,_L=Ee.lex;H();ue();F();K();ul();il();Te();or();H();Zt();mn();I();Zt();Vt();ve();var Tm=et(Me(),1);ot();var sF=new Set("a an and are as at be by for from in is it of on or that the this to with you your".split(" "));var fF=256*1024;Te();or();Lt();var rR=Da("en",{compact:!0});function nR(t,e){let r=ei.relative(ei.resolve(t),ei.resolve(e));if(ei.isAbsolute(r)||r===".."||r.startsWith(`..${ei.sep}`))throw new Error("Native local check cwd escaped the project root");let i=r.length===0?".":r.split(ei.sep).join("/");return qh(t,i),i}function hu(t,e=t.workspace.projectRoot){return t.checks.map(r=>{let[i,...n]=r.argv;if(!i)throw new Error(`Native local check ${r.id} has no executable`);return{id:r.id,name:r.name,executable:i,argv:n,cwdRef:nR(e,r.cwd),timeoutMs:r.timeoutMs,repeatable:r.repeatable}})}var Pq=1024*1024*1024;ve();K();cr();Lt();Te();or();K();So();mn();Lt();K();Lt();K();bl();Ji();import In from"path";import{realpathSync as DR}from"fs";function Dm(t,e){let r=d=>d!==null&&typeof d=="object"&&!Array.isArray(d)?d:{},i=r(t),n=r(i.entry),a=r(i.state??n.state??i),o=r(i.preparation??i.workspace??n.workspace),s=r(i.continuation??n.continuation),c=typeof o.projectRoot=="string"&&o.projectRoot!=="."?o.projectRoot:e??null,l=a.stateVersion??a.state_version;return{phase:typeof a.phase=="string"?a.phase:null,status:typeof a.status=="string"?a.status:null,stateVersion:typeof l=="number"?l:null,workspace:{cwd:c},continuation:Object.keys(s).length?{...s,cwd:c}:null}}var mt={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Bm(t){return t?t.command?`${mt.next} ${t.command}`:t.ask_user?`${mt.next} ${t.ask_user}`:null:null}function Lm(t,e){let r=[t.summary],i=Bm(t.next);return i&&r.push(i),t.user_message&&r.push("",mt.relay,t.user_message),e!==void 0&&r.push("",mt.details,JSON.stringify(e,null,2)),`${r.join(`
231
235
  `)}
232
- `}function Dm(t,e,r){let i=[t.summary],n=Om(t.next);return n&&i.push(n),t.user_message&&i.push("",mt.relay,t.user_message),i.push("",`${mt.detail} ${e}`),r!==void 0&&i.push("",mt.details,JSON.stringify(r,null,2)),i.join(`
233
- `)}F();ue();F();var eR=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});Vt();Ne();ve();I();rn();ue();Vt();Vr();ur();Io();import{execFile as oR}from"node:child_process";Pr();$i();ql();import{promisify as sR}from"node:util";H();du();I();Ve();Vt();K();Ft();var _n=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};Vr();En();ur();var NV=64*1024;var bV=3600*1e3;var kV=sR(oR);En();var Wo=class extends Error{details;constructor(e){let r=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=e}};Oe();Ne();H();Ve();I();Ne();uo();H();Zt();Vt();var NW=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});Oe();Ki();K();I();Ne();ve();K();var RW=16*1024;uo();var zo=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},Go=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};I();ve();function C(t,e,r){return t==="zh-CN"?r:e}var vu={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Fm(t,e){return typeof t=="string"&&vu[t]?C(e,vu[t].en,vu[t].zh):typeof t=="string"?t:""}function gu(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&typeof e.passed=="number"&&typeof e.failed=="number"&&typeof e.blocked=="number"&&typeof e.pending=="number"}function vR(t){let e={total:t.length,passed:0,failed:0,blocked:0,pending:0};for(let r of t){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;e[i]+=1}return e}function qm(t,e){let r=[];t.failed>0&&r.push(C(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(C(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(C(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=C(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Mm(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.change!="string"||e.disposition!=="continue"&&e.disposition!=="await-user"&&e.disposition!=="blocked"&&e.disposition!=="done"||e.commandArgs!==null&&e.commandArgs!==void 0&&!Array.isArray(e.commandArgs))return!1;let r=e.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function wu(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function gR(t,e,r){return t==="done"?C(r,"complete","已完成"):t==="await-user"?C(r,"waiting for a user decision","等待用户决定"):t==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):e?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function wR(t,e,r){let i=wu(t),n=[];r&&n.push(r);let a=C(i,`Change ${t.change}`,`需求 ${t.change}`),o=Fm(t.phase,i),s=gR(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(qm(e,i));let c=t.userCommunication,l=Vm(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Vm(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:C(e,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(t.commandArgs&&t.commandArgs.length>0)return{command:t.commandArgs.join(" ")};if(t.disposition==="done")return{ask_user:C(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:C(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function yR(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function NR(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=Fm(t.phase,e),n=t.status==="await-user"?C(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?C(e,"paused","已暂停"):t.status==="done"?C(e,"complete","已完成"):C(e,"in progress","进行中"),a=gu(t.acceptance)?`${C(e,", ",",")}${qm(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function bR(t){for(let e of t){let r=e.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function kR(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.healthy!="boolean"?!1:e.findings===void 0||Array.isArray(e.findings)}function SR(t){if(t.healthy){let i=t.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=ER(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:C("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:C("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function ER(t){return Mm(t)?Vm(t,wu(t)):void 0}function Wm(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(kR(e))return SR(e);if(yR(e)){let i=bR(e.items);return{summary:[e.total===e.items.length?C(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):C(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>NR(a,i))].join(`
234
- `)}}let r=e.continuation;if(Mm(r)){let i=wu(r),n=wR(r,xR(e),RR(e,i));return CR(e)==="unconfirmed"?{...n,summary:`${n.summary}${C(i,"; the dispatched Verifier has not confirmed startup yet — verify the subagent actually launched before waiting on it",";已派发的 Verifier 尚未确认启动——先核实子代理确实启动,再继续等待")}`}:n}if(typeof e.artifactRoot=="string"&&typeof e.nativeRoot=="string"){let i=e.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in e;return{summary:C(i,n?`Comet Native artifacts live under ${e.artifactRoot} (state root: ${e.nativeRoot}).`:`Initialized Comet Native at ${e.nativeRoot} (artifacts: ${e.artifactRoot}).`,n?`Comet Native 产物位于 ${e.artifactRoot}(状态根目录:${e.nativeRoot})。`:`Comet Native 已初始化于 ${e.nativeRoot}(产物目录:${e.artifactRoot})。`)}}}function xR(t){if(gu(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(gu(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return vR(r.acceptance)}return null}function CR(t){let e=t.localExecution;if(!e||typeof e!="object"||Array.isArray(e))return;let r=e.verifierStartup;if(!(!r||typeof r!="object"||Array.isArray(r)))return r.confirmation}function RR(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return C(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?C(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function zm(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"document-invalid":return{summary:t.message,...typeof r.change=="string"?{next:{command:`comet native next ${r.change} --summary <summary>`}}:{}};case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}eo();to();var Gm=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--verbose Append the raw machine projection after the human/agent text.","--help Show help without requiring an initialized project."],yu=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",agentQuickStart:["Run `comet native status --json` to discover active changes.","Select an existing change with `select`, or create one with `new`.","In `agent.workspace.cwd`, execute the exact `agent.continuation.commandArgs` returned by Runtime.","Use `agent.continuation.inputOptions` templates for JSON input; do not reconstruct fields from memory."],subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec disassociate Revoke a capability association through Runtime.","spec remove Record a complete capability removal intent.","spec sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:Gm,output:"A human summary plus a NEXT step by default (RELAY TO USER blocks carry user decisions); use --json for the structured envelope, --verbose to append the raw machine projection.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--task <text>] [--capability <id>] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--task <text> Search Project Knowledge for an existing capability and save a revocable association draft.","--capability <id> Directly validate and associate an existing capability without retrieval.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, canonical artifact paths, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN",'comet native new add-sms-login --task "add SMS login to authentication"',"comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:`comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability
236
+ `}function Fm(t,e,r){let i=[t.summary],n=Bm(t.next);return n&&i.push(n),t.user_message&&i.push("",mt.relay,t.user_message),i.push("",`${mt.detail} ${e}`),r!==void 0&&i.push("",mt.details,JSON.stringify(r,null,2)),i.join(`
237
+ `)}F();ue();F();var oR=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});Vt();Ne();ve();I();nn();ue();Vt();Vr();ur();To();import{execFile as pR}from"node:child_process";Pr();$i();Ml();import{promisify as fR}from"node:util";H();pu();I();Ve();Vt();K();Ft();var An=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};Vr();xn();ur();var _V=64*1024;var AV=3600*1e3;var IV=fR(pR);xn();var zo=class extends Error{details;constructor(e){let r=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=e}};Oe();Ne();H();Ve();I();Ne();po();H();Zt();Vt();var _W=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});Oe();Yi();K();I();Ne();ve();K();var HW=16*1024;po();var Go=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},Jo=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};I();ve();function C(t,e,r){return t==="zh-CN"?r:e}var gu={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Vm(t,e){return typeof t=="string"&&gu[t]?C(e,gu[t].en,gu[t].zh):typeof t=="string"?t:""}function wu(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&typeof e.passed=="number"&&typeof e.failed=="number"&&typeof e.blocked=="number"&&typeof e.pending=="number"}function kR(t){let e={total:t.length,passed:0,failed:0,blocked:0,pending:0};for(let r of t){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;e[i]+=1}return e}function Wm(t,e){let r=[];t.failed>0&&r.push(C(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(C(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(C(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=C(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function zm(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.change!="string"||e.disposition!=="continue"&&e.disposition!=="await-user"&&e.disposition!=="blocked"&&e.disposition!=="done"||e.commandArgs!==null&&e.commandArgs!==void 0&&!Array.isArray(e.commandArgs))return!1;let r=e.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function yu(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function SR(t,e,r){return t==="done"?C(r,"complete","已完成"):t==="await-user"?C(r,"waiting for a user decision","等待用户决定"):t==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):e?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function ER(t,e,r){let i=yu(t),n=[];r&&n.push(r);let a=C(i,`Change ${t.change}`,`需求 ${t.change}`),o=Vm(t.phase,i),s=SR(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(Wm(e,i));let c=t.userCommunication,l=Gm(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Gm(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:C(e,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(t.commandArgs&&t.commandArgs.length>0)return{command:t.commandArgs.join(" ")};if(t.disposition==="done")return{ask_user:C(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:C(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function xR(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function CR(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=Vm(t.phase,e),n=t.status==="await-user"?C(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?C(e,"paused","已暂停"):t.status==="done"?C(e,"complete","已完成"):C(e,"in progress","进行中"),a=wu(t.acceptance)?`${C(e,", ",",")}${Wm(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function RR(t){for(let e of t){let r=e.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function PR(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.healthy!="boolean"?!1:e.findings===void 0||Array.isArray(e.findings)}function _R(t){if(t.healthy){let i=t.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=AR(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:C("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:C("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function AR(t){return zm(t)?Gm(t,yu(t)):void 0}function Jm(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(PR(e))return _R(e);if(xR(e)){let i=RR(e.items);return{summary:[e.total===e.items.length?C(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):C(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>CR(a,i))].join(`
238
+ `)}}let r=e.continuation;if(zm(r)){let i=yu(r),n=ER(r,IR(e),jR(e,i));return TR(e)==="unconfirmed"?{...n,summary:`${n.summary}${C(i,"; the dispatched Verifier has not confirmed startup yet — verify the subagent actually launched before waiting on it",";已派发的 Verifier 尚未确认启动——先核实子代理确实启动,再继续等待")}`}:n}if(typeof e.artifactRoot=="string"&&typeof e.nativeRoot=="string"){let i=e.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in e;return{summary:C(i,n?`Comet Native artifacts live under ${e.artifactRoot} (state root: ${e.nativeRoot}).`:`Initialized Comet Native at ${e.nativeRoot} (artifacts: ${e.artifactRoot}).`,n?`Comet Native 产物位于 ${e.artifactRoot}(状态根目录:${e.nativeRoot})。`:`Comet Native 已初始化于 ${e.nativeRoot}(产物目录:${e.artifactRoot})。`)}}}function IR(t){if(wu(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(wu(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return kR(r.acceptance)}return null}function TR(t){let e=t.localExecution;if(!e||typeof e!="object"||Array.isArray(e))return;let r=e.verifierStartup;if(!(!r||typeof r!="object"||Array.isArray(r)))return r.confirmation}function jR(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return C(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?C(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function Um(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"document-invalid":return{summary:t.message,...typeof r.change=="string"?{next:{command:`comet native next ${r.change} --summary <summary>`}}:{}};case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}to();ro();var Km=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--verbose Append the raw machine projection after the human/agent text.","--help Show help without requiring an initialized project."],Nu=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",agentQuickStart:["Run `comet native status --json` to discover active changes.","Select an existing change with `select`, or create one with `new`.","In `agent.workspace.cwd`, execute the exact `agent.continuation.commandArgs` returned by Runtime.","Use `agent.continuation.inputOptions` templates for JSON input; do not reconstruct fields from memory."],subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec disassociate Revoke a capability association through Runtime.","spec remove Record a complete capability removal intent.","spec sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:Km,output:"A human summary plus a NEXT step by default (RELAY TO USER blocks carry user decisions); use --json for the structured envelope, --verbose to append the raw machine projection.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--task <text>] [--capability <id>] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--task <text> Search Project Knowledge for an existing capability and save a revocable association draft.","--capability <id> Directly validate and associate an existing capability without retrieval.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, canonical artifact paths, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN",'comet native new add-sms-login --task "add SMS login to authentication"',"comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:`comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability
235
239
  comet native spec remove <change-name> <capability>
236
240
  comet native spec sync <change-name> <capability> --input <json-file>`,purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["disassociate <change-name> Revoke a capability association and return to Shape.","remove <change-name> <capability> Record a capability removal.","sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections without changing prose or acceptance."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},"spec disassociate":{usage:"comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability",purpose:"Revoke a capability association through Runtime without hand-editing artifacts.",options:["--expected-state-version <n> State version returned by the latest status response.","--expected-action <action> Must be disassociate-capability."],output:"The updated portable state and continuation with the next Runner action."},"spec sync":{usage:"comet native spec sync <change-name> <capability> --input <json-file>",purpose:"Sync local Markdown link destinations in an already confirmed target spec; semantic edits require Shape.",options:["--input <json-file> Fields: expectedStateVersion, actor, reason, affectedAcceptanceIds, replacements [{from,to}]. Include all acceptance IDs from the affected spec."],output:"The audited portable state, preserved unaffected acceptance results and Build continuation for re-verification."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"A compact summary and NEXT action by default. Use --json to read canonical artifact paths, the portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required. Fill command-template placeholders before executing NEXT commands."},check:{usage:"comet native check <change-name>",purpose:"Legacy-only verification command; not supported for current portable changes.",output:"For current changes, run comet native status <change-name> --json and follow the continuation to dispatch verification through comet native next."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page, or a named details/history page.","--details Include one fixed-size page of acceptance, Spec, handoff, verification, history, workspace, and report details."],output:"A compact v2 status page or one compact Loop projection with canonical artifact paths and local execution availability. Use --details and --cursor to read fixed-size detail pages; parent changes expose childSummary and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--coordination-mode multi-session|single-session] [--max-parallel <n>] [--expected-state-version <n>] [--expected-action <action>]
237
241
  comet native next <change-name> --summary <text> [--confirmed|--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker] [--expected-state-version <n>] [--expected-action <action>]
238
242
  comet native next <change-name> --runner-input <json-file> [--validate-only]`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm the persisted Shape boundary with both expected guards, or confirm an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Choose how a multi-child Supervisor proceeds. Supply it with --confirmed at the persisted Shape boundary to confirm the full plan and mode together, or select it during preparation and confirm the plan afterward.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--finish keep|merge|push|pull-request With --accept-result, record the explicitly chosen isolated-workspace finish in the same guarded decision.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, retry-checks, verifier-response, verifier-started, verifier-execution-error, or verifier-unavailable. Builder/dispatch identity fields are rejected; verifier responses must echo the current candidateId and verifierExecutionRef from the Verifier dispatch.","--validate-only Validate the Runner JSON shape and current boundary without writing state or starting a process; requires --runner-input."," Choose one object template from an inputOptions exclusiveGroup and save it as UTF-8 JSON (BOM accepted). Field errors return issues with JSON pointer, missingFields and unknownFields. Execute agent.continuation in agent.workspace.cwd; Supervisor results use task.returnAction."," builder-handoff fields: kind, summary, addressed_acceptance_ids, acceptance_review, checks, verification_checks, known_limits, optional review. acceptance_review must cover every confirmed ID exactly once with id, status, evidence (concrete references or observations), and note. Only implemented-with-evidence with nonempty evidence is ready for handoff; implemented-no-evidence, not-implemented, and known-fail remain in Build. This Builder declaration does not replace independent verification. checks summarize development feedback. verification_checks is an optional Runtime plan executed after the candidate is frozen; a passing plan returns the Verifier dispatch immediately. Completed Runtime checks can carry to a new candidate only when the implementation, confirmed documents, plan, workspace, environment, and saved evidence still match. If review is supplied, its fields are status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," retry-checks fields: kind, check_ids for repeatable interrupted Runtime checks from the current candidate; each check can be retried at most three times."," verifier-response fields: kind, candidateId, verifierExecutionRef, response (request-checks or final-result); copy the two binding fields from the current continuation."," verifier-started fields: kind, candidateId, verifierExecutionRef copied from verifierDispatch; the dispatched Verifier submits it as its first Runtime action so status can distinguish a registered dispatch from a Verifier that actually started. Repeating it is accepted without side effects."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," Supervisor task fields: supervisor-builder-result (child, runId, candidateCommit), supervisor-builder-failure (child, runId, reason), supervisor-verifier-result (child, runId, verdict, verification data), supervisor-reconnect (child, runId), supervisor-cancel (child, runId, reason), or supervisor-integrate (child, checks)."," supervisor-checks fields: kind, child, runId, checks (non-empty repeatable Runtime check plans), materials [{name,content}], and optional retry_check_ids for interrupted checks from the same candidate, machine and workspace. Returns per-check execution state plus operationId, status and receiptRef. Repeated running plans return the same handle."," supervisor-verifier-result evidence fields: summary, checks (informal notes), acceptance [{id,result,reason}], receiptRef. verdict is pass, fail or blocked; every task acceptance ID must appear exactly once. Runtime receipts determine formal check status; receiptRef may be null for fail or blocked."," supervisor-integrate checks are non-empty Runtime check plans executed after the merge in the integration worktree, not declared statuses."],output:'A compact portable state summary, explicit skill-coordinated label, Runtime-owned check results, scoped verifierDispatch, bounded request-check response, continuation.runnerAction, machine-readable continuation.inputOptions, and continuation.userCommunication with a user-ready message and Agent relay guidance. Read acceptance text and other long fields from paged status --details output. Human-readable verification statuses include "Host independently verified", "Checks completed, but your confirmation is required", "Full verification was unavailable; only automatic checks completed", and "You accepted the incomplete verification result". This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.',examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed --expected-state-version <n> --expected-action confirm-shape','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep] [--commit-message <text>] [--merge-message <text>]
239
- comet native archive <change-name> [--confirmed] [--serial-first <current-change>] [--commit-message <text>] [--merge-message <text>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Run the complete read-only Archive and workspace-finish readiness check; it persists only an explicit --finish choice.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--expected-state-version <n> Preserve this continuation-issued guard when confirming a new finish choice; stale choices are rejected before it is recorded.","--commit-message <text> Set the archive commit message; Unicode and multiline text are supported. Git hooks still run.","--merge-message <text> Set the local merge commit message; requires merge finish. Omit it to use Git defaults.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness, every blocker, actual prepared commitMessages (mergeMessage is null when no merge is planned), and the exact next continuation, or the completed Archive transaction and workspace finish result. Messages are retained for retries. After a Git hook rejects a message, provide a corrected message with --confirmed for the unfinished step; completed commits are never rewritten. Execute the returned confirmed command only after ready is true; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function Jo(t,e){return`${t}:
243
+ comet native archive <change-name> [--confirmed] [--serial-first <current-change>] [--commit-message <text>] [--merge-message <text>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Run the complete read-only Archive and workspace-finish readiness check; it persists only an explicit --finish choice.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--expected-state-version <n> Preserve this continuation-issued guard when confirming a new finish choice; stale choices are rejected before it is recorded.","--commit-message <text> Set the archive commit message; Unicode and multiline text are supported. Git hooks still run.","--merge-message <text> Set the local merge commit message; requires merge finish. Omit it to use Git defaults.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness, every blocker, actual prepared commitMessages (mergeMessage is null when no merge is planned), and the exact next continuation, or the completed Archive transaction and workspace finish result. Messages are retained for retries. After a Git hook rejects a message, provide a corrected message with --confirmed for the unfinished step; completed commits are never rewritten. Execute the returned confirmed command only after ready is true; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function Uo(t,e){return`${t}:
240
244
  ${e.map(r=>` ${r}`).join(`
241
- `)}`}function PR(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return yu[r]||e.length>1&&yu[e[0]]?.subcommands?r:e[0]}function _R(t=[]){let e=PR(t),r=yu[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.agentQuickStart&&i.push("",Jo("Agent Quick Start",r.agentQuickStart)),r.subcommands&&i.push("",Jo("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...Gm];return n&&n.length>0&&i.push("",Jo("Options",n)),i.push("",`Output:
242
- ${r.output}`),r.examples&&i.push("",Jo("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
245
+ `)}`}function $R(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return Nu[r]||e.length>1&&Nu[e[0]]?.subcommands?r:e[0]}function OR(t=[]){let e=$R(t),r=Nu[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.agentQuickStart&&i.push("",Uo("Agent Quick Start",r.agentQuickStart)),r.subcommands&&i.push("",Uo("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...Km];return n&&n.length>0&&i.push("",Uo("Options",n)),i.push("",`Output:
246
+ ${r.output}`),r.examples&&i.push("",Uo("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
243
247
  `)}
244
- `}}var AR=_R().usage;var Um=10*1024*1024,Wt=class extends Error{};function bu(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new Wt(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function Km(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new Wt(`${e} may only be provided once`);if(r.length===0)return;let i=r[0],n=t[i+1];if(n===void 0||n.startsWith("--"))throw new Wt(`${e} requires a value`);return t.splice(i,2),n}function Ym(t){if(t.length>0)throw new Wt(`Unexpected argument: ${t[0]}`)}function Xm(t,e){let r=t.shift();if(!r||r.startsWith("--"))throw new Wt(`${e} is required`);return r}function Nu(t,e){let r=An.normalize(Jm(t)),i=An.normalize(Jm(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Jm(t){let e=An.resolve(t);try{return IR.native(e)}catch{return e}}function TR(t,e){let r=An.resolve(e,t),i=G(e);if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return r;let n=G(r);return!n.isGitWorktree||n.currentWorktreeRoot===null||n.primaryWorktreeRoot===null||!Nu(i.primaryWorktreeRoot,n.primaryWorktreeRoot)||Nu(i.currentWorktreeRoot,n.currentWorktreeRoot)?r:Nu(e,i.currentWorktreeRoot)?An.resolve(e):i.currentWorktreeRoot}async function Qm(t,e=process.cwd()){return t?TR(t,e):Ka(e)}function Zm(t,e){return t==="status"||t==="show"||t==="root"&&e[0]==="show"}async function ev(t){let e=await Vf({startPath:t,allowMissingConfig:!1});return{config:e.config,paths:e.paths}}function tv(t){return JSON.stringify(t,null,2)+`
245
- `}function Uo(t,e,r){return{command:t,exitCode:0,data:e,text:r??tv(e)}}function jR(t,e){if(e instanceof gn)return{command:t,exitCode:65,data:{change:e.change,findings:e.findings},error:{code:"document-invalid",message:e.message}};if(e instanceof Dr)return{command:t,exitCode:65,data:{builderReadiness:{ready:!1,missingIds:e.missingIds,incompleteIds:e.incompleteIds}},error:{code:"invalid-data",message:e.message}};if(e instanceof nn)return{command:t,exitCode:65,error:{code:"invalid-data",message:e.message,issues:e.issues}};if(e instanceof Wt)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof zo)return{command:t,exitCode:73,data:{capability:e.capability,expectedHash:e.expectedHash,actualHash:e.actualHash,canonicalPath:e.canonicalPath},error:{code:"conflict",message:e.message}};if(e instanceof Go)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof go)return{command:t,exitCode:73,data:{change:e.change,expectedRevision:e.expectedRevision,actualRevision:e.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:e.message}};if(e instanceof fn)return{command:t,exitCode:73,data:{requestedIsolation:e.requestedIsolation,activeChanges:e.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:e.message}};if(e instanceof _o)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof wo)return{command:t,exitCode:65,data:{change:e.change,complete:!1,omittedCount:e.omittedCount,omittedByReason:e.omittedByReason,samplePaths:e.samplePaths,sampleTruncated:e.sampleTruncated,effectiveLimits:e.effectiveLimits,policyHash:e.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:e.message}};if(e instanceof Wo)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof _n)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let r=e.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function rv(t,e){let r=jR(t,e),i=r.error;if(!i)return r;let n=zm({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function $R(t,e,r=!1){let i=t.envelope??Wm(t.data);return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,agent:$m(t.data,t.executionCwd),...i===void 0?{}:{summary:i.summary,...i.next===void 0?{}:{next:i.next},...i.user_message===void 0?{}:{user_message:i.user_message}},...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
246
- `}:t.error?{exitCode:t.exitCode,stderr:i?Dm(i,t.error.message,r?t.data:void 0):t.error.message}:i?{exitCode:t.exitCode,stdout:Hm(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==tv(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
248
+ `}}var HR=OR().usage;var Xm=10*1024*1024,Wt=class extends Error{};function ku(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new Wt(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function Qm(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new Wt(`${e} may only be provided once`);if(r.length===0)return;let i=r[0],n=t[i+1];if(n===void 0||n.startsWith("--"))throw new Wt(`${e} requires a value`);return t.splice(i,2),n}function Zm(t){if(t.length>0)throw new Wt(`Unexpected argument: ${t[0]}`)}function ev(t,e){let r=t.shift();if(!r||r.startsWith("--"))throw new Wt(`${e} is required`);return r}function bu(t,e){let r=In.normalize(Ym(t)),i=In.normalize(Ym(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Ym(t){let e=In.resolve(t);try{return DR.native(e)}catch{return e}}function BR(t,e){let r=In.resolve(e,t),i=G(e);if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return r;let n=G(r);return!n.isGitWorktree||n.currentWorktreeRoot===null||n.primaryWorktreeRoot===null||!bu(i.primaryWorktreeRoot,n.primaryWorktreeRoot)||bu(i.currentWorktreeRoot,n.currentWorktreeRoot)?r:bu(e,i.currentWorktreeRoot)?In.resolve(e):i.currentWorktreeRoot}async function tv(t,e=process.cwd()){return t?BR(t,e):Ya(e)}function rv(t,e){return t==="status"||t==="show"||t==="root"&&e[0]==="show"}async function iv(t){let e=await Gf({startPath:t,allowMissingConfig:!1});return{config:e.config,paths:e.paths}}function nv(t){return JSON.stringify(t,null,2)+`
249
+ `}function Ko(t,e,r){return{command:t,exitCode:0,data:e,text:r??nv(e)}}function LR(t,e){if(e instanceof wn)return{command:t,exitCode:65,data:{change:e.change,findings:e.findings},error:{code:"document-invalid",message:e.message}};if(e instanceof Dr)return{command:t,exitCode:65,data:{builderReadiness:{ready:!1,missingIds:e.missingIds,incompleteIds:e.incompleteIds}},error:{code:"invalid-data",message:e.message}};if(e instanceof an)return{command:t,exitCode:65,error:{code:"invalid-data",message:e.message,issues:e.issues}};if(e instanceof Wt)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof Go)return{command:t,exitCode:73,data:{capability:e.capability,expectedHash:e.expectedHash,actualHash:e.actualHash,canonicalPath:e.canonicalPath},error:{code:"conflict",message:e.message}};if(e instanceof Jo)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof wo)return{command:t,exitCode:73,data:{change:e.change,expectedRevision:e.expectedRevision,actualRevision:e.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:e.message}};if(e instanceof hn)return{command:t,exitCode:73,data:{requestedIsolation:e.requestedIsolation,activeChanges:e.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:e.message}};if(e instanceof Ao)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof yo)return{command:t,exitCode:65,data:{change:e.change,complete:!1,omittedCount:e.omittedCount,omittedByReason:e.omittedByReason,samplePaths:e.samplePaths,sampleTruncated:e.sampleTruncated,effectiveLimits:e.effectiveLimits,policyHash:e.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:e.message}};if(e instanceof zo)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof An)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let r=e.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function av(t,e){let r=LR(t,e),i=r.error;if(!i)return r;let n=Um({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function FR(t,e,r=!1){let i=t.envelope??Jm(t.data);return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,agent:Dm(t.data,t.executionCwd),...i===void 0?{}:{summary:i.summary,...i.next===void 0?{}:{next:i.next},...i.user_message===void 0?{}:{user_message:i.user_message}},...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
250
+ `}:t.error?{exitCode:t.exitCode,stderr:i?Fm(i,t.error.message,r?t.data:void 0):t.error.message}:i?{exitCode:t.exitCode,stdout:Lm(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==nv(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
247
251
  ${mt.details}
248
252
  ${JSON.stringify(t.data,null,2)}
249
- `}:{exitCode:t.exitCode,stdout:t.text}}function OR(t,e,r=!1){let i=$R(t,e,r),n=!1;if(i.stdout?.trim())try{let a=JSON.parse(i.stdout);n=!!a&&typeof a=="object"&&!Array.isArray(a)}catch{n=!1}return{output:i,structuredDataVisible:n}}function iv(t,e,r=!1){return OR(t,e,r).output}I();import vr from"node:path";import{realpathSync as KR}from"node:fs";F();ve();import{promises as DR}from"fs";rn();F();I();Vr();I();I();Vt();En();ur();Vt();Ne();I();var In=Object.freeze({maxItems:24,maxChanges:4096,maxSerializedBytes:512*1024});async function av(t){let e;try{e=await un({root:t.nativeRoot,directory:t.changesDir,label:"Native status changes directory"})}catch(n){if(n.code==="ENOENT")return[];throw n}let r=[],i=await DR.opendir(t.changesDir);try{for await(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink())&&(r.push(n.name),r.length>In.maxChanges))throw new Error(`Native status exceeds ${In.maxChanges} visible changes`)}finally{await i.close().catch(n=>{if(n.code!=="ERR_DIR_CLOSED")throw n})}return await e.verify(),r.sort()}I();var Su=et(Me(),1);Se();F();ue();Te();import{promises as BR}from"node:fs";import ku from"node:path";var Ko=class extends Error{};async function Xo(t,e){let r=await L({root:t.nativeRoot,ref:ku.relative(t.nativeRoot,e).replaceAll("\\","/"),maxBytes:null,includeHash:!1}),i=(0,Su.parse)(r.text);if(["comet.native.v1","comet.native.v2","comet.native.v3"].includes(i?.schema))throw new Ko("Historical Native schema");return{projectRoot:t.projectRoot,file:e,state:fe(i)}}async function sv(t,e,r){let i;try{i=await BR.readdir(t.archiveDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return[];throw a}if(i.length>4096)throw new Error("Native archive discovery exceeds 4096 records");let n=[];for(let a of i){if(!a.isDirectory()||a.isSymbolicLink())continue;let o=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(a.name)?.[1];if(r!==void 0&&o!==void 0&&o!==r)continue;let s=ku.join(t.archiveDir,a.name,"comet-state.yaml");try{let c=await Xo(t,s);c.state.archived&&c.state.status==="done"&&n.push(c)}catch(c){if(c.code==="ENOENT"||c instanceof Ko)continue;let l=a.name.replace(/^\d{4}-\d{2}-\d{2}-/u,"");e?.(l,`Native archive ${a.name} is unreadable: ${c.message}`)}}return n}function Yo(t){return O("comet.native.status-record.v1",t)}function ov(t){let e=ku.relative(t.projectRoot,t.file).replaceAll("\\","/");try{let r=me(t.projectRoot,["log","-1","--format=%H","HEAD","--",e]);if(!r)return null;let i=fe((0,Su.parse)(me(t.projectRoot,["show",`${r}:${e}`])));return Yo(i)===Yo(t.state)?r:null}catch{return null}}function cv(t,e){if(!t.state.archived||t.state.status!=="done"||t.state.name!==e.state.name||t.state.created_at!==e.state.created_at)return!1;let r=ov(t),i=ov(e);if(!r||!i)return!1;try{return me(t.projectRoot,["merge-base","--is-ancestor",i,r]),!0}catch{return!1}}function lv(t,e){return t.state.archived&&e.state.archived&&Yo(t.state)===Yo(e.state)}import fv from"node:path";F();import uv from"node:path";function dv(t){let e=t.replace(/\s+/gu," ").trim();return e.length<=240?e:`${e.slice(0,237)}...`}function pv(t,e){let r=t.acceptance.reduce((i,n)=>({...i,[n.result]:i[n.result]+1}),{total:t.acceptance.length,passed:0,failed:0,blocked:0,pending:0});return{schema:"comet.native.state-summary.v1",name:t.name,phase:t.phase,status:t.status,state_version:t.state_version,...t.coordination_mode===void 0?{}:{coordination_mode:t.coordination_mode},loop:t.loop,acceptance:r,unresolved_acceptance_ids:t.acceptance.filter(({result:i})=>i==="failed"||i==="blocked").map(({id:i})=>i),verification_result:t.verification_result,blockers:t.blockers.slice(0,8).map(i=>({owner:i.owner,reason:dv(i.reason.text),acceptance_ids:i.acceptance_ids,resolution_action:i.resolution_action})),workspace:{isolation:t.workspace.isolation,change_branch:t.workspace.change_branch,target_branch:t.workspace.target_branch,finish:t.workspace.finish},learning:{failureResolved:t.verification_result==="pass"&&t.history.some(i=>i.outcome==="fail"&&i.goal_cycle===t.loop.goal_cycle),...t.verification?{summary:dv(t.verification.summary.text)}:{},artifactRefs:e?["brief.md",...t.verification_report?[t.verification_report]:[],...t.spec_changes.map(i=>i.source).filter(i=>i!==null)].slice(0,16).map(i=>uv.relative(e.projectRoot,uv.join(e.changesDir,t.name,i)).replaceAll("\\","/")):[]},archived:t.archived}}I();function LR(t,e,r){return`native-details-v2.${t}.${e}.${r.toString(36)}`}function FR(t,e,r){if(!t)return 0;let i=/^native-details-v2\.(\d+)\.(\d+)\.([0-9a-z]+)$/u.exec(t);if(!i||Number(i[1])!==e||Number(i[2])!==r)throw new Error("Native details cursor is stale or invalid");let n=Number.parseInt(i[3],36);if(!Number.isSafeInteger(n)||n<0)throw new Error("Native details cursor offset is invalid");return n}function qR(t,e,r){return[...t.acceptance.map(i=>({kind:"acceptance",value:i})),...t.spec_changes.map(i=>({kind:"spec-change",value:i})),...t.builder_handoff?[{kind:"builder-handoff",value:t.builder_handoff}]:[],...t.verification?[{kind:"verification",value:t.verification}]:[],...t.history.map(i=>({kind:"history",value:i})),{kind:"history-overflow",value:t.history_overflow},{kind:"workspace",value:t.workspace},...t.verification_report?[{kind:"verification-report",value:t.verification_report}]:[],...e?[{kind:"supervisor-integration",value:{...e.integration,worktree:"<worktree>",targetCommit:"<redacted>",headCommit:"<redacted>"}},{kind:"supervisor-final-verification",value:e.finalVerification},...e.children.map(i=>({kind:"supervisor-child",value:VR(i,r)})),...e.history.map(i=>({kind:"supervisor-history",value:WR(i,r)}))]:[]]}function MR(t){return t.acceptance.reduce((e,r)=>({...e,[r.result]:e[r.result]+1}),{total:t.acceptance.length,passed:0,failed:0,blocked:0,pending:0})}function hv(t,e,r=G(t.projectRoot)){let i=null;return e.workspace.change_branch!==null&&(r.isGitWorktree?r.currentBranch!==e.workspace.change_branch&&(i=`Expected branch ${e.workspace.change_branch}, current branch is ${r.currentBranch??"(detached)"}.`):i="The Native change requires a registered Git worktree."),i===null&&e.workspace.isolation==="worktree"&&!r.isSecondaryWorktree&&(i="The Native change requires its linked worktree."),{projectRoot:fv.resolve(t.projectRoot),isolation:e.workspace.isolation,bindingState:i===null?"aligned":"mismatch",changeBranch:e.workspace.change_branch,targetBranch:e.workspace.target_branch,finish:e.workspace.finish,message:i}}function mv(t){let{state:e,paths:r}=t,i=t.finishJournal??null,n=pv(e),a=i!==null,o=i?.result?.message??"Native Archive completed, but workspace finish is still pending; retry the recorded finish command.",s=a?{...Jr(e),status:"blocked",disposition:"blocked",action:"archive",requiresUserDecision:!1,commandArgs:i?.result?.recoveryArgs??["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],inputOptions:[],userCommunication:{required:!0,message:o,suggestedReply:null,agentInstruction:"Report the Git blocker and resolve it within the recorded delivery authorization, then retry the recorded Native workspace finish command. Ask the user only when new information or authorization is required; keep delivery pending until it succeeds."},runnerAction:{...Jr(e).runnerAction,kind:"none"}}:Jr(e),c=t.details?qR(e,null,[]):[],l=FR(t.cursor,e.state_version,0),d=c.slice(l,l+32),u=l+d.length<c.length?LR(e.state_version,0,l+d.length):null;return{schema:"comet.native.status.v2",name:e.name,artifacts:ir(r,e.name),phase:e.phase,status:a?"blocked":e.status,stateVersion:e.state_version,archived:!0,archiveRef:fv.relative(r.projectRoot,t.file).replaceAll("\\","/"),loop:e.loop,acceptance:MR(e),unresolvedAcceptanceIds:n.unresolved_acceptance_ids,verificationResult:e.verification_result,blockers:a?[...n.blockers,{owner:"runtime",reason:o,acceptance_ids:[],resolution_action:"wait-external"}]:n.blockers,workspace:{projectRoot:r.projectRoot,isolation:e.workspace.isolation,bindingState:"aligned",changeBranch:e.workspace.change_branch,targetBranch:e.workspace.target_branch,finish:e.workspace.finish,message:null},localExecution:{status:"not-expected",operation:null},continuation:s,...t.details?{details:{stateVersion:e.state_version,items:d,nextCursor:u,nextPageArgs:u?["comet","native","status",e.name,"--details","--cursor",u,"--project-root",r.projectRoot,"--json"]:null}}:{}}}function vv(t,e){return t===null?null:e.reduce((r,i)=>r.replaceAll(i,"<worktree>").replaceAll(i.replaceAll("\\","/"),"<worktree>"),t)}function VR(t,e){return{...t,projectRoot:t.projectRoot?"<worktree>":null,baseCommit:t.baseCommit?"<redacted>":null,candidateCommit:t.candidateCommit?"<redacted>":null,verifiedCommit:t.verifiedCommit?"<redacted>":null,integrationCommit:t.integrationCommit?"<redacted>":null,blocker:vv(t.blocker,e),task:t.task?{...t.task,projectRoot:"<worktree>",baseCommit:"<redacted>",runId:"<redacted>"}:null}}function WR(t,e){return{...t,runId:t.runId?"<redacted>":null,summary:vv(t.summary,e)??""}}import{accessSync as PG,constants as _G,promises as Eu}from"node:fs";import ti from"node:path";H();_r();Se();Po();_r();var gv="comet.native.workspace-finish.v1",yv="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",Nv=new RegExp(`^${yv}$`,"u"),GR=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Tn=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;function wv(t,e){if(!t.trim()||t.includes("\0"))throw new Error(`${e} must contain non-whitespace text and no NUL character`)}function JR(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace finish journal is invalid");let e=t;if(e.schema!==gv||typeof e.name!="string"||!Nv.test(e.name)||typeof e.transactionId!="string"||!GR.test(e.transactionId)||e.archiveDir!==null&&(typeof e.archiveDir!="string"||!ti.isAbsolute(e.archiveDir))||!["pending","blocked"].includes(String(e.status))||typeof e.updatedAt!="string"||!Number.isFinite(Date.parse(e.updatedAt)))throw new Error("Native workspace finish journal is invalid");if(e.result!==null){if(!e.result||typeof e.result!="object"||Array.isArray(e.result))throw new Error("Native workspace finish journal result is invalid");let r=e.result;if(!["merge","push","pull-request","keep"].includes(String(r.action))||!["completed","kept","blocked"].includes(String(r.status))||!Array.isArray(r.blockedPaths)||r.blockedPaths.some(i=>typeof i!="string")||r.recoveryArgs!==null&&(!Array.isArray(r.recoveryArgs)||r.recoveryArgs.some(i=>typeof i!="string")))throw new Error("Native workspace finish journal result is invalid")}if(e.plan!==void 0){let r=e.plan;if(!r||typeof r!="object"||!["keep","merge","push","pull-request"].includes(r.finish)||!["current","branch","worktree"].includes(r.isolation)||![r.changeRoot,r.primaryRoot].every(i=>typeof i=="string"&&ti.isAbsolute(i))||![r.changeBranch,r.targetBranch].every(i=>typeof i=="string"&&i.length>0)||r.targetRoot!==null&&(typeof r.targetRoot!="string"||!ti.isAbsolute(r.targetRoot))||r.remote!==null&&typeof r.remote!="string"||typeof r.commitMessage!="string"||r.mergeMessage!==null&&typeof r.mergeMessage!="string")throw new Error("Native workspace finish journal plan is invalid");wv(r.commitMessage,"commit-message"),r.mergeMessage!==null&&wv(r.mergeMessage,"merge-message")}if(e.createdAt!==void 0&&(typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))))throw new Error("Native workspace finish journal creation identity is invalid");if(e.commit!==void 0){let r=e.commit;if(!r||!Tn.test(r.parent)||!Array.isArray(r.paths)||!r.paths.every(i=>typeof i=="string"&&i.length>0&&!ti.posix.isAbsolute(i)&&!ti.win32.isAbsolute(i)&&!i.split("/").includes(".."))||!Array.isArray(r.entries)||!r.entries.every(i=>typeof i=="string")||r.sha!==null&&!Tn.test(r.sha))throw new Error("Native workspace finish journal commit is invalid")}if(e.merge!==void 0){let r=e.merge;if(!r||!Tn.test(r.target)||!Tn.test(r.source)||r.sha!==null&&!Tn.test(r.sha))throw new Error("Native workspace finish journal merge is invalid")}return{schema:gv,name:e.name,transactionId:e.transactionId,archiveDir:e.archiveDir,status:e.status,result:e.result,updatedAt:e.updatedAt,...e.createdAt===void 0?{}:{createdAt:e.createdAt},...e.plan===void 0?{}:{plan:e.plan},...e.commit===void 0?{}:{commit:e.commit},...e.merge===void 0?{}:{merge:e.merge}}}function UR(t,e){if(!Nv.test(e))throw new Error(`Invalid Native workspace finish journal name: ${e}`);return ti.join(t.transactionsDir,`workspace-finish-${e}.json`)}async function xu(t,e,r={}){let i=UR(t,e);try{let n=await Eu.lstat(i);if(!n.isFile()||n.isSymbolicLink())throw new Error("Native workspace finish journal is not a regular file");let a=JR(JSON.parse(await Eu.readFile(i,"utf8")));if(a.name!==e)throw new Error("Native workspace finish journal name is invalid");return a}catch(n){if(n.code==="ENOENT")return null;if(r.onError)return r.onError(e,n instanceof Error?n.message:String(n)),null;throw n}}async function bv(t,e={}){let r;try{r=await Eu.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r){if(!n.isFile()&&!n.isSymbolicLink()||n.isDirectory())continue;let a=new RegExp(`^workspace-finish-(${yv})\\.json$`,"u").exec(n.name);if(!a)continue;let o=await xu(t,a[1],e);o&&i.push(o)}return i}function Qo(t,e){let r=vr.normalize(Cu(t)),i=vr.normalize(Cu(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Cu(t){let e=vr.resolve(t);try{return KR.native(e)}catch{return e}}async function kv(t,e){let r=[];for(let i of await av(t))e!==void 0&&i!==e||r.push({name:i,kind:await Xr(t,i)?"portable":"legacy"});return r}async function YR(t,e){let r=vr.resolve(t),i=Ta(t),n=i.map(({root:c})=>c),a=n.length>0?n:[r];a.some(c=>Qo(c,r))||a.push(r);let o=[],s=new Set;for(let c of a.map(l=>vr.resolve(l)).sort()){let l=Qo(c,r)?r:c,d=Cu(l),u=process.platform==="win32"?d.toLowerCase():d;if(s.has(u))continue;s.add(u);let p=await pe(l);if(!p)continue;let f=await Je(l,p.native.artifact_root);o.push({projectRoot:l,config:p,paths:f,gitContext:Di(l,i)??G(l),changes:await kv(f,e)})}if(o.length===0){let c=await pe(t);if(!c)throw new Error(".comet/config.yaml was not found in any registered worktree");let l=await Je(t,c.native.artifact_root);o.push({projectRoot:vr.resolve(t),config:c,paths:l,gitContext:Di(t,i)??G(t),changes:await kv(l,e)})}for(let c of o){c.archiveErrors=[],c.finishJournalErrors=[],c.archives=await sv(c.paths,(d,u)=>c.archiveErrors.push({name:d,message:u}),e),e!==void 0&&(c.archives=c.archives.filter(({state:d})=>d.name===e),c.archiveErrors=c.archiveErrors.filter(({name:d})=>d===e));let l=(d,u)=>c.finishJournalErrors.push({name:d,message:u});c.finishJournals=e?[await xu(c.paths,e,{onError:l})].filter(d=>d!==null):await bv(c.paths,{onError:l})}return o}function Sv(t,e){return t.workspace.bindingState==="aligned"?0:Qo(t.source.projectRoot,e)?1:t.workspace.bindingState==="legacy"?2:t.workspace.bindingState==="missing"?3:t.workspace.bindingState==="drifted"?4:5}async function XR(t,e){let r=new Map;for(let n of e){for(let a of n.changes)r.set(a.name,[...r.get(a.name)??[],{source:n,kind:a.kind}]);for(let a of n.archives??[])r.has(a.state.name)||r.set(a.state.name,[]);for(let a of n.archiveErrors??[])r.has(a.name)||r.set(a.name,[]);for(let a of n.finishJournals??[])r.has(a.name)||r.set(a.name,[]);for(let a of n.finishJournalErrors??[])r.has(a.name)||r.set(a.name,[])}let i=[];for(let[n,a]of[...r.entries()].sort(([o],[s])=>o.localeCompare(s))){let o=await Promise.all(a.map(async({source:u,kind:p})=>{let f=u.finishJournalErrors?.find(({name:m})=>m===n);if(p==="portable")try{let m=await Be(u.paths,n);return{source:u,name:n,kind:p,workspace:hv(u.paths,m,u.gitContext),portableStatus:null,inspectionError:f?.message??null,finishJournal:u.finishJournals?.find(({name:h})=>h===n)??null}}catch(m){return{source:u,name:n,kind:p,workspace:{projectRoot:u.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:"The portable state could not be inspected."},portableStatus:null,inspectionError:m instanceof Error?m.message:String(m)}}return{source:u,name:n,kind:p,workspace:a.length>1?await Al(u.paths,n):{projectRoot:u.projectRoot,currentBranch:u.gitContext.currentBranch,isSecondaryWorktree:u.gitContext.isSecondaryWorktree,bindingState:"legacy",isolation:null,changeBranch:null,targetBranch:null,finish:null},portableStatus:null,inspectionError:f?.message??null}})),s=e.flatMap(u=>(u.archives??[]).filter(({state:p})=>p.name===n).map(p=>{let f=mv({paths:u.paths,...p,finishJournal:u.finishJournals?.find(({name:m})=>m===n)??null});return{source:u,name:n,kind:"portable",workspace:f.workspace,portableStatus:f,inspectionError:u.finishJournalErrors?.find(({name:m})=>m===n)?.message??null,record:p,finishJournal:u.finishJournals?.find(({name:m})=>m===n)??null}})),c=e.flatMap(u=>(u.archiveErrors??[]).filter(p=>p.name===n).map(p=>({source:u,error:p})))[0];if(c){i.push({source:c.source,name:n,kind:"portable",portableStatus:null,inspectionError:c.error.message,workspace:{projectRoot:c.source.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:c.error.message}});continue}let l=e.flatMap(u=>(u.finishJournalErrors??[]).filter(p=>p.name===n).map(p=>({source:u,error:p})))[0];if(l&&o.length===0&&s.length===0){i.push({source:l.source,name:n,kind:"portable",portableStatus:null,inspectionError:l.error.message,workspace:{projectRoot:l.source.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:l.error.message}});continue}if(o.length===0&&s.length===0){let u=e.find(f=>f.finishJournals?.some(({name:m})=>m===n)),p=u?.finishJournals?.find(({name:f})=>f===n);if(u&&p){i.push({source:u,name:n,kind:"portable",portableStatus:null,inspectionError:p.result?.message??"Native workspace finish journal has no matching active or archived change record.",workspace:{projectRoot:u.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:p.result?.message??"Native workspace finish record is orphaned."},finishJournal:p});continue}}if(s.length>0){for(let p of o)if(p.kind==="portable")try{p.record=await Xo(p.source.paths,vr.join(p.source.paths.changesDir,n,"comet-state.yaml"))}catch{}let u=s.find(p=>[...o,...s.filter(f=>!lv(p.record,f.record))].every(f=>f.record&&cv(p.record,f.record)));if(u){i.push(u);continue}i.push({...s[0],inspectionError:`Native change ${n} has conflicting active/archive records; identity and committed Git ancestry do not prove supersession. Resolve the records explicitly.`});continue}o.sort((u,p)=>Sv(u,t)-Sv(p,t)||u.source.projectRoot.localeCompare(p.source.projectRoot));let d=o.filter(u=>u.workspace.bindingState==="aligned");d.length>1?i.push(...d):d.length===0&&o.length>1?i.push({...o[0],inspectionError:`Native change ${n} has conflicting workspace records and no aligned binding`}):i.push(d[0]??o[0])}if(i.length>In.maxChanges)throw new Error(`Native status discovery exceeds ${In.maxChanges} visible changes`);return i.sort((n,a)=>`${n.name}\0${n.source.projectRoot}`.localeCompare(`${a.name}\0${a.source.projectRoot}`))}async function QR(t,e){let r=await YR(t,e),i=(await XR(t,r)).filter(n=>n.name===e);if(i.length>1)throw new Error(`Native change ${e} has multiple aligned workspace bindings: ${i.map(n=>n.source.projectRoot).join(", ")}`);return{sources:r,candidates:i}}async function Ev(t){let{sources:e,candidates:r}=await QR(t.projectRoot,t.name);return r.length>0?r[0].source.projectRoot:(e.find(i=>Qo(i.projectRoot,t.projectRoot))??e[0]).projectRoot}async function xv(t,e){let r=Xm(t,"change name");Ym(t);let i=await Ev({projectRoot:e,name:r}),{paths:n}=await ev(i);if(await Xr(n,r)){let u=await Do({paths:n,name:r}),p=u.state,f=ft(n,r),m=await L({root:f,ref:p.brief,maxBytes:null,includeHash:!1}),h=[];for(let v of p.spec_changes){if(v.source===null)continue;let N=await L({root:f,ref:v.source,maxBytes:null,includeHash:!1});h.push({capability:v.capability,operation:v.operation,source:v.source,content:N.text})}let g={state:p,artifacts:ir(n,p.name),brief:m.text,proposedSpecs:h,continuation:Jr(p,await Gr({paths:n,state:p}),{verifierExecutionRef:Ql(p,u.local),...u.local?{verificationCheckPlans:fu(u.local,u.local.workspace.projectRoot)}:{}})};return{...Uo("show",g),executionCwd:i}}let a=await $l(n,r);if(a.status==="migration-required")return{...Uo("show",{name:r,artifacts:ir(n,r),schema:a.schema,minimumRuntimeVersion:a.minimumRuntimeVersion,migrationRequired:!0,message:a.message}),executionCwd:i};if(a.status!=="current"||!a.state)throw new Ke(a.schema,a.minimumRuntimeVersion);let o=a.state,s=oe(n,r),c=await tm(n,r),l=await L({root:s,ref:o.brief,maxBytes:null}),d={state:o,artifacts:ir(n,o.name),brief:l.text,proposedSpecs:c};if(Buffer.byteLength(JSON.stringify(d),"utf8")>Um)throw new Error("Native show output exceeds its serialized byte budget");return{...Uo("show",d),executionCwd:i}}async function Cv(t,e,r=process.argv.slice(2)){let i=r.indexOf("--"),n=i<0?[...r]:r.slice(0,i),a=i<0?[]:r.slice(i),o=n.includes("--json"),s=n.includes("--verbose"),c,l;try{bu(n,"--json"),bu(n,"--verbose"),c=Km(n,"--project-root");let u=[...n,...a],p=async()=>{let f=await Qm(c);return{executionCwd:f,...await e(u,f)}};l=Zm(t,u)?await kf(p):await p()}catch(u){l=rv(t,u)}let d=iv(l,o,s);return d.stdout&&process.stdout.write(d.stdout),d.stderr&&process.stderr.write(d.stderr+(d.stderr.endsWith(`
253
+ `}:{exitCode:t.exitCode,stdout:t.text}}function qR(t,e,r=!1){let i=FR(t,e,r),n=!1;if(i.stdout?.trim())try{let a=JSON.parse(i.stdout);n=!!a&&typeof a=="object"&&!Array.isArray(a)}catch{n=!1}return{output:i,structuredDataVisible:n}}function ov(t,e,r=!1){return qR(t,e,r).output}I();import vr from"node:path";import{realpathSync as tP}from"node:fs";F();ve();import{promises as VR}from"fs";nn();F();I();Vr();I();I();Vt();xn();ur();Vt();Ne();I();var Tn=Object.freeze({maxItems:24,maxChanges:4096,maxSerializedBytes:512*1024});async function cv(t){let e;try{e=await dn({root:t.nativeRoot,directory:t.changesDir,label:"Native status changes directory"})}catch(n){if(n.code==="ENOENT")return[];throw n}let r=[],i=await VR.opendir(t.changesDir);try{for await(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink())&&(r.push(n.name),r.length>Tn.maxChanges))throw new Error(`Native status exceeds ${Tn.maxChanges} visible changes`)}finally{await i.close().catch(n=>{if(n.code!=="ERR_DIR_CLOSED")throw n})}return await e.verify(),r.sort()}I();var Eu=et(Me(),1);Se();F();ue();Te();import{promises as WR}from"node:fs";import Su from"node:path";var Yo=class extends Error{};async function Qo(t,e){let r=await L({root:t.nativeRoot,ref:Su.relative(t.nativeRoot,e).replaceAll("\\","/"),maxBytes:null,includeHash:!1}),i=(0,Eu.parse)(r.text);if(["comet.native.v1","comet.native.v2","comet.native.v3"].includes(i?.schema))throw new Yo("Historical Native schema");return{projectRoot:t.projectRoot,file:e,state:fe(i)}}async function uv(t,e,r){let i;try{i=await WR.readdir(t.archiveDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return[];throw a}if(i.length>4096)throw new Error("Native archive discovery exceeds 4096 records");let n=[];for(let a of i){if(!a.isDirectory()||a.isSymbolicLink())continue;let o=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(a.name)?.[1];if(r!==void 0&&o!==void 0&&o!==r)continue;let s=Su.join(t.archiveDir,a.name,"comet-state.yaml");try{let c=await Qo(t,s);c.state.archived&&c.state.status==="done"&&n.push(c)}catch(c){if(c.code==="ENOENT"||c instanceof Yo)continue;let l=a.name.replace(/^\d{4}-\d{2}-\d{2}-/u,"");e?.(l,`Native archive ${a.name} is unreadable: ${c.message}`)}}return n}function Xo(t){return O("comet.native.status-record.v1",t)}function lv(t){let e=Su.relative(t.projectRoot,t.file).replaceAll("\\","/");try{let r=me(t.projectRoot,["log","-1","--format=%H","HEAD","--",e]);if(!r)return null;let i=fe((0,Eu.parse)(me(t.projectRoot,["show",`${r}:${e}`])));return Xo(i)===Xo(t.state)?r:null}catch{return null}}function dv(t,e){if(!t.state.archived||t.state.status!=="done"||t.state.name!==e.state.name||t.state.created_at!==e.state.created_at)return!1;let r=lv(t),i=lv(e);if(!r||!i)return!1;try{return me(t.projectRoot,["merge-base","--is-ancestor",i,r]),!0}catch{return!1}}function pv(t,e){return t.state.archived&&e.state.archived&&Xo(t.state)===Xo(e.state)}import vv from"node:path";F();import fv from"node:path";function hv(t){let e=t.replace(/\s+/gu," ").trim();return e.length<=240?e:`${e.slice(0,237)}...`}function mv(t,e){let r=t.acceptance.reduce((i,n)=>({...i,[n.result]:i[n.result]+1}),{total:t.acceptance.length,passed:0,failed:0,blocked:0,pending:0});return{schema:"comet.native.state-summary.v1",name:t.name,phase:t.phase,status:t.status,state_version:t.state_version,...t.coordination_mode===void 0?{}:{coordination_mode:t.coordination_mode},loop:t.loop,acceptance:r,unresolved_acceptance_ids:t.acceptance.filter(({result:i})=>i==="failed"||i==="blocked").map(({id:i})=>i),verification_result:t.verification_result,blockers:t.blockers.slice(0,8).map(i=>({owner:i.owner,reason:hv(i.reason.text),acceptance_ids:i.acceptance_ids,resolution_action:i.resolution_action})),workspace:{isolation:t.workspace.isolation,change_branch:t.workspace.change_branch,target_branch:t.workspace.target_branch,finish:t.workspace.finish},learning:{failureResolved:t.verification_result==="pass"&&t.history.some(i=>i.outcome==="fail"&&i.goal_cycle===t.loop.goal_cycle),...t.verification?{summary:hv(t.verification.summary.text)}:{},artifactRefs:e?["brief.md",...t.verification_report?[t.verification_report]:[],...t.spec_changes.map(i=>i.source).filter(i=>i!==null)].slice(0,16).map(i=>fv.relative(e.projectRoot,fv.join(e.changesDir,t.name,i)).replaceAll("\\","/")):[]},archived:t.archived}}I();function zR(t,e,r){return`native-details-v2.${t}.${e}.${r.toString(36)}`}function GR(t,e,r){if(!t)return 0;let i=/^native-details-v2\.(\d+)\.(\d+)\.([0-9a-z]+)$/u.exec(t);if(!i||Number(i[1])!==e||Number(i[2])!==r)throw new Error("Native details cursor is stale or invalid");let n=Number.parseInt(i[3],36);if(!Number.isSafeInteger(n)||n<0)throw new Error("Native details cursor offset is invalid");return n}function JR(t,e,r){return[...t.acceptance.map(i=>({kind:"acceptance",value:i})),...t.spec_changes.map(i=>({kind:"spec-change",value:i})),...t.builder_handoff?[{kind:"builder-handoff",value:t.builder_handoff}]:[],...t.verification?[{kind:"verification",value:t.verification}]:[],...t.history.map(i=>({kind:"history",value:i})),{kind:"history-overflow",value:t.history_overflow},{kind:"workspace",value:t.workspace},...t.verification_report?[{kind:"verification-report",value:t.verification_report}]:[],...e?[{kind:"supervisor-integration",value:{...e.integration,worktree:"<worktree>",targetCommit:"<redacted>",headCommit:"<redacted>"}},{kind:"supervisor-final-verification",value:e.finalVerification},...e.children.map(i=>({kind:"supervisor-child",value:KR(i,r)})),...e.history.map(i=>({kind:"supervisor-history",value:YR(i,r)}))]:[]]}function UR(t){return t.acceptance.reduce((e,r)=>({...e,[r.result]:e[r.result]+1}),{total:t.acceptance.length,passed:0,failed:0,blocked:0,pending:0})}function gv(t,e,r=G(t.projectRoot)){let i=null;return e.workspace.change_branch!==null&&(r.isGitWorktree?r.currentBranch!==e.workspace.change_branch&&(i=`Expected branch ${e.workspace.change_branch}, current branch is ${r.currentBranch??"(detached)"}.`):i="The Native change requires a registered Git worktree."),i===null&&e.workspace.isolation==="worktree"&&!r.isSecondaryWorktree&&(i="The Native change requires its linked worktree."),{projectRoot:vv.resolve(t.projectRoot),isolation:e.workspace.isolation,bindingState:i===null?"aligned":"mismatch",changeBranch:e.workspace.change_branch,targetBranch:e.workspace.target_branch,finish:e.workspace.finish,message:i}}function wv(t){let{state:e,paths:r}=t,i=t.finishJournal??null,n=mv(e),a=i!==null,o=i?.result?.message??"Native Archive completed, but workspace finish is still pending; retry the recorded finish command.",s=a?{...Jr(e),status:"blocked",disposition:"blocked",action:"archive",requiresUserDecision:!1,commandArgs:i?.result?.recoveryArgs??["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],inputOptions:[],userCommunication:{required:!0,message:o,suggestedReply:null,agentInstruction:"Report the Git blocker and resolve it within the recorded delivery authorization, then retry the recorded Native workspace finish command. Ask the user only when new information or authorization is required; keep delivery pending until it succeeds."},runnerAction:{...Jr(e).runnerAction,kind:"none"}}:Jr(e),c=t.details?JR(e,null,[]):[],l=GR(t.cursor,e.state_version,0),d=c.slice(l,l+32),u=l+d.length<c.length?zR(e.state_version,0,l+d.length):null;return{schema:"comet.native.status.v2",name:e.name,artifacts:ir(r,e.name),phase:e.phase,status:a?"blocked":e.status,stateVersion:e.state_version,archived:!0,archiveRef:vv.relative(r.projectRoot,t.file).replaceAll("\\","/"),loop:e.loop,acceptance:UR(e),unresolvedAcceptanceIds:n.unresolved_acceptance_ids,verificationResult:e.verification_result,blockers:a?[...n.blockers,{owner:"runtime",reason:o,acceptance_ids:[],resolution_action:"wait-external"}]:n.blockers,workspace:{projectRoot:r.projectRoot,isolation:e.workspace.isolation,bindingState:"aligned",changeBranch:e.workspace.change_branch,targetBranch:e.workspace.target_branch,finish:e.workspace.finish,message:null},localExecution:{status:"not-expected",operation:null},continuation:s,...t.details?{details:{stateVersion:e.state_version,items:d,nextCursor:u,nextPageArgs:u?["comet","native","status",e.name,"--details","--cursor",u,"--project-root",r.projectRoot,"--json"]:null}}:{}}}function yv(t,e){return t===null?null:e.reduce((r,i)=>r.replaceAll(i,"<worktree>").replaceAll(i.replaceAll("\\","/"),"<worktree>"),t)}function KR(t,e){return{...t,projectRoot:t.projectRoot?"<worktree>":null,baseCommit:t.baseCommit?"<redacted>":null,candidateCommit:t.candidateCommit?"<redacted>":null,verifiedCommit:t.verifiedCommit?"<redacted>":null,integrationCommit:t.integrationCommit?"<redacted>":null,blocker:yv(t.blocker,e),task:t.task?{...t.task,projectRoot:"<worktree>",baseCommit:"<redacted>",runId:"<redacted>"}:null}}function YR(t,e){return{...t,runId:t.runId?"<redacted>":null,summary:yv(t.summary,e)??""}}import{accessSync as DG,constants as BG,promises as xu}from"node:fs";import ti from"node:path";H();_r();Se();_o();_r();var Nv="comet.native.workspace-finish.v1",kv="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",Sv=new RegExp(`^${kv}$`,"u"),QR=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,jn=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;function bv(t,e){if(!t.trim()||t.includes("\0"))throw new Error(`${e} must contain non-whitespace text and no NUL character`)}function ZR(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace finish journal is invalid");let e=t;if(e.schema!==Nv||typeof e.name!="string"||!Sv.test(e.name)||typeof e.transactionId!="string"||!QR.test(e.transactionId)||e.archiveDir!==null&&(typeof e.archiveDir!="string"||!ti.isAbsolute(e.archiveDir))||!["pending","blocked"].includes(String(e.status))||typeof e.updatedAt!="string"||!Number.isFinite(Date.parse(e.updatedAt)))throw new Error("Native workspace finish journal is invalid");if(e.result!==null){if(!e.result||typeof e.result!="object"||Array.isArray(e.result))throw new Error("Native workspace finish journal result is invalid");let r=e.result;if(!["merge","push","pull-request","keep"].includes(String(r.action))||!["completed","kept","blocked"].includes(String(r.status))||!Array.isArray(r.blockedPaths)||r.blockedPaths.some(i=>typeof i!="string")||r.recoveryArgs!==null&&(!Array.isArray(r.recoveryArgs)||r.recoveryArgs.some(i=>typeof i!="string")))throw new Error("Native workspace finish journal result is invalid")}if(e.plan!==void 0){let r=e.plan;if(!r||typeof r!="object"||!["keep","merge","push","pull-request"].includes(r.finish)||!["current","branch","worktree"].includes(r.isolation)||![r.changeRoot,r.primaryRoot].every(i=>typeof i=="string"&&ti.isAbsolute(i))||![r.changeBranch,r.targetBranch].every(i=>typeof i=="string"&&i.length>0)||r.targetRoot!==null&&(typeof r.targetRoot!="string"||!ti.isAbsolute(r.targetRoot))||r.remote!==null&&typeof r.remote!="string"||typeof r.commitMessage!="string"||r.mergeMessage!==null&&typeof r.mergeMessage!="string")throw new Error("Native workspace finish journal plan is invalid");bv(r.commitMessage,"commit-message"),r.mergeMessage!==null&&bv(r.mergeMessage,"merge-message")}if(e.createdAt!==void 0&&(typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))))throw new Error("Native workspace finish journal creation identity is invalid");if(e.commit!==void 0){let r=e.commit;if(!r||!jn.test(r.parent)||!Array.isArray(r.paths)||!r.paths.every(i=>typeof i=="string"&&i.length>0&&!ti.posix.isAbsolute(i)&&!ti.win32.isAbsolute(i)&&!i.split("/").includes(".."))||!Array.isArray(r.entries)||!r.entries.every(i=>typeof i=="string")||r.sha!==null&&!jn.test(r.sha))throw new Error("Native workspace finish journal commit is invalid")}if(e.merge!==void 0){let r=e.merge;if(!r||!jn.test(r.target)||!jn.test(r.source)||r.sha!==null&&!jn.test(r.sha))throw new Error("Native workspace finish journal merge is invalid")}return{schema:Nv,name:e.name,transactionId:e.transactionId,archiveDir:e.archiveDir,status:e.status,result:e.result,updatedAt:e.updatedAt,...e.createdAt===void 0?{}:{createdAt:e.createdAt},...e.plan===void 0?{}:{plan:e.plan},...e.commit===void 0?{}:{commit:e.commit},...e.merge===void 0?{}:{merge:e.merge}}}function eP(t,e){if(!Sv.test(e))throw new Error(`Invalid Native workspace finish journal name: ${e}`);return ti.join(t.transactionsDir,`workspace-finish-${e}.json`)}async function Cu(t,e,r={}){let i=eP(t,e);try{let n=await xu.lstat(i);if(!n.isFile()||n.isSymbolicLink())throw new Error("Native workspace finish journal is not a regular file");let a=ZR(JSON.parse(await xu.readFile(i,"utf8")));if(a.name!==e)throw new Error("Native workspace finish journal name is invalid");return a}catch(n){if(n.code==="ENOENT")return null;if(r.onError)return r.onError(e,n instanceof Error?n.message:String(n)),null;throw n}}async function Ev(t,e={}){let r;try{r=await xu.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r){if(!n.isFile()&&!n.isSymbolicLink()||n.isDirectory())continue;let a=new RegExp(`^workspace-finish-(${kv})\\.json$`,"u").exec(n.name);if(!a)continue;let o=await Cu(t,a[1],e);o&&i.push(o)}return i}function Zo(t,e){let r=vr.normalize(Ru(t)),i=vr.normalize(Ru(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Ru(t){let e=vr.resolve(t);try{return tP.native(e)}catch{return e}}async function xv(t,e){let r=[];for(let i of await cv(t))e!==void 0&&i!==e||r.push({name:i,kind:await Xr(t,i)?"portable":"legacy"});return r}async function rP(t,e){let r=vr.resolve(t),i=ja(t),n=i.map(({root:c})=>c),a=n.length>0?n:[r];a.some(c=>Zo(c,r))||a.push(r);let o=[],s=new Set;for(let c of a.map(l=>vr.resolve(l)).sort()){let l=Zo(c,r)?r:c,d=Ru(l),u=process.platform==="win32"?d.toLowerCase():d;if(s.has(u))continue;s.add(u);let p=await pe(l);if(!p)continue;let f=await Je(l,p.native.artifact_root);o.push({projectRoot:l,config:p,paths:f,gitContext:Di(l,i)??G(l),changes:await xv(f,e)})}if(o.length===0){let c=await pe(t);if(!c)throw new Error(".comet/config.yaml was not found in any registered worktree");let l=await Je(t,c.native.artifact_root);o.push({projectRoot:vr.resolve(t),config:c,paths:l,gitContext:Di(t,i)??G(t),changes:await xv(l,e)})}for(let c of o){c.archiveErrors=[],c.finishJournalErrors=[],c.archives=await uv(c.paths,(d,u)=>c.archiveErrors.push({name:d,message:u}),e),e!==void 0&&(c.archives=c.archives.filter(({state:d})=>d.name===e),c.archiveErrors=c.archiveErrors.filter(({name:d})=>d===e));let l=(d,u)=>c.finishJournalErrors.push({name:d,message:u});c.finishJournals=e?[await Cu(c.paths,e,{onError:l})].filter(d=>d!==null):await Ev(c.paths,{onError:l})}return o}function Cv(t,e){return t.workspace.bindingState==="aligned"?0:Zo(t.source.projectRoot,e)?1:t.workspace.bindingState==="legacy"?2:t.workspace.bindingState==="missing"?3:t.workspace.bindingState==="drifted"?4:5}async function iP(t,e){let r=new Map;for(let n of e){for(let a of n.changes)r.set(a.name,[...r.get(a.name)??[],{source:n,kind:a.kind}]);for(let a of n.archives??[])r.has(a.state.name)||r.set(a.state.name,[]);for(let a of n.archiveErrors??[])r.has(a.name)||r.set(a.name,[]);for(let a of n.finishJournals??[])r.has(a.name)||r.set(a.name,[]);for(let a of n.finishJournalErrors??[])r.has(a.name)||r.set(a.name,[])}let i=[];for(let[n,a]of[...r.entries()].sort(([o],[s])=>o.localeCompare(s))){let o=await Promise.all(a.map(async({source:u,kind:p})=>{let f=u.finishJournalErrors?.find(({name:m})=>m===n);if(p==="portable")try{let m=await Be(u.paths,n);return{source:u,name:n,kind:p,workspace:gv(u.paths,m,u.gitContext),portableStatus:null,inspectionError:f?.message??null,finishJournal:u.finishJournals?.find(({name:h})=>h===n)??null}}catch(m){return{source:u,name:n,kind:p,workspace:{projectRoot:u.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:"The portable state could not be inspected."},portableStatus:null,inspectionError:m instanceof Error?m.message:String(m)}}return{source:u,name:n,kind:p,workspace:a.length>1?await Il(u.paths,n):{projectRoot:u.projectRoot,currentBranch:u.gitContext.currentBranch,isSecondaryWorktree:u.gitContext.isSecondaryWorktree,bindingState:"legacy",isolation:null,changeBranch:null,targetBranch:null,finish:null},portableStatus:null,inspectionError:f?.message??null}})),s=e.flatMap(u=>(u.archives??[]).filter(({state:p})=>p.name===n).map(p=>{let f=wv({paths:u.paths,...p,finishJournal:u.finishJournals?.find(({name:m})=>m===n)??null});return{source:u,name:n,kind:"portable",workspace:f.workspace,portableStatus:f,inspectionError:u.finishJournalErrors?.find(({name:m})=>m===n)?.message??null,record:p,finishJournal:u.finishJournals?.find(({name:m})=>m===n)??null}})),c=e.flatMap(u=>(u.archiveErrors??[]).filter(p=>p.name===n).map(p=>({source:u,error:p})))[0];if(c){i.push({source:c.source,name:n,kind:"portable",portableStatus:null,inspectionError:c.error.message,workspace:{projectRoot:c.source.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:c.error.message}});continue}let l=e.flatMap(u=>(u.finishJournalErrors??[]).filter(p=>p.name===n).map(p=>({source:u,error:p})))[0];if(l&&o.length===0&&s.length===0){i.push({source:l.source,name:n,kind:"portable",portableStatus:null,inspectionError:l.error.message,workspace:{projectRoot:l.source.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:l.error.message}});continue}if(o.length===0&&s.length===0){let u=e.find(f=>f.finishJournals?.some(({name:m})=>m===n)),p=u?.finishJournals?.find(({name:f})=>f===n);if(u&&p){i.push({source:u,name:n,kind:"portable",portableStatus:null,inspectionError:p.result?.message??"Native workspace finish journal has no matching active or archived change record.",workspace:{projectRoot:u.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:p.result?.message??"Native workspace finish record is orphaned."},finishJournal:p});continue}}if(s.length>0){for(let p of o)if(p.kind==="portable")try{p.record=await Qo(p.source.paths,vr.join(p.source.paths.changesDir,n,"comet-state.yaml"))}catch{}let u=s.find(p=>[...o,...s.filter(f=>!pv(p.record,f.record))].every(f=>f.record&&dv(p.record,f.record)));if(u){i.push(u);continue}i.push({...s[0],inspectionError:`Native change ${n} has conflicting active/archive records; identity and committed Git ancestry do not prove supersession. Resolve the records explicitly.`});continue}o.sort((u,p)=>Cv(u,t)-Cv(p,t)||u.source.projectRoot.localeCompare(p.source.projectRoot));let d=o.filter(u=>u.workspace.bindingState==="aligned");d.length>1?i.push(...d):d.length===0&&o.length>1?i.push({...o[0],inspectionError:`Native change ${n} has conflicting workspace records and no aligned binding`}):i.push(d[0]??o[0])}if(i.length>Tn.maxChanges)throw new Error(`Native status discovery exceeds ${Tn.maxChanges} visible changes`);return i.sort((n,a)=>`${n.name}\0${n.source.projectRoot}`.localeCompare(`${a.name}\0${a.source.projectRoot}`))}async function nP(t,e){let r=await rP(t,e),i=(await iP(t,r)).filter(n=>n.name===e);if(i.length>1)throw new Error(`Native change ${e} has multiple aligned workspace bindings: ${i.map(n=>n.source.projectRoot).join(", ")}`);return{sources:r,candidates:i}}async function Rv(t){let{sources:e,candidates:r}=await nP(t.projectRoot,t.name);return r.length>0?r[0].source.projectRoot:(e.find(i=>Zo(i.projectRoot,t.projectRoot))??e[0]).projectRoot}async function Pv(t,e){let r=ev(t,"change name");Zm(t);let i=await Rv({projectRoot:e,name:r}),{paths:n}=await iv(i);if(await Xr(n,r)){let u=await Bo({paths:n,name:r}),p=u.state,f=ft(n,r),m=await L({root:f,ref:p.brief,maxBytes:null,includeHash:!1}),h=[];for(let v of p.spec_changes){if(v.source===null)continue;let N=await L({root:f,ref:v.source,maxBytes:null,includeHash:!1});h.push({capability:v.capability,operation:v.operation,source:v.source,content:N.text})}let g={state:p,artifacts:ir(n,p.name),brief:m.text,proposedSpecs:h,continuation:Jr(p,await Gr({paths:n,state:p}),{verifierExecutionRef:Zl(p,u.local),...u.local?{verificationCheckPlans:hu(u.local,u.local.workspace.projectRoot)}:{}})};return{...Ko("show",g),executionCwd:i}}let a=await Ol(n,r);if(a.status==="migration-required")return{...Ko("show",{name:r,artifacts:ir(n,r),schema:a.schema,minimumRuntimeVersion:a.minimumRuntimeVersion,migrationRequired:!0,message:a.message}),executionCwd:i};if(a.status!=="current"||!a.state)throw new Ke(a.schema,a.minimumRuntimeVersion);let o=a.state,s=oe(n,r),c=await nm(n,r),l=await L({root:s,ref:o.brief,maxBytes:null}),d={state:o,artifacts:ir(n,o.name),brief:l.text,proposedSpecs:c};if(Buffer.byteLength(JSON.stringify(d),"utf8")>Xm)throw new Error("Native show output exceeds its serialized byte budget");return{...Ko("show",d),executionCwd:i}}async function _v(t,e,r=process.argv.slice(2)){let i=r.indexOf("--"),n=i<0?[...r]:r.slice(0,i),a=i<0?[]:r.slice(i),o=n.includes("--json"),s=n.includes("--verbose"),c,l;try{ku(n,"--json"),ku(n,"--verbose"),c=Qm(n,"--project-root");let u=[...n,...a],p=async()=>{let f=await tv(c);return{executionCwd:f,...await e(u,f)}};l=rv(t,u)?await Sf(p):await p()}catch(u){l=av(t,u)}let d=ov(l,o,s);return d.stdout&&process.stdout.write(d.stdout),d.stderr&&process.stderr.write(d.stderr+(d.stderr.endsWith(`
250
254
  `)?"":`
251
- `)),d.exitCode}process.exitCode=await Cv("show",xv);
255
+ `)),d.exitCode}process.exitCode=await _v("show",Pv);