@rpamis/comet 0.4.0-rc.3 → 0.4.0-rc.4

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 (229) hide show
  1. package/README.md +1 -0
  2. package/assets/manifest.json +1 -1
  3. package/assets/skills/comet/scripts/comet-archive.mjs +2 -2
  4. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +56 -56
  5. package/assets/skills/comet/scripts/comet-guard.mjs +51 -51
  6. package/assets/skills/comet/scripts/comet-handoff.mjs +29 -29
  7. package/assets/skills/comet/scripts/comet-hook-guard.mjs +35 -35
  8. package/assets/skills/comet/scripts/comet-hook-router.mjs +140 -137
  9. package/assets/skills/comet/scripts/comet-resume-probe.mjs +34 -34
  10. package/assets/skills/comet/scripts/comet-runtime.mjs +69 -69
  11. package/assets/skills/comet/scripts/comet-state.mjs +38 -38
  12. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +20 -20
  13. package/assets/skills/comet-native/SKILL.md +6 -7
  14. package/assets/skills/comet-native/reference/artifacts.md +1 -2
  15. package/assets/skills/comet-native/reference/clarification.md +6 -6
  16. package/assets/skills/comet-native/reference/commands.md +2 -0
  17. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +127 -126
  18. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +136 -135
  19. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +61 -60
  20. package/assets/skills/comet-native/scripts/comet-native-init.mjs +30 -29
  21. package/assets/skills/comet-native/scripts/comet-native-new.mjs +125 -124
  22. package/assets/skills/comet-native/scripts/comet-native-next.mjs +123 -122
  23. package/assets/skills/comet-native/scripts/comet-native-root.mjs +16 -15
  24. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +169 -168
  25. package/assets/skills/comet-native/scripts/comet-native-select.mjs +111 -110
  26. package/assets/skills/comet-native/scripts/comet-native-show.mjs +81 -80
  27. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +118 -117
  28. package/assets/skills/comet-native/scripts/comet-native-status.mjs +108 -107
  29. package/assets/skills-zh/comet-native/SKILL.md +6 -7
  30. package/assets/skills-zh/comet-native/reference/artifacts.md +1 -2
  31. package/assets/skills-zh/comet-native/reference/clarification.md +6 -6
  32. package/assets/skills-zh/comet-native/reference/commands.md +2 -0
  33. package/dist/domains/comet-memory/personal-memory.d.ts.map +1 -1
  34. package/dist/domains/comet-memory/personal-memory.js +41 -0
  35. package/dist/domains/comet-memory/personal-memory.js.map +1 -1
  36. package/dist/domains/comet-memory/types.d.ts +7 -0
  37. package/dist/domains/comet-memory/types.d.ts.map +1 -1
  38. package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
  39. package/dist/domains/comet-native/native-archive-command.js +114 -19
  40. package/dist/domains/comet-native/native-archive-command.js.map +1 -1
  41. package/dist/domains/comet-native/native-artifacts.d.ts +1 -0
  42. package/dist/domains/comet-native/native-artifacts.d.ts.map +1 -1
  43. package/dist/domains/comet-native/native-artifacts.js +53 -2
  44. package/dist/domains/comet-native/native-artifacts.js.map +1 -1
  45. package/dist/domains/comet-native/native-children.d.ts +1 -0
  46. package/dist/domains/comet-native/native-children.d.ts.map +1 -1
  47. package/dist/domains/comet-native/native-children.js +1 -0
  48. package/dist/domains/comet-native/native-children.js.map +1 -1
  49. package/dist/domains/comet-native/native-cli-help.js +6 -6
  50. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  51. package/dist/domains/comet-native/native-doctor-command.d.ts.map +1 -1
  52. package/dist/domains/comet-native/native-doctor-command.js +41 -1
  53. package/dist/domains/comet-native/native-doctor-command.js.map +1 -1
  54. package/dist/domains/comet-native/native-loop-runtime.d.ts +4 -0
  55. package/dist/domains/comet-native/native-loop-runtime.d.ts.map +1 -1
  56. package/dist/domains/comet-native/native-loop-runtime.js +29 -2
  57. package/dist/domains/comet-native/native-loop-runtime.js.map +1 -1
  58. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  59. package/dist/domains/comet-native/native-next-command.js +30 -6
  60. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  61. package/dist/domains/comet-native/native-portable-continuation.d.ts +11 -4
  62. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  63. package/dist/domains/comet-native/native-portable-continuation.js +173 -15
  64. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  65. package/dist/domains/comet-native/native-portable-recovery.d.ts +1 -1
  66. package/dist/domains/comet-native/native-portable-recovery.d.ts.map +1 -1
  67. package/dist/domains/comet-native/native-portable-recovery.js +26 -1
  68. package/dist/domains/comet-native/native-portable-recovery.js.map +1 -1
  69. package/dist/domains/comet-native/native-portable-runtime.d.ts +7 -1
  70. package/dist/domains/comet-native/native-portable-runtime.d.ts.map +1 -1
  71. package/dist/domains/comet-native/native-portable-runtime.js +163 -11
  72. package/dist/domains/comet-native/native-portable-runtime.js.map +1 -1
  73. package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
  74. package/dist/domains/comet-native/native-portable-state.js +6 -0
  75. package/dist/domains/comet-native/native-portable-state.js.map +1 -1
  76. package/dist/domains/comet-native/native-portable-status.d.ts +5 -0
  77. package/dist/domains/comet-native/native-portable-status.d.ts.map +1 -1
  78. package/dist/domains/comet-native/native-portable-status.js +21 -1
  79. package/dist/domains/comet-native/native-portable-status.js.map +1 -1
  80. package/dist/domains/comet-native/native-portable-types.d.ts +1 -0
  81. package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
  82. package/dist/domains/comet-native/native-portable-types.js.map +1 -1
  83. package/dist/domains/comet-native/native-runner-input.d.ts.map +1 -1
  84. package/dist/domains/comet-native/native-runner-input.js +12 -4
  85. package/dist/domains/comet-native/native-runner-input.js.map +1 -1
  86. package/dist/domains/comet-native/native-supervisor-overlay.d.ts +30 -0
  87. package/dist/domains/comet-native/native-supervisor-overlay.d.ts.map +1 -0
  88. package/dist/domains/comet-native/native-supervisor-overlay.js +202 -0
  89. package/dist/domains/comet-native/native-supervisor-overlay.js.map +1 -0
  90. package/dist/domains/comet-native/native-supervisor.d.ts.map +1 -1
  91. package/dist/domains/comet-native/native-supervisor.js +7 -3
  92. package/dist/domains/comet-native/native-supervisor.js.map +1 -1
  93. package/dist/domains/comet-native/native-types.d.ts +1 -0
  94. package/dist/domains/comet-native/native-types.d.ts.map +1 -1
  95. package/dist/domains/comet-native/native-workspace-finish.d.ts +12 -1
  96. package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -1
  97. package/dist/domains/comet-native/native-workspace-finish.js +77 -22
  98. package/dist/domains/comet-native/native-workspace-finish.js.map +1 -1
  99. package/dist/domains/dashboard/web/assets/{abnfDiagram-VCTEODGH-UcCx24DV.js → abnfDiagram-VCTEODGH-Bql0JkFh.js} +1 -1
  100. package/dist/domains/dashboard/web/assets/{arc-n8qsRq7W.js → arc-CCUY9L8x.js} +1 -1
  101. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-F2w5dggy.js +1 -0
  102. package/dist/domains/dashboard/web/assets/{architectureDiagram-5GKGNRK7-D4pJ8CU0.js → architectureDiagram-5GKGNRK7-iYP_D3CC.js} +1 -1
  103. package/dist/domains/dashboard/web/assets/{blockDiagram-I7D4REHJ-C7n-qrSQ.js → blockDiagram-I7D4REHJ-DyW07-ad.js} +1 -1
  104. package/dist/domains/dashboard/web/assets/{c4Diagram-7LVT6UL2-cMVrWYOm.js → c4Diagram-7LVT6UL2-DDD_Y9Gj.js} +1 -1
  105. package/dist/domains/dashboard/web/assets/channel-DLABCQMO.js +1 -0
  106. package/dist/domains/dashboard/web/assets/{chunk-4HAMMTFA-CE5QrCQd.js → chunk-4HAMMTFA-cZryt4d4.js} +1 -1
  107. package/dist/domains/dashboard/web/assets/{chunk-75Z2AOVW-BtZqN-pM.js → chunk-75Z2AOVW-Ciqzt_fM.js} +1 -1
  108. package/dist/domains/dashboard/web/assets/{chunk-DU6HZSFF-CChv0huc.js → chunk-DU6HZSFF-0EtIdyLT.js} +1 -1
  109. package/dist/domains/dashboard/web/assets/{chunk-F27PBJKO-CDT1ttJ8.js → chunk-F27PBJKO-B09yMHfO.js} +1 -1
  110. package/dist/domains/dashboard/web/assets/{chunk-GMAD6QVW-y5m6LMR7.js → chunk-GMAD6QVW-D_hJqXpD.js} +1 -1
  111. package/dist/domains/dashboard/web/assets/{chunk-GVQU2GXP-DkhKkaHd.js → chunk-GVQU2GXP-DIvLb3as.js} +1 -1
  112. package/dist/domains/dashboard/web/assets/{chunk-IMKFNOWR-BaDSh7Jp.js → chunk-IMKFNOWR-B_oII0H5.js} +1 -1
  113. package/dist/domains/dashboard/web/assets/{chunk-L3NEJ4N5-B4ztH2fV.js → chunk-L3NEJ4N5-BALKwnUb.js} +1 -1
  114. package/dist/domains/dashboard/web/assets/{chunk-OSK3NFVY-BhX6NVzA.js → chunk-OSK3NFVY-zA0G74ff.js} +1 -1
  115. package/dist/domains/dashboard/web/assets/{chunk-P2QGCYS3-BCNdGJkX.js → chunk-P2QGCYS3-B9FFBdWw.js} +1 -1
  116. package/dist/domains/dashboard/web/assets/{chunk-POPQ4Y6H-DwYVuiXw.js → chunk-POPQ4Y6H-Fwh05sRj.js} +1 -1
  117. package/dist/domains/dashboard/web/assets/{chunk-PWAF6VOD-Cyg0IO0R.js → chunk-PWAF6VOD-cCaczJjE.js} +1 -1
  118. package/dist/domains/dashboard/web/assets/{chunk-SHT3W25Y-BZ6skx8I.js → chunk-SHT3W25Y-ffjS5Q53.js} +1 -1
  119. package/dist/domains/dashboard/web/assets/{chunk-SVP7TREG-CLIGmSO0.js → chunk-SVP7TREG-IDmA7lw7.js} +1 -1
  120. package/dist/domains/dashboard/web/assets/{chunk-TICWLB2K-BAQBbsn9.js → chunk-TICWLB2K-8Gmmm4In.js} +1 -1
  121. package/dist/domains/dashboard/web/assets/{chunk-XXDRQBXY-D07UbEpV.js → chunk-XXDRQBXY-DS9V6N2-.js} +1 -1
  122. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-DJ9Y8TBe.js +1 -0
  123. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-DJ9Y8TBe.js +1 -0
  124. package/dist/domains/dashboard/web/assets/{cose-bilkent-JH36ORCC-wIi0mUih.js → cose-bilkent-JH36ORCC-DTBreOtW.js} +1 -1
  125. package/dist/domains/dashboard/web/assets/{cynefin-OW5HDTMX-DBdxyuTN.js → cynefin-OW5HDTMX-DQuEyCa9.js} +1 -1
  126. package/dist/domains/dashboard/web/assets/{cynefinDiagram-5FMLGOSQ-DzO3jXxV.js → cynefinDiagram-5FMLGOSQ-Bb0YxnR5.js} +1 -1
  127. package/dist/domains/dashboard/web/assets/{dagre-GXQ25YYZ-CE7H_hZS.js → dagre-GXQ25YYZ-DCdqnZ1z.js} +1 -1
  128. package/dist/domains/dashboard/web/assets/{diagram-S7CK7UJ4-jUGQk5n-.js → diagram-S7CK7UJ4-CBO5Oebq.js} +1 -1
  129. package/dist/domains/dashboard/web/assets/{diagram-UQ7AKVKN-DaH_zW8T.js → diagram-UQ7AKVKN-Do5KGiae.js} +1 -1
  130. package/dist/domains/dashboard/web/assets/{diagram-VSXAHHWV-DmG80db0.js → diagram-VSXAHHWV-4Xskky28.js} +1 -1
  131. package/dist/domains/dashboard/web/assets/{diagram-VX7I27RA-ltQ6niKn.js → diagram-VX7I27RA-DHaxCMg1.js} +1 -1
  132. package/dist/domains/dashboard/web/assets/{diagram-Z3DM3KII-x92ex4lK.js → diagram-Z3DM3KII-_b0C8RCs.js} +1 -1
  133. package/dist/domains/dashboard/web/assets/{dist-Cf0h0n6i.js → dist-D_v6faRz.js} +1 -1
  134. package/dist/domains/dashboard/web/assets/{ebnfDiagram-PWID7BFC-CI2u976k.js → ebnfDiagram-PWID7BFC-BlWWQsBx.js} +1 -1
  135. package/dist/domains/dashboard/web/assets/{erDiagram-RLTQ6QDP-DKs90SRd.js → erDiagram-RLTQ6QDP-CaZks0yu.js} +1 -1
  136. package/dist/domains/dashboard/web/assets/{es-D7xGlyQk.js → es-DMM6Y5Bv.js} +1 -1
  137. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-LE_eXkBk.js +1 -0
  138. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-Dhg9N1uf.js +1 -0
  139. package/dist/domains/dashboard/web/assets/{ganttDiagram-EL5Y4UJY-D3z6G60S.js → ganttDiagram-EL5Y4UJY-BSjOQ_Cg.js} +1 -1
  140. package/dist/domains/dashboard/web/assets/{gitGraph-4MIJSDKK-vT1UnORT.js → gitGraph-4MIJSDKK-DYwq3-1L.js} +1 -1
  141. package/dist/domains/dashboard/web/assets/{gitGraphDiagram-WWUBYQGX-BJmJ96jv.js → gitGraphDiagram-WWUBYQGX-oVngpACZ.js} +1 -1
  142. package/dist/domains/dashboard/web/assets/{index-BG3MF8re.js → index-7epoYLF6.js} +31 -31
  143. package/dist/domains/dashboard/web/assets/index-C5iz4lns.css +1 -0
  144. package/dist/domains/dashboard/web/assets/{info-A6RAGUB7-DFeLqqen.js → info-A6RAGUB7-CLoje88f.js} +1 -1
  145. package/dist/domains/dashboard/web/assets/{infoDiagram-27XIBGKW-DxuY43XD.js → infoDiagram-27XIBGKW-sS6zp9EL.js} +1 -1
  146. package/dist/domains/dashboard/web/assets/{ishikawaDiagram-5VMMS53U-DxillfWQ.js → ishikawaDiagram-5VMMS53U-kETJqqgb.js} +1 -1
  147. package/dist/domains/dashboard/web/assets/{journeyDiagram-3NMN7TZE-BPngQ3ag.js → journeyDiagram-3NMN7TZE-ByJPB5Tw.js} +1 -1
  148. package/dist/domains/dashboard/web/assets/{kanban-definition-UXKFOSKX-DHMLEGD4.js → kanban-definition-UXKFOSKX-JKqPn1FZ.js} +1 -1
  149. package/dist/domains/dashboard/web/assets/{line-D31peBjo.js → line-CnHo6lWD.js} +1 -1
  150. package/dist/domains/dashboard/web/assets/{linear-B7X50T2m.js → linear-B2pLEjo4.js} +1 -1
  151. package/dist/domains/dashboard/web/assets/{mermaid-parser.core-CX3Pzygh.js → mermaid-parser.core-OtNk5rQN.js} +3 -3
  152. package/dist/domains/dashboard/web/assets/{mermaid.core-DlMjBFb6.js → mermaid.core-D1ElL3aM.js} +4 -4
  153. package/dist/domains/dashboard/web/assets/{mindmap-definition-YA3MSWOX-BKuSGF75.js → mindmap-definition-YA3MSWOX-BxJqN_qn.js} +1 -1
  154. package/dist/domains/dashboard/web/assets/{packet-AYTQ26CC-B1T8Bds9.js → packet-AYTQ26CC-DM9DL0wE.js} +1 -1
  155. package/dist/domains/dashboard/web/assets/{pegDiagram-XKGWAZYB-BYgTNxLw.js → pegDiagram-XKGWAZYB-BDe-x6aH.js} +1 -1
  156. package/dist/domains/dashboard/web/assets/{pie-WAS4IAKB-fqAjmoQw.js → pie-WAS4IAKB-ClmkkApZ.js} +1 -1
  157. package/dist/domains/dashboard/web/assets/{pieDiagram-E7YTZNPT-BAO0Ufky.js → pieDiagram-E7YTZNPT-DSFQ6yQn.js} +1 -1
  158. package/dist/domains/dashboard/web/assets/{quadrantDiagram-AXDQQJYC-SA_1-7DT.js → quadrantDiagram-AXDQQJYC-CV2lLCpu.js} +1 -1
  159. package/dist/domains/dashboard/web/assets/{radar-RG4KPBEZ-Bl_UfUle.js → radar-RG4KPBEZ-BduOvwgQ.js} +1 -1
  160. package/dist/domains/dashboard/web/assets/{railroad-74A4TZTK-yj6dkiSy.js → railroad-74A4TZTK-BYnUo_HE.js} +1 -1
  161. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CPiOAGi2.js +1 -0
  162. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-DOuNY-jw.js +1 -0
  163. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-DjNccNww.js +1 -0
  164. package/dist/domains/dashboard/web/assets/{railroadDiagram-O6MQD6OU-DqV18Y46.js → railroadDiagram-O6MQD6OU-Y0OnScVm.js} +1 -1
  165. package/dist/domains/dashboard/web/assets/{requirementDiagram-BXWQKSXE-Ca2K5LuT.js → requirementDiagram-BXWQKSXE-Dqs0b-_F.js} +1 -1
  166. package/dist/domains/dashboard/web/assets/{sankeyDiagram-P5KCCOFB-D9MKl-Nr.js → sankeyDiagram-P5KCCOFB-DafYyCgJ.js} +1 -1
  167. package/dist/domains/dashboard/web/assets/{sequenceDiagram-WJ2MYXX4-CXfvIzRx.js → sequenceDiagram-WJ2MYXX4-DEu4sb48.js} +1 -1
  168. package/dist/domains/dashboard/web/assets/{src-CquUPIQx.js → src-je_XM8Ul.js} +1 -1
  169. package/dist/domains/dashboard/web/assets/{stateDiagram-D77RDMKH-B7iaZHW7.js → stateDiagram-D77RDMKH-vHbZoYCK.js} +1 -1
  170. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-C4dywNHK.js +1 -0
  171. package/dist/domains/dashboard/web/assets/{swimlanes-42K2YHIH-OK-62yZl.js → swimlanes-42K2YHIH-DxEqhoUX.js} +1 -1
  172. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-CHhHUVep.js +8 -0
  173. package/dist/domains/dashboard/web/assets/{timeline-definition-24CTP7MA-D0l01B1h.js → timeline-definition-24CTP7MA-B4XpTytf.js} +1 -1
  174. package/dist/domains/dashboard/web/assets/{treeView-Q6P3EWNA-Bg5u_o3A.js → treeView-Q6P3EWNA-CrismRW3.js} +1 -1
  175. package/dist/domains/dashboard/web/assets/{treemap-WGGIJYW6-x89ccozk.js → treemap-WGGIJYW6-BGFmknIY.js} +1 -1
  176. package/dist/domains/dashboard/web/assets/{vennDiagram-4TSXK5OY-DV19Cqhv.js → vennDiagram-4TSXK5OY-DphMzj7N.js} +1 -1
  177. package/dist/domains/dashboard/web/assets/{wardley-WFR3VGLG-BWoeoVk5.js → wardley-WFR3VGLG-DmeLufag.js} +1 -1
  178. package/dist/domains/dashboard/web/assets/{wardleyDiagram-VM6X3IG4-D4fCpoIP.js → wardleyDiagram-VM6X3IG4-BUDxONKk.js} +1 -1
  179. package/dist/domains/dashboard/web/assets/{xychartDiagram-S5SC5T6Z-DALnOMLb.js → xychartDiagram-S5SC5T6Z-BjqVHkW2.js} +1 -1
  180. package/dist/domains/dashboard/web/index.html +2 -2
  181. package/dist/domains/project-knowledge/deterministic-extractors.d.ts.map +1 -1
  182. package/dist/domains/project-knowledge/deterministic-extractors.js +7 -6
  183. package/dist/domains/project-knowledge/deterministic-extractors.js.map +1 -1
  184. package/dist/domains/project-knowledge/index-store.d.ts +1 -1
  185. package/dist/domains/project-knowledge/index-store.d.ts.map +1 -1
  186. package/dist/domains/project-knowledge/index-store.js +19 -10
  187. package/dist/domains/project-knowledge/index-store.js.map +1 -1
  188. package/dist/domains/project-knowledge/learning.d.ts +1 -0
  189. package/dist/domains/project-knowledge/learning.d.ts.map +1 -1
  190. package/dist/domains/project-knowledge/learning.js +27 -8
  191. package/dist/domains/project-knowledge/learning.js.map +1 -1
  192. package/dist/domains/project-knowledge/local-provider.d.ts +1 -0
  193. package/dist/domains/project-knowledge/local-provider.d.ts.map +1 -1
  194. package/dist/domains/project-knowledge/local-provider.js +26 -1
  195. package/dist/domains/project-knowledge/local-provider.js.map +1 -1
  196. package/dist/domains/project-knowledge/local-store.d.ts +2 -1
  197. package/dist/domains/project-knowledge/local-store.d.ts.map +1 -1
  198. package/dist/domains/project-knowledge/local-store.js +82 -22
  199. package/dist/domains/project-knowledge/local-store.js.map +1 -1
  200. package/dist/domains/project-knowledge/plugin.d.ts.map +1 -1
  201. package/dist/domains/project-knowledge/plugin.js +55 -8
  202. package/dist/domains/project-knowledge/plugin.js.map +1 -1
  203. package/dist/domains/project-knowledge/records.d.ts +2 -0
  204. package/dist/domains/project-knowledge/records.d.ts.map +1 -1
  205. package/dist/domains/project-knowledge/records.js +8 -0
  206. package/dist/domains/project-knowledge/records.js.map +1 -1
  207. package/dist/domains/project-knowledge/types.d.ts +16 -0
  208. package/dist/domains/project-knowledge/types.d.ts.map +1 -1
  209. package/dist/domains/workflow-contract/protected-project-path.d.ts +4 -1
  210. package/dist/domains/workflow-contract/protected-project-path.d.ts.map +1 -1
  211. package/dist/domains/workflow-contract/protected-project-path.js +25 -1
  212. package/dist/domains/workflow-contract/protected-project-path.js.map +1 -1
  213. package/dist/platform/fs/race-safe-read.d.ts +14 -0
  214. package/dist/platform/fs/race-safe-read.d.ts.map +1 -1
  215. package/dist/platform/fs/race-safe-read.js +81 -0
  216. package/dist/platform/fs/race-safe-read.js.map +1 -1
  217. package/package.json +1 -1
  218. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-B5p4GzJf.js +0 -1
  219. package/dist/domains/dashboard/web/assets/channel-BZeSeXVb.js +0 -1
  220. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-2fcinal6.js +0 -1
  221. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-2fcinal6.js +0 -1
  222. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-uARcGZPD.js +0 -1
  223. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-DXL1E4Bl.js +0 -1
  224. package/dist/domains/dashboard/web/assets/index-C2Hlo7VZ.css +0 -1
  225. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CvouMciM.js +0 -1
  226. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-CkYQEX72.js +0 -1
  227. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-B0uYr48F.js +0 -1
  228. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-B6KoHQVe.js +0 -1
  229. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-CjdOls9K.js +0 -8
@@ -1,170 +1,171 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var Sf=Object.create;var Ss=Object.defineProperty;var Ef=Object.getOwnPropertyDescriptor;var Cf=Object.getOwnPropertyNames;var xf=Object.getPrototypeOf,Pf=Object.prototype.hasOwnProperty;var Br=(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 g=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Rf=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Cf(e))!Pf.call(t,n)&&n!==r&&Ss(t,n,{get:()=>e[n],enumerable:!(i=Ef(e,n))||i.enumerable});return t};var Bt=(t,e,r)=>(r=t!=null?Sf(xf(t)):{},Rf(e||!t||!t.__esModule?Ss(r,"default",{value:t,enumerable:!0}):r,t));var x=g(V=>{"use strict";var Wn=Symbol.for("yaml.alias"),Is=Symbol.for("yaml.document"),zr=Symbol.for("yaml.map"),Ts=Symbol.for("yaml.pair"),zn=Symbol.for("yaml.scalar"),Jr=Symbol.for("yaml.seq"),xe=Symbol.for("yaml.node.type"),Xf=t=>!!t&&typeof t=="object"&&t[xe]===Wn,Qf=t=>!!t&&typeof t=="object"&&t[xe]===Is,Zf=t=>!!t&&typeof t=="object"&&t[xe]===zr,ep=t=>!!t&&typeof t=="object"&&t[xe]===Ts,js=t=>!!t&&typeof t=="object"&&t[xe]===zn,tp=t=>!!t&&typeof t=="object"&&t[xe]===Jr;function $s(t){if(t&&typeof t=="object")switch(t[xe]){case zr:case Jr:return!0}return!1}function rp(t){if(t&&typeof t=="object")switch(t[xe]){case Wn:case zr:case zn:case Jr:return!0}return!1}var ip=t=>(js(t)||$s(t))&&!!t.anchor;V.ALIAS=Wn;V.DOC=Is;V.MAP=zr;V.NODE_TYPE=xe;V.PAIR=Ts;V.SCALAR=zn;V.SEQ=Jr;V.hasAnchor=ip;V.isAlias=Xf;V.isCollection=$s;V.isDocument=Qf;V.isMap=Zf;V.isNode=rp;V.isPair=ep;V.isScalar=js;V.isSeq=tp});var qt=g(Jn=>{"use strict";var D=x(),J=Symbol("break visit"),Os=Symbol("skip children"),he=Symbol("remove node");function Gr(t,e){let r=Hs(e);D.isDocument(t)?mt(null,t.contents,r,Object.freeze([t]))===he&&(t.contents=null):mt(null,t,r,Object.freeze([]))}Gr.BREAK=J;Gr.SKIP=Os;Gr.REMOVE=he;function mt(t,e,r,i){let n=Ds(t,e,r,i);if(D.isNode(n)||D.isPair(n))return Ls(t,i,n),mt(t,n,r,i);if(typeof n!="symbol"){if(D.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=mt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===J)return J;o===he&&(e.items.splice(a,1),a-=1)}}}else if(D.isPair(e)){i=Object.freeze(i.concat(e));let a=mt("key",e.key,r,i);if(a===J)return J;a===he&&(e.key=null);let o=mt("value",e.value,r,i);if(o===J)return J;o===he&&(e.value=null)}}return n}async function Ur(t,e){let r=Hs(e);D.isDocument(t)?await vt(null,t.contents,r,Object.freeze([t]))===he&&(t.contents=null):await vt(null,t,r,Object.freeze([]))}Ur.BREAK=J;Ur.SKIP=Os;Ur.REMOVE=he;async function vt(t,e,r,i){let n=await Ds(t,e,r,i);if(D.isNode(n)||D.isPair(n))return Ls(t,i,n),vt(t,n,r,i);if(typeof n!="symbol"){if(D.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await vt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===J)return J;o===he&&(e.items.splice(a,1),a-=1)}}}else if(D.isPair(e)){i=Object.freeze(i.concat(e));let a=await vt("key",e.key,r,i);if(a===J)return J;a===he&&(e.key=null);let o=await vt("value",e.value,r,i);if(o===J)return J;o===he&&(e.value=null)}}return n}function Hs(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 Ds(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(D.isMap(e))return r.Map?.(t,e,i);if(D.isSeq(e))return r.Seq?.(t,e,i);if(D.isPair(e))return r.Pair?.(t,e,i);if(D.isScalar(e))return r.Scalar?.(t,e,i);if(D.isAlias(e))return r.Alias?.(t,e,i)}function Ls(t,e,r){let i=e[e.length-1];if(D.isCollection(i))i.items[t]=r;else if(D.isPair(i))t==="key"?i.key=r:i.value=r;else if(D.isDocument(i))i.contents=r;else{let n=D.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Jn.visit=Gr;Jn.visitAsync=Ur});var Gn=g(Vs=>{"use strict";var Bs=x(),np=qt(),ap={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},op=t=>t.replace(/[!,[\]{}]/g,e=>ap[e]),Wt=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+op(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&&Bs.isNode(e.contents)){let a={};np.visit(e.contents,(o,s)=>{Bs.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
- `)}};Wt.defaultYaml={explicit:!1,version:"1.2"};Wt.defaultTags={"!!":"tag:yaml.org,2002:"};Vs.Directives=Wt});var Kr=g(zt=>{"use strict";var Ms=x(),sp=qt();function cp(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 Fs(t){let e=new Set;return sp.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function qs(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function lp(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Fs(t));let o=qs(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Ms.isScalar(o.node)||Ms.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}}zt.anchorIsValid=cp;zt.anchorNames=Fs;zt.createNodeAnchors=lp;zt.findNewAnchor=qs});var Un=g(Ws=>{"use strict";function Jt(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=Jt(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=Jt(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=Jt(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=Jt(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}Ws.applyReviver=Jt});var Oe=g(Js=>{"use strict";var up=x();function zs(t,e,r){if(Array.isArray(t))return t.map((i,n)=>zs(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!up.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}Js.toJS=zs});var Yr=g(Us=>{"use strict";var dp=Un(),Gs=x(),fp=Oe(),Kn=class{constructor(e){Object.defineProperty(this,Gs.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(!Gs.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=fp.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?dp.applyReviver(a,{"":s},"",s):s}};Us.NodeBase=Kn});var Gt=g(Ks=>{"use strict";var pp=Kr(),hp=qt(),gt=x(),mp=Yr(),vp=Oe(),Yn=class extends mp.NodeBase{constructor(e){super(gt.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=[],hp.visit(e,{Node:(a,o)=>{(gt.isAlias(o)||gt.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||(vp.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=Xr(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(pp.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 Xr(t,e,r){if(gt.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(gt.isCollection(e)){let i=0;for(let n of e.items){let a=Xr(t,n,r);a>i&&(i=a)}return i}else if(gt.isPair(e)){let i=Xr(t,e.key,r),n=Xr(t,e.value,r);return Math.max(i,n)}return 1}Ks.Alias=Yn});var j=g(Xn=>{"use strict";var gp=x(),wp=Yr(),yp=Oe(),Np=t=>!t||typeof t!="function"&&typeof t!="object",He=class extends wp.NodeBase{constructor(e){super(gp.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:yp.toJS(this.value,e,r)}toString(){return String(this.value)}};He.BLOCK_FOLDED="BLOCK_FOLDED";He.BLOCK_LITERAL="BLOCK_LITERAL";He.PLAIN="PLAIN";He.QUOTE_DOUBLE="QUOTE_DOUBLE";He.QUOTE_SINGLE="QUOTE_SINGLE";Xn.Scalar=He;Xn.isScalarValue=Np});var Ut=g(Xs=>{"use strict";var bp=Gt(),Ze=x(),Ys=j(),kp="tag:yaml.org,2002:";function Sp(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 Ep(t,e,r){if(Ze.isDocument(t)&&(t=t.contents),Ze.isNode(t))return t;if(Ze.isPair(t)){let u=r.schema[Ze.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 bp.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=kp+e.slice(2));let l=Sp(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new Ys.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?o[Ze.MAP]:Symbol.iterator in Object(t)?o[Ze.SEQ]:o[Ze.MAP]}a&&(a(l),delete r.onTagObj);let f=l?.createNode?l.createNode(r.schema,t,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,t,r):new Ys.Scalar(t);return e?f.tag=e:l.default||(f.tag=l.tag),c&&(c.node=f),f}Xs.createNode=Ep});var Zr=g(Qr=>{"use strict";var Cp=Ut(),me=x(),xp=Yr();function Qn(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 Cp.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 Qs=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Zn=class extends xp.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=>me.isNode(i)||me.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(Qs(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(me.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,Qn(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(me.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&&me.isScalar(a)?a.value:a:me.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!me.isPair(r))return!1;let i=r.value;return i==null||e&&me.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 me.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(me.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,Qn(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Qr.Collection=Zn;Qr.collectionFromPath=Qn;Qr.isEmptyPath=Qs});var Kt=g(ei=>{"use strict";var Pp=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function ea(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Rp=(t,e,r)=>t.endsWith(`
6
- `)?ea(r,e):r.includes(`
4
+ var Ef=Object.create;var Ss=Object.defineProperty;var Cf=Object.getOwnPropertyDescriptor;var xf=Object.getOwnPropertyNames;var Pf=Object.getPrototypeOf,Rf=Object.prototype.hasOwnProperty;var Br=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var g=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var Af=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of xf(t))!Rf.call(e,n)&&n!==r&&Ss(e,n,{get:()=>t[n],enumerable:!(i=Cf(t,n))||i.enumerable});return e};var Mt=(e,t,r)=>(r=e!=null?Ef(Pf(e)):{},Af(t||!e||!e.__esModule?Ss(r,"default",{value:e,enumerable:!0}):r,e));var x=g(M=>{"use strict";var Wn=Symbol.for("yaml.alias"),Is=Symbol.for("yaml.document"),zr=Symbol.for("yaml.map"),Ts=Symbol.for("yaml.pair"),zn=Symbol.for("yaml.scalar"),Jr=Symbol.for("yaml.seq"),Pe=Symbol.for("yaml.node.type"),eh=e=>!!e&&typeof e=="object"&&e[Pe]===Wn,th=e=>!!e&&typeof e=="object"&&e[Pe]===Is,rh=e=>!!e&&typeof e=="object"&&e[Pe]===zr,ih=e=>!!e&&typeof e=="object"&&e[Pe]===Ts,js=e=>!!e&&typeof e=="object"&&e[Pe]===zn,nh=e=>!!e&&typeof e=="object"&&e[Pe]===Jr;function $s(e){if(e&&typeof e=="object")switch(e[Pe]){case zr:case Jr:return!0}return!1}function ah(e){if(e&&typeof e=="object")switch(e[Pe]){case Wn:case zr:case zn:case Jr:return!0}return!1}var oh=e=>(js(e)||$s(e))&&!!e.anchor;M.ALIAS=Wn;M.DOC=Is;M.MAP=zr;M.NODE_TYPE=Pe;M.PAIR=Ts;M.SCALAR=zn;M.SEQ=Jr;M.hasAnchor=oh;M.isAlias=eh;M.isCollection=$s;M.isDocument=th;M.isMap=rh;M.isNode=ah;M.isPair=ih;M.isScalar=js;M.isSeq=nh});var qt=g(Jn=>{"use strict";var D=x(),J=Symbol("break visit"),Os=Symbol("skip children"),pe=Symbol("remove node");function Gr(e,t){let r=Hs(t);D.isDocument(e)?vt(null,e.contents,r,Object.freeze([e]))===pe&&(e.contents=null):vt(null,e,r,Object.freeze([]))}Gr.BREAK=J;Gr.SKIP=Os;Gr.REMOVE=pe;function vt(e,t,r,i){let n=Ds(e,t,r,i);if(D.isNode(n)||D.isPair(n))return Ls(e,i,n),vt(e,n,r,i);if(typeof n!="symbol"){if(D.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=vt(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===J)return J;o===pe&&(t.items.splice(a,1),a-=1)}}}else if(D.isPair(t)){i=Object.freeze(i.concat(t));let a=vt("key",t.key,r,i);if(a===J)return J;a===pe&&(t.key=null);let o=vt("value",t.value,r,i);if(o===J)return J;o===pe&&(t.value=null)}}return n}async function Ur(e,t){let r=Hs(t);D.isDocument(e)?await gt(null,e.contents,r,Object.freeze([e]))===pe&&(e.contents=null):await gt(null,e,r,Object.freeze([]))}Ur.BREAK=J;Ur.SKIP=Os;Ur.REMOVE=pe;async function gt(e,t,r,i){let n=await Ds(e,t,r,i);if(D.isNode(n)||D.isPair(n))return Ls(e,i,n),gt(e,n,r,i);if(typeof n!="symbol"){if(D.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=await gt(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===J)return J;o===pe&&(t.items.splice(a,1),a-=1)}}}else if(D.isPair(t)){i=Object.freeze(i.concat(t));let a=await gt("key",t.key,r,i);if(a===J)return J;a===pe&&(t.key=null);let o=await gt("value",t.value,r,i);if(o===J)return J;o===pe&&(t.value=null)}}return n}function Hs(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Ds(e,t,r,i){if(typeof r=="function")return r(e,t,i);if(D.isMap(t))return r.Map?.(e,t,i);if(D.isSeq(t))return r.Seq?.(e,t,i);if(D.isPair(t))return r.Pair?.(e,t,i);if(D.isScalar(t))return r.Scalar?.(e,t,i);if(D.isAlias(t))return r.Alias?.(e,t,i)}function Ls(e,t,r){let i=t[t.length-1];if(D.isCollection(i))i.items[e]=r;else if(D.isPair(i))e==="key"?i.key=r:i.value=r;else if(D.isDocument(i))i.contents=r;else{let n=D.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Jn.visit=Gr;Jn.visitAsync=Ur});var Gn=g(Ms=>{"use strict";var Bs=x(),sh=qt(),ch={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},lh=e=>e.replace(/[!,[\]{}]/g,t=>ch[t]),Wt=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||r(`The ${t} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,i]of Object.entries(this.tags))if(t.startsWith(i))return r+lh(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(t&&i.length>0&&Bs.isNode(t.contents)){let a={};sh.visit(t.contents,(o,s)=>{Bs.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(`
5
+ `)}};Wt.defaultYaml={explicit:!1,version:"1.2"};Wt.defaultTags={"!!":"tag:yaml.org,2002:"};Ms.Directives=Wt});var Kr=g(zt=>{"use strict";var Vs=x(),uh=qt();function dh(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function Fs(e){let t=new Set;return uh.visit(e,{Value(r,i){i.anchor&&t.add(i.anchor)}}),t}function qs(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function fh(e,t){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Fs(e));let o=qs(t,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Vs.isScalar(o.node)||Vs.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}}zt.anchorIsValid=dh;zt.anchorNames=Fs;zt.createNodeAnchors=fh;zt.findNewAnchor=qs});var Un=g(Ws=>{"use strict";function Jt(e,t,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=Jt(e,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=Jt(e,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=Jt(e,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=Jt(e,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return e.call(t,r,i)}Ws.applyReviver=Jt});var De=g(Js=>{"use strict";var hh=x();function zs(e,t,r){if(Array.isArray(e))return e.map((i,n)=>zs(i,String(n),r));if(e&&typeof e.toJSON=="function"){if(!r||!hh.hasAnchor(e))return e.toJSON(t,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=e.toJSON(t,r);return r.onCreate&&r.onCreate(n),n}return typeof e=="bigint"&&!r?.keep?Number(e):e}Js.toJS=zs});var Yr=g(Us=>{"use strict";var ph=Un(),Gs=x(),mh=De(),Kn=class{constructor(t){Object.defineProperty(this,Gs.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!Gs.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=mh.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?ph.applyReviver(a,{"":s},"",s):s}};Us.NodeBase=Kn});var Gt=g(Ks=>{"use strict";var vh=Kr(),gh=qt(),wt=x(),wh=Yr(),yh=De(),Yn=class extends wh.NodeBase{constructor(t){super(wt.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],gh.visit(t,{Node:(a,o)=>{(wt.isAlias(o)||wt.hasAnchor(o))&&i.push(o)}}),r&&(r.aliasResolveCache=i));let n;for(let a of i){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(t,r){if(!r)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:a}=r,o=this.resolve(n,r);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=i.get(o);if(s||(yh.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=Xr(n,o,i)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(t,r,i){let n=`*${this.source}`;if(t){if(vh.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${n} `}return n}};function Xr(e,t,r){if(wt.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(wt.isCollection(t)){let i=0;for(let n of t.items){let a=Xr(e,n,r);a>i&&(i=a)}return i}else if(wt.isPair(t)){let i=Xr(e,t.key,r),n=Xr(e,t.value,r);return Math.max(i,n)}return 1}Ks.Alias=Yn});var j=g(Xn=>{"use strict";var Nh=x(),bh=Yr(),kh=De(),Sh=e=>!e||typeof e!="function"&&typeof e!="object",Le=class extends bh.NodeBase{constructor(t){super(Nh.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:kh.toJS(this.value,t,r)}toString(){return String(this.value)}};Le.BLOCK_FOLDED="BLOCK_FOLDED";Le.BLOCK_LITERAL="BLOCK_LITERAL";Le.PLAIN="PLAIN";Le.QUOTE_DOUBLE="QUOTE_DOUBLE";Le.QUOTE_SINGLE="QUOTE_SINGLE";Xn.Scalar=Le;Xn.isScalarValue=Sh});var Ut=g(Xs=>{"use strict";var Eh=Gt(),Ze=x(),Ys=j(),Ch="tag:yaml.org,2002:";function xh(e,t,r){if(t){let i=r.filter(a=>a.tag===t),n=i.find(a=>!a.format)??i[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return r.find(i=>i.identify?.(e)&&!i.format)}function Ph(e,t,r){if(Ze.isDocument(e)&&(e=e.contents),Ze.isNode(e))return e;if(Ze.isPair(e)){let u=r.schema[Ze.MAP].createNode?.(r.schema,null,r);return u.items.push(e),u}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=r,c;if(i&&e&&typeof e=="object"){if(c=s.get(e),c)return c.anchor??(c.anchor=n(e)),new Eh.Alias(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith("!!")&&(t=Ch+t.slice(2));let l=xh(e,t,o.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let u=new Ys.Scalar(e);return c&&(c.node=u),u}l=e instanceof Map?o[Ze.MAP]:Symbol.iterator in Object(e)?o[Ze.SEQ]:o[Ze.MAP]}a&&(a(l),delete r.onTagObj);let f=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,e,r):new Ys.Scalar(e);return t?f.tag=t:l.default||(f.tag=l.tag),c&&(c.node=f),f}Xs.createNode=Ph});var Zr=g(Qr=>{"use strict";var Rh=Ut(),me=x(),Ah=Yr();function Qn(e,t,r){let i=r;for(let n=t.length-1;n>=0;--n){let a=t[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return Rh.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Qs=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,Zn=class extends Ah.NodeBase{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(i=>me.isNode(i)||me.isPair(i)?i.clone(t):i),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(Qs(t))this.add(r);else{let[i,...n]=t,a=this.get(i,!0);if(me.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,Qn(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(t){let[r,...i]=t;if(i.length===0)return this.delete(r);let n=this.get(r,!0);if(me.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}getIn(t,r){let[i,...n]=t,a=this.get(i,!0);return n.length===0?!r&&me.isScalar(a)?a.value:a:me.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!me.isPair(r))return!1;let i=r.value;return i==null||t&&me.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[r,...i]=t;if(i.length===0)return this.has(r);let n=this.get(r,!0);return me.isCollection(n)?n.hasIn(i):!1}setIn(t,r){let[i,...n]=t;if(n.length===0)this.set(i,r);else{let a=this.get(i,!0);if(me.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,Qn(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Qr.Collection=Zn;Qr.collectionFromPath=Qn;Qr.isEmptyPath=Qs});var Kt=g(ei=>{"use strict";var _h=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function ea(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Ih=(e,t,r)=>e.endsWith(`
6
+ `)?ea(r,t):r.includes(`
7
7
  `)?`
8
- `+ea(r,e):(t.endsWith(" ")?"":" ")+r;ei.indentComment=ea;ei.lineComment=Rp;ei.stringifyComment=Pp});var ec=g(Yt=>{"use strict";var Ap="flow",ta="block",ti="quoted";function _p(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=[],f={},u=n-e.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):u=n-i);let d,h,v=!1,p=-1,m=-1,w=-1;r===ta&&(p=Zs(t,p,e.length),p!==-1&&(u=p+c));for(let b;b=t[p+=1];){if(r===ti&&b==="\\"){switch(m=p,t[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}w=p}if(b===`
9
- `)r===ta&&(p=Zs(t,p,e.length)),u=p+e.length+c,d=void 0;else{if(b===" "&&h&&h!==" "&&h!==`
10
- `&&h!==" "){let k=t[p+1];k&&k!==" "&&k!==`
11
- `&&k!==" "&&(d=p)}if(p>=u)if(d)l.push(d),u=d+c,d=void 0;else if(r===ti){for(;h===" "||h===" ";)h=b,b=t[p+=1],v=!0;let k=p>w+1?p-2:m-1;if(f[k])return t;l.push(k),f[k]=!0,u=k+c,d=void 0}else v=!0}h=b}if(v&&s&&s(),l.length===0)return t;o&&o();let y=t.slice(0,l[0]);for(let b=0;b<l.length;++b){let k=l[b],S=l[b+1]||t.length;k===0?y=`
12
- ${e}${t.slice(0,S)}`:(r===ti&&f[k]&&(y+=`${t[k]}\\`),y+=`
13
- ${e}${t.slice(k+1,S)}`)}return y}function Zs(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}Yt.FOLD_BLOCK=ta;Yt.FOLD_FLOW=Ap;Yt.FOLD_QUOTED=ti;Yt.foldFlowLines=_p});var Qt=g(tc=>{"use strict";var oe=j(),De=ec(),ii=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),ni=t=>/^(%|---|\.\.\.)/m.test(t);function Ip(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 Xt(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(ni(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 f=r.substr(c+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=r.substr(c,6)}c+=5,s=c+1}break;case"n":if(i||r[c+2]==='"'||r.length<n)c+=1;else{for(o+=r.slice(s,c)+`
8
+ `+ea(r,t):(e.endsWith(" ")?"":" ")+r;ei.indentComment=ea;ei.lineComment=Ih;ei.stringifyComment=_h});var ec=g(Yt=>{"use strict";var Th="flow",ta="block",ti="quoted";function jh(e,t,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return e;n<a&&(a=0);let c=Math.max(1+a,1+n-t.length);if(e.length<=c)return e;let l=[],f={},u=n-t.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):u=n-i);let d,p,v=!1,h=-1,m=-1,w=-1;r===ta&&(h=Zs(e,h,t.length),h!==-1&&(u=h+c));for(let b;b=e[h+=1];){if(r===ti&&b==="\\"){switch(m=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}w=h}if(b===`
9
+ `)r===ta&&(h=Zs(e,h,t.length)),u=h+t.length+c,d=void 0;else{if(b===" "&&p&&p!==" "&&p!==`
10
+ `&&p!==" "){let k=e[h+1];k&&k!==" "&&k!==`
11
+ `&&k!==" "&&(d=h)}if(h>=u)if(d)l.push(d),u=d+c,d=void 0;else if(r===ti){for(;p===" "||p===" ";)p=b,b=e[h+=1],v=!0;let k=h>w+1?h-2:m-1;if(f[k])return e;l.push(k),f[k]=!0,u=k+c,d=void 0}else v=!0}p=b}if(v&&s&&s(),l.length===0)return e;o&&o();let y=e.slice(0,l[0]);for(let b=0;b<l.length;++b){let k=l[b],S=l[b+1]||e.length;k===0?y=`
12
+ ${t}${e.slice(0,S)}`:(r===ti&&f[k]&&(y+=`${e[k]}\\`),y+=`
13
+ ${t}${e.slice(k+1,S)}`)}return y}function Zs(e,t,r){let i=t,n=t+1,a=e[n];for(;a===" "||a===" ";)if(t<n+r)a=e[++t];else{do a=e[++t];while(a&&a!==`
14
+ `);i=t,n=t+1,a=e[n]}return i}Yt.FOLD_BLOCK=ta;Yt.FOLD_FLOW=Th;Yt.FOLD_QUOTED=ti;Yt.foldFlowLines=jh});var Qt=g(tc=>{"use strict";var oe=j(),Be=ec(),ii=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),ni=e=>/^(%|---|\.\.\.)/m.test(e);function $h(e,t,r){if(!t||t<0)return!1;let i=t-r,n=e.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(e[a]===`
15
+ `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function Xt(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(ni(e)?" ":""),o="",s=0;for(let c=0,l=r[c];l;l=r[++c])if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n"&&(o+=r.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(r[c+1]){case"u":{o+=r.slice(s,c);let f=r.substr(c+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=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:De.foldFlowLines(o,a,De.FOLD_QUOTED,ii(e,!1))}function ra(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(t))return Xt(t,e);let r=e.indent||(ni(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${r}`)+"'";return e.implicitKey?i:De.foldFlowLines(i,r,De.FOLD_FLOW,ii(e,!1))}function wt(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=Xt;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=ra:a&&!n?i=Xt:i=r?ra:Xt}return i(t,e)}var ia;try{ia=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:Be.foldFlowLines(o,a,Be.FOLD_QUOTED,ii(t,!1))}function ra(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(e))return Xt(e,t);let r=t.indent||(ni(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${r}`)+"'";return t.implicitKey?i:Be.foldFlowLines(i,r,Be.FOLD_FLOW,ii(t,!1))}function yt(e,t){let{singleQuote:r}=t.options,i;if(r===!1)i=Xt;else{let n=e.includes('"'),a=e.includes("'");n&&!a?i=ra:a&&!n?i=Xt:i=r?ra:Xt}return i(e,t)}var ia;try{ia=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{ia=/\n+(?!\n|$)/g}function ri({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 wt(r,i);let l=i.indent||(i.forceBlockIndent||ni(r)?" ":""),f=o==="literal"?!0:o==="folded"||e===oe.Scalar.BLOCK_FOLDED?!1:e===oe.Scalar.BLOCK_LITERAL?!0:!Ip(r,c,l.length);if(!r)return f?`|
23
+ |$)`,"g")}catch{ia=/\n+(?!\n|$)/g}function ri({comment:e,type:t,value:r},i,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=i.options;if(!o||/\n[\t ]+$/.test(r))return yt(r,i);let l=i.indent||(i.forceBlockIndent||ni(r)?" ":""),f=o==="literal"?!0:o==="folded"||t===oe.Scalar.BLOCK_FOLDED?!1:t===oe.Scalar.BLOCK_LITERAL?!0:!$h(r,c,l.length);if(!r)return f?`|
24
24
  `:`>
25
25
  `;let u,d;for(d=r.length;d>0;--d){let S=r[d-1];if(S!==`
26
- `&&S!==" "&&S!==" ")break}let h=r.substring(d),v=h.indexOf(`
27
- `);v===-1?u="-":r===h||v!==h.length-1?(u="+",a&&a()):u="",h&&(r=r.slice(0,-h.length),h[h.length-1]===`
28
- `&&(h=h.slice(0,-1)),h=h.replace(ia,`$&${l}`));let p=!1,m,w=-1;for(m=0;m<r.length;++m){let S=r[m];if(S===" ")p=!0;else if(S===`
29
- `)w=m;else break}let y=r.substring(0,w<m?w+1:m);y&&(r=r.substring(y.length),y=y.replace(/\n+/g,`$&${l}`));let k=(p?l?"2":"1":"")+u;if(t&&(k+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let S=r.replace(/\n+/g,`
30
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,A=ii(i,!0);o!=="folded"&&e!==oe.Scalar.BLOCK_FOLDED&&(A.onOverflow=()=>{E=!0});let N=De.foldFlowLines(`${y}${S}${h}`,l,De.FOLD_BLOCK,A);if(!E)return`>${k}
26
+ `&&S!==" "&&S!==" ")break}let p=r.substring(d),v=p.indexOf(`
27
+ `);v===-1?u="-":r===p||v!==p.length-1?(u="+",a&&a()):u="",p&&(r=r.slice(0,-p.length),p[p.length-1]===`
28
+ `&&(p=p.slice(0,-1)),p=p.replace(ia,`$&${l}`));let h=!1,m,w=-1;for(m=0;m<r.length;++m){let S=r[m];if(S===" ")h=!0;else if(S===`
29
+ `)w=m;else break}let y=r.substring(0,w<m?w+1:m);y&&(r=r.substring(y.length),y=y.replace(/\n+/g,`$&${l}`));let k=(h?l?"2":"1":"")+u;if(e&&(k+=" "+s(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let S=r.replace(/\n+/g,`
30
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,A=ii(i,!0);o!=="folded"&&t!==oe.Scalar.BLOCK_FOLDED&&(A.onOverflow=()=>{E=!0});let N=Be.foldFlowLines(`${y}${S}${p}`,l,Be.FOLD_BLOCK,A);if(!E)return`>${k}
31
31
  ${l}${N}`}return r=r.replace(/\n+/g,`$&${l}`),`|${k}
32
- ${l}${y}${r}${h}`}function Tp(t,e,r,i){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:f}=e;if(s&&a.includes(`
33
- `)||f&&/[[\]{},]/.test(a))return wt(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||f||!a.includes(`
34
- `)?wt(a,e):ri(t,e,r,i);if(!s&&!f&&n!==oe.Scalar.PLAIN&&a.includes(`
35
- `))return ri(t,e,r,i);if(ni(a)){if(c==="")return e.forceBlockIndent=!0,ri(t,e,r,i);if(s&&c===l)return wt(a,e)}let u=a.replace(/\n+/g,`$&
36
- ${c}`);if(o){let d=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(u),{compat:h,tags:v}=e.doc.schema;if(v.some(d)||h?.some(d))return wt(a,e)}return s?u:De.foldFlowLines(u,c,De.FOLD_FLOW,ii(e,!1))}function jp(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!==oe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=oe.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case oe.Scalar.BLOCK_FOLDED:case oe.Scalar.BLOCK_LITERAL:return n||a?wt(o.value,e):ri(o,e,r,i);case oe.Scalar.QUOTE_DOUBLE:return Xt(o.value,e);case oe.Scalar.QUOTE_SINGLE:return ra(o.value,e);case oe.Scalar.PLAIN:return Tp(o,e,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=n&&f||u;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}tc.stringifyString=jp});var Zt=g(na=>{"use strict";var $p=Kr(),Le=x(),Op=Kt(),Hp=Qt();function Dp(t,e){let r=Object.assign({blockQuote:!0,commentString:Op.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 Lp(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(Le.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 Bp(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(Le.isScalar(t)||Le.isCollection(t))&&t.anchor;a&&$p.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 Vp(t,e,r,i){if(Le.isPair(t))return t.toString(e,r,i);if(Le.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=Le.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Lp(e.doc.schema.tags,a));let o=Bp(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):Le.isScalar(a)?Hp.stringifyString(a,e,r,i):a.toString(e,r,i);return o?Le.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${e.indent}${s}`:s}na.createStringifyContext=Dp;na.stringify=Vp});var ac=g(nc=>{"use strict";var Pe=x(),rc=j(),ic=Zt(),er=Kt();function Mp({key:t,value:e},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:u}}=r,d=Pe.isNode(t)&&t.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Pe.isCollection(t)||!Pe.isNode(t)&&typeof t=="object"){let A="With simple keys, collection cannot be used as a key value";throw new Error(A)}}let h=!u&&(!t||d&&e==null&&!r.inFlow||Pe.isCollection(t)||(Pe.isScalar(t)?t.type===rc.Scalar.BLOCK_FOLDED||t.type===rc.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(u||!a),indent:s+c});let v=!1,p=!1,m=ic.stringify(t,r,()=>v=!0,()=>p=!0);if(!h&&!r.inFlow&&m.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(a||e==null)return v&&i&&i(),m===""?"?":h?`? ${m}`:m}else if(a&&!u||e==null&&h)return m=`? ${m}`,d&&!v?m+=er.lineComment(m,r.indent,l(d)):p&&n&&n(),m;v&&(d=null),h?(d&&(m+=er.lineComment(m,r.indent,l(d))),m=`? ${m}
38
- ${s}:`):(m=`${m}:`,d&&(m+=er.lineComment(m,r.indent,l(d))));let w,y,b;Pe.isNode(e)?(w=!!e.spaceBefore,y=e.commentBefore,b=e.comment):(w=!1,y=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!h&&!d&&Pe.isScalar(e)&&(r.indentAtStart=m.length+1),p=!1,!f&&c.length>=2&&!r.inFlow&&!h&&Pe.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let k=!1,S=ic.stringify(e,r,()=>k=!0,()=>p=!0),E=" ";if(d||w||y){if(E=w?`
32
+ ${l}${y}${r}${p}`}function Oh(e,t,r,i){let{type:n,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:f}=t;if(s&&a.includes(`
33
+ `)||f&&/[[\]{},]/.test(a))return yt(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||f||!a.includes(`
34
+ `)?yt(a,t):ri(e,t,r,i);if(!s&&!f&&n!==oe.Scalar.PLAIN&&a.includes(`
35
+ `))return ri(e,t,r,i);if(ni(a)){if(c==="")return t.forceBlockIndent=!0,ri(e,t,r,i);if(s&&c===l)return yt(a,t)}let u=a.replace(/\n+/g,`$&
36
+ ${c}`);if(o){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:v}=t.doc.schema;if(v.some(d)||p?.some(d))return yt(a,t)}return s?u:Be.foldFlowLines(u,c,Be.FOLD_FLOW,ii(t,!1))}function Hh(e,t,r,i){let{implicitKey:n,inFlow:a}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==oe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=oe.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case oe.Scalar.BLOCK_FOLDED:case oe.Scalar.BLOCK_LITERAL:return n||a?yt(o.value,t):ri(o,t,r,i);case oe.Scalar.QUOTE_DOUBLE:return Xt(o.value,t);case oe.Scalar.QUOTE_SINGLE:return ra(o.value,t);case oe.Scalar.PLAIN:return Oh(o,t,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:f,defaultStringType:u}=t.options,d=n&&f||u;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}tc.stringifyString=Hh});var Zt=g(na=>{"use strict";var Dh=Kr(),Me=x(),Lh=Kt(),Bh=Qt();function Mh(e,t){let r=Object.assign({blockQuote:!0,commentString:Lh.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function Vh(e,t){if(t.tag){let n=e.filter(a=>a.tag===t.tag);if(n.length>0)return n.find(a=>a.format===t.format)??n[0]}let r,i;if(Me.isScalar(t)){i=t.value;let n=e.filter(a=>a.identify?.(i));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}r=n.find(a=>a.format===t.format)??n.find(a=>!a.format)}else i=t,r=e.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return r}function Fh(e,t,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(Me.isScalar(e)||Me.isCollection(e))&&e.anchor;a&&Dh.anchorIsValid(a)&&(r.add(a),n.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function qh(e,t,r,i){if(Me.isPair(e))return e.toString(t,r,i);if(Me.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,a=Me.isNode(e)?e:t.doc.createNode(e,{onTagObj:c=>n=c});n??(n=Vh(t.doc.schema.tags,a));let o=Fh(a,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,t,r,i):Me.isScalar(a)?Bh.stringifyString(a,t,r,i):a.toString(t,r,i);return o?Me.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${t.indent}${s}`:s}na.createStringifyContext=Mh;na.stringify=qh});var ac=g(nc=>{"use strict";var Re=x(),rc=j(),ic=Zt(),er=Kt();function Wh({key:e,value:t},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:u}}=r,d=Re.isNode(e)&&e.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Re.isCollection(e)||!Re.isNode(e)&&typeof e=="object"){let A="With simple keys, collection cannot be used as a key value";throw new Error(A)}}let p=!u&&(!e||d&&t==null&&!r.inFlow||Re.isCollection(e)||(Re.isScalar(e)?e.type===rc.Scalar.BLOCK_FOLDED||e.type===rc.Scalar.BLOCK_LITERAL:typeof e=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!p&&(u||!a),indent:s+c});let v=!1,h=!1,m=ic.stringify(e,r,()=>v=!0,()=>h=!0);if(!p&&!r.inFlow&&m.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(r.inFlow){if(a||t==null)return v&&i&&i(),m===""?"?":p?`? ${m}`:m}else if(a&&!u||t==null&&p)return m=`? ${m}`,d&&!v?m+=er.lineComment(m,r.indent,l(d)):h&&n&&n(),m;v&&(d=null),p?(d&&(m+=er.lineComment(m,r.indent,l(d))),m=`? ${m}
38
+ ${s}:`):(m=`${m}:`,d&&(m+=er.lineComment(m,r.indent,l(d))));let w,y,b;Re.isNode(t)?(w=!!t.spaceBefore,y=t.commentBefore,b=t.comment):(w=!1,y=null,b=null,t&&typeof t=="object"&&(t=o.createNode(t))),r.implicitKey=!1,!p&&!d&&Re.isScalar(t)&&(r.indentAtStart=m.length+1),h=!1,!f&&c.length>=2&&!r.inFlow&&!p&&Re.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(r.indent=r.indent.substring(2));let k=!1,S=ic.stringify(t,r,()=>k=!0,()=>h=!0),E=" ";if(d||w||y){if(E=w?`
39
39
  `:"",y){let A=l(y);E+=`
40
40
  ${er.indentComment(A,r.indent)}`}S===""&&!r.inFlow?E===`
41
41
  `&&b&&(E=`
42
42
 
43
43
  `):E+=`
44
- ${r.indent}`}else if(!h&&Pe.isCollection(e)){let A=S[0],N=S.indexOf(`
45
- `),O=N!==-1,je=r.inFlow??e.flow??e.items.length===0;if(O||!je){let ft=!1;if(O&&(A==="&"||A==="!")){let H=S.indexOf(" ");A==="&"&&H!==-1&&H<N&&S[H+1]==="!"&&(H=S.indexOf(" ",H+1)),(H===-1||N<H)&&(ft=!0)}ft||(E=`
44
+ ${r.indent}`}else if(!p&&Re.isCollection(t)){let A=S[0],N=S.indexOf(`
45
+ `),O=N!==-1,$e=r.inFlow??t.flow??t.items.length===0;if(O||!$e){let ft=!1;if(O&&(A==="&"||A==="!")){let H=S.indexOf(" ");A==="&"&&H!==-1&&H<N&&S[H+1]==="!"&&(H=S.indexOf(" ",H+1)),(H===-1||N<H)&&(ft=!0)}ft||(E=`
46
46
  ${r.indent}`)}}else(S===""||S[0]===`
47
- `)&&(E="");return m+=E+S,r.inFlow?k&&i&&i():b&&!k?m+=er.lineComment(m,r.indent,l(b)):p&&n&&n(),m}nc.stringifyPair=Mp});var oa=g(aa=>{"use strict";var oc=Br("process");function Fp(t,...e){t==="debug"&&console.log(...e)}function qp(t,e){(t==="debug"||t==="warn")&&(typeof oc.emitWarning=="function"?oc.emitWarning(e):console.warn(e))}aa.debug=Fp;aa.warn=qp});var li=g(ci=>{"use strict";var si=x(),sc=j(),ai="<<",oi={identify:t=>t===ai||typeof t=="symbol"&&t.description===ai,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new sc.Scalar(Symbol(ai)),{addToJSMap:cc}),stringify:()=>ai},Wp=(t,e)=>(oi.identify(e)||si.isScalar(e)&&(!e.type||e.type===sc.Scalar.PLAIN)&&oi.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===oi.tag&&r.default);function cc(t,e,r){let i=lc(t,r);if(si.isSeq(i))for(let n of i.items)sa(t,e,n);else if(Array.isArray(i))for(let n of i)sa(t,e,n);else sa(t,e,i)}function sa(t,e,r){let i=lc(t,r);if(!si.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 lc(t,e){return t&&si.isAlias(e)?e.resolve(t.doc,t):e}ci.addMergeToJSMap=cc;ci.isMergeKey=Wp;ci.merge=oi});var la=g(fc=>{"use strict";var zp=oa(),uc=li(),Jp=Zt(),dc=x(),ca=Oe();function Gp(t,e,{key:r,value:i}){if(dc.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(uc.isMergeKey(t,r))uc.addMergeToJSMap(t,e,i);else{let n=ca.toJS(r,"",t);if(e instanceof Map)e.set(n,ca.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=Up(r,n,t),o=ca.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 Up(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(dc.isNode(t)&&r?.doc){let i=Jp.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)+'..."'),zp.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)}fc.addPairToJSMap=Gp});var Be=g(ua=>{"use strict";var pc=Ut(),Kp=ac(),Yp=la(),ui=x();function Xp(t,e,r){let i=pc.createNode(t,void 0,r),n=pc.createNode(e,void 0,r);return new di(i,n)}var di=class t{constructor(e,r=null){Object.defineProperty(this,ui.NODE_TYPE,{value:ui.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return ui.isNode(r)&&(r=r.clone(e)),ui.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return Yp.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?Kp.stringifyPair(this,e,r,i):JSON.stringify(this)}};ua.Pair=di;ua.createPair=Xp});var da=g(mc=>{"use strict";var et=x(),hc=Zt(),fi=Kt();function Qp(t,e,r){return(e.inFlow??t.flow?eh:Zp)(t,e,r)}function Zp({comment:t,items:e},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,f=Object.assign({},r,{indent:a,type:null}),u=!1,d=[];for(let v=0;v<e.length;++v){let p=e[v],m=null;if(et.isNode(p))!u&&p.spaceBefore&&d.push(""),pi(r,d,p.commentBefore,u),p.comment&&(m=p.comment);else if(et.isPair(p)){let y=et.isNode(p.key)?p.key:null;y&&(!u&&y.spaceBefore&&d.push(""),pi(r,d,y.commentBefore,u))}u=!1;let w=hc.stringify(p,f,()=>m=null,()=>u=!0);m&&(w+=fi.lineComment(w,a,l(m))),u&&m&&(u=!1),d.push(i+w)}let h;if(d.length===0)h=n.start+n.end;else{h=d[0];for(let v=1;v<d.length;++v){let p=d[v];h+=p?`
48
- ${c}${p}`:`
49
- `}}return t?(h+=`
50
- `+fi.indentComment(l(t),c),s&&s()):u&&o&&o(),h}function eh({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,f=0,u=[];for(let v=0;v<t.length;++v){let p=t[v],m=null;if(et.isNode(p))p.spaceBefore&&u.push(""),pi(e,u,p.commentBefore,!1),p.comment&&(m=p.comment);else if(et.isPair(p)){let y=et.isNode(p.key)?p.key:null;y&&(y.spaceBefore&&u.push(""),pi(e,u,y.commentBefore,!1),y.comment&&(l=!0));let b=et.isNode(p.value)?p.value:null;b?(b.comment&&(m=b.comment),b.commentBefore&&(l=!0)):p.value==null&&y?.comment&&(m=y.comment)}m&&(l=!0);let w=hc.stringify(p,c,()=>m=null);l||(l=u.length>f||w.includes(`
51
- `)),v<t.length-1?w+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((y,b)=>y+b.length+2,2)+(w.length+2)>e.options.lineWidth)),l&&(w+=",")),m&&(w+=fi.lineComment(w,i,s(m))),u.push(w),f=u.length}let{start:d,end:h}=r;if(u.length===0)return d+h;if(!l){let v=u.reduce((p,m)=>p+m.length+2,2);l=e.options.lineWidth>0&&v>e.options.lineWidth}if(l){let v=d;for(let p of u)v+=p?`
52
- ${a}${n}${p}`:`
47
+ `)&&(E="");return m+=E+S,r.inFlow?k&&i&&i():b&&!k?m+=er.lineComment(m,r.indent,l(b)):h&&n&&n(),m}nc.stringifyPair=Wh});var oa=g(aa=>{"use strict";var oc=Br("process");function zh(e,...t){e==="debug"&&console.log(...t)}function Jh(e,t){(e==="debug"||e==="warn")&&(typeof oc.emitWarning=="function"?oc.emitWarning(t):console.warn(t))}aa.debug=zh;aa.warn=Jh});var li=g(ci=>{"use strict";var si=x(),sc=j(),ai="<<",oi={identify:e=>e===ai||typeof e=="symbol"&&e.description===ai,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new sc.Scalar(Symbol(ai)),{addToJSMap:cc}),stringify:()=>ai},Gh=(e,t)=>(oi.identify(t)||si.isScalar(t)&&(!t.type||t.type===sc.Scalar.PLAIN)&&oi.identify(t.value))&&e?.doc.schema.tags.some(r=>r.tag===oi.tag&&r.default);function cc(e,t,r){let i=lc(e,r);if(si.isSeq(i))for(let n of i.items)sa(e,t,n);else if(Array.isArray(i))for(let n of i)sa(e,t,n);else sa(e,t,i)}function sa(e,t,r){let i=lc(e,r);if(!si.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[a,o]of n)t instanceof Map?t.has(a)||t.set(a,o):t instanceof Set?t.add(a):Object.prototype.hasOwnProperty.call(t,a)||Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function lc(e,t){return e&&si.isAlias(t)?t.resolve(e.doc,e):t}ci.addMergeToJSMap=cc;ci.isMergeKey=Gh;ci.merge=oi});var la=g(fc=>{"use strict";var Uh=oa(),uc=li(),Kh=Zt(),dc=x(),ca=De();function Yh(e,t,{key:r,value:i}){if(dc.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,i);else if(uc.isMergeKey(e,r))uc.addMergeToJSMap(e,t,i);else{let n=ca.toJS(r,"",e);if(t instanceof Map)t.set(n,ca.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let a=Xh(r,n,e),o=ca.toJS(i,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Xh(e,t,r){if(t===null)return"";if(typeof t!="object")return String(t);if(dc.isNode(e)&&r?.doc){let i=Kh.createStringifyContext(r.doc,{});i.anchors=new Set;for(let a of r.anchors.keys())i.anchors.add(a.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=e.toString(i);if(!r.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Uh.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(t)}fc.addPairToJSMap=Yh});var Ve=g(ua=>{"use strict";var hc=Ut(),Qh=ac(),Zh=la(),ui=x();function ep(e,t,r){let i=hc.createNode(e,void 0,r),n=hc.createNode(t,void 0,r);return new di(i,n)}var di=class e{constructor(t,r=null){Object.defineProperty(this,ui.NODE_TYPE,{value:ui.PAIR}),this.key=t,this.value=r}clone(t){let{key:r,value:i}=this;return ui.isNode(r)&&(r=r.clone(t)),ui.isNode(i)&&(i=i.clone(t)),new e(r,i)}toJSON(t,r){let i=r?.mapAsMap?new Map:{};return Zh.addPairToJSMap(r,i,this)}toString(t,r,i){return t?.doc?Qh.stringifyPair(this,t,r,i):JSON.stringify(this)}};ua.Pair=di;ua.createPair=ep});var da=g(mc=>{"use strict";var et=x(),pc=Zt(),fi=Kt();function tp(e,t,r){return(t.inFlow??e.flow?ip:rp)(e,t,r)}function rp({comment:e,items:t},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,f=Object.assign({},r,{indent:a,type:null}),u=!1,d=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(et.isNode(h))!u&&h.spaceBefore&&d.push(""),hi(r,d,h.commentBefore,u),h.comment&&(m=h.comment);else if(et.isPair(h)){let y=et.isNode(h.key)?h.key:null;y&&(!u&&y.spaceBefore&&d.push(""),hi(r,d,y.commentBefore,u))}u=!1;let w=pc.stringify(h,f,()=>m=null,()=>u=!0);m&&(w+=fi.lineComment(w,a,l(m))),u&&m&&(u=!1),d.push(i+w)}let p;if(d.length===0)p=n.start+n.end;else{p=d[0];for(let v=1;v<d.length;++v){let h=d[v];p+=h?`
48
+ ${c}${h}`:`
49
+ `}}return e?(p+=`
50
+ `+fi.indentComment(l(e),c),s&&s()):u&&o&&o(),p}function ip({items:e},t,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;i+=a;let c=Object.assign({},t,{indent:i,inFlow:!0,type:null}),l=!1,f=0,u=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(et.isNode(h))h.spaceBefore&&u.push(""),hi(t,u,h.commentBefore,!1),h.comment&&(m=h.comment);else if(et.isPair(h)){let y=et.isNode(h.key)?h.key:null;y&&(y.spaceBefore&&u.push(""),hi(t,u,y.commentBefore,!1),y.comment&&(l=!0));let b=et.isNode(h.value)?h.value:null;b?(b.comment&&(m=b.comment),b.commentBefore&&(l=!0)):h.value==null&&y?.comment&&(m=y.comment)}m&&(l=!0);let w=pc.stringify(h,c,()=>m=null);l||(l=u.length>f||w.includes(`
51
+ `)),v<e.length-1?w+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(l||(l=u.reduce((y,b)=>y+b.length+2,2)+(w.length+2)>t.options.lineWidth)),l&&(w+=",")),m&&(w+=fi.lineComment(w,i,s(m))),u.push(w),f=u.length}let{start:d,end:p}=r;if(u.length===0)return d+p;if(!l){let v=u.reduce((h,m)=>h+m.length+2,2);l=t.options.lineWidth>0&&v>t.options.lineWidth}if(l){let v=d;for(let h of u)v+=h?`
52
+ ${a}${n}${h}`:`
53
53
  `;return`${v}
54
- ${n}${h}`}else return`${d}${o}${u.join(" ")}${o}${h}`}function pi({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=fi.indentComment(e(i),t);r.push(a.trimStart())}}mc.stringifyCollection=Qp});var Me=g(pa=>{"use strict";var th=da(),rh=la(),ih=Zr(),Ve=x(),hi=Be(),nh=j();function tr(t,e){let r=Ve.isScalar(e)?e.value:e;for(let i of t)if(Ve.isPair(i)&&(i.key===e||i.key===r||Ve.isScalar(i.key)&&i.key.value===r))return i}var fa=class extends ih.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Ve.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(hi.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;Ve.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new hi.Pair(e,e?.value):i=new hi.Pair(e.key,e.value);let n=tr(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);Ve.isScalar(n.value)&&nh.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=tr(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=tr(this.items,e)?.value;return(!r&&Ve.isScalar(n)?n.value:n)??void 0}has(e){return!!tr(this.items,e)}set(e,r){this.add(new hi.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)rh.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!Ve.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})),th.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};pa.YAMLMap=fa;pa.findPair=tr});var yt=g(gc=>{"use strict";var ah=x(),vc=Me(),oh={collection:"map",default:!0,nodeClass:vc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return ah.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>vc.YAMLMap.from(t,e,r)};gc.map=oh});var Fe=g(wc=>{"use strict";var sh=Ut(),ch=da(),lh=Zr(),vi=x(),uh=j(),dh=Oe(),ha=class extends lh.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(vi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=mi(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=mi(e);if(typeof i!="number")return;let n=this.items[i];return!r&&vi.isScalar(n)?n.value:n}has(e){let r=mi(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=mi(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];vi.isScalar(n)&&uh.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(dh.toJS(a,String(n++),r));return i}toString(e,r,i){return e?ch.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(sh.createNode(s,void 0,i))}}return a}};function mi(t){let e=vi.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}wc.YAMLSeq=ha});var Nt=g(Nc=>{"use strict";var fh=x(),yc=Fe(),ph={collection:"seq",default:!0,nodeClass:yc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return fh.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>yc.YAMLSeq.from(t,e,r)};Nc.seq=ph});var rr=g(bc=>{"use strict";var hh=Qt(),mh={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),hh.stringifyString(t,e,r,i)}};bc.string=mh});var gi=g(Ec=>{"use strict";var kc=j(),Sc={identify:t=>t==null,createNode:()=>new kc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new kc.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Sc.test.test(t)?t:e.options.nullStr};Ec.nullTag=Sc});var ma=g(xc=>{"use strict";var vh=j(),Cc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new vh.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&Cc.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};xc.boolTag=Cc});var bt=g(Pc=>{"use strict";function gh({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}Pc.stringifyNumber=gh});var ga=g(wi=>{"use strict";var wh=j(),va=bt(),yh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:va.stringifyNumber},Nh={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():va.stringifyNumber(t)}},bh={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 wh.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:va.stringifyNumber};wi.float=bh;wi.floatExp=Nh;wi.floatNaN=yh});var ya=g(Ni=>{"use strict";var Rc=bt(),yi=t=>typeof t=="bigint"||Number.isInteger(t),wa=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function Ac(t,e,r){let{value:i}=t;return yi(i)&&i>=0?r+i.toString(e):Rc.stringifyNumber(t)}var kh={identify:t=>yi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>wa(t,2,8,r),stringify:t=>Ac(t,8,"0o")},Sh={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>wa(t,0,10,r),stringify:Rc.stringifyNumber},Eh={identify:t=>yi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>wa(t,2,16,r),stringify:t=>Ac(t,16,"0x")};Ni.int=Sh;Ni.intHex=Eh;Ni.intOct=kh});var Ic=g(_c=>{"use strict";var Ch=yt(),xh=gi(),Ph=Nt(),Rh=rr(),Ah=ma(),Na=ga(),ba=ya(),_h=[Ch.map,Ph.seq,Rh.string,xh.nullTag,Ah.boolTag,ba.intOct,ba.int,ba.intHex,Na.floatNaN,Na.floatExp,Na.float];_c.schema=_h});var $c=g(jc=>{"use strict";var Ih=j(),Th=yt(),jh=Nt();function Tc(t){return typeof t=="bigint"||Number.isInteger(t)}var bi=({value:t})=>JSON.stringify(t),$h=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:bi},{identify:t=>t==null,createNode:()=>new Ih.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:bi},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:bi},{identify:Tc,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})=>Tc(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:bi}],Oh={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Hh=[Th.map,jh.seq].concat($h,Oh);jc.schema=Hh});var Sa=g(Oc=>{"use strict";var ir=Br("buffer"),ka=j(),Dh=Qt(),Lh={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof ir.Buffer=="function")return ir.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 ir.Buffer=="function")s=o instanceof ir.Buffer?o.toString("base64"):ir.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=ka.Scalar.BLOCK_LITERAL),e!==ka.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),f=new Array(l);for(let u=0,d=0;u<l;++u,d+=c)f[u]=s.substr(d,c);s=f.join(e===ka.Scalar.BLOCK_LITERAL?`
55
- `:" ")}return Dh.stringifyString({comment:t,type:e,value:s},i,n,a)}};Oc.binary=Lh});var Ei=g(Si=>{"use strict";var ki=x(),Ea=Be(),Bh=j(),Vh=Fe();function Hc(t,e){if(ki.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!ki.isPair(i)){if(ki.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new Ea.Pair(new Bh.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
54
+ ${n}${p}`}else return`${d}${o}${u.join(" ")}${o}${p}`}function hi({indent:e,options:{commentString:t}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=fi.indentComment(t(i),e);r.push(a.trimStart())}}mc.stringifyCollection=tp});var qe=g(ha=>{"use strict";var np=da(),ap=la(),op=Zr(),Fe=x(),pi=Ve(),sp=j();function tr(e,t){let r=Fe.isScalar(t)?t.value:t;for(let i of e)if(Fe.isPair(i)&&(i.key===t||i.key===r||Fe.isScalar(i.key)&&i.key.value===r))return i}var fa=class extends op.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Fe.MAP,t),this.items=[]}static from(t,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(t),s=(c,l)=>{if(typeof a=="function")l=a.call(r,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(pi.createPair(c,l,i))};if(r instanceof Map)for(let[c,l]of r)s(c,l);else if(r&&typeof r=="object")for(let c of Object.keys(r))s(c,r[c]);return typeof t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,r){let i;Fe.isPair(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new pi.Pair(t,t?.value):i=new pi.Pair(t.key,t.value);let n=tr(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);Fe.isScalar(n.value)&&sp.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(a){let o=this.items.findIndex(s=>a(i,s)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){let r=tr(this.items,t);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(t,r){let n=tr(this.items,t)?.value;return(!r&&Fe.isScalar(n)?n.value:n)??void 0}has(t){return!!tr(this.items,t)}set(t,r){this.add(new pi.Pair(t,r),!0)}toJSON(t,r,i){let n=i?new i:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(n);for(let a of this.items)ap.addPairToJSMap(r,n,a);return n}toString(t,r,i){if(!t)return JSON.stringify(this);for(let n of this.items)if(!Fe.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),np.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:r})}};ha.YAMLMap=fa;ha.findPair=tr});var Nt=g(gc=>{"use strict";var cp=x(),vc=qe(),lp={collection:"map",default:!0,nodeClass:vc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return cp.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,r)=>vc.YAMLMap.from(e,t,r)};gc.map=lp});var We=g(wc=>{"use strict";var up=Ut(),dp=da(),fp=Zr(),vi=x(),hp=j(),pp=De(),pa=class extends fp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(vi.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let r=mi(t);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(t,r){let i=mi(t);if(typeof i!="number")return;let n=this.items[i];return!r&&vi.isScalar(n)?n.value:n}has(t){let r=mi(t);return typeof r=="number"&&r<this.items.length}set(t,r){let i=mi(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];vi.isScalar(n)&&hp.isScalarValue(r)?n.value=r:this.items[i]=r}toJSON(t,r){let i=[];r?.onCreate&&r.onCreate(i);let n=0;for(let a of this.items)i.push(pp.toJS(a,String(n++),r));return i}toString(t,r,i){return t?dp.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:i,onComment:r}):JSON.stringify(this)}static from(t,r,i){let{replacer:n}=i,a=new this(t);if(r&&Symbol.iterator in Object(r)){let o=0;for(let s of r){if(typeof n=="function"){let c=r instanceof Set?s:String(o++);s=n.call(r,c,s)}a.items.push(up.createNode(s,void 0,i))}}return a}};function mi(e){let t=vi.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}wc.YAMLSeq=pa});var bt=g(Nc=>{"use strict";var mp=x(),yc=We(),vp={collection:"seq",default:!0,nodeClass:yc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return mp.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,r)=>yc.YAMLSeq.from(e,t,r)};Nc.seq=vp});var rr=g(bc=>{"use strict";var gp=Qt(),wp={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,r,i){return t=Object.assign({actualString:!0},t),gp.stringifyString(e,t,r,i)}};bc.string=wp});var gi=g(Ec=>{"use strict";var kc=j(),Sc={identify:e=>e==null,createNode:()=>new kc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new kc.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&Sc.test.test(e)?e:t.options.nullStr};Ec.nullTag=Sc});var ma=g(xc=>{"use strict";var yp=j(),Cc={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new yp.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&Cc.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?r.options.trueStr:r.options.falseStr}};xc.boolTag=Cc});var kt=g(Pc=>{"use strict";function Np({format:e,minFractionDigits:t,tag:r,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=t-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Pc.stringifyNumber=Np});var ga=g(wi=>{"use strict";var bp=j(),va=kt(),kp={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:va.stringifyNumber},Sp={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():va.stringifyNumber(e)}},Ep={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new bp.Scalar(parseFloat(e)),r=e.indexOf(".");return r!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-r-1),t},stringify:va.stringifyNumber};wi.float=Ep;wi.floatExp=Sp;wi.floatNaN=kp});var ya=g(Ni=>{"use strict";var Rc=kt(),yi=e=>typeof e=="bigint"||Number.isInteger(e),wa=(e,t,r,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),r);function Ac(e,t,r){let{value:i}=e;return yi(i)&&i>=0?r+i.toString(t):Rc.stringifyNumber(e)}var Cp={identify:e=>yi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>wa(e,2,8,r),stringify:e=>Ac(e,8,"0o")},xp={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>wa(e,0,10,r),stringify:Rc.stringifyNumber},Pp={identify:e=>yi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>wa(e,2,16,r),stringify:e=>Ac(e,16,"0x")};Ni.int=xp;Ni.intHex=Pp;Ni.intOct=Cp});var Ic=g(_c=>{"use strict";var Rp=Nt(),Ap=gi(),_p=bt(),Ip=rr(),Tp=ma(),Na=ga(),ba=ya(),jp=[Rp.map,_p.seq,Ip.string,Ap.nullTag,Tp.boolTag,ba.intOct,ba.int,ba.intHex,Na.floatNaN,Na.floatExp,Na.float];_c.schema=jp});var $c=g(jc=>{"use strict";var $p=j(),Op=Nt(),Hp=bt();function Tc(e){return typeof e=="bigint"||Number.isInteger(e)}var bi=({value:e})=>JSON.stringify(e),Dp=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:bi},{identify:e=>e==null,createNode:()=>new $p.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:bi},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:bi},{identify:Tc,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>Tc(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:bi}],Lp={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Bp=[Op.map,Hp.seq].concat(Dp,Lp);jc.schema=Bp});var Sa=g(Oc=>{"use strict";var ir=Br("buffer"),ka=j(),Mp=Qt(),Vp={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof ir.Buffer=="function")return ir.Buffer.from(e,"base64");if(typeof atob=="function"){let r=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof ir.Buffer=="function")s=o instanceof ir.Buffer?o.toString("base64"):ir.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=ka.Scalar.BLOCK_LITERAL),t!==ka.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),f=new Array(l);for(let u=0,d=0;u<l;++u,d+=c)f[u]=s.substr(d,c);s=f.join(t===ka.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return Mp.stringifyString({comment:e,type:t,value:s},i,n,a)}};Oc.binary=Vp});var Ei=g(Si=>{"use strict";var ki=x(),Ea=Ve(),Fp=j(),qp=We();function Hc(e,t){if(ki.isSeq(e))for(let r=0;r<e.items.length;++r){let i=e.items[r];if(!ki.isPair(i)){if(ki.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new Ea.Pair(new Fp.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]=ki.isPair(i)?i:new Ea.Pair(i)}}else e("Expected a sequence for this tag");return t}function Dc(t,e,r){let{replacer:i}=r,n=new Vh.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(Ea.createPair(s,c,r))}return n}var Mh={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Hc,createNode:Dc};Si.createPairs=Dc;Si.pairs=Mh;Si.resolvePairs=Hc});var Pa=g(xa=>{"use strict";var Lc=x(),Ca=Oe(),nr=Me(),Fh=Fe(),Bc=Ei(),tt=class t extends Fh.YAMLSeq{constructor(){super(),this.add=nr.YAMLMap.prototype.add.bind(this),this.delete=nr.YAMLMap.prototype.delete.bind(this),this.get=nr.YAMLMap.prototype.get.bind(this),this.has=nr.YAMLMap.prototype.has.bind(this),this.set=nr.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(Lc.isPair(n)?(a=Ca.toJS(n.key,"",r),o=Ca.toJS(n.value,a,r)):a=Ca.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=Bc.createPairs(e,r,i),a=new this;return a.items=n.items,a}};tt.tag="tag:yaml.org,2002:omap";var qh={collection:"seq",identify:t=>t instanceof Map,nodeClass:tt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=Bc.resolvePairs(t,e),i=[];for(let{key:n}of r.items)Lc.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new tt,r)},createNode:(t,e,r)=>tt.from(t,e,r)};xa.YAMLOMap=tt;xa.omap=qh});var Wc=g(Ra=>{"use strict";var Vc=j();function Mc({value:t,source:e},r){return e&&(t?Fc:qc).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Fc={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 Vc.Scalar(!0),stringify:Mc},qc={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 Vc.Scalar(!1),stringify:Mc};Ra.falseTag=qc;Ra.trueTag=Fc});var zc=g(Ci=>{"use strict";var Wh=j(),Aa=bt(),zh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Aa.stringifyNumber},Jh={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():Aa.stringifyNumber(t)}},Gh={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 Wh.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:Aa.stringifyNumber};Ci.float=Gh;Ci.floatExp=Jh;Ci.floatNaN=zh});var Gc=g(or=>{"use strict";var Jc=bt(),ar=t=>typeof t=="bigint"||Number.isInteger(t);function xi(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 _a(t,e,r){let{value:i}=t;if(ar(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return Jc.stringifyNumber(t)}var Uh={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>xi(t,2,2,r),stringify:t=>_a(t,2,"0b")},Kh={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>xi(t,1,8,r),stringify:t=>_a(t,8,"0")},Yh={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>xi(t,0,10,r),stringify:Jc.stringifyNumber},Xh={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>xi(t,2,16,r),stringify:t=>_a(t,16,"0x")};or.int=Yh;or.intBin=Uh;or.intHex=Xh;or.intOct=Kh});var Ta=g(Ia=>{"use strict";var Ai=x(),Pi=Be(),Ri=Me(),rt=class t extends Ri.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;Ai.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new Pi.Pair(e.key,null):r=new Pi.Pair(e,null),Ri.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=Ri.findPair(this.items,e);return!r&&Ai.isPair(i)?Ai.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=Ri.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Pi.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(Pi.createPair(o,null,i));return a}};rt.tag="tag:yaml.org,2002:set";var Qh={collection:"map",identify:t=>t instanceof Set,nodeClass:rt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>rt.from(t,e,r),resolve(t,e){if(Ai.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new rt,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Ia.YAMLSet=rt;Ia.set=Qh});var $a=g(_i=>{"use strict";var Zh=bt();function ja(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 Uc(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Zh.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 em={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})=>ja(t,r),stringify:Uc},tm={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=>ja(t,!1),stringify:Uc},Kc={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(Kc.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),f=e[8];if(f&&f!=="Z"){let u=ja(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};_i.floatTime=tm;_i.intTime=em;_i.timestamp=Kc});var Qc=g(Xc=>{"use strict";var rm=yt(),im=gi(),nm=Nt(),am=rr(),om=Sa(),Yc=Wc(),Oa=zc(),Ii=Gc(),sm=li(),cm=Pa(),lm=Ei(),um=Ta(),Ha=$a(),dm=[rm.map,nm.seq,am.string,im.nullTag,Yc.trueTag,Yc.falseTag,Ii.intBin,Ii.intOct,Ii.int,Ii.intHex,Oa.floatNaN,Oa.floatExp,Oa.float,om.binary,sm.merge,cm.omap,lm.pairs,um.set,Ha.intTime,Ha.floatTime,Ha.timestamp];Xc.schema=dm});var cl=g(Ba=>{"use strict";var rl=yt(),fm=gi(),il=Nt(),pm=rr(),hm=ma(),Da=ga(),La=ya(),mm=Ic(),vm=$c(),nl=Sa(),sr=li(),al=Pa(),ol=Ei(),Zc=Qc(),sl=Ta(),Ti=$a(),el=new Map([["core",mm.schema],["failsafe",[rl.map,il.seq,pm.string]],["json",vm.schema],["yaml11",Zc.schema],["yaml-1.1",Zc.schema]]),tl={binary:nl.binary,bool:hm.boolTag,float:Da.float,floatExp:Da.floatExp,floatNaN:Da.floatNaN,floatTime:Ti.floatTime,int:La.int,intHex:La.intHex,intOct:La.intOct,intTime:Ti.intTime,map:rl.map,merge:sr.merge,null:fm.nullTag,omap:al.omap,pairs:ol.pairs,seq:il.seq,set:sl.set,timestamp:Ti.timestamp},gm={"tag:yaml.org,2002:binary":nl.binary,"tag:yaml.org,2002:merge":sr.merge,"tag:yaml.org,2002:omap":al.omap,"tag:yaml.org,2002:pairs":ol.pairs,"tag:yaml.org,2002:set":sl.set,"tag:yaml.org,2002:timestamp":Ti.timestamp};function wm(t,e,r){let i=el.get(e);if(i&&!t)return r&&!i.includes(sr.merge)?i.concat(sr.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(el.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(sr.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?tl[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(tl).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}Ba.coreKnownTags=gm;Ba.getTags=wm});var Fa=g(ll=>{"use strict";var Va=x(),ym=yt(),Nm=Nt(),bm=rr(),ji=cl(),km=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Ma=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?ji.getTags(e,"compat"):e?ji.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?ji.coreKnownTags:{},this.tags=ji.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Va.MAP,{value:ym.map}),Object.defineProperty(this,Va.SCALAR,{value:bm.string}),Object.defineProperty(this,Va.SEQ,{value:Nm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?km:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};ll.Schema=Ma});var dl=g(ul=>{"use strict";var Sm=x(),qa=Zt(),cr=Kt();function Em(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=qa.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(cr.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(Sm.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let f=a(t.contents.commentBefore);r.push(cr.indentComment(f,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=qa.stringify(t.contents,n,()=>s=null,c);s&&(l+=cr.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(qa.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
- `)?(r.push("..."),r.push(cr.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(cr.indentComment(a(c),"")))}return r.join(`
57
+ ${a.comment}`:i.comment}i=n}e.items[r]=ki.isPair(i)?i:new Ea.Pair(i)}}else t("Expected a sequence for this tag");return e}function Dc(e,t,r){let{replacer:i}=r,n=new qp.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let a=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(a++),o));let s,c;if(Array.isArray(o))if(o.length===2)s=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)s=l[0],c=o[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=o;n.items.push(Ea.createPair(s,c,r))}return n}var Wp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Hc,createNode:Dc};Si.createPairs=Dc;Si.pairs=Wp;Si.resolvePairs=Hc});var Pa=g(xa=>{"use strict";var Lc=x(),Ca=De(),nr=qe(),zp=We(),Bc=Ei(),tt=class e extends zp.YAMLSeq{constructor(){super(),this.add=nr.YAMLMap.prototype.add.bind(this),this.delete=nr.YAMLMap.prototype.delete.bind(this),this.get=nr.YAMLMap.prototype.get.bind(this),this.has=nr.YAMLMap.prototype.has.bind(this),this.set=nr.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,r){if(!r)return super.toJSON(t);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if(Lc.isPair(n)?(a=Ca.toJS(n.key,"",r),o=Ca.toJS(n.value,a,r)):a=Ca.toJS(n,"",r),i.has(a))throw new Error("Ordered maps must not include duplicate keys");i.set(a,o)}return i}static from(t,r,i){let n=Bc.createPairs(t,r,i),a=new this;return a.items=n.items,a}};tt.tag="tag:yaml.org,2002:omap";var Jp={collection:"seq",identify:e=>e instanceof Map,nodeClass:tt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=Bc.resolvePairs(e,t),i=[];for(let{key:n}of r.items)Lc.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new tt,r)},createNode:(e,t,r)=>tt.from(e,t,r)};xa.YAMLOMap=tt;xa.omap=Jp});var Wc=g(Ra=>{"use strict";var Mc=j();function Vc({value:e,source:t},r){return t&&(e?Fc:qc).test.test(t)?t:e?r.options.trueStr:r.options.falseStr}var Fc={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Mc.Scalar(!0),stringify:Vc},qc={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Mc.Scalar(!1),stringify:Vc};Ra.falseTag=qc;Ra.trueTag=Fc});var zc=g(Ci=>{"use strict";var Gp=j(),Aa=kt(),Up={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Aa.stringifyNumber},Kp={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Aa.stringifyNumber(e)}},Yp={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Gp.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let i=e.substring(r+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Aa.stringifyNumber};Ci.float=Yp;Ci.floatExp=Kp;Ci.floatNaN=Up});var Gc=g(or=>{"use strict";var Jc=kt(),ar=e=>typeof e=="bigint"||Number.isInteger(e);function xi(e,t,r,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let a=parseInt(e,r);return n==="-"?-1*a:a}function _a(e,t,r){let{value:i}=e;if(ar(i)){let n=i.toString(t);return i<0?"-"+r+n.substr(1):r+n}return Jc.stringifyNumber(e)}var Xp={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>xi(e,2,2,r),stringify:e=>_a(e,2,"0b")},Qp={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>xi(e,1,8,r),stringify:e=>_a(e,8,"0")},Zp={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>xi(e,0,10,r),stringify:Jc.stringifyNumber},em={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>xi(e,2,16,r),stringify:e=>_a(e,16,"0x")};or.int=Zp;or.intBin=Xp;or.intHex=em;or.intOct=Qp});var Ta=g(Ia=>{"use strict";var Ai=x(),Pi=Ve(),Ri=qe(),rt=class e extends Ri.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let r;Ai.isPair(t)?r=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?r=new Pi.Pair(t.key,null):r=new Pi.Pair(t,null),Ri.findPair(this.items,r.key)||this.items.push(r)}get(t,r){let i=Ri.findPair(this.items,t);return!r&&Ai.isPair(i)?Ai.isScalar(i.key)?i.key.value:i.key:i}set(t,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let i=Ri.findPair(this.items,t);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Pi.Pair(t))}toJSON(t,r){return super.toJSON(t,r,Set)}toString(t,r,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),r,i);throw new Error("Set items must all have null values")}static from(t,r,i){let{replacer:n}=i,a=new this(t);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),a.items.push(Pi.createPair(o,null,i));return a}};rt.tag="tag:yaml.org,2002:set";var tm={collection:"map",identify:e=>e instanceof Set,nodeClass:rt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>rt.from(e,t,r),resolve(e,t){if(Ai.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new rt,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Ia.YAMLSet=rt;Ia.set=tm});var $a=g(_i=>{"use strict";var rm=kt();function ja(e,t){let r=e[0],i=r==="-"||r==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),a=i.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return r==="-"?n(-1)*a:a}function Uc(e){let{value:t}=e,r=o=>o;if(typeof t=="bigint")r=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return rm.stringifyNumber(e);let i="";t<0&&(i="-",t*=r(-1));let n=r(60),a=[t%n];return t<60?a.unshift(0):(t=(t-a[0])/n,a.unshift(t%n),t>=60&&(t=(t-a[0])/n,a.unshift(t))),i+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var im={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>ja(e,r),stringify:Uc},nm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>ja(e,!1),stringify:Uc},Kc={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Kc.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,a||0,o||0,s||0,c),f=t[8];if(f&&f!=="Z"){let u=ja(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};_i.floatTime=nm;_i.intTime=im;_i.timestamp=Kc});var Qc=g(Xc=>{"use strict";var am=Nt(),om=gi(),sm=bt(),cm=rr(),lm=Sa(),Yc=Wc(),Oa=zc(),Ii=Gc(),um=li(),dm=Pa(),fm=Ei(),hm=Ta(),Ha=$a(),pm=[am.map,sm.seq,cm.string,om.nullTag,Yc.trueTag,Yc.falseTag,Ii.intBin,Ii.intOct,Ii.int,Ii.intHex,Oa.floatNaN,Oa.floatExp,Oa.float,lm.binary,um.merge,dm.omap,fm.pairs,hm.set,Ha.intTime,Ha.floatTime,Ha.timestamp];Xc.schema=pm});var cl=g(Ba=>{"use strict";var rl=Nt(),mm=gi(),il=bt(),vm=rr(),gm=ma(),Da=ga(),La=ya(),wm=Ic(),ym=$c(),nl=Sa(),sr=li(),al=Pa(),ol=Ei(),Zc=Qc(),sl=Ta(),Ti=$a(),el=new Map([["core",wm.schema],["failsafe",[rl.map,il.seq,vm.string]],["json",ym.schema],["yaml11",Zc.schema],["yaml-1.1",Zc.schema]]),tl={binary:nl.binary,bool:gm.boolTag,float:Da.float,floatExp:Da.floatExp,floatNaN:Da.floatNaN,floatTime:Ti.floatTime,int:La.int,intHex:La.intHex,intOct:La.intOct,intTime:Ti.intTime,map:rl.map,merge:sr.merge,null:mm.nullTag,omap:al.omap,pairs:ol.pairs,seq:il.seq,set:sl.set,timestamp:Ti.timestamp},Nm={"tag:yaml.org,2002:binary":nl.binary,"tag:yaml.org,2002:merge":sr.merge,"tag:yaml.org,2002:omap":al.omap,"tag:yaml.org,2002:pairs":ol.pairs,"tag:yaml.org,2002:set":sl.set,"tag:yaml.org,2002:timestamp":Ti.timestamp};function bm(e,t,r){let i=el.get(t);if(i&&!e)return r&&!i.includes(sr.merge)?i.concat(sr.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let a=Array.from(el.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`)}if(Array.isArray(e))for(let a of e)n=n.concat(a);else typeof e=="function"&&(n=e(n.slice()));return r&&(n=n.concat(sr.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?tl[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(tl).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}Ba.coreKnownTags=Nm;Ba.getTags=bm});var Fa=g(ll=>{"use strict";var Ma=x(),km=Nt(),Sm=bt(),Em=rr(),ji=cl(),Cm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Va=class e{constructor({compat:t,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(t)?ji.getTags(t,"compat"):t?ji.getTags(null,t):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?ji.coreKnownTags:{},this.tags=ji.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Ma.MAP,{value:km.map}),Object.defineProperty(this,Ma.SCALAR,{value:Em.string}),Object.defineProperty(this,Ma.SEQ,{value:Sm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Cm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};ll.Schema=Va});var dl=g(ul=>{"use strict";var xm=x(),qa=Zt(),cr=Kt();function Pm(e,t){let r=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);c?(r.push(c),i=!0):e.directives.docStart&&(i=!0)}i&&r.push("---");let n=qa.createStringifyContext(e,t),{commentString:a}=n.options;if(e.commentBefore){r.length!==1&&r.unshift("");let c=a(e.commentBefore);r.unshift(cr.indentComment(c,""))}let o=!1,s=null;if(e.contents){if(xm.isNode(e.contents)){if(e.contents.spaceBefore&&i&&r.push(""),e.contents.commentBefore){let f=a(e.contents.commentBefore);r.push(cr.indentComment(f,""))}n.forceBlockIndent=!!e.comment,s=e.contents.comment}let c=s?void 0:()=>o=!0,l=qa.stringify(e.contents,n,()=>s=null,c);s&&(l+=cr.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(qa.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=a(e.comment);c.includes(`
58
+ `)?(r.push("..."),r.push(cr.indentComment(c,""))):r.push(`... ${c}`)}else r.push("...");else{let c=e.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&r[r.length-1]!==""&&r.push(""),r.push(cr.indentComment(a(c),"")))}return r.join(`
59
59
  `)+`
60
- `}ul.stringifyDocument=Em});var lr=g(fl=>{"use strict";var Cm=Gt(),kt=Zr(),Z=x(),xm=Be(),Pm=Oe(),Rm=Fa(),Am=dl(),Wa=Kr(),_m=Un(),Im=Ut(),za=Gn(),Ja=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Z.NODE_TYPE,{value:Z.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 za.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,{[Z.NODE_TYPE]:{value:Z.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=Z.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){St(this.contents)&&this.contents.add(e)}addIn(e,r){St(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=Wa.anchorNames(this);e.anchor=!r||i.has(r)?Wa.findNewAnchor(r||"a",i):r}return new Cm.Alias(e.anchor)}createNode(e,r,i){let n;if(typeof r=="function")e=r.call({"":e},"",e),n=r;else if(Array.isArray(r)){let m=y=>typeof y=="number"||y instanceof String||y instanceof Number,w=r.filter(m).map(String);w.length>0&&(r=r.concat(w)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:f}=i??{},{onAnchor:u,setAnchors:d,sourceObjects:h}=Wa.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:h},p=Im.createNode(e,f,v);return s&&Z.isCollection(p)&&(p.flow=!0),d(),p}createPair(e,r,i={}){let n=this.createNode(e,null,i),a=this.createNode(r,null,i);return new xm.Pair(n,a)}delete(e){return St(this.contents)?this.contents.delete(e):!1}deleteIn(e){return kt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):St(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return Z.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return kt.isEmptyPath(e)?!r&&Z.isScalar(this.contents)?this.contents.value:this.contents:Z.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return Z.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return kt.isEmptyPath(e)?this.contents!==void 0:Z.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=kt.collectionFromPath(this.schema,[e],r):St(this.contents)&&this.contents.set(e,r)}setIn(e,r){kt.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=kt.collectionFromPath(this.schema,Array.from(e),r):St(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 za.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 za.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 Rm.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=Pm.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:f}of s.anchors.values())a(f,l);return typeof o=="function"?_m.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 Am.stringifyDocument(this,e)}};function St(t){if(Z.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}fl.Document=Ja});var fr=g(dr=>{"use strict";var ur=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},Ga=class extends ur{constructor(e,r,i){super("YAMLParseError",e,r,i)}},Ua=class extends ur{constructor(e,r,i){super("YAMLWarning",e,r,i)}},Tm=(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
+ `}ul.stringifyDocument=Pm});var lr=g(fl=>{"use strict";var Rm=Gt(),St=Zr(),Z=x(),Am=Ve(),_m=De(),Im=Fa(),Tm=dl(),Wa=Kr(),jm=Un(),$m=Ut(),za=Gn(),Ja=class e{constructor(t,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Z.NODE_TYPE,{value:Z.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 za.Directives({version:o}),this.setSchema(o,i),this.contents=t===void 0?null:this.createNode(t,n,i)}clone(){let t=Object.create(e.prototype,{[Z.NODE_TYPE]:{value:Z.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Z.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){Et(this.contents)&&this.contents.add(t)}addIn(t,r){Et(this.contents)&&this.contents.addIn(t,r)}createAlias(t,r){if(!t.anchor){let i=Wa.anchorNames(this);t.anchor=!r||i.has(r)?Wa.findNewAnchor(r||"a",i):r}return new Rm.Alias(t.anchor)}createNode(t,r,i){let n;if(typeof r=="function")t=r.call({"":t},"",t),n=r;else if(Array.isArray(r)){let m=y=>typeof y=="number"||y instanceof String||y instanceof Number,w=r.filter(m).map(String);w.length>0&&(r=r.concat(w)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:f}=i??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=Wa.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=$m.createNode(t,f,v);return s&&Z.isCollection(h)&&(h.flow=!0),d(),h}createPair(t,r,i={}){let n=this.createNode(t,null,i),a=this.createNode(r,null,i);return new Am.Pair(n,a)}delete(t){return Et(this.contents)?this.contents.delete(t):!1}deleteIn(t){return St.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):Et(this.contents)?this.contents.deleteIn(t):!1}get(t,r){return Z.isCollection(this.contents)?this.contents.get(t,r):void 0}getIn(t,r){return St.isEmptyPath(t)?!r&&Z.isScalar(this.contents)?this.contents.value:this.contents:Z.isCollection(this.contents)?this.contents.getIn(t,r):void 0}has(t){return Z.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return St.isEmptyPath(t)?this.contents!==void 0:Z.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,r){this.contents==null?this.contents=St.collectionFromPath(this.schema,[t],r):Et(this.contents)&&this.contents.set(t,r)}setIn(t,r){St.isEmptyPath(t)?this.contents=r:this.contents==null?this.contents=St.collectionFromPath(this.schema,Array.from(t),r):Et(this.contents)&&this.contents.setIn(t,r)}setSchema(t,r={}){typeof t=="number"&&(t=String(t));let i;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new za.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new za.Directives({version:t}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(i)this.schema=new Im.Schema(Object.assign(i,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:r,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!t,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=_m.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:f}of s.anchors.values())a(f,l);return typeof o=="function"?jm.applyReviver(o,{"":c},"",c):c}toJSON(t,r){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:r})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let r=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return Tm.stringifyDocument(this,t)}};function Et(e){if(Z.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}fl.Document=Ja});var fr=g(dr=>{"use strict";var ur=class extends Error{constructor(t,r,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=r}},Ga=class extends ur{constructor(t,r,i){super("YAMLParseError",t,r,i)}},Ua=class extends ur{constructor(t,r,i){super("YAMLWarning",t,r,i)}},Om=(e,t)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>t.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,a))){let s=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
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
- `}};dr.YAMLError=ur;dr.YAMLParseError=Ga;dr.YAMLWarning=Ua;dr.prettifyError=Tm});var pr=g(pl=>{"use strict";function jm(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,f=s,u="",d="",h=!1,v=!1,p=null,m=null,w=null,y=null,b=null,k=null,S=null;for(let N of t)switch(v&&(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma"&&a(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),p&&(l&&N.type!=="comment"&&N.type!=="newline"&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),N.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&N.source.includes(" ")&&(p=N),f=!0;break;case"comment":{f||a(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let O=N.source.substring(1)||" ";u?u+=d+O:u=O,d="",l=!1;break}case"newline":l?u?u+=N.source:(!k||r!=="seq-item-ind")&&(c=!0):d+=N.source,l=!0,h=!0,(m||w)&&(y=N),f=!0;break;case"anchor":m&&a(N,"MULTIPLE_ANCHORS","A node can have at most one anchor"),N.source.endsWith(":")&&a(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=N,S??(S=N.offset),l=!1,f=!1,v=!0;break;case"tag":{w&&a(N,"MULTIPLE_TAGS","A node can have at most one tag"),w=N,S??(S=N.offset),l=!1,f=!1,v=!0;break}case r:(m||w)&&a(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`),k&&a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${e??"collection"}`),k=N,l=r==="seq-item-ind"||r==="explicit-key-ind",f=!1;break;case"comma":if(e){b&&a(N,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=N,l=!1,f=!1;break}default:a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),l=!1,f=!1}let E=t[t.length-1],A=E?E.offset+E.source.length:n;return v&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(l&&p.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:k,spaceBefore:c,comment:u,hasNewline:h,anchor:m,tag:w,newlineAfterProp:y,end:A,start:S??A}}pl.resolveProps=jm});var $i=g(hl=>{"use strict";function Ka(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(Ka(e.key)||Ka(e.value))return!0}return!1;default:return!0}}hl.containsNewline=Ka});var Ya=g(ml=>{"use strict";var $m=$i();function Om(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&$m.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}ml.flowIndentCheck=Om});var Xa=g(gl=>{"use strict";var vl=x();function Hm(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||vl.isScalar(a)&&vl.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}gl.mapIncludes=Hm});var Sl=g(kl=>{"use strict";var wl=Be(),Dm=Me(),yl=pr(),Lm=$i(),Nl=Ya(),Bm=Xa(),bl="All mapping items must start at the same column";function Vm({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Dm.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let f of i.items){let{start:u,key:d,sep:h,value:v}=f,p=yl.resolveProps(u,{indicator:"explicit-key-ind",next:d??h?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),m=!p.found;if(m){if(d&&(d.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==i.indent&&n(c,"BAD_INDENT",bl)),!p.anchor&&!p.tag&&!h){l=p.end,p.comment&&(s.comment?s.comment+=`
67
- `+p.comment:s.comment=p.comment);continue}(p.newlineAfterProp||Lm.containsNewline(d))&&n(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==i.indent&&n(c,"BAD_INDENT",bl);r.atKey=!0;let w=p.end,y=d?t(r,d,p,n):e(r,w,u,null,p,n);r.schema.compat&&Nl.flowIndentCheck(i.indent,d,n),r.atKey=!1,Bm.mapIncludes(r,s.items,y)&&n(w,"DUPLICATE_KEY","Map keys must be unique");let b=yl.resolveProps(h??[],{indicator:"map-value-ind",next:v,offset:y.range[2],onError:n,parentIndent:i.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=b.end,b.found){m&&(v?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&p.start<b.found.offset-1024&&n(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=v?t(r,v,b,n):e(r,c,h,null,b,n);r.schema.compat&&Nl.flowIndentCheck(i.indent,v,n),c=k.range[2];let S=new wl.Pair(y,k);r.options.keepSourceTokens&&(S.srcToken=f),s.items.push(S)}else{m&&n(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(y.comment?y.comment+=`
68
- `+b.comment:y.comment=b.comment);let k=new wl.Pair(y);r.options.keepSourceTokens&&(k.srcToken=f),s.items.push(k)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}kl.resolveBlockMap=Vm});var Cl=g(El=>{"use strict";var Mm=Fe(),Fm=pr(),qm=Ya();function Wm({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Mm.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:f,value:u}of i.items){let d=Fm.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?n(d.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(s.comment=d.comment);continue}let h=u?t(r,u,d,n):e(r,d.end,f,null,d,n);r.schema.compat&&qm.flowIndentCheck(i.indent,u,n),c=h.range[2],s.items.push(h)}return s.range=[i.offset,c,l??c],s}El.resolveBlockSeq=Wm});var Et=g(xl=>{"use strict";function zm(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 f=c.substring(1)||" ";n?n+=o+f:n=f,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}}xl.resolveEnd=zm});var _l=g(Al=>{"use strict";var Jm=x(),Gm=Be(),Pl=Me(),Um=Fe(),Km=Et(),Rl=pr(),Ym=$i(),Xm=Xa(),Qa="Block collections are not allowed within flow collections",Za=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Qm({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Pl.YAMLMap:Um.YAMLSeq),l=new c(r.schema);l.flow=!0;let f=r.atRoot;f&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=i.offset+i.start.source.length;for(let m=0;m<i.items.length;++m){let w=i.items[m],{start:y,key:b,sep:k,value:S}=w,E=Rl.resolveProps(y,{flow:s,indicator:"explicit-key-ind",next:b??k?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!k&&!S){m===0&&E.comma?n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<i.items.length-1&&n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),E.comment&&(l.comment?l.comment+=`
69
- `+E.comment:l.comment=E.comment),u=E.end;continue}!o&&r.options.strict&&Ym.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)E.comma&&n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(E.comma||n(E.start,"MISSING_CHAR",`Missing , between ${s} items`),E.comment){let A="";e:for(let N of y)switch(N.type){case"comma":case"space":break;case"comment":A=N.source.substring(1);break e;default:break e}if(A){let N=l.items[l.items.length-1];Jm.isPair(N)&&(N=N.value??N.key),N.comment?N.comment+=`
70
- `+A:N.comment=A,E.comment=E.comment.substring(A.length+1)}}if(!o&&!k&&!E.found){let A=S?t(r,S,E,n):e(r,E.end,k,null,E,n);l.items.push(A),u=A.range[2],Za(S)&&n(A.range,"BLOCK_IN_FLOW",Qa)}else{r.atKey=!0;let A=E.end,N=b?t(r,b,E,n):e(r,A,y,null,E,n);Za(b)&&n(N.range,"BLOCK_IN_FLOW",Qa),r.atKey=!1;let O=Rl.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:S,offset:N.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(O.found){if(!o&&!E.found&&r.options.strict){if(k)for(let H of k){if(H===O.found)break;if(H.type==="newline"){n(H,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<O.found.offset-1024&&n(O.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${s}`):n(O.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let je=S?t(r,S,O,n):O.found?e(r,O.end,k,null,O,n):null;je?Za(S)&&n(je.range,"BLOCK_IN_FLOW",Qa):O.comment&&(N.comment?N.comment+=`
71
- `+O.comment:N.comment=O.comment);let ft=new Gm.Pair(N,je);if(r.options.keepSourceTokens&&(ft.srcToken=w),o){let H=l;Xm.mapIncludes(r,H.items,N)&&n(A,"DUPLICATE_KEY","Map keys must be unique"),H.items.push(ft)}else{let H=new Pl.YAMLMap(r.schema);H.flow=!0,H.items.push(ft);let ks=(je??N).range;H.range=[N.range[0],ks[1],ks[2]],l.items.push(H)}u=je?je.range[2]:O.end}}let d=o?"}":"]",[h,...v]=i.end,p=u;if(h?.source===d)p=h.offset+h.source.length;else{let m=s[0].toUpperCase()+s.substring(1),w=f?`${m} must end with a ${d}`:`${m} in block collection must be sufficiently indented and end with a ${d}`;n(u,f?"MISSING_CHAR":"BAD_INDENT",w),h&&h.source.length!==1&&v.unshift(h)}if(v.length>0){let m=Km.resolveEnd(v,p,r.options.strict,n);m.comment&&(l.comment?l.comment+=`
72
- `+m.comment:l.comment=m.comment),l.range=[i.offset,p,m.offset]}else l.range=[i.offset,p,p];return l}Al.resolveFlowCollection=Qm});var Tl=g(Il=>{"use strict";var Zm=x(),ev=j(),tv=Me(),rv=Fe(),iv=Sl(),nv=Cl(),av=_l();function eo(t,e,r,i,n,a){let o=r.type==="block-map"?iv.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?nv.resolveBlockSeq(t,e,r,i,a):av.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 ov(t,e,r,i,n){let a=i.tag,o=a?e.directives.tagName(a.source,d=>n(a,"TAG_RESOLVE_FAILED",d)):null;if(r.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=i,v=d&&a?d.offset>a.offset?d:a:d??a;v&&(!h||h.offset<v.offset)&&n(v,"MISSING_CHAR","Missing newline after block sequence props")}let s=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===tv.YAMLMap.tagName&&s==="map"||o===rv.YAMLSeq.tagName&&s==="seq")return eo(t,e,r,n,o);let c=e.schema.tags.find(d=>d.tag===o&&d.collection===s);if(!c){let d=e.schema.knownTags[o];if(d?.collection===s)e.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?n(a,"BAD_COLLECTION_TYPE",`${d.tag} used for ${s} collection, but expects ${d.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),eo(t,e,r,n,o)}let l=eo(t,e,r,n,o,c),f=c.resolve?.(l,d=>n(a,"TAG_RESOLVE_FAILED",d),e.options)??l,u=Zm.isNode(f)?f:new ev.Scalar(f);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Il.composeCollection=ov});var ro=g(jl=>{"use strict";var to=j();function sv(t,e,r){let i=e.offset,n=cv(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?to.Scalar.BLOCK_FOLDED:to.Scalar.BLOCK_LITERAL,o=e.source?lv(e.source):[],s=o.length;for(let p=o.length-1;p>=0;--p){let m=o[p][1];if(m===""||m==="\r")s=p;else break}if(s===0){let p=n.chomp==="+"&&o.length>0?`
73
- `.repeat(Math.max(1,o.length-1)):"",m=i+n.length;return e.source&&(m+=e.source.length),{value:p,type:a,comment:n.comment,range:[i,m,m]}}let c=e.indent+n.indent,l=e.offset+n.length,f=0;for(let p=0;p<s;++p){let[m,w]=o[p];if(w===""||w==="\r")n.indent===0&&m.length>c&&(c=m.length);else{m.length<c&&r(l+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=m.length),f=p,c===0&&!t.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+w.length+1}for(let p=o.length-1;p>=s;--p)o[p][0].length>c&&(s=p+1);let u="",d="",h=!1;for(let p=0;p<f;++p)u+=o[p][0].slice(c)+`
74
- `;for(let p=f;p<s;++p){let[m,w]=o[p];l+=m.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&m.length<c){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-w.length-(y?2:1),"BAD_INDENT",k),m=""}a===to.Scalar.BLOCK_LITERAL?(u+=d+m.slice(c)+w,d=`
65
+ `}};dr.YAMLError=ur;dr.YAMLParseError=Ga;dr.YAMLWarning=Ua;dr.prettifyError=Om});var hr=g(hl=>{"use strict";function Hm(e,{flow:t,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,f=s,u="",d="",p=!1,v=!1,h=null,m=null,w=null,y=null,b=null,k=null,S=null;for(let N of e)switch(v&&(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma"&&a(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&N.type!=="comment"&&N.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),N.type){case"space":!t&&(r!=="doc-start"||i?.type!=="flow-collection")&&N.source.includes(" ")&&(h=N),f=!0;break;case"comment":{f||a(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let O=N.source.substring(1)||" ";u?u+=d+O:u=O,d="",l=!1;break}case"newline":l?u?u+=N.source:(!k||r!=="seq-item-ind")&&(c=!0):d+=N.source,l=!0,p=!0,(m||w)&&(y=N),f=!0;break;case"anchor":m&&a(N,"MULTIPLE_ANCHORS","A node can have at most one anchor"),N.source.endsWith(":")&&a(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=N,S??(S=N.offset),l=!1,f=!1,v=!0;break;case"tag":{w&&a(N,"MULTIPLE_TAGS","A node can have at most one tag"),w=N,S??(S=N.offset),l=!1,f=!1,v=!0;break}case r:(m||w)&&a(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`),k&&a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${t??"collection"}`),k=N,l=r==="seq-item-ind"||r==="explicit-key-ind",f=!1;break;case"comma":if(t){b&&a(N,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),b=N,l=!1,f=!1;break}default:a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),l=!1,f=!1}let E=e[e.length-1],A=E?E.offset+E.source.length:n;return v&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(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:k,spaceBefore:c,comment:u,hasNewline:p,anchor:m,tag:w,newlineAfterProp:y,end:A,start:S??A}}hl.resolveProps=Hm});var $i=g(pl=>{"use strict";function Ka(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
66
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(Ka(t.key)||Ka(t.value))return!0}return!1;default:return!0}}pl.containsNewline=Ka});var Ya=g(ml=>{"use strict";var Dm=$i();function Lm(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&Dm.containsNewline(t)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}ml.flowIndentCheck=Lm});var Xa=g(gl=>{"use strict";var vl=x();function Bm(e,t,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||vl.isScalar(a)&&vl.isScalar(o)&&a.value===o.value;return t.some(a=>n(a.key,r))}gl.mapIncludes=Bm});var Sl=g(kl=>{"use strict";var wl=Ve(),Mm=qe(),yl=hr(),Vm=$i(),Nl=Ya(),Fm=Xa(),bl="All mapping items must start at the same column";function qm({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=a?.nodeClass??Mm.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let f of i.items){let{start:u,key:d,sep:p,value:v}=f,h=yl.resolveProps(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),m=!h.found;if(m){if(d&&(d.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==i.indent&&n(c,"BAD_INDENT",bl)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Vm.containsNewline(d))&&n(d??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",bl);r.atKey=!0;let w=h.end,y=d?e(r,d,h,n):t(r,w,u,null,h,n);r.schema.compat&&Nl.flowIndentCheck(i.indent,d,n),r.atKey=!1,Fm.mapIncludes(r,s.items,y)&&n(w,"DUPLICATE_KEY","Map keys must be unique");let b=yl.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:y.range[2],onError:n,parentIndent:i.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=b.end,b.found){m&&(v?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<b.found.offset-1024&&n(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=v?e(r,v,b,n):t(r,c,p,null,b,n);r.schema.compat&&Nl.flowIndentCheck(i.indent,v,n),c=k.range[2];let S=new wl.Pair(y,k);r.options.keepSourceTokens&&(S.srcToken=f),s.items.push(S)}else{m&&n(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(y.comment?y.comment+=`
68
+ `+b.comment:y.comment=b.comment);let k=new wl.Pair(y);r.options.keepSourceTokens&&(k.srcToken=f),s.items.push(k)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}kl.resolveBlockMap=qm});var Cl=g(El=>{"use strict";var Wm=We(),zm=hr(),Jm=Ya();function Gm({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=a?.nodeClass??Wm.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:f,value:u}of i.items){let d=zm.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?n(d.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(s.comment=d.comment);continue}let p=u?e(r,u,d,n):t(r,d.end,f,null,d,n);r.schema.compat&&Jm.flowIndentCheck(i.indent,u,n),c=p.range[2],s.items.push(p)}return s.range=[i.offset,c,l??c],s}El.resolveBlockSeq=Gm});var Ct=g(xl=>{"use strict";function Um(e,t,r,i){let n="";if(e){let a=!1,o="";for(let s of e){let{source:c,type:l}=s;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=c),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:n,offset:t}}xl.resolveEnd=Um});var _l=g(Al=>{"use strict";var Km=x(),Ym=Ve(),Pl=qe(),Xm=We(),Qm=Ct(),Rl=hr(),Zm=$i(),ev=Xa(),Qa="Block collections are not allowed within flow collections",Za=e=>e&&(e.type==="block-map"||e.type==="block-seq");function tv({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Pl.YAMLMap:Xm.YAMLSeq),l=new c(r.schema);l.flow=!0;let f=r.atRoot;f&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=i.offset+i.start.source.length;for(let m=0;m<i.items.length;++m){let w=i.items[m],{start:y,key:b,sep:k,value:S}=w,E=Rl.resolveProps(y,{flow:s,indicator:"explicit-key-ind",next:b??k?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!k&&!S){m===0&&E.comma?n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<i.items.length-1&&n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),E.comment&&(l.comment?l.comment+=`
69
+ `+E.comment:l.comment=E.comment),u=E.end;continue}!o&&r.options.strict&&Zm.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)E.comma&&n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(E.comma||n(E.start,"MISSING_CHAR",`Missing , between ${s} items`),E.comment){let A="";e:for(let N of y)switch(N.type){case"comma":case"space":break;case"comment":A=N.source.substring(1);break e;default:break e}if(A){let N=l.items[l.items.length-1];Km.isPair(N)&&(N=N.value??N.key),N.comment?N.comment+=`
70
+ `+A:N.comment=A,E.comment=E.comment.substring(A.length+1)}}if(!o&&!k&&!E.found){let A=S?e(r,S,E,n):t(r,E.end,k,null,E,n);l.items.push(A),u=A.range[2],Za(S)&&n(A.range,"BLOCK_IN_FLOW",Qa)}else{r.atKey=!0;let A=E.end,N=b?e(r,b,E,n):t(r,A,y,null,E,n);Za(b)&&n(N.range,"BLOCK_IN_FLOW",Qa),r.atKey=!1;let O=Rl.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:S,offset:N.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(O.found){if(!o&&!E.found&&r.options.strict){if(k)for(let H of k){if(H===O.found)break;if(H.type==="newline"){n(H,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<O.found.offset-1024&&n(O.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${s}`):n(O.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let $e=S?e(r,S,O,n):O.found?t(r,O.end,k,null,O,n):null;$e?Za(S)&&n($e.range,"BLOCK_IN_FLOW",Qa):O.comment&&(N.comment?N.comment+=`
71
+ `+O.comment:N.comment=O.comment);let ft=new Ym.Pair(N,$e);if(r.options.keepSourceTokens&&(ft.srcToken=w),o){let H=l;ev.mapIncludes(r,H.items,N)&&n(A,"DUPLICATE_KEY","Map keys must be unique"),H.items.push(ft)}else{let H=new Pl.YAMLMap(r.schema);H.flow=!0,H.items.push(ft);let ks=($e??N).range;H.range=[N.range[0],ks[1],ks[2]],l.items.push(H)}u=$e?$e.range[2]:O.end}}let d=o?"}":"]",[p,...v]=i.end,h=u;if(p?.source===d)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),w=f?`${m} must end with a ${d}`:`${m} in block collection must be sufficiently indented and end with a ${d}`;n(u,f?"MISSING_CHAR":"BAD_INDENT",w),p&&p.source.length!==1&&v.unshift(p)}if(v.length>0){let m=Qm.resolveEnd(v,h,r.options.strict,n);m.comment&&(l.comment?l.comment+=`
72
+ `+m.comment:l.comment=m.comment),l.range=[i.offset,h,m.offset]}else l.range=[i.offset,h,h];return l}Al.resolveFlowCollection=tv});var Tl=g(Il=>{"use strict";var rv=x(),iv=j(),nv=qe(),av=We(),ov=Sl(),sv=Cl(),cv=_l();function eo(e,t,r,i,n,a){let o=r.type==="block-map"?ov.resolveBlockMap(e,t,r,i,a):r.type==="block-seq"?sv.resolveBlockSeq(e,t,r,i,a):cv.resolveFlowCollection(e,t,r,i,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function lv(e,t,r,i,n){let a=i.tag,o=a?t.directives.tagName(a.source,d=>n(a,"TAG_RESOLVE_FAILED",d)):null;if(r.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=i,v=d&&a?d.offset>a.offset?d:a:d??a;v&&(!p||p.offset<v.offset)&&n(v,"MISSING_CHAR","Missing newline after block sequence props")}let s=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===nv.YAMLMap.tagName&&s==="map"||o===av.YAMLSeq.tagName&&s==="seq")return eo(e,t,r,n,o);let c=t.schema.tags.find(d=>d.tag===o&&d.collection===s);if(!c){let d=t.schema.knownTags[o];if(d?.collection===s)t.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?n(a,"BAD_COLLECTION_TYPE",`${d.tag} used for ${s} collection, but expects ${d.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),eo(e,t,r,n,o)}let l=eo(e,t,r,n,o,c),f=c.resolve?.(l,d=>n(a,"TAG_RESOLVE_FAILED",d),t.options)??l,u=rv.isNode(f)?f:new iv.Scalar(f);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Il.composeCollection=lv});var ro=g(jl=>{"use strict";var to=j();function uv(e,t,r){let i=t.offset,n=dv(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?to.Scalar.BLOCK_FOLDED:to.Scalar.BLOCK_LITERAL,o=t.source?fv(t.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
+ `.repeat(Math.max(1,o.length-1)):"",m=i+n.length;return t.source&&(m+=t.source.length),{value:h,type:a,comment:n.comment,range:[i,m,m]}}let c=t.indent+n.indent,l=t.offset+n.length,f=0;for(let h=0;h<s;++h){let[m,w]=o[h];if(w===""||w==="\r")n.indent===0&&m.length>c&&(c=m.length);else{m.length<c&&r(l+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=m.length),f=h,c===0&&!e.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+w.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let u="",d="",p=!1;for(let h=0;h<f;++h)u+=o[h][0].slice(c)+`
74
+ `;for(let h=f;h<s;++h){let[m,w]=o[h];l+=m.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&m.length<c){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-w.length-(y?2:1),"BAD_INDENT",k),m=""}a===to.Scalar.BLOCK_LITERAL?(u+=d+m.slice(c)+w,d=`
75
75
  `):m.length>c||w[0]===" "?(d===" "?d=`
76
- `:!h&&d===`
76
+ `:!p&&d===`
77
77
  `&&(d=`
78
78
 
79
79
  `),u+=d+m.slice(c)+w,d=`
80
- `,h=!0):w===""?d===`
80
+ `,p=!0):w===""?d===`
81
81
  `?u+=`
82
82
  `:d=`
83
- `:(u+=d+w,d=" ",h=!1)}switch(n.chomp){case"-":break;case"+":for(let p=s;p<o.length;++p)u+=`
84
- `+o[p][0].slice(c);u[u.length-1]!==`
83
+ `:(u+=d+w,d=" ",p=!1)}switch(n.chomp){case"-":break;case"+":for(let h=s;h<o.length;++h)u+=`
84
+ `+o[h][0].slice(c);u[u.length-1]!==`
85
85
  `&&(u+=`
86
86
  `);break;default:u+=`
87
- `}let v=i+n.length+e.source.length;return{value:u,type:a,comment:n.comment,range:[i,v,v]}}function cv({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 d=1;d<n.length;++d){let h=n[d];if(!s&&(h==="-"||h==="+"))s=h;else{let v=Number(h);!o&&v?o=v:c===-1&&(c=t+d)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,f="",u=n.length;for(let d=1;d<e.length;++d){let h=e[d];switch(h.type){case"space":l=!0;case"newline":u+=h.source.length;break;case"comment":r&&!l&&i(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=h.source.length,f=h.source.substring(1);break;case"error":i(h,"UNEXPECTED_TOKEN",h.message),u+=h.source.length;break;default:{let v=`Unexpected token in block scalar header: ${h.type}`;i(h,"UNEXPECTED_TOKEN",v);let p=h.source;p&&typeof p=="string"&&(u+=p.length)}}}return{mode:a,indent:o,chomp:s,comment:f,length:u}}function lv(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}jl.resolveBlockScalar=sv});var no=g(Ol=>{"use strict";var io=j(),uv=Et();function dv(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(d,h,v)=>r(i+d,h,v);switch(n){case"scalar":s=io.Scalar.PLAIN,c=fv(a,l);break;case"single-quoted-scalar":s=io.Scalar.QUOTE_SINGLE,c=pv(a,l);break;case"double-quoted-scalar":s=io.Scalar.QUOTE_DOUBLE,c=hv(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 f=i+a.length,u=uv.resolveEnd(o,f,e,r);return{value:c,type:s,comment:u.comment,range:[i,f,u.offset]}}function fv(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}`),$l(t)}function pv(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),$l(t.slice(1,-1)).replace(/''/g,"'")}function $l(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
+ `}let v=i+n.length+t.source.length;return{value:u,type:a,comment:n.comment,range:[i,v,v]}}function dv({offset:e,props:t},r,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],a=n[0],o=0,s="",c=-1;for(let d=1;d<n.length;++d){let p=n[d];if(!s&&(p==="-"||p==="+"))s=p;else{let v=Number(p);!o&&v?o=v:c===-1&&(c=e+d)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,f="",u=n.length;for(let d=1;d<t.length;++d){let p=t[d];switch(p.type){case"space":l=!0;case"newline":u+=p.source.length;break;case"comment":r&&!l&&i(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":i(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let v=`Unexpected token in block scalar header: ${p.type}`;i(p,"UNEXPECTED_TOKEN",v);let h=p.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:f,length:u}}function fv(e){let t=e.split(/\n( *)/),r=t[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<t.length;o+=2)a.push([t[o],t[o+1]]);return a}jl.resolveBlockScalar=uv});var no=g(Ol=>{"use strict";var io=j(),hv=Ct();function pv(e,t,r){let{offset:i,type:n,source:a,end:o}=e,s,c,l=(d,p,v)=>r(i+d,p,v);switch(n){case"scalar":s=io.Scalar.PLAIN,c=mv(a,l);break;case"single-quoted-scalar":s=io.Scalar.QUOTE_SINGLE,c=vv(a,l);break;case"double-quoted-scalar":s=io.Scalar.QUOTE_DOUBLE,c=gv(a,l);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let f=i+a.length,u=hv.resolveEnd(o,f,t,r);return{value:c,type:s,comment:u.comment,range:[i,f,u.offset]}}function mv(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),$l(e)}function vv(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),$l(e.slice(1,-1)).replace(/''/g,"'")}function $l(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
88
88
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
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===`
89
+ `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let n=i[1],a=" ",o=t.lastIndex;for(r.lastIndex=o;i=r.exec(e);)i[1]===""?a===`
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 hv(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(e),n+a+(i?.[1]??"")}function gv(e,t){let r="";for(let i=1;i<e.length-1;++i){let n=e[i];if(!(n==="\r"&&e[i+1]===`
92
92
  `))if(n===`
93
- `){let{fold:a,offset:o}=mv(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=vv[a];if(o)r+=o;else if(a===`
94
- `)for(a=t[i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="\r"&&t[i+1]===`
95
- `)for(a=t[++i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=gv(t,i+1,s,e),i+=s}else{let s=t.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=t[i+1];for(;o===" "||o===" ";)o=t[++i+1];o!==`
96
- `&&!(o==="\r"&&t[i+2]===`
97
- `)&&(r+=i>a?t.slice(a,i+1):n)}else r+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function mv(t,e){let r="",i=t[e+1];for(;(i===" "||i===" "||i===`
98
- `||i==="\r")&&!(i==="\r"&&t[e+2]!==`
93
+ `){let{fold:a,offset:o}=wv(e,i);r+=a,i=o}else if(n==="\\"){let a=e[++i],o=yv[a];if(o)r+=o;else if(a===`
94
+ `)for(a=e[i+1];a===" "||a===" ";)a=e[++i+1];else if(a==="\r"&&e[i+1]===`
95
+ `)for(a=e[++i+1];a===" "||a===" ";)a=e[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=Nv(e,i+1,s,t),i+=s}else{let s=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=e[i+1];for(;o===" "||o===" ";)o=e[++i+1];o!==`
96
+ `&&!(o==="\r"&&e[i+2]===`
97
+ `)&&(r+=i>a?e.slice(a,i+1):n)}else r+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}function wv(e,t){let r="",i=e[t+1];for(;(i===" "||i===" "||i===`
98
+ `||i==="\r")&&!(i==="\r"&&e[t+2]!==`
99
99
  `);)i===`
100
100
  `&&(r+=`
101
- `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var vv={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function gv(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}}Ol.resolveFlowScalar=dv});var Ll=g(Dl=>{"use strict";var it=x(),Hl=j(),wv=ro(),yv=no();function Nv(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?wv.resolveBlockScalar(t,e,i):yv.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[it.SCALAR]:c?l=bv(t.schema,n,c,r,i):e.type==="scalar"?l=kv(t,n,e,i):l=t.schema[it.SCALAR];let f;try{let u=l.resolve(n,d=>i(r??e,"TAG_RESOLVE_FAILED",d),t.options);f=it.isScalar(u)?u:new Hl.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);i(r??e,"TAG_RESOLVE_FAILED",d),f=new Hl.Scalar(n)}return f.range=s,f.source=n,a&&(f.type=a),c&&(f.tag=c),l.format&&(f.format=l.format),o&&(f.comment=o),f}function bv(t,e,r,i,n){if(r==="!")return t[it.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[it.SCALAR])}function kv({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[it.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[it.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),f=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}Dl.composeScalar=Nv});var Vl=g(Bl=>{"use strict";function Sv(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}Bl.emptyScalarPosition=Sv});var ql=g(oo=>{"use strict";var Ev=Gt(),Cv=x(),xv=Tl(),Ml=Ll(),Pv=Et(),Rv=Vl(),Av={composeNode:Fl,composeEmptyNode:ao};function Fl(t,e,r,i){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,f=!0;switch(e.type){case"alias":l=_v(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=Ml.composeScalar(t,e,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=xv.composeCollection(Av,t,e,r,i),s&&(l.anchor=s.source.substring(1))}catch(u){let d=u instanceof Error?u.message:String(u);i(e,"RESOURCE_EXHAUSTION",d)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",u),f=!1}}return l??(l=ao(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&&(!Cv.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&&f&&(l.srcToken=e),l}function ao(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let f={type:"scalar",offset:Rv.emptyScalarPosition(e,r,i),indent:-1,source:""},u=Ml.composeScalar(t,f,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 _v({options:t},{offset:e,source:r,end:i},n){let a=new Ev.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=Pv.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}oo.composeEmptyNode=ao;oo.composeNode=Fl});var Jl=g(zl=>{"use strict";var Iv=lr(),Wl=ql(),Tv=Et(),jv=pr();function $v(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new Iv.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=jv.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Wl.composeNode(l,n,f,o):Wl.composeEmptyNode(l,f.end,i,null,f,o);let u=c.contents.range[2],d=Tv.resolveEnd(a,u,!1,o);return d.comment&&(c.comment=d.comment),c.range=[r,u,d.offset],c}zl.composeDoc=$v});var co=g(Kl=>{"use strict";var Ov=Br("process"),Hv=Gn(),Dv=lr(),hr=fr(),Gl=x(),Lv=Jl(),Bv=Et();function mr(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 Ul(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
+ `),t+=1,i=e[t+1];return r||(r=" "),{fold:r,offset:t}}var yv={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Nv(e,t,r,i){let n=e.substr(t,r),o=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=e.substr(t-2,r+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Ol.resolveFlowScalar=pv});var Ll=g(Dl=>{"use strict";var it=x(),Hl=j(),bv=ro(),kv=no();function Sv(e,t,r,i){let{value:n,type:a,comment:o,range:s}=t.type==="block-scalar"?bv.resolveBlockScalar(e,t,i):kv.resolveFlowScalar(t,e.options.strict,i),c=r?e.directives.tagName(r.source,u=>i(r,"TAG_RESOLVE_FAILED",u)):null,l;e.options.stringKeys&&e.atKey?l=e.schema[it.SCALAR]:c?l=Ev(e.schema,n,c,r,i):t.type==="scalar"?l=Cv(e,n,t,i):l=e.schema[it.SCALAR];let f;try{let u=l.resolve(n,d=>i(r??t,"TAG_RESOLVE_FAILED",d),e.options);f=it.isScalar(u)?u:new Hl.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);i(r??t,"TAG_RESOLVE_FAILED",d),f=new Hl.Scalar(n)}return f.range=s,f.source=n,a&&(f.type=a),c&&(f.tag=c),l.format&&(f.format=l.format),o&&(f.comment=o),f}function Ev(e,t,r,i,n){if(r==="!")return e[it.SCALAR];let a=[];for(let s of e.tags)if(!s.collection&&s.tag===r)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(t))return s;let o=e.knownTags[r];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[it.SCALAR])}function Cv({atKey:e,directives:t,schema:r},i,n,a){let o=r.tags.find(s=>(s.default===!0||e&&s.default==="key")&&s.test?.test(i))||r[it.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[it.SCALAR];if(o.tag!==s.tag){let c=t.tagString(o.tag),l=t.tagString(s.tag),f=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}Dl.composeScalar=Sv});var Ml=g(Bl=>{"use strict";function xv(e,t,r){if(t){r??(r=t.length);for(let i=r-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++i];n?.type==="space";)e+=n.source.length,n=t[++i];break}}return e}Bl.emptyScalarPosition=xv});var ql=g(oo=>{"use strict";var Pv=Gt(),Rv=x(),Av=Tl(),Vl=Ll(),_v=Ct(),Iv=Ml(),Tv={composeNode:Fl,composeEmptyNode:ao};function Fl(e,t,r,i){let n=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,f=!0;switch(t.type){case"alias":l=jv(e,t,i),(s||c)&&i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=Vl.composeScalar(e,t,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Av.composeCollection(Tv,e,t,r,i),s&&(l.anchor=s.source.substring(1))}catch(u){let d=u instanceof Error?u.message:String(u);i(t,"RESOURCE_EXHAUSTION",d)}break;default:{let u=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",u),f=!1}}return l??(l=ao(e,t.offset,void 0,null,r,i)),s&&l.anchor===""&&i(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!Rv.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&i(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&f&&(l.srcToken=t),l}function ao(e,t,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let f={type:"scalar",offset:Iv.emptyScalarPosition(t,r,i),indent:-1,source:""},u=Vl.composeScalar(e,f,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 jv({options:e},{offset:t,source:r,end:i},n){let a=new Pv.Alias(r.substring(1));a.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+r.length,s=_v.resolveEnd(i,o,e.strict,n);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}oo.composeEmptyNode=ao;oo.composeNode=Fl});var Jl=g(zl=>{"use strict";var $v=lr(),Wl=ql(),Ov=Ct(),Hv=hr();function Dv(e,t,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:t},e),c=new $v.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=Hv.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Wl.composeNode(l,n,f,o):Wl.composeEmptyNode(l,f.end,i,null,f,o);let u=c.contents.range[2],d=Ov.resolveEnd(a,u,!1,o);return d.comment&&(c.comment=d.comment),c.range=[r,u,d.offset],c}zl.composeDoc=Dv});var co=g(Kl=>{"use strict";var Lv=Br("process"),Bv=Gn(),Mv=lr(),pr=fr(),Gl=x(),Vv=Jl(),Fv=Ct();function mr(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r=="string"?r.length:1)]}function Ul(e){let t="",r=!1,i=!1;for(let n=0;n<e.length;++n){let a=e[n];switch(a[0]){case"#":t+=(t===""?"":i?`
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 so=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=mr(r);a?this.warnings.push(new hr.YAMLWarning(o,i,n)):this.errors.push(new hr.YAMLParseError(o,i,n))},this.directives=new Hv.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=Ul(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(Gl.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Gl.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
105
+ `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:t,afterEmptyLine:i}}var so=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=mr(r);a?this.warnings.push(new pr.YAMLWarning(o,i,n)):this.errors.push(new pr.YAMLParseError(o,i,n))},this.directives=new Bv.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,r){let{comment:i,afterEmptyLine:n}=Ul(this.prelude);if(i){let a=t.contents;if(r)t.comment=t.comment?`${t.comment}
106
+ ${i}`:i;else if(n||t.directives.docStart||!a)t.commentBefore=i;else if(Gl.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Gl.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:Ul(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(Ov.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=mr(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=Lv.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 hr.YAMLParseError(mr(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 hr.YAMLParseError(mr(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=Bv.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 hr.YAMLParseError(mr(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 Dv.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}}};Kl.Composer=so});var Ql=g(Oi=>{"use strict";var Vv=ro(),Mv=no(),Fv=fr(),Yl=Qt();function qv(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 Fv.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Mv.resolveFlowScalar(t,e,i);case"block-scalar":return Vv.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function Wv(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=Yl.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)t.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)t.warnings.push(this.warnings[a])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Ul(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,r=!1,i=-1){for(let n of t)yield*this.next(n);yield*this.end(r,i)}*next(t){switch(Lv.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(r,i,n)=>{let a=mr(t);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let r=Vv.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let r=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new pr.YAMLParseError(mr(t),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new pr.YAMLParseError(mr(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=Fv.resolveEnd(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
109
+ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new pr.YAMLParseError(mr(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let i=Object.assign({_directives:this.directives},this.options),n=new Mv.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}}};Kl.Composer=so});var Ql=g(Oi=>{"use strict";var qv=ro(),Wv=no(),zv=fr(),Yl=Qt();function Jv(e,t=!0,r){if(e){let i=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(s,a,o);else throw new zv.YAMLParseError([s,s+1],a,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Wv.resolveFlowScalar(e,t,i);case"block-scalar":return qv.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function Gv(e,t){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=t,s=Yl.stringifyString({type:o,value:e},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:i,source:`
110
110
  `}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
111
111
  `),f=s.substring(0,l),u=s.substring(l+1)+`
112
112
  `,d=[{type:"block-scalar-header",offset:a,indent:i,source:f}];return Xl(d,c)||d.push({type:"newline",offset:-1,indent:i,source:`
113
- `}),{type:"block-scalar",offset:a,indent:i,props:d,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 zv(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=Yl.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">":Jv(t,c);break;case'"':lo(t,c,"double-quoted-scalar");break;case"'":lo(t,c,"single-quoted-scalar");break;default:lo(t,c,"scalar")}}function Jv(t,e){let r=e.indexOf(`
114
- `),i=e.substring(0,r),n=e.substring(r+1)+`
115
- `;if(t.type==="block-scalar"){let a=t.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,t.source=n}else{let{offset:a}=t,o="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];Xl(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 Xl(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 lo(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})}}}Oi.createScalarToken=Wv;Oi.resolveAsScalar=qv;Oi.setScalarValue=zv});var eu=g(Zl=>{"use strict";var Gv=t=>"type"in t?Di(t):Hi(t);function Di(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=Di(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=Hi(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=Hi(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=Hi(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 Hi({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Di(e)),r)for(let a of r)n+=a.source;return i&&(n+=Di(i)),n}Zl.stringify=Gv});var nu=g(iu=>{"use strict";var uo=Symbol("break visit"),Uv=Symbol("skip children"),tu=Symbol("remove item");function nt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),ru(Object.freeze([]),t,e)}nt.BREAK=uo;nt.SKIP=Uv;nt.REMOVE=tu;nt.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};nt.parentCollection=(t,e)=>{let r=nt.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 ru(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=ru(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===uo)return uo;s===tu&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}iu.visit=nt});var Li=g(G=>{"use strict";var fo=Ql(),Kv=eu(),Yv=nu(),po="\uFEFF",ho="",mo="",vo="",Xv=t=>!!t&&"items"in t,Qv=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function Zv(t){switch(t){case po:return"<BOM>";case ho:return"<DOC>";case mo:return"<FLOW_END>";case vo:return"<SCALAR>";default:return JSON.stringify(t)}}function eg(t){switch(t){case po:return"byte-order-mark";case ho:return"doc-mode";case mo:return"flow-error-end";case vo:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
113
+ `}),{type:"block-scalar",offset:a,indent:i,props:d,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 Uv(e,t,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in e?e.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Yl.stringifyString({type:o,value:t},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":Kv(e,c);break;case'"':lo(e,c,"double-quoted-scalar");break;case"'":lo(e,c,"single-quoted-scalar");break;default:lo(e,c,"scalar")}}function Kv(e,t){let r=t.indexOf(`
114
+ `),i=t.substring(0,r),n=t.substring(r+1)+`
115
+ `;if(e.type==="block-scalar"){let a=e.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,e.source=n}else{let{offset:a}=e,o="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];Xl(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
+ `});for(let c of Object.keys(e))c!=="type"&&c!=="offset"&&delete e[c];Object.assign(e,{type:"block-scalar",indent:o,props:s,source:n})}}function Xl(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function lo(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let i=e.props.slice(1),n=t.length;e.props[0].type==="block-scalar-header"&&(n-=e.props[0].source.length);for(let a of i)a.offset+=n;delete e.props,Object.assign(e,{type:r,source:t,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
117
+ `};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let i="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(e))a!=="type"&&a!=="offset"&&delete e[a];Object.assign(e,{type:r,indent:i,source:t,end:n})}}}Oi.createScalarToken=Gv;Oi.resolveAsScalar=Jv;Oi.setScalarValue=Uv});var eu=g(Zl=>{"use strict";var Yv=e=>"type"in e?Di(e):Hi(e);function Di(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=Di(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=Hi(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=Hi(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=Hi(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function Hi({start:e,key:t,sep:r,value:i}){let n="";for(let a of e)n+=a.source;if(t&&(n+=Di(t)),r)for(let a of r)n+=a.source;return i&&(n+=Di(i)),n}Zl.stringify=Yv});var nu=g(iu=>{"use strict";var uo=Symbol("break visit"),Xv=Symbol("skip children"),tu=Symbol("remove item");function nt(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),ru(Object.freeze([]),e,t)}nt.BREAK=uo;nt.SKIP=Xv;nt.REMOVE=tu;nt.itemAtPath=(e,t)=>{let r=e;for(let[i,n]of t){let a=r?.[i];if(a&&"items"in a)r=a.items[n];else return}return r};nt.parentCollection=(e,t)=>{let r=nt.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function ru(e,t,r){let i=r(t,e);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=t[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=ru(Object.freeze(e.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===uo)return uo;s===tu&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}iu.visit=nt});var Li=g(G=>{"use strict";var fo=Ql(),Qv=eu(),Zv=nu(),ho="\uFEFF",po="",mo="",vo="",eg=e=>!!e&&"items"in e,tg=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function rg(e){switch(e){case ho:return"<BOM>";case po:return"<DOC>";case mo:return"<FLOW_END>";case vo:return"<SCALAR>";default:return JSON.stringify(e)}}function ig(e){switch(e){case ho:return"byte-order-mark";case po:return"doc-mode";case mo:return"flow-error-end";case vo: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}G.createScalarToken=fo.createScalarToken;G.resolveAsScalar=fo.resolveAsScalar;G.setScalarValue=fo.setScalarValue;G.stringify=Kv.stringify;G.visit=Yv.visit;G.BOM=po;G.DOCUMENT=ho;G.FLOW_END=mo;G.SCALAR=vo;G.isCollection=Xv;G.isScalar=Qv;G.prettyToken=Zv;G.tokenType=eg});var yo=g(ou=>{"use strict";var vr=Li();function se(t){switch(t){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var au=new Set("0123456789ABCDEFabcdef"),tg=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Bi=new Set(",[]{}"),rg=new Set(` ,[]{}
121
- \r `),go=t=>!t||rg.has(t),wo=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
122
- `?!0:r==="\r"?this.buffer[e+1]===`
123
- `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let r=this.buffer[e];if(this.indentNext>0){let i=0;for(;r===" ";)r=this.buffer[++i+e];if(r==="\r"){let n=this.buffer[i+e+1];if(n===`
124
- `||!n&&!this.atEnd)return e+i+1}return r===`
125
- `||i>=this.indentNext||!r&&!this.atEnd?e+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&se(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]===vr.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 vr.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==="...")&&se(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&&!se(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===":")&&se(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(go),"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("..."))&&se(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield vr.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(go),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||se(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(`
119
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}G.createScalarToken=fo.createScalarToken;G.resolveAsScalar=fo.resolveAsScalar;G.setScalarValue=fo.setScalarValue;G.stringify=Qv.stringify;G.visit=Zv.visit;G.BOM=ho;G.DOCUMENT=po;G.FLOW_END=mo;G.SCALAR=vo;G.isCollection=eg;G.isScalar=tg;G.prettyToken=rg;G.tokenType=ig});var yo=g(ou=>{"use strict";var vr=Li();function se(e){switch(e){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var au=new Set("0123456789ABCDEFabcdef"),ng=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Bi=new Set(",[]{}"),ag=new Set(` ,[]{}
121
+ \r `),go=e=>!e||ag.has(e),wo=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,r=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let t=this.pos,r=this.buffer[t];for(;r===" "||r===" ";)r=this.buffer[++t];return!r||r==="#"||r===`
122
+ `?!0:r==="\r"?this.buffer[t+1]===`
123
+ `:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let r=this.buffer[t];if(this.indentNext>0){let i=0;for(;r===" ";)r=this.buffer[++i+t];if(r==="\r"){let n=this.buffer[i+t+1];if(n===`
124
+ `||!n&&!this.atEnd)return t+i+1}return r===`
125
+ `||i>=this.indentNext||!r&&!this.atEnd?t+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&se(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
126
+ `,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===vr.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let r=t.length,i=t.indexOf("#");for(;i!==-1;){let a=t[i-1];if(a===" "||a===" "){r=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let a=t[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-r),yield*this.pushNewline(),"stream"}return yield vr.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&se(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&&!se(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&se(r)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(t[r]){case"#":yield*this.pushCount(t.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(go),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,r,i=-1;do t=yield*this.pushNewline(),t>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(t+r>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&se(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield vr.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(go),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||se(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),r=this.buffer.indexOf(t,this.pos+1);if(t==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
127
127
  `,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=i.indexOf(`
128
- `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>se(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
129
- `:e=a,r=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
130
- `)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(e+1);if(a===-1)break;e=this.buffer.indexOf(`
131
- `,a)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
132
- `;)i=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let a=e-1,o=this.buffer[a];o==="\r"&&(o=this.buffer[--a]);let s=a;for(;o===" ";)o=this.buffer[--a];if(o===`
133
- `&&a>=this.pos&&a+1+r>s)e=a;else break}while(!0);return yield vr.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(se(a)||e&&Bi.has(a))break;r=i}else if(se(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
128
+ `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let t=this.pos;for(;;){let r=this.buffer[++t];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>se(r)||r==="#")}*parseBlockScalar(){let t=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
129
+ `:t=a,r=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
130
+ `)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(t+1);if(a===-1)break;t=this.buffer.indexOf(`
131
+ `,a)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let n=t+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
132
+ `;)i=this.buffer[++n];t=n-1}else if(!this.blockScalarKeep)do{let a=t-1,o=this.buffer[a];o==="\r"&&(o=this.buffer[--a]);let s=a;for(;o===" ";)o=this.buffer[--a];if(o===`
133
+ `&&a>=this.pos&&a+1+r>s)t=a;else break}while(!0);return yield vr.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(se(a)||t&&Bi.has(a))break;r=i}else if(se(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&&Bi.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&&Bi.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield vr.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(go),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(se(i)||r&&Bi.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(;!se(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(tg.has(r))r=this.buffer[++e];else if(r==="%"&&au.has(this.buffer[e+1])&&au.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
137
- `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
138
- `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||e&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let r=this.pos,i=this.buffer[r];for(;!e(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};ou.Lexer=wo});var bo=g(su=>{"use strict";var No=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}}}};su.LineCounter=No});var So=g(fu=>{"use strict";var ig=Br("process"),cu=Li(),ng=yo();function qe(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function lu(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 du(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 Vi(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 Ct(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 Mi(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 uu(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!qe(e.start,"explicit-key-ind")&&!qe(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,du(e.value)?e.value.end?Mi(e.value.end,e.sep):e.value.end=e.sep:Mi(e.start,e.sep),delete e.sep)}var ko=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 ng.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,ig.env.LOG_TOKENS&&console.log("|",cu.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=cu.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"&&uu(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&&lu(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":{lu(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=Vi(this.peek(2)),i=Ct(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(`
135
+ `,a=this.buffer[i+1]):r=i),a==="#"||t&&Bi.has(a))break;if(n===`
136
+ `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&Bi.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield vr.SCALAR,yield*this.pushToIndex(r+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,r){let i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(go),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(se(i)||r&&Bi.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,r=this.buffer[t];for(;!se(r)&&r!==">";)r=this.buffer[++t];return yield*this.pushToIndex(r===">"?t+1:t,!1)}else{let t=this.pos+1,r=this.buffer[t];for(;r;)if(ng.has(r))r=this.buffer[++t];else if(r==="%"&&au.has(this.buffer[t+1])&&au.has(this.buffer[t+2]))r=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`
137
+ `?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===`
138
+ `?yield*this.pushCount(2):0}*pushSpaces(t){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||t&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(t){let r=this.pos,i=this.buffer[r];for(;!t(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};ou.Lexer=wo});var bo=g(su=>{"use strict";var No=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<t?r=a+1:i=a}if(this.lineStarts[r]===t)return{line:r+1,col:1};if(r===0)return{line:0,col:t};let n=this.lineStarts[r-1];return{line:r,col:t-n+1}}}};su.LineCounter=No});var So=g(fu=>{"use strict";var og=Br("process"),cu=Li(),sg=yo();function ze(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function lu(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function du(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Mi(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function xt(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function Vi(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function uu(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!ze(t.start,"explicit-key-ind")&&!ze(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,du(t.value)?t.value.end?Vi(t.value.end,t.sep):t.value.end=t.sep:Vi(t.start,t.sep),delete t.sep)}var ko=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new sg.Lexer,this.onNewLine=t}*parse(t,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(t,r))yield*this.next(i);r||(yield*this.end())}*next(t){if(this.source=t,og.env.LOG_TOKENS&&console.log("|",cu.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let r=cu.tokenType(t);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let i=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let r=t??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let i=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in i?i.indent:0:r.type==="flow-collection"&&i.type==="document"&&(r.indent=0),r.type==="flow-collection"&&uu(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&&lu(n.start)===-1&&(r.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<r.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{lu(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let r=this.startBlockValue(t);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let r=Mi(this.peek(2)),i=xt(r),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:i,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
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)){Mi(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(qe(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(du(r.key)&&!qe(r.sep,"newline")){let o=Ct(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(qe(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Ct(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]}):qe(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&&!qe(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)){Mi(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||qe(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=Vi(i),a=Ct(n);uu(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(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Vi(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let i=!this.onKeyLine&&this.indent===t.indent,n=i&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&r.sep&&!r.value){let o=[];for(let s=0;s<r.sep.length;++s){let c=r.sep[s];switch(c.type){case"newline":o.push(s);break;case"space":break;case"comment":c.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||r.value?(a.push(this.sourceToken),t.items.push({start:a}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):n||r.value?(a.push(this.sourceToken),t.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ze(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(du(r.key)&&!ze(r.sep,"newline")){let o=xt(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(ze(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=xt(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||n?t.items.push({start:a,key:null,sep:[this.sourceToken]}):ze(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||r.value?(t.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(t);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!ze(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Vi(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=t.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;r.value||ze(r.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>t.indent){let i=this.startBlockValue(t);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let r=t.items[t.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?t.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!r||r.value?t.items.push({start:[],key:n,sep:[]}):r.sep?this.stack.push(n):Object.assign(r,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===t.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=Mi(i),a=xt(n);uu(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:a,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let r=this.source.indexOf(`
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=Vi(e),i=Ct(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=Vi(e),i=Ct(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())}}};fu.Parser=ko});var gu=g(wr=>{"use strict";var pu=co(),ag=lr(),gr=fr(),og=oa(),sg=x(),cg=bo(),hu=So();function mu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new cg.LineCounter||null,prettyErrors:e}}function lg(t,e={}){let{lineCounter:r,prettyErrors:i}=mu(e),n=new hu.Parser(r?.addNewLine),a=new pu.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(gr.prettifyError(t,r)),s.warnings.forEach(gr.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function vu(t,e={}){let{lineCounter:r,prettyErrors:i}=mu(e),n=new hu.Parser(r?.addNewLine),a=new pu.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 gr.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(gr.prettifyError(t,r)),o.warnings.forEach(gr.prettifyError(t,r))),o}function ug(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=vu(t,r);if(!n)return null;if(n.warnings.forEach(a=>og.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 dg(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 sg.isDocument(t)&&!i?t.toString(r):new ag.Document(t,i,r).toString(r)}wr.parse=ug;wr.parseAllDocuments=lg;wr.parseDocument=vu;wr.stringify=dg});var xt=g(P=>{"use strict";var fg=co(),pg=lr(),hg=Fa(),Eo=fr(),mg=Gt(),We=x(),vg=Be(),gg=j(),wg=Me(),yg=Fe(),Ng=Li(),bg=yo(),kg=bo(),Sg=So(),Fi=gu(),wu=qt();P.Composer=fg.Composer;P.Document=pg.Document;P.Schema=hg.Schema;P.YAMLError=Eo.YAMLError;P.YAMLParseError=Eo.YAMLParseError;P.YAMLWarning=Eo.YAMLWarning;P.Alias=mg.Alias;P.isAlias=We.isAlias;P.isCollection=We.isCollection;P.isDocument=We.isDocument;P.isMap=We.isMap;P.isNode=We.isNode;P.isPair=We.isPair;P.isScalar=We.isScalar;P.isSeq=We.isSeq;P.Pair=vg.Pair;P.Scalar=gg.Scalar;P.YAMLMap=wg.YAMLMap;P.YAMLSeq=yg.YAMLSeq;P.CST=Ng;P.Lexer=bg.Lexer;P.LineCounter=kg.LineCounter;P.Parser=Sg.Parser;P.parse=Fi.parse;P.parseAllDocuments=Fi.parseAllDocuments;P.parseDocument=Fi.parseDocument;P.stringify=Fi.stringify;P.visit=wu.visit;P.visitAsync=wu.visitAsync});var pt="comet.native.v4",Vt="comet.native.local-execution.v4";var Es=["multi-session","single-session"];function Vn(){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}}}function Xe(t,e,r){return t.language==="zh-CN"?r:e}function Af(t,e){let r=i=>({required:!1,message:null,suggestedReply:null,agentInstruction:i});if(e&&t.phase==="shape"&&t.status==="active")return{required:!0,message:Xe(t,"This Supervisor Change has multiple independent children. Choose one coordination mode before confirming Shape: A) Multi-session coordination (recommended), or B) Single-session progression.","当前 Supervisor Change 包含多个可独立执行的 Child。确认 Shape 前请选择推进方式:A)多会话协作(推荐),或 B)单会话推进。"),suggestedReply:Xe(t,"Reply A or B","回复 A 或 B"),agentInstruction:Xe(t,"Relay the two coordination choices and wait for the user decision. Do not treat a generic confirmation as a mode selection or run --confirmed without --coordination-mode.","转述这两个推进方式并等待用户选择。不要把普通“确认”视为已选择推进方式,也不要在没有 --coordination-mode 时运行 --confirmed。")};if(t.phase==="verify"&&t.status==="active"&&t.loop.stage==="verify-ready"&&t.loop.next_action!=="await-verifier-result")return r(Xe(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")return r(Xe(t,"Wait only while the dispatched Verifier task is still active. If the task did not start, failed, timed out, ended without a response, or was lost, immediately submit verifier-execution-error. Submit verifier-unavailable only when the current platform truly has no usable subagent capability. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","仅在已派发的独立验收任务仍在运行时等待。如果任务未启动、执行失败、超时、结束后没有返回结果或已经丢失,立即提交 verifier-execution-error;只有当前平台确实没有可用的 subagent 能力时才提交 verifier-unavailable。不要让用户恢复文件或进程,也不要向用户展示 attempt、requestCheckRounds 等机器状态。"));if(t.status==="blocked"&&t.blockers.some(({resolution_action:i})=>i==="retry-verifier"))return 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 n=(t.loop.stop_reason??(t.loop.no_progress_count>=3?"stalled":"budget"))==="stalled",a=n?"验证已连续三轮失败且未通过的验收场景一直没有减少,本次修改已暂停,以避免在同一个问题上反复循环。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。":"本次修改的验证失败次数已用完配置的预算,因此暂停等待你的决定,而不是自动重试。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。",o=n?"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:a,suggestedReply:"继续修复",agentInstruction:"向用户转述 message 和 suggestedReply,等待用户在“继续修复实现”(revise-implementation)与“调整需求”(revise-requirements)之间明确选择,再执行 commandAlternatives 中对应的完整命令。选择继续修复时,要求 Builder 更换修复思路。不要替用户选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:o,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."}}return r(Xe(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 Cs(t){return["comet","native","next",t.change,"--summary","<summary>",t.flag,"--expected-state-version",String(t.stateVersion),"--expected-action",t.action]}function Mt(t,e){return{name:t,flag:e,valueKind:"text",required:!0,template:null}}function xs(t,e){return{name:t,flag:e,valueKind:"confirmation",required:!0,template:null}}function _f(t,e,r){return{name:t,flag:e,valueKind:"choice",required:!0,template:null,choices:[...r]}}function If(t){return t?.coordinationChoiceRequired===!0||t?.schema==="comet.native.children.v2"&&t.children.length>=2}function Tf(t){return["comet","native","next",t.change,"--summary","<summary>",...t.coordinationRequired?["--coordination-mode","<coordination-mode>"]:[],"--confirmed","--expected-state-version",String(t.stateVersion),"--expected-action","confirm-shape"]}function Qe(t){return{name:t.name,stateVersion:t.stateVersion,expectedAction:t.expectedAction,commandArgs:Cs({change:t.change,stateVersion:t.stateVersion,action:t.expectedAction,flag:t.flag}),requiredInputs:["summary",t.confirmationInput],inputOptions:[Mt("summary","--summary"),xs(t.name,t.flag)]}}function Mn(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 Ps(t,e){let r=If(e)&&t.coordination_mode===void 0,i={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[],userCommunication:Af(t,r)},n=a=>({kind:a,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...i,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:n("none")};if(t.status==="await-user")return t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...i,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Mt("summary","--summary")],commandAlternatives:[Qe({name:"accept-result",change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...Mn({change:t.name,stateVersion:t.state_version})],runnerAction:n("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...i,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Mt("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:n("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...i,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Mt("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"}),...Mn({change:t.name,stateVersion:t.state_version})],runnerAction:n("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...i,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Mt("summary","--summary")],commandAlternatives:Mn({change:t.name,stateVersion:t.state_version}),runnerAction:n("none")}:{...i,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:n("none")};if(t.status==="blocked"){let a=t.blockers.some(({resolution_action:o})=>o==="retry-verifier");return{...i,disposition:"blocked",action:a?"retry-verifier":"none",commandArgs:a?Cs({change:t.name,stateVersion:t.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:a?["summary"]:["repair-runtime"],inputOptions:a?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:n(a?"retry-verifier":"none")}}if(t.phase==="shape")return{...i,disposition:r?"await-user":"continue",action:"confirm-shape",commandArgs:Tf({change:t.name,stateVersion:t.state_version,coordinationRequired:r}),requiredInputs:["summary",...r?["coordination-choice"]:[],"shared-understanding-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},...r?[_f("coordination-mode","--coordination-mode",Es)]:[],xs("confirmed","--confirmed")],runnerAction:n("none")};if(t.phase==="build"){if(e){if(!e.confirmed)return{...i,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:n("none")};if(t.loop.stage==="repairing"&&t.verification_result==="fail")return{...i,disposition:"continue",action:"repair",commandArgs:null,requiredInputs:["repair-child"],inputOptions:[],runnerAction:n("none")};if(e.allDone)return{...i,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:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[],review:{status:"passed",summary:"<review-summary>",reviewer_execution_ref:"<reviewer-execution-ref>"}}}],runnerAction:n("builder-handoff")};let a=e.children.some(({status:s})=>s==="blocked"||s==="needs-reverify"),o=e.children.some(({status:s})=>s==="ready"||s==="active");return{...i,disposition:a&&!o?"blocked":"continue",action:"advance-children",commandArgs:null,requiredInputs:a&&!o?["resolve-child-blocker"]:["ready-children"],inputOptions:[],runnerAction:n("none")}}return{...i,disposition:"continue",action:t.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[],review:{status:"passed",summary:"<review-summary>",reviewer_execution_ref:"<reviewer-execution-ref>"}}}],runnerAction:n("builder-handoff")}}if(t.phase==="verify"){let a=t.loop.next_action==="await-verifier-result",o=!!t.children_contract_hash,s={id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0};return{...i,userCommunication:!a&&o?{...i.userCommunication,agentInstruction:`${i.userCommunication.agentInstruction} ${Xe(t,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:i.userCommunication,disposition:"continue",action:a?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[a?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:a?[{kind:"verifier-response",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[s]}},{kind:"verifier-response",response:{kind:"final-result",result:{iteration:t.loop.iteration,attempt:t.loop.attempt,verdict:"<pass|fail|blocked>",acceptance:[{id:"<acceptance-id>",result:"<passed|failed|blocked>",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:o?[s]:[]}}],runnerAction:n(a?"await-verifier":"dispatch-verifier")}}return t.phase==="archive"&&t.status==="active"&&t.loop.stage==="archive-ready"&&!t.archived?{...i,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],commandAlternatives:[Qe({name:"revise-requirements",change:t.name,stateVersion:t.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:n("none")}:{...i,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:n("none")}}import{randomUUID as FN}from"node:crypto";import{promises as Hr}from"node:fs";import qN from"node:path";import{execFileSync as jf}from"child_process";import Vr from"path";function Fn(t,e){return jf("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function $f(t,e){let r=Vr.normalize(t),i=Vr.normalize(e);return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function ie(t){try{let e=Vr.resolve(Fn(t,["rev-parse","--show-toplevel"])),i=Fn(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?Vr.resolve(i.slice(9)):e,a=null;try{a=Fn(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!$f(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}import{randomUUID as Of}from"crypto";import{promises as L}from"fs";import ne from"path";function $e(t){return t!==0&&t!==0n&&t!=="0"}function fe(t,e){return $e(t.dev)&&$e(e.dev)&&$e(t.ino)&&$e(e.ino)}function _(t,e){let r=$e(t.dev)&&$e(e.dev);if(r&&t.dev!==e.dev)return!1;let i=$e(t.ino)&&$e(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}function Mr(t,e){let r=ne.relative(t,e);return r===""||!ne.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ne.sep}`)}function Hf(t,e){return _({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Fr(t,e){return _({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function Df(t,e){return Fr(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Rs(t){let e=await L.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await L.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function ht(t){for(let e of t){let r=await L.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Hf(e,r)||await L.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Lf(t,e,r){let[i,n]=await Promise.all([L.lstat(t),L.realpath(t),r?ht(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Fr(i,e)||r&&!Mr(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function Bf(t,e){let r=ne.resolve(t),i=ne.resolve(e);if(!Mr(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Rs(r)],a=ne.relative(r,i).split(ne.sep).filter(Boolean),o=r;for(let s of a){await ht(n),o=ne.join(o,s);try{await L.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Rs(o);if(!Mr(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await ht(n),n}async function Vf(t){let e;try{e=await L.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 Mf(t,e,r={}){let i=ne.dirname(t),n=r.containedRoot?await Bf(r.containedRoot,i):null;n||await L.mkdir(i,{recursive:!0});let a=ne.join(i,`.${ne.basename(t)}.${Of()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await L.open(a,"wx"),s=await o.stat(),n){let[l,f]=await Promise.all([L.lstat(a),L.realpath(a)]);if(await ht(n),!l.isFile()||l.isSymbolicLink()||!Fr(s,l)||!Mr(n[0].realPath,f))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(),!Fr(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 Lf(a,c,n),await r.beforeCommit?.(),n){await ht(n);let l=await L.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!Df(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await L.link(a,t),await L.unlink(a)):await L.rename(a,t),await Vf(i)}catch(l){if(await o?.close(),!n)await L.rm(a,{force:!0});else try{await ht(n),await L.rm(a,{force:!0})}catch{}throw l}}async function pe(t,e,r={}){await Mf(t,e,r)}async function U(t,e,r={}){await pe(t,JSON.stringify(e,null,2)+`
143
- `,r)}import{createHash as zf}from"node:crypto";import{promises as ae}from"node:fs";import Q from"node:path";import{TextDecoder as Jf}from"node:util";var Ff=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),qf=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Wf(t){return t.toLowerCase().startsWith(".env")}function Ft(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>Wf(i))?"environment-file":r.some(i=>qf.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>Ff.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var Wr=1024*1024;function qn(t,e){let r=Q.relative(t,e);return r===""||!Q.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Q.sep}`)}function Gf(t){let e=Q.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})||Q.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=Ft(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 Uf(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Kf(t,e){return _({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function qr(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return fe(r,i)?_(r,i):_(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function As(t){let e=await ae.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await ae.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Yf(t,e){let r=Q.resolve(t),i=Q.resolve(e);if(!qn(r,i))throw new Error("Native artifact path is outside its root");let n=[await As(r)],a=r;for(let o of Q.relative(r,i).split(Q.sep).filter(Boolean)){a=Q.join(a,o);let s=await As(a);if(!qn(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function _s(t){for(let e of t){let r=await ae.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Kf(e,r)||await ae.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function M(t){let e=Gf(t.ref),r=t.maxBytes===null?null:Uf(t.maxBytes??Wr),i=Q.resolve(t.root,...e.split("/")),n=await Yf(t.root,Q.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await ae.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);let o=await ae.realpath(i);if(!qn(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await ae.open(i,"r");try{let[c,l,f]=await Promise.all([s.stat(),ae.lstat(i),ae.realpath(i)]);if(await _s(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||f!==o||!qr(a,c)||!qr(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let u=[],d=0,h=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let b=r===null?h.length:r+1-d,k=await s.read(h,0,Math.min(h.length,b),null);if(k.bytesRead===0)break;if(d+=k.bytesRead,r!==null&&d>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);u.push(Buffer.from(h.subarray(0,k.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[v,p,m]=await Promise.all([s.stat(),ae.lstat(i),ae.realpath(i)]);if(await _s(n),!p.isFile()||p.isSymbolicLink()||m!==o||!qr(c,v)||!qr(c,p))throw new Error(`Native artifact changed while reading: ${e}`);let w=Buffer.concat(u,d),y;try{y=new Jf("utf-8",{fatal:!0}).decode(w)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:b})}return{ref:e,size:d,hash:t.includeHash===!1?null:zf("sha256").update(w).digest("hex"),text:y}}finally{await s.close()}}var ls=Bt(xt(),1);import Ht from"path";var Co={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:"验证预期"}},Eg={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:"结论"}},Cg={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:"结论"}},Nu=new Map,yu=new Map;for(let t of Object.keys(Co)){for(let[e,r]of Object.entries(Co[t]))Nu.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Eg[t]))yu.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Cg[t]))yu.set(r.toLocaleLowerCase("en-US"),e)}function xg(t,e){return Co[t][e]}function xo(t){return Nu.get(t.trim().toLocaleLowerCase("en-US"))??null}function qi(t){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${xg(t,r)}
142
+ `,r)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Mi(t),i=xt(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=Mi(t),i=xt(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};fu.Parser=ko});var gu=g(wr=>{"use strict";var hu=co(),cg=lr(),gr=fr(),lg=oa(),ug=x(),dg=bo(),pu=So();function mu(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new dg.LineCounter||null,prettyErrors:t}}function fg(e,t={}){let{lineCounter:r,prettyErrors:i}=mu(t),n=new pu.Parser(r?.addNewLine),a=new hu.Composer(t),o=Array.from(a.compose(n.parse(e)));if(i&&r)for(let s of o)s.errors.forEach(gr.prettifyError(e,r)),s.warnings.forEach(gr.prettifyError(e,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function vu(e,t={}){let{lineCounter:r,prettyErrors:i}=mu(t),n=new pu.Parser(r?.addNewLine),a=new hu.Composer(t),o=null;for(let s of a.compose(n.parse(e),!0,e.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new gr.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(gr.prettifyError(e,r)),o.warnings.forEach(gr.prettifyError(e,r))),o}function hg(e,t,r){let i;typeof t=="function"?i=t:r===void 0&&t&&typeof t=="object"&&(r=t);let n=vu(e,r);if(!n)return null;if(n.warnings.forEach(a=>lg.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 pg(e,t,r){let i=null;if(typeof t=="function"||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}return ug.isDocument(e)&&!i?e.toString(r):new cg.Document(e,i,r).toString(r)}wr.parse=hg;wr.parseAllDocuments=fg;wr.parseDocument=vu;wr.stringify=pg});var Pt=g(P=>{"use strict";var mg=co(),vg=lr(),gg=Fa(),Eo=fr(),wg=Gt(),Je=x(),yg=Ve(),Ng=j(),bg=qe(),kg=We(),Sg=Li(),Eg=yo(),Cg=bo(),xg=So(),Fi=gu(),wu=qt();P.Composer=mg.Composer;P.Document=vg.Document;P.Schema=gg.Schema;P.YAMLError=Eo.YAMLError;P.YAMLParseError=Eo.YAMLParseError;P.YAMLWarning=Eo.YAMLWarning;P.Alias=wg.Alias;P.isAlias=Je.isAlias;P.isCollection=Je.isCollection;P.isDocument=Je.isDocument;P.isMap=Je.isMap;P.isNode=Je.isNode;P.isPair=Je.isPair;P.isScalar=Je.isScalar;P.isSeq=Je.isSeq;P.Pair=yg.Pair;P.Scalar=Ng.Scalar;P.YAMLMap=bg.YAMLMap;P.YAMLSeq=kg.YAMLSeq;P.CST=Sg;P.Lexer=Eg.Lexer;P.LineCounter=Cg.LineCounter;P.Parser=xg.Parser;P.parse=Fi.parse;P.parseAllDocuments=Fi.parseAllDocuments;P.parseDocument=Fi.parseDocument;P.stringify=Fi.stringify;P.visit=wu.visit;P.visitAsync=wu.visitAsync});var ht="comet.native.v4",Vt="comet.native.local-execution.v4";var Es=["multi-session","single-session"];function Mn(){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}}}function xe(e,t,r){return e.language==="zh-CN"?r:t}function _f(e,t){let r=i=>({required:!1,message:null,suggestedReply:null,agentInstruction:i});if(e.phase==="shape"&&e.status==="await-user"&&e.loop.next_action==="confirm-shape")return e.language==="zh-CN"?{required:!0,message:"Shape 已整理完成。请确认目标、范围、关键决定、验收标准和非目标是否准确;明确确认后才会进入 Build。",suggestedReply:"确认进入 Build",agentInstruction:"先用自然语言简要展示目标、范围、关键决定、验收标准和非目标,再转述 message 并等待用户明确确认。只有用户明确同意当前完整 Shape 时,才执行 commandAlternatives 中的 confirm-shape;补充或修改要求不算确认。不要展示机器状态或提前运行 --confirmed。"}:{required:!0,message:"Shape is ready. Confirm that the target, scope, key decisions, acceptance criteria, and non-goals are accurate; Build starts only after explicit confirmation.",suggestedReply:"Confirm and enter Build",agentInstruction:"First present a concise natural-language summary of the target, scope, key decisions, acceptance criteria, and non-goals. Then relay message and wait for explicit user confirmation. Run confirm-shape from commandAlternatives only when the user explicitly accepts the complete current Shape; additions or corrections are not confirmation. Do not expose machine state or run --confirmed early."};if(t&&e.phase==="shape"&&e.status==="active")return{required:!0,message:xe(e,"This Supervisor Change has multiple independent children. Choose one coordination mode before confirming Shape: A) Multi-session coordination (recommended), or B) Single-session progression.","当前 Supervisor Change 包含多个可独立执行的 Child。确认 Shape 前请选择推进方式:A)多会话协作(推荐),或 B)单会话推进。"),suggestedReply:xe(e,"Reply A or B","回复 A 或 B"),agentInstruction:xe(e,"Relay the two coordination choices and wait for the user decision. After the user chooses, execute the prepare-shape-confirmation commandArgs with the selected --coordination-mode. Do not combine mode selection with final confirmation; confirmation of the complete Shape is a separate await-user step.","转述这两个推进方式并等待用户选择。用户选择后,使用对应的 --coordination-mode 执行 prepare-shape-confirmation 的完整 commandArgs;不要把推进方式选择和最终确认合并执行,完整 Shape 的确认是后续单独的 await-user 步骤。")};if(e.phase==="verify"&&e.status==="active"&&e.loop.stage==="verify-ready"&&e.loop.next_action!=="await-verifier-result")return r(xe(e,"The current candidate and completed checks are preserved. Continue with dispatch-verifier without asking the user to recover files, processes, or workflow state. If a brief status update is necessary, say only that verification is being retried and the code is unchanged.","当前候选和已经完成的检查都已保留。直接继续 dispatch-verifier,不要让用户恢复文件、进程或工作流状态。如果确实需要简短同步进度,只说明正在重新尝试验收且代码没有变化。"));if(e.phase==="verify"&&e.status==="active"&&e.loop.next_action==="await-verifier-result")return r(xe(e,"Wait only while the dispatched Verifier task is still active. If the task did not start, failed, timed out, ended without a response, or was lost, immediately submit verifier-execution-error. Submit verifier-unavailable only when the current platform truly has no usable subagent capability. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","仅在已派发的独立验收任务仍在运行时等待。如果任务未启动、执行失败、超时、结束后没有返回结果或已经丢失,立即提交 verifier-execution-error;只有当前平台确实没有可用的 subagent 能力时才提交 verifier-unavailable。不要让用户恢复文件或进程,也不要向用户展示 attempt、requestCheckRounds 等机器状态。"));if(e.status==="blocked"&&e.blockers.some(({resolution_action:i})=>i==="retry-verifier"))return e.language==="zh-CN"?{required:!0,message:"由于独立验收任务连续几次没有正常返回结果,本次验收已暂停。你的代码和已经完成的检查都已安全保留。回复“继续”即可重新尝试,不需要处理文件或进程。",suggestedReply:"继续",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户回复。不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification paused because the independent verification task repeatedly ended without a result. Your code and completed checks are safely preserved. Reply “Continue” to retry; you do not need to manage files or processes.",suggestedReply:"Continue",agentInstruction:"Relay only message and suggestedReply to the user, then wait for that reply. Do not expose internal attempts, counters, paths, or recovery steps."};if(e.phase==="verify"&&e.status==="await-user"&&e.verification?.assurance==="semantic-verification-unavailable")return e.language==="zh-CN"?{required:!0,message:"独立验收当前不可用,但你的代码和已经完成的检查都已安全保留。你可以直接重新尝试独立验收,也可以明确接受只有自动检查的结果。",suggestedReply:"重新尝试独立验收",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户选择。用户要求重试时执行 commandAlternatives 中的 retry-verifier;只有用户明确接受降级结果时才执行 confirm-verifier-unavailable。不要把“继续”视为接受降级结果,也不要要求用户处理文件、进程、服务或回调。"}:{required:!0,message:"Independent verification is currently unavailable, but your code and completed checks are safely preserved. You can retry independent verification directly or explicitly accept the automatic-check-only result.",suggestedReply:"Retry independent verification",agentInstruction:"Relay only message and suggestedReply, then wait for the user choice. If the user asks to retry, run retry-verifier from commandAlternatives; run confirm-verifier-unavailable only when the user explicitly accepts the degraded result. Do not treat “Continue” as accepting the degraded result, and do not ask the user to manage files, processes, services, or callbacks."};if(e.phase==="verify"&&e.status==="await-user"&&e.loop.next_action==="resolve-verifier-blocker")return e.language==="zh-CN"?{required:!0,message:"验证暂时无法下结论,因为缺少只有你能提供的信息,例如外部系统的真实行为或某个业务决定。你的代码和已经完成的检查都已安全保留。补充所需信息后可继续验证,也可以选择修改实现或调整需求。",suggestedReply:null,agentInstruction:"向用户转述 message,请用户补充缺失的信息,或在继续验证(resolve-verifier-blocker)、修改实现、调整需求之间明确选择,再执行 commandAlternatives 中对应的完整命令。不要把“继续”当作默认选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification cannot reach a verdict yet because information only you can provide is missing, such as the real behavior of an external system or a business decision. Your code and completed checks are safely preserved. Supply the missing information to resume verification, or choose to revise the implementation or the requirements.",suggestedReply:null,agentInstruction:"Relay message and ask the user to supply the missing information or explicitly choose between resuming verification (resolve-verifier-blocker), revising the implementation, and revising the requirements; run the matching commandAlternative afterwards. Do not treat “Continue” as a default choice, and do not expose internal rounds, counters, paths, or recovery steps."};if(e.phase==="verify"&&e.status==="await-user"&&e.loop.next_action==="await-user"){let n=(e.loop.stop_reason??(e.loop.no_progress_count>=3?"stalled":"budget"))==="stalled",a=n?"验证已连续三轮失败且未通过的验收场景一直没有减少,本次修改已暂停,以避免在同一个问题上反复循环。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。":"本次修改的验证失败次数已用完配置的预算,因此暂停等待你的决定,而不是自动重试。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。",o=n?"Verification has failed three times in a row without the unresolved scenarios shrinking, so this change is paused to avoid looping on the same problem. Your code and completed checks are safely preserved. You can have the Builder try a different repair approach, or go back and adjust the requirements.":"Verification for this change has used its configured failure budget, so it is paused for your decision instead of retrying automatically. Your code and completed checks are safely preserved. You can have the Builder continue with a different repair approach, or go back and adjust the requirements.";return e.language==="zh-CN"?{required:!0,message:a,suggestedReply:"继续修复",agentInstruction:"向用户转述 message 和 suggestedReply,等待用户在“继续修复实现”(revise-implementation)与“调整需求”(revise-requirements)之间明确选择,再执行 commandAlternatives 中对应的完整命令。选择继续修复时,要求 Builder 更换修复思路。不要替用户选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:o,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."}}return r(xe(e,"Follow the continuation action. Unless required is true, continue without asking the user to handle internal workflow state, and do not present machine fields as a user-facing explanation.","按 continuation 执行下一步。除非 required 为 true,否则继续推进,不要让用户处理内部工作流状态,也不要把机器字段作为面向用户的说明。"))}function If(e){let t=e.workspace.change_branch??"<change-branch>",r=e.workspace.target_branch??"<target-branch>";return e.language==="zh-CN"?{required:!0,message:`当前 change 位于 ${t},目标分支为 ${r}。请选择一次工作区收尾方式:A) 保留工作区;B) 本地合并;C) 推送分支;D) 推送并创建 PR;E) 暂不归档。选择 A-D 后 Runtime 会先执行完整 dry-run,再给出唯一的 confirmed 命令;选择 E 将保留当前 change 等待稍后继续。`,suggestedReply:"回复 A、B、C、D 或 E",agentInstruction:"只向用户展示五种收尾方式及实际影响,等待用户选择。选择 A-D 时执行对应 commandAlternatives 中包含 --dry-run --finish 的完整命令;选择 E 时停止,不运行任何 Archive 命令。不要直接运行 --confirmed,也不要自行猜测 finish。"}:{required:!0,message:`This change is on ${t} and targets ${r}. Choose one workspace finish: A) keep the workspace; B) merge locally; C) push the branch; D) push and create a PR; or E) defer Archive. For A-D, Runtime will run a complete dry-run first, then return one confirmed command; E keeps the current change for later.`,suggestedReply:"Reply A, B, C, D, or E",agentInstruction:"Show all five finish choices and their actual effects, then wait. For A-D, execute the matching complete commandAlternative containing --dry-run --finish; for E, stop without running an Archive command. Do not run --confirmed directly or guess a finish mode."}}function Tf(e){return[...[{finish:"keep",name:"keep-workspace",description:["保留当前分支和目录;完成归档提交,不合并、不推送、不创建 PR。","Keep the current branch and directory; create the archive commit without merging, pushing, or creating a PR."]},{finish:"merge",name:"merge-locally",description:["完成归档提交,并把 change 分支本地合并到目标分支;不推送、不创建 PR。","Create the archive commit and merge the change branch locally into the target branch without pushing or creating a PR."]},{finish:"push",name:"push-branch",description:["完成归档提交并推送 change 分支;不合并到目标分支、不创建 PR。","Create the archive commit and push the change branch without merging into the target branch or creating a PR."]},{finish:"pull-request",name:"push-pull-request",description:["完成归档提交、推送 change 分支,并以目标分支为基础创建 PR。","Create the archive commit, push the change branch, and create a PR against the target branch."]}].map(({finish:i,name:n,description:a})=>({name:n,stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","archive",e.name,"--dry-run","--finish",i],requiredInputs:[],inputOptions:[],description:xe(e,a[1],a[0])})),{name:"defer-archive",stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:null,requiredInputs:[],inputOptions:[],description:xe(e,"Keep the current change and workspace without archiving; stop and resume later.","保留当前 change 和工作区,不执行归档;停止本次流程,稍后再继续。")}]}function xs(e){return["comet","native","next",e.change,"--summary","<summary>",e.flag,"--expected-state-version",String(e.stateVersion),"--expected-action",e.action]}function pt(e,t){return{name:e,flag:t,valueKind:"text",required:!0,template:null}}function jf(e,t){return{name:e,flag:t,valueKind:"confirmation",required:!0,template:null}}function Cs(e,t,r){return{name:e,flag:t,valueKind:"choice",required:!0,template:null,choices:[...r]}}function $f(e){return e?.coordinationChoiceRequired===!0||e?.schema==="comet.native.children.v2"&&e.children.length>=2}function Of(e){return["comet","native","next",e.change,"--summary","<summary>",...e.coordinationRequired?["--coordination-mode","<coordination-mode>"]:[],"--expected-state-version",String(e.stateVersion),"--expected-action","prepare-shape-confirmation"]}function Oe(e){return{name:e.name,stateVersion:e.stateVersion,expectedAction:e.expectedAction,commandArgs:xs({change:e.change,stateVersion:e.stateVersion,action:e.expectedAction,flag:e.flag}),requiredInputs:["summary",e.confirmationInput],inputOptions:[pt("summary","--summary"),jf(e.name,e.flag)]}}function Vn(e){return[Oe({name:"revise-implementation",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),Oe({name:"revise-requirements",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function Ps(e,t,r={}){let i=$f(t)&&e.coordination_mode===void 0,n=_f(e,i),a={schema:"comet.native.continuation.v2",skill:"comet-native",change:e.name,phase:e.phase,status:e.status,stateVersion:e.state_version,inputOptions:[],requiresUserDecision:n.required,userCommunication:n},o=s=>({kind:s,candidateId:e.builder_handoff?.candidate_id??null,iteration:e.loop.iteration,attempt:e.loop.attempt});if(e.status==="done")return{...a,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:o("none")};if(e.status==="await-user")return e.phase==="shape"&&e.loop.next_action==="confirm-shape"?{...a,disposition:"await-user",action:"confirm-shape",commandArgs:null,requiredInputs:["summary","shared-understanding-confirmation"],inputOptions:[pt("summary","--summary")],commandAlternatives:[Oe({name:"confirm-shape",change:e.name,stateVersion:e.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"})],runnerAction:o("none")}:e.phase==="verify"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass"?{...a,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pt("summary","--summary")],commandAlternatives:[Oe({name:"accept-result",change:e.name,stateVersion:e.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...Vn({change:e.name,stateVersion:e.state_version})],runnerAction:o("none")}:e.phase==="verify"&&e.verification?.assurance==="semantic-verification-unavailable"&&e.loop.next_action==="confirm-verifier-unavailable"?{...a,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pt("summary","--summary")],commandAlternatives:[Oe({name:"retry-verifier",change:e.name,stateVersion:e.state_version,expectedAction:"retry-verifier",flag:"--retry-verifier",confirmationInput:"user-decision"}),Oe({name:"confirm-verifier-unavailable",change:e.name,stateVersion:e.state_version,expectedAction:"confirm-verifier-unavailable",flag:"--confirmed",confirmationInput:"user-decision"})],runnerAction:o("none")}:e.phase==="verify"&&e.loop.next_action==="resolve-verifier-blocker"?{...a,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pt("summary","--summary")],commandAlternatives:[Oe({name:"resolve-verifier-blocker",change:e.name,stateVersion:e.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...Vn({change:e.name,stateVersion:e.state_version})],runnerAction:o("none")}:e.phase==="verify"&&e.loop.next_action==="await-user"?{...a,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pt("summary","--summary")],commandAlternatives:Vn({change:e.name,stateVersion:e.state_version}),runnerAction:o("none")}:{...a,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:o("none")};if(e.status==="blocked"){let s=e.blockers.some(({resolution_action:c})=>c==="retry-verifier");return{...a,disposition:"blocked",action:s?"retry-verifier":"none",commandArgs:s?xs({change:e.name,stateVersion:e.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:s?["summary"]:["repair-runtime"],inputOptions:s?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:o(s?"retry-verifier":"none")}}if(e.phase==="shape")return{...a,disposition:i?"await-user":"continue",action:"prepare-shape-confirmation",commandArgs:Of({change:e.name,stateVersion:e.state_version,coordinationRequired:i}),requiredInputs:["summary",...i?["coordination-choice"]:[]],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},...i?[Cs("coordination-mode","--coordination-mode",Es)]:[]],runnerAction:o("none")};if(e.phase==="build"){if(t){if(!t.confirmed)return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(e.loop.stage==="repairing"&&e.verification_result==="fail")return{...a,disposition:"continue",action:"repair",commandArgs:null,requiredInputs:["repair-child"],inputOptions:[],runnerAction:o("none")};if(t.allDone)return{...a,disposition:"continue",action:"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[],review:{status:"passed",summary:"<review-summary>",reviewer_execution_ref:"<reviewer-execution-ref>"}}}],runnerAction:o("builder-handoff")};let s=t.children.some(({status:l})=>l==="blocked"||l==="needs-reverify"),c=t.children.some(({status:l})=>l==="ready"||l==="active");return{...a,disposition:s&&!c?"blocked":"continue",action:"advance-children",commandArgs:null,requiredInputs:s&&!c?["resolve-child-blocker"]:["ready-children"],inputOptions:[],runnerAction:o("none")}}return{...a,disposition:"continue",action:e.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[],review:{status:"passed",summary:"<review-summary>",reviewer_execution_ref:"<reviewer-execution-ref>"}}}],runnerAction:o("builder-handoff")}}if(e.phase==="verify"){let s=e.loop.next_action==="await-verifier-result",c=!!e.children_contract_hash,l={id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0};return{...a,userCommunication:!s&&c?{...a.userCommunication,agentInstruction:`${a.userCommunication.agentInstruction} ${xe(e,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:a.userCommunication,disposition:"continue",action:s?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:[s?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:s?[{kind:"verifier-response",response:{kind:"request-checks",iteration:e.loop.iteration,attempt:e.loop.attempt,checks:[l]}},{kind:"verifier-response",response:{kind:"final-result",result:{iteration:e.loop.iteration,attempt:e.loop.attempt,verdict:"<pass|fail|blocked>",acceptance:[{id:"<acceptance-id>",result:"<passed|failed|blocked>",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:c?[l]:[]}}],runnerAction:o(s?"await-verifier":"dispatch-verifier")}}if(e.phase==="archive"&&e.status==="active"&&e.loop.stage==="archive-ready"&&!e.archived){let s=r.archiveMode??"archive-ready",l=e.workspace.isolation!=="current"&&e.workspace.finish===null;return s==="blocked"?{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],runnerAction:o("none")}:s==="preview"?r.archiveBlockers&&r.archiveBlockers.length>0?{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}:l?{...a,disposition:"await-user",action:"archive",commandArgs:null,requiredInputs:["workspace-finish"],inputOptions:[Cs("finish","--finish",["keep","merge","push","pull-request"])],commandAlternatives:[...Tf(e)],userCommunication:If(e),runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--dry-run"],requiredInputs:[],commandAlternatives:[Oe({name:"revise-requirements",change:e.name,stateVersion:e.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}import{randomUUID as JN}from"node:crypto";import{promises as Hr}from"node:fs";import GN from"node:path";import{execFileSync as Hf}from"child_process";import Mr from"path";function Fn(e,t){return Hf("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Df(e,t){let r=Mr.normalize(e),i=Mr.normalize(t);return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function ie(e){try{let t=Mr.resolve(Fn(e,["rev-parse","--show-toplevel"])),i=Fn(e,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?Mr.resolve(i.slice(9)):t,a=null;try{a=Fn(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Df(t,n),currentWorktreeRoot:t,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}import{randomUUID as Lf}from"crypto";import{promises as L}from"fs";import ne from"path";function He(e){return e!==0&&e!==0n&&e!=="0"}function fe(e,t){return He(e.dev)&&He(t.dev)&&He(e.ino)&&He(t.ino)}function _(e,t){let r=He(e.dev)&&He(t.dev);if(r&&e.dev!==t.dev)return!1;let i=He(e.ino)&&He(t.ino);return i&&e.ino!==t.ino?!1:r&&i?!0:e.birthtime===t.birthtime}function Vr(e,t){let r=ne.relative(e,t);return r===""||!ne.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ne.sep}`)}function Bf(e,t){return _({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Fr(e,t){return _({dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs},{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs})}function Mf(e,t){return Fr(e,t)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Rs(e){let t=await L.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${e}`);return{path:e,realPath:await L.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function mt(e){for(let t of e){let r=await L.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!Bf(t,r)||await L.realpath(t.path)!==t.realPath)throw new Error(`Native atomic write parent changed before commit: ${t.path}`)}}async function Vf(e,t,r){let[i,n]=await Promise.all([L.lstat(e),L.realpath(e),r?mt(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Fr(i,t)||r&&!Vr(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function Ff(e,t){let r=ne.resolve(e),i=ne.resolve(t);if(!Vr(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${t}`);let n=[await Rs(r)],a=ne.relative(r,i).split(ne.sep).filter(Boolean),o=r;for(let s of a){await mt(n),o=ne.join(o,s);try{await L.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Rs(o);if(!Vr(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await mt(n),n}async function qf(e){let t;try{t=await L.open(e,"r"),await t.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await t?.close()}}async function Wf(e,t,r={}){let i=ne.dirname(e),n=r.containedRoot?await Ff(r.containedRoot,i):null;n||await L.mkdir(i,{recursive:!0});let a=ne.join(i,`.${ne.basename(e)}.${Lf()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await L.open(a,"wx"),s=await o.stat(),n){let[l,f]=await Promise.all([L.lstat(a),L.realpath(a)]);if(await mt(n),!l.isFile()||l.isSymbolicLink()||!Fr(s,l)||!Vr(n[0].realPath,f))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof t=="string"?await o.writeFile(t,"utf8"):await o.writeFile(t),await o.sync(),c=await o.stat(),!Fr(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 Vf(a,c,n),await r.beforeCommit?.(),n){await mt(n);let l=await L.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!Mf(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await L.link(a,e),await L.unlink(a)):await L.rename(a,e),await qf(i)}catch(l){if(await o?.close(),!n)await L.rm(a,{force:!0});else try{await mt(n),await L.rm(a,{force:!0})}catch{}throw l}}async function he(e,t,r={}){await Wf(e,t,r)}async function K(e,t,r={}){await he(e,JSON.stringify(t,null,2)+`
143
+ `,r)}import{createHash as Uf}from"node:crypto";import{promises as ae}from"node:fs";import Q from"node:path";import{TextDecoder as Kf}from"node:util";var zf=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Jf=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Gf(e){return e.toLowerCase().startsWith(".env")}function Ft(e){let r=e.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>Gf(i))?"environment-file":r.some(i=>Jf.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>zf.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var Wr=1024*1024;function qn(e,t){let r=Q.relative(e,t);return r===""||!Q.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Q.sep}`)}function Yf(e){let t=Q.posix.normalize(e);if(e.length===0||e!==e.trim()||e.includes("\\")||Array.from(e).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||Q.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||t!==e||t==="."||e.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${e}`);let r=e.toLowerCase(),i=Ft(e);if(i||r==="runtime"||r.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${i??"native-runtime"}): ${e}`);return e}function Xf(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native artifact byte limit must be a positive integer");return e}function Qf(e,t){return _({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function qr(e,t){let r={...e,birthtime:e.birthtimeMs},i={...t,birthtime:t.birthtimeMs};return fe(r,i)?_(r,i):_(r,i)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function As(e){let t=await ae.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${e}`);return{path:e,realPath:await ae.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function Zf(e,t){let r=Q.resolve(e),i=Q.resolve(t);if(!qn(r,i))throw new Error("Native artifact path is outside its root");let n=[await As(r)],a=r;for(let o of Q.relative(r,i).split(Q.sep).filter(Boolean)){a=Q.join(a,o);let s=await As(a);if(!qn(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function _s(e){for(let t of e){let r=await ae.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!Qf(t,r)||await ae.realpath(t.path)!==t.realPath)throw new Error(`Native artifact parent changed while reading: ${t.path}`)}}async function V(e){let t=Yf(e.ref),r=e.maxBytes===null?null:Xf(e.maxBytes??Wr),i=Q.resolve(e.root,...t.split("/")),n=await Zf(e.root,Q.dirname(i));await e.hooks?.afterParentChainCaptured?.();let a=await ae.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${t}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${t}`);let o=await ae.realpath(i);if(!qn(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${t}`);let s=await ae.open(i,"r");try{let[c,l,f]=await Promise.all([s.stat(),ae.lstat(i),ae.realpath(i)]);if(await _s(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||f!==o||!qr(a,c)||!qr(c,l))throw new Error(`Native artifact changed while opening: ${t}`);await e.hooks?.afterOpen?.();let u=[],d=0,p=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let b=r===null?p.length:r+1-d,k=await s.read(p,0,Math.min(p.length,b),null);if(k.bytesRead===0)break;if(d+=k.bytesRead,r!==null&&d>r)throw new Error(`Native artifact exceeds ${r} bytes: ${t}`);u.push(Buffer.from(p.subarray(0,k.bytesRead)))}await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),ae.lstat(i),ae.realpath(i)]);if(await _s(n),!h.isFile()||h.isSymbolicLink()||m!==o||!qr(c,v)||!qr(c,h))throw new Error(`Native artifact changed while reading: ${t}`);let w=Buffer.concat(u,d),y;try{y=new Kf("utf-8",{fatal:!0}).decode(w)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${t}`,{cause:b})}return{ref:t,size:d,hash:e.includeHash===!1?null:Uf("sha256").update(w).digest("hex"),text:y}}finally{await s.close()}}var ls=Mt(Pt(),1);import Dt from"path";var Co={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:"验证预期"}},Pg={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:"结论"}},Rg={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:"结论"}},Nu=new Map,yu=new Map;for(let e of Object.keys(Co)){for(let[t,r]of Object.entries(Co[e]))Nu.set(r.toLocaleLowerCase("en-US"),t);for(let[t,r]of Object.entries(Pg[e]))yu.set(r.toLocaleLowerCase("en-US"),t);for(let[t,r]of Object.entries(Rg[e]))yu.set(r.toLocaleLowerCase("en-US"),t)}function Ag(e,t){return Co[e][t]}function xo(e){return Nu.get(e.trim().toLocaleLowerCase("en-US"))??null}function qi(e){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${Ag(e,r)}
144
144
  `).join(`
145
- `)}var Ro=Bt(xt(),1);import ze from"path";var yr=64*1024,zi=1024,Ji=64,bu=1024,ku=64,Ao=5,Wi={learning:!0,retrieval:!0},Cu={provider:"local"},Pg=12e4,Su=6e5,Rg=[".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/**"],Ag=["**/.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"],_g=[...Rg,...Ag].sort((t,e)=>t.localeCompare(e,"en"));var K={include:["**/*"],exclude:[..._g],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function Ig(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||ze.posix.isAbsolute(r)||ze.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 at(t){let e=Ig(t,"native.artifact_root");return e.length===0?".":e.join("/")}function xu(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 Gi(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||ze.posix.isAbsolute(i)||ze.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 Re(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Pu(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 _o(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>zi)throw new Error(`${e} exceeds ${zi} 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>Ji)throw new Error(`${e} contains more than ${Ji} wildcard tokens`);return t}function Eu(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=>_o(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function Po(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 Tg(t){if(t===void 0)return{...K,include:[...K.include],exclude:[...K.exclude]};let e=Re(t,"native.snapshot");return{include:Eu(e.include,"native.snapshot.include",K.include),exclude:Eu(e.exclude,"native.snapshot.exclude",K.exclude),max_files:Po(e.max_files,K.max_files,"native.snapshot.max_files"),max_total_bytes:Po(e.max_total_bytes,K.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Po(e.max_duration_ms,K.max_duration_ms,"native.snapshot.max_duration_ms")}}function jg(t){if(t===void 0)return;let e=Re(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=Re(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,f=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof f!="string"||!/^[a-f0-9]{64}$/u.test(f))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:f}}return{id:r,fromArtifactRoot:at(i),toArtifactRoot:at(n),stage:a,...o?{cleanup:o}:{}}}function $g(t){if(t===void 0)return;let e=Re(t,"native.finish");if(e.pull_request===void 0)return{};let r=Re(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(ze.posix.isAbsolute(i[0])||ze.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??Pg;if(!Number.isSafeInteger(n)||n<1||n>Su)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Su}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function Og(t,e={}){let r=Re(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??Ao;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=jg(r.pending_root_move),c=$g(r.finish);return{artifact_root:at(i),language:Pu(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Tg(r.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function Hg(t){let e=Re(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");return{artifact_layout:xu(e.artifact_layout),language:Pu(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n}}function Dg(t){let r=Re(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)=>Gi(i,`hook.allow_paths[${n}]`)))]}}function Lg(t){if(t===void 0)return{...Wi};let e=Re(t,"memory"),r=e.learning??Wi.learning,i=e.retrieval??Wi.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 Io(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Bg(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")||ze.posix.isAbsolute(r)||ze.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>bu)throw new Error(`${e} exceeds ${bu} 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>ku)throw new Error(`${e} contains more than ${ku} wildcard tokens`);return r}function Vg(t){let r=Io(t,"knowledge.local").include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");return{include:[...new Set(r.map((i,n)=>Bg(i,`knowledge.local.include[${n}]`)))]}}function Mg(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 Fg(t){let e=Io(t,"knowledge.remote"),r=Mg(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 qg(t){if(t===void 0)return{...Cu};let e=Io(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:Vg(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:Fg(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 Wg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function zg(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 f=t.workflows??[t.default_workflow];if(!Array.isArray(f)||f.length===0||f.some(d=>d!=="native"&&d!=="classic"))throw new Error("workflows must contain native and/or classic");let u=[...new Set(f)];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 Nr(t,e={}){let r=(0,Ro.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=Wg(n.ambient_resume),o=n.hook===void 0?void 0:Dg(n.hook),s=Lg(n.memory),c=qg(n.knowledge),l=n.native===void 0?void 0:Og(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),f=n.classic===void 0?void 0:Hg(n.classic),u=zg(n,o,s,c,l,f,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:u,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...f?{classic:f}:{}}}function Ui(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Wi},knowledge:{...Cu},native:{artifact_root:at(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Ao,snapshot:{...K,include:[...K.include],exclude:[...K.exclude]}}}}import{createHash as Gg}from"crypto";import{promises as Xi}from"fs";import Je from"path";import{constants as Ki,promises as ot}from"fs";var ce=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}};function To(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Ru(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function br(t){return{dev:t.dev,ino:t.ino,birthtime:To(t)}}function Yi(t,e){let r=br(t),i=br(e);return fe(r,i)?_(r,i):_(r,i)&&To(t)===To(e)&&Ru(t)===Ru(e)&&t.size===e.size}async function Pt(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 ot.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new ce("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new ce("too-large",`${i} exceeds ${e} bytes`);let o=await ot.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:br(a)});let s=process.platform==="win32"?Ki.O_RDONLY:Ki.O_RDONLY|Ki.O_NOFOLLOW|Ki.O_NONBLOCK,c;try{c=await ot.open(t,s)}catch(l){throw l.code==="ELOOP"?new ce("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,f,u]=await Promise.all([c.stat({bigint:n}),ot.lstat(t,{bigint:n}),ot.realpath(t)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||u!==o||!Yi(a,l)||!Yi(a,f))throw new ce("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:u,identity:br(l)}),await r.hooks?.afterOpen?.();let d=[],h=0,v=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let y=e+1-h,{bytesRead:b}=await c.read(v,0,Math.min(v.length,y),null);if(b===0)break;if(h+=b,h>e)throw new ce("too-large",`${i} exceeds ${e} bytes`);d.push(Buffer.from(v.subarray(0,b)))}await r.hooks?.beforeFinalCheck?.();let[p,m,w]=await Promise.all([c.stat({bigint:n}),ot.lstat(t,{bigint:n}),ot.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||w!==o||!Yi(a,p)||!Yi(a,m))throw new ce("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:w,identity:br(p)}),{bytes:Buffer.concat(d,h),stat:p,realPath:w}}finally{await c.close()}}function Jg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function jo(t,e){let r=Je.relative(t,e);return r===""||!Je.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Je.sep}`)}async function Au(t,e){let r=Je.resolve(t),i=await Xi.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Xi.realpath(r)}async function _u(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=Je.join(n,r[a]);let o;try{o=await Xi.lstat(n)}catch(f){if(Jg(f))return{exists:!1,kind:"missing"};throw f}let s=Je.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 Xi.realpath(n);if(!jo(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 Rt(t,e,r){let i=Gi(e,r.label),n=Je.resolve(t),a=await Au(n,r.label),o=i.split("/"),s=Je.resolve(n,...o);if(!jo(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await _u(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 Rt(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 Au(n.projectRoot,i.label);return Pt(n.target,r,{...i,verify:async(o,s)=>{if(!jo(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await _u(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var kr=".comet/config.yaml";function Ug(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Qi(t,e={}){return(await Zi(t,e)).document}async function Kg(t){try{return(await Ge(t,kr,yr,{label:kr})).bytes}catch(e){if(Ug(e))return null;throw e}}function Yg(t){return t?{exists:!0,sha256:Gg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Zi(t,e={}){let r=await Kg(t);return{document:r?Nr(r.toString("utf8"),e):null,identity:Yg(r)}}async function $o(t){return(await Qi(t))?.config??null}var QS=16*1024;import{existsSync as Tu,promises as st}from"fs";import R from"path";import tw from"os";var en=".comet/config.yaml",rw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function Do(t){try{return await st.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function iw(t){try{let e=await st.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function _t(t,e){let r=R.relative(t,e);return r===""||!R.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${R.sep}`)}async function At(t){let e=[],r=t;for(;!await Do(r);){let n=R.dirname(r);if(n===r)break;e.push(R.basename(r)),r=n}let i=await st.realpath(r);return R.resolve(i,...e.reverse())}async function Lo(t){try{return(await st.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function tn(t){let e=R.resolve(t);try{(await st.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=R.resolve(tw.homedir());for(;;){if(!(e===i&&r!==i)){let o=R.join(e,...en.split("/")),s=e===r||await iw(o);if(await Do(o)&&s)return e}if(await Do(R.join(e,".git")))return e;let a=R.dirname(e);if(a===e)return r;e=a}}function rn(t){return at(t)}async function nw(t,e){let r=rn(e),i=R.resolve(t,...r.split("/")),n=await st.realpath(t),a=await At(i);if(!_t(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function It(t,e){let r=rn(e),i=await nw(t,r),n=R.join(i,"comet");if(await Lo(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([At(i),At(n)]);if(!_t(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 Lo(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,f]=await Promise.all([st.realpath(s),At(c)]);if(!_t(l,f))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(t,...en.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 ju(t){if(!rw.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Ue(t,e){ju(e);let r=R.join(t.changesRuntimeDir,e);if(!F(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function Bo(t,e){ju(e);let r=R.join(t.changesDir,e,"runtime");if(!F(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function ve(t,e){let r=Ue(t,e);if(Tu(r))return r;let i=Bo(t,e);return Tu(i)?i:r}function ge(t,e){let r=R.resolve(e);if(F(t.runtimeDir,r))return t.runtimeDir;if(F(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function F(t,e){return _t(R.resolve(t),R.resolve(e))}async function T(t,e){let r=R.resolve(t),i=R.resolve(e);if(!_t(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await Lo(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([At(r),At(i)]);if(!_t(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}function ow(t="docs",e="en"){return Ui(t,e)}async function we(t){let e=(await Qi(t))?.config??null;return e?.native?e:null}async function nn(t){let e=await we(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function $u(t){let e=await tn(t.startPath),r=await we(e);if(!r&&t.allowMissingConfig===!1)throw new Error(`${en} 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?rn(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??ow(i??"docs"),a=await It(e,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}import{promises as Dy}from"fs";import Ly from"path";import{AsyncLocalStorage as sw}from"async_hooks";import{randomUUID as Du}from"crypto";import{promises as ee}from"fs";import Lu from"os";import q from"path";var Ou=16*1024,Bu=".coordinator",cw=5e3,Hu=new sw,an=new Map;function lw(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function uw(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let r=t;if(typeof r.id!="string"||r.id.length===0||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<1||typeof r.hostname!="string"||r.hostname.length===0||typeof r.createdAt!="string"||r.createdAt.length===0||typeof r.operation!="string"||r.operation.length===0)throw new Error(`Invalid Native lock metadata: ${e}`);return r}function Vu(t){return{device:t.dev.toString(),inode:t.ino.toString(),size:t.size.toString(),birthtimeNs:t.birthtimeNs.toString(),ctimeNs:t.ctimeNs.toString(),mtimeNs:t.mtimeNs.toString()}}function on(t,e){let r={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},i={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return fe(r,i)?_(r,i):_(r,i)&&t.size===e.size}function Vo(t,e){return on(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}async function ye(t){let e,r;try{let i=await Pt(t,Ou,{bigint:!0,label:"Native lock"});e=i.bytes,r=i.stat}catch(i){if(i.code==="ENOENT")return null;throw i instanceof ce?i.reason==="too-large"?new Error(`Native lock metadata exceeds ${Ou} bytes: ${t}`,{cause:i}):i.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:i}):new Error(`Native lock changed while reading: ${t}`,{cause:i}):i}return{file:t,owner:uw(JSON.parse(e.toString("utf8")),t),identity:Vu(r)}}async function dw(t){return(await ye(t))?.owner??null}function Mu(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==Lu.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=gw(t.owner.pid);return{status:e===!0?"active":e===!1?"stale":"unknown",owner:t.owner,identity:t.identity}}async function fw(t,e){try{await ee.lstat(e);return}catch(r){if(r.code!=="ENOENT")throw r}try{await ee.rename(t,e)}catch(r){if(r.code!=="ENOENT")throw r}}async function Mo(t,e){let r=await ye(t.file);if(!r)return"missing";if(r.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!Vo(r.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await ee.mkdir(e,{recursive:!0});let i=q.join(e,`${q.basename(t.file)}.${t.owner.id}.${Du()}.removed`);try{await ee.rename(t.file,i)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await ye(i);if(!n||n.owner.id!==t.owner.id||!on(n.identity,t.identity))throw await fw(i,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await ee.rm(i,{force:!0}),"removed"}function Fu(t){return{id:Du(),pid:process.pid,hostname:Lu.hostname(),createdAt:new Date().toISOString(),operation:t}}async function qu(t,e){let r;try{r=await ee.open(t,"wx")}catch(a){if(a.code==="EEXIST"){let o=await dw(t);throw new Error(`Native lock is already held: ${t}${o?` by pid ${o.pid} for ${o.operation}`:""}`,{cause:a})}throw a}let i;try{await r.writeFile(JSON.stringify(e,null,2)+`
146
- `,"utf8"),await r.sync(),i=Vu(await r.stat({bigint:!0}))}finally{await r.close()}let n=await ye(t);if(!i||!n||n.owner.id!==e.id||!on(n.identity,i))throw new Error(`Native lock changed after write: ${t}`);return n.identity}async function pw(t,e){let r=await T(t.runtimeDir,t.locksDir);await ee.mkdir(r,{recursive:!0});let i=await T(t.runtimeDir,q.join(r,Bu));await ee.mkdir(i,{recursive:!0});let n=Fu(e),a=q.join(i,`.${n.id}.tmp`),o=q.join(i,`${n.id}.claim`);try{let s=await qu(a,n);await ee.rename(a,o);let c=await ye(o);if(!c||!on(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:r,owner:n,identity:c.identity}}finally{await ee.rm(a,{force:!0})}}async function hw(t){let e=q.dirname(t.file),r=!1,i=q.basename(t.file);for(let n of await ee.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=q.join(e,n.name);if(q.resolve(a)!==q.resolve(t.file))try{let o=await ye(a),s=Mu(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await Mo(o,e);continue}n.name<i&&(r=!0)}catch{n.name<i&&(r=!0)}}return r}async function Wu(t){let e=await ye(t.file);if(e){if(e.owner.id!==t.owner.id||!Vo(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await Mo(e,q.dirname(t.file))}}async function mw(t,e){let r=Date.now()+cw;for(;;){let i=await pw(t,e);if(!await hw(i))return i;if(await Wu(i),Date.now()>=r)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function vw(t){let e=an.get(t)??Promise.resolve(),r,i=new Promise(a=>{r=a}),n=e.then(()=>i);return an.set(t,n),await e,()=>{r(),an.get(t)===n&&an.delete(t)}}async function zu(t,e,r){let i=q.resolve(t.locksDir),n=Hu.getStore();if(n?.has(i))return r();let a=await vw(i);try{let o=await mw(t,e),s=new Map(n??[]);return s.set(i,o),await Hu.run(s,async()=>{try{return await r()}finally{await Wu(o)}})}finally{a()}}async function sn(t,e,r){return zu(t,`acquire ${e}`,async()=>{let i=await T(t.runtimeDir,t.locksDir);await ee.mkdir(i,{recursive:!0});let n=await T(t.runtimeDir,q.join(i,lw(e))),a=Fu(r),o=await qu(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:i,owner:a,identity:o}})}async function cn(t){await ye(t.file)&&await zu({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${q.basename(t.file)}`,async()=>{let e=await ye(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!Vo(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let r=q.join(t.locksDir,Bu);await Mo(e,r)})}function gw(t){try{return process.kill(t,0),!0}catch(e){let r=e.code;return r==="ESRCH"?!1:r==="EPERM"?!0:null}}async function Ju(t){return Mu(await ye(t))}import Yo from"node:path";import Yw from"node:path";import Qu from"node:path";import{createHash as ww}from"crypto";function le(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function yw(t,e){e.has(t)&&le("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)||le("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&le("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&le("symbol properties are not supported"),`[${t.map(i=>Fo(i,e)).join(",")}]`}finally{e.delete(t)}}function Nw(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&le("only plain objects are supported"),e.has(t)&&le("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&le("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))&&le("accessor properties are not supported"),`${JSON.stringify(o)}:${Fo(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function Fo(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)||le("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?yw(t,e):Nw(t,e);case"bigint":case"function":case"symbol":case"undefined":return le(`${typeof t} values are not supported`)}return le("unsupported value type")}function qo(t){return Fo(t,new Set)}function Y(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 ww("sha256").update(`${t}
147
- ${qo(e)}`).digest("hex")}var bw="comet.native.acceptance.v1";var TE=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),un=Object.freeze({maxCriteria:1024});function Ku(t){let e=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(t);return e?{level:e[1].length,text:e[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function Gu(t,e){let r=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(t);if(!r)return e;let i=r[1][0];return e===null?{marker:i,length:r[1].length}:i===e.marker&&r[1].length>=e.length&&r[2].trim().length===0?null:e}function Uu(t){return t.includes("-->")||t.includes("--!>")}function*ln(t){let e=null,r=!1,i=null,n=new Set(["code","pre","script","style","svg","template"]),a=t.replace(/\r\n?/gu,`
145
+ `)}var Ro=Mt(Pt(),1);import Ge from"path";var yr=64*1024,zi=1024,Ji=64,bu=1024,ku=64,Ao=5,Wi={learning:!0,retrieval:!0},Cu={provider:"local"},_g=12e4,Su=6e5,Ig=[".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/**"],Tg=["**/.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"],jg=[...Ig,...Tg].sort((e,t)=>e.localeCompare(t,"en"));var Y={include:["**/*"],exclude:[...jg],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function $g(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim();if(r.length===0||Ge.posix.isAbsolute(r)||Ge.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${t} must be a project-relative path`);if(r===".")return[];let i=r.replaceAll("\\","/").split("/");if(i.some(n=>n===".."))throw new Error(`${t} must stay inside the project root`);if(i.some(n=>n===""||n==="."))throw new Error(`${t} must not contain empty or dot path segments`);return i}function at(e){let t=$g(e,"native.artifact_root");return t.length===0?".":t.join("/")}function xu(e,t="docs"){let r=e??t;if(r!=="legacy"&&r!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return r}function Gi(e,t,r=!1){if(typeof e!="string")throw new Error(`${t} must be a string`);let i=e.trim().replaceAll("\\","/");if(i.length===0||Ge.posix.isAbsolute(i)||Ge.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${t} must be relative to its declared path base`);let n=i.split("/");if(n.some(a=>a===".."))throw new Error(`${t} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${t} must not contain empty or dot path segments`);if(!r&&/[*?]/u.test(i))throw new Error(`${t} cannot contain wildcards`);return n.join("/")}function Ae(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Pu(e,t,r){let i=e??t;if(i!=="en"&&i!=="zh-CN")throw new Error(`${r} must be en or zh-CN`);return i}function _o(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||e.startsWith("/")||e.split("/").includes(".."))throw new Error(`${t} contains an unsafe pattern`);if(e.length>zi)throw new Error(`${t} exceeds ${zi} characters`);let r=0;for(let i=0;i<e.length;i+=1)e[i]==="?"?r+=1:e[i]==="*"&&(r+=1,e[i+1]==="*"&&(i+=1));if(r>Ji)throw new Error(`${t} contains more than ${Ji} wildcard tokens`);return e}function Eu(e,t,r){if(e===void 0)return[...r];if(!Array.isArray(e))throw new Error(`${t} contains an unsafe pattern`);return[...new Set(e.map(i=>_o(i,t)))].sort((i,n)=>i.localeCompare(n,"en"))}function Po(e,t,r){let i=e??t;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${r} must be a positive integer`);return i}function Og(e){if(e===void 0)return{...Y,include:[...Y.include],exclude:[...Y.exclude]};let t=Ae(e,"native.snapshot");return{include:Eu(t.include,"native.snapshot.include",Y.include),exclude:Eu(t.exclude,"native.snapshot.exclude",Y.exclude),max_files:Po(t.max_files,Y.max_files,"native.snapshot.max_files"),max_total_bytes:Po(t.max_total_bytes,Y.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Po(t.max_duration_ms,Y.max_duration_ms,"native.snapshot.max_duration_ms")}}function Hg(e){if(e===void 0)return;let t=Ae(e,"native.pending_root_move"),r=t.id,i=t.from_artifact_root,n=t.to_artifact_root,a=t.stage;if(typeof r!="string"||!/^[a-f0-9-]{8,}$/u.test(r))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(t.cleanup!==void 0){let s=Ae(t.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,f=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof f!="string"||!/^[a-f0-9]{64}$/u.test(f))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:f}}return{id:r,fromArtifactRoot:at(i),toArtifactRoot:at(n),stage:a,...o?{cleanup:o}:{}}}function Dg(e){if(e===void 0)return;let t=Ae(e,"native.finish");if(t.pull_request===void 0)return{};let r=Ae(t.pull_request,"native.finish.pull_request");if(r.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(r.command)||r.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(r.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=r.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(Ge.posix.isAbsolute(i[0])||Ge.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??_g;if(!Number.isSafeInteger(n)||n<1||n>Su)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Su}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function Lg(e,t={}){let r=Ae(e,"native"),i=r.artifact_root??(t.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let n=r.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=r.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=r.max_verify_failures??Ao;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Hg(r.pending_root_move),c=Dg(r.finish);return{artifact_root:at(i),language:Pu(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Og(r.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function Bg(e){let t=Ae(e,"classic"),r=t.context_compression??"off";if(r!=="off"&&r!=="beta")throw new Error("classic.context_compression must be off or beta");let i=t.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=t.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:xu(t.artifact_layout),language:Pu(t.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n}}function Mg(e){let r=Ae(e,"hook").allow_paths??[];if(!Array.isArray(r))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(r.map((i,n)=>Gi(i,`hook.allow_paths[${n}]`)))]}}function Vg(e){if(e===void 0)return{...Wi};let t=Ae(e,"memory"),r=t.learning??Wi.learning,i=t.retrieval??Wi.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 Io(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Fg(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim();if(r.length===0||r.includes("\\")||r.includes("\0")||Ge.posix.isAbsolute(r)||Ge.win32.isAbsolute(r)||r.startsWith("~")||r.split("/").some(n=>n===""||n==="."||n===".."))throw new Error(`${t} must be a safe project-relative glob`);if(!r.toLowerCase().endsWith(".md"))throw new Error(`${t} must target a Markdown file ending in .md`);if(r.length>bu)throw new Error(`${t} exceeds ${bu} 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>ku)throw new Error(`${t} contains more than ${ku} wildcard tokens`);return r}function qg(e){let r=Io(e,"knowledge.local").include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");return{include:[...new Set(r.map((i,n)=>Fg(i,`knowledge.local.include[${n}]`)))]}}function Wg(e){if(typeof e!="string"||e.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let t;try{t=new URL(e)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let r=t.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=r==="localhost"||r==="127.0.0.1"||r==="::1";if(t.protocol!=="https:"&&!(t.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return t.toString()}function zg(e){let t=Io(e,"knowledge.remote"),r=Wg(t.endpoint),i=t.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let n=t.scope;if(n!==void 0&&(typeof n!="string"||n.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let a=t.timeout_ms??5e3;if(typeof a!="number"||!Number.isSafeInteger(a)||a<100||a>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:r,...i===void 0?{}:{token_env:i},...n===void 0?{}:{scope:n},timeout_ms:a}}function Jg(e){if(e===void 0)return{...Cu};let t=Io(e,"knowledge"),r=t.provider??"local";if(r!=="local"&&r!=="remote")throw new Error("knowledge.provider must be local or remote");let i=t.local===void 0?void 0:qg(t.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=t.remote===void 0?void 0:zg(t.remote);if(n===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:r,...i?{local:i}:{},remote:n}}function Gg(e){let t=e??!0;if(typeof t!="boolean")throw new Error("ambient_resume must be true or false");return t}function Ug(e,t,r,i,n,a,o,s){let c=e.schema!==void 0;if(!(c||e.default_workflow!==void 0||e.workflows!==void 0||!s.allowPartialProject&&e.native!==void 0)||s.allowPartialProject&&!c)return null;if(e.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(e.default_workflow!=="native"&&e.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let f=e.workflows??[e.default_workflow];if(!Array.isArray(f)||f.length===0||f.some(d=>d!=="native"&&d!=="classic"))throw new Error("workflows must contain native and/or classic");let u=[...new Set(f)];if(!u.includes(e.default_workflow))throw new Error("workflows must include default_workflow");if(u.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:e.default_workflow,workflows:u,ambient_resume:o,...t?{hook:t}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function Nr(e,t={}){let r=(0,Ro.parseDocument)(e,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${r.errors[0].message}`);let i=r.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=i,a=Gg(n.ambient_resume),o=n.hook===void 0?void 0:Mg(n.hook),s=Vg(n.memory),c=Jg(n.knowledge),l=n.native===void 0?void 0:Lg(n.native,{allowMissingArtifactRoot:t.allowMissingNativeFields}),f=n.classic===void 0?void 0:Bg(n.classic),u=Ug(n,o,s,c,l,f,a,{allowPartialProject:t.allowPartialProject??!1});return{value:n,config:u,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...f?{classic:f}:{}}}function Ui(e="docs",t="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Wi},knowledge:{...Cu},native:{artifact_root:at(e),language:t,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Ao,snapshot:{...Y,include:[...Y.include],exclude:[...Y.exclude]}}}}import{createHash as Yg}from"crypto";import{promises as Xi}from"fs";import Ue from"path";import{constants as Ki,promises as ot}from"fs";var ce=class extends Error{reason;constructor(t,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=t}};function To(e){return"birthtimeNs"in e&&typeof e.birthtimeNs=="bigint"?e.birthtimeNs:e.birthtimeMs}function Ru(e){return"ctimeNs"in e&&typeof e.ctimeNs=="bigint"?e.ctimeNs:e.ctimeMs}function br(e){return{dev:e.dev,ino:e.ino,birthtime:To(e)}}function Yi(e,t){let r=br(e),i=br(t);return fe(r,i)?_(r,i):_(r,i)&&To(e)===To(t)&&Ru(e)===Ru(t)&&e.size===t.size}async function Rt(e,t,r={}){if(!Number.isSafeInteger(t)||t<1)throw new Error("race-safe read byte limit must be a positive integer");let i=r.label??"file",n=r.bigint===!0,a=await ot.lstat(e,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new ce("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(t))throw new ce("too-large",`${i} exceeds ${t} bytes`);let o=await ot.realpath(e);await r.verify?.("pre-open",{realPath:o,identity:br(a)});let s=process.platform==="win32"?Ki.O_RDONLY:Ki.O_RDONLY|Ki.O_NOFOLLOW|Ki.O_NONBLOCK,c;try{c=await ot.open(e,s)}catch(l){throw l.code==="ELOOP"?new ce("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,f,u]=await Promise.all([c.stat({bigint:n}),ot.lstat(e,{bigint:n}),ot.realpath(e)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||u!==o||!Yi(a,l)||!Yi(a,f))throw new ce("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:u,identity:br(l)}),await r.hooks?.afterOpen?.();let d=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let y=t+1-p,{bytesRead:b}=await c.read(v,0,Math.min(v.length,y),null);if(b===0)break;if(p+=b,p>t)throw new ce("too-large",`${i} exceeds ${t} bytes`);d.push(Buffer.from(v.subarray(0,b)))}await r.hooks?.beforeFinalCheck?.();let[h,m,w]=await Promise.all([c.stat({bigint:n}),ot.lstat(e,{bigint:n}),ot.realpath(e)]);if(!m.isFile()||m.isSymbolicLink()||w!==o||!Yi(a,h)||!Yi(a,m))throw new ce("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:w,identity:br(h)}),{bytes:Buffer.concat(d,p),stat:h,realPath:w}}finally{await c.close()}}function Kg(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function jo(e,t){let r=Ue.relative(e,t);return r===""||!Ue.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ue.sep}`)}async function Au(e,t){let r=Ue.resolve(e),i=await Xi.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${t} project root must be a real directory`);return Xi.realpath(r)}async function _u(e,t,r,i){let n=e;for(let a=0;a<r.length;a++){n=Ue.join(n,r[a]);let o;try{o=await Xi.lstat(n)}catch(f){if(Kg(f))return{exists:!1,kind:"missing"};throw f}let s=Ue.relative(e,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${s}`);let c=a===r.length-1;if(!c&&!o.isDirectory())throw new Error(`${i.label} ancestor ${s} must be a real directory`);if(c&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let l=await Xi.realpath(n);if(!jo(t,l))throw new Error(`${i.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function At(e,t,r){let i=Gi(t,r.label),n=Ue.resolve(e),a=await Au(n,r.label),o=i.split("/"),s=Ue.resolve(n,...o);if(!jo(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await _u(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:c.exists,kind:c.kind}}async function Ke(e,t,r,i){let n=await At(e,t,{label:i.label,expected:"file"});if(!n.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let a=await Au(n.projectRoot,i.label);return Rt(n.target,r,{...i,verify:async(o,s)=>{if(!jo(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await _u(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var kr=".comet/config.yaml";function Xg(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}async function Qi(e,t={}){return(await Zi(e,t)).document}async function Qg(e){try{return(await Ke(e,kr,yr,{label:kr})).bytes}catch(t){if(Xg(t))return null;throw t}}function Zg(e){return e?{exists:!0,sha256:Yg("sha256").update(e).digest("hex")}:{exists:!1,sha256:null}}async function Zi(e,t={}){let r=await Qg(e);return{document:r?Nr(r.toString("utf8"),t):null,identity:Zg(r)}}async function $o(e){return(await Qi(e))?.config??null}var tE=16*1024;import{existsSync as Tu,promises as st}from"fs";import R from"path";import nw from"os";var en=".comet/config.yaml",aw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function Do(e){try{return await st.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function ow(e){try{let t=await st.readFile(e,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(t)}catch(t){if(t.code==="ENOENT")return!1;throw t}}function It(e,t){let r=R.relative(e,t);return r===""||!R.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${R.sep}`)}async function _t(e){let t=[],r=e;for(;!await Do(r);){let n=R.dirname(r);if(n===r)break;t.push(R.basename(r)),r=n}let i=await st.realpath(r);return R.resolve(i,...t.reverse())}async function Lo(e){try{return(await st.lstat(e)).isSymbolicLink()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function tn(e){let t=R.resolve(e);try{(await st.stat(t)).isDirectory()||(t=R.dirname(t))}catch(n){if(n.code!=="ENOENT")throw n}let r=t,i=R.resolve(nw.homedir());for(;;){if(!(t===i&&r!==i)){let o=R.join(t,...en.split("/")),s=t===r||await ow(o);if(await Do(o)&&s)return t}if(await Do(R.join(t,".git")))return t;let a=R.dirname(t);if(a===t)return r;t=a}}function rn(e){return at(e)}async function sw(e,t){let r=rn(t),i=R.resolve(e,...r.split("/")),n=await st.realpath(e),a=await _t(i);if(!It(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Tt(e,t){let r=rn(t),i=await sw(e,r),n=R.join(i,"comet");if(await Lo(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([_t(i),_t(n)]);if(!It(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=R.resolve(e),c=R.join(s,".comet","runtime","native");if(await Lo(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,f]=await Promise.all([st.realpath(s),_t(c)]);if(!It(l,f))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(e,...en.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 ju(e){if(!aw.test(e))throw new Error(`Invalid Native change name: ${e}`)}function Ye(e,t){ju(t);let r=R.join(e.changesRuntimeDir,t);if(!F(e.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function Bo(e,t){ju(t);let r=R.join(e.changesDir,t,"runtime");if(!F(e.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function ve(e,t){let r=Ye(e,t);if(Tu(r))return r;let i=Bo(e,t);return Tu(i)?i:r}function ge(e,t){let r=R.resolve(t);if(F(e.runtimeDir,r))return e.runtimeDir;if(F(e.nativeRoot,r))return e.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${t}`)}function F(e,t){return It(R.resolve(e),R.resolve(t))}async function T(e,t){let r=R.resolve(e),i=R.resolve(t);if(!It(r,i))throw new Error(`Path is outside the Native root: ${t}`);if(await Lo(r))throw new Error(`Native root must not be a symbolic link: ${e}`);let[n,a]=await Promise.all([_t(r),_t(i)]);if(!It(n,a))throw new Error(`Path resolves outside the Native root: ${t}`);return i}function lw(e="docs",t="en"){return Ui(e,t)}async function we(e){let t=(await Qi(e))?.config??null;return t?.native?t:null}async function nn(e){let t=await we(e);if(t?.native.pending_root_move)throw new Error(`Native root move ${t.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function $u(e){let t=await tn(e.startPath),r=await we(t);if(!r&&e.allowMissingConfig===!1)throw new Error(`${en} was not found`);if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let i=e.explicitArtifactRoot?rn(e.explicitArtifactRoot):void 0;if(r&&i&&i!==r.native.artifact_root)throw new Error(`Configured Native artifact root is ${r.native.artifact_root}; refusing conflicting root ${i}`);let n=r??lw(i??"docs"),a=await Tt(t,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}import{promises as By}from"fs";import My from"path";import{AsyncLocalStorage as uw}from"async_hooks";import{randomUUID as Du}from"crypto";import{promises as ee}from"fs";import Lu from"os";import q from"path";var Ou=16*1024,Bu=".coordinator",dw=5e3,Hu=new uw,an=new Map;function fw(e){if(!/^[a-z][a-z0-9-]*$/u.test(e))throw new Error(`Invalid Native lock name: ${e}`);return`${e}.lock`}function hw(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid Native lock metadata: ${t}`);let r=e;if(typeof r.id!="string"||r.id.length===0||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<1||typeof r.hostname!="string"||r.hostname.length===0||typeof r.createdAt!="string"||r.createdAt.length===0||typeof r.operation!="string"||r.operation.length===0)throw new Error(`Invalid Native lock metadata: ${t}`);return r}function Mu(e){return{device:e.dev.toString(),inode:e.ino.toString(),size:e.size.toString(),birthtimeNs:e.birthtimeNs.toString(),ctimeNs:e.ctimeNs.toString(),mtimeNs:e.mtimeNs.toString()}}function on(e,t){let r={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs},i={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs};return fe(r,i)?_(r,i):_(r,i)&&e.size===t.size}function Mo(e,t){return on(e,t)&&e.size===t.size&&e.birthtimeNs===t.birthtimeNs&&e.ctimeNs===t.ctimeNs&&e.mtimeNs===t.mtimeNs}async function ye(e){let t,r;try{let i=await Rt(e,Ou,{bigint:!0,label:"Native lock"});t=i.bytes,r=i.stat}catch(i){if(i.code==="ENOENT")return null;throw i instanceof ce?i.reason==="too-large"?new Error(`Native lock metadata exceeds ${Ou} bytes: ${e}`,{cause:i}):i.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${e}`,{cause:i}):new Error(`Native lock changed while reading: ${e}`,{cause:i}):i}return{file:e,owner:hw(JSON.parse(t.toString("utf8")),e),identity:Mu(r)}}async function pw(e){return(await ye(e))?.owner??null}function Vu(e){if(!e)return{status:"missing",owner:null,identity:null};if(e.owner.hostname!==Lu.hostname())return{status:"unknown",owner:e.owner,identity:e.identity};let t=Nw(e.owner.pid);return{status:t===!0?"active":t===!1?"stale":"unknown",owner:e.owner,identity:e.identity}}async function mw(e,t){try{await ee.lstat(t);return}catch(r){if(r.code!=="ENOENT")throw r}try{await ee.rename(e,t)}catch(r){if(r.code!=="ENOENT")throw r}}async function Vo(e,t){let r=await ye(e.file);if(!r)return"missing";if(r.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!Mo(r.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);await ee.mkdir(t,{recursive:!0});let i=q.join(t,`${q.basename(e.file)}.${e.owner.id}.${Du()}.removed`);try{await ee.rename(e.file,i)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await ye(i);if(!n||n.owner.id!==e.owner.id||!on(n.identity,e.identity))throw await mw(i,e.file),new Error(`Native lock changed before quarantine: ${e.file}`);return await ee.rm(i,{force:!0}),"removed"}function Fu(e){return{id:Du(),pid:process.pid,hostname:Lu.hostname(),createdAt:new Date().toISOString(),operation:e}}async function qu(e,t){let r;try{r=await ee.open(e,"wx")}catch(a){if(a.code==="EEXIST"){let o=await pw(e);throw new Error(`Native lock is already held: ${e}${o?` by pid ${o.pid} for ${o.operation}`:""}`,{cause:a})}throw a}let i;try{await r.writeFile(JSON.stringify(t,null,2)+`
146
+ `,"utf8"),await r.sync(),i=Mu(await r.stat({bigint:!0}))}finally{await r.close()}let n=await ye(e);if(!i||!n||n.owner.id!==t.id||!on(n.identity,i))throw new Error(`Native lock changed after write: ${e}`);return n.identity}async function vw(e,t){let r=await T(e.runtimeDir,e.locksDir);await ee.mkdir(r,{recursive:!0});let i=await T(e.runtimeDir,q.join(r,Bu));await ee.mkdir(i,{recursive:!0});let n=Fu(t),a=q.join(i,`.${n.id}.tmp`),o=q.join(i,`${n.id}.claim`);try{let s=await qu(a,n);await ee.rename(a,o);let c=await ye(o);if(!c||!on(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:e.runtimeDir,locksDir:r,owner:n,identity:c.identity}}finally{await ee.rm(a,{force:!0})}}async function gw(e){let t=q.dirname(e.file),r=!1,i=q.basename(e.file);for(let n of await ee.readdir(t,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=q.join(t,n.name);if(q.resolve(a)!==q.resolve(e.file))try{let o=await ye(a),s=Vu(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await Vo(o,t);continue}n.name<i&&(r=!0)}catch{n.name<i&&(r=!0)}}return r}async function Wu(e){let t=await ye(e.file);if(t){if(t.owner.id!==e.owner.id||!Mo(t.identity,e.identity))throw new Error(`Native lock coordinator ownership changed: ${e.file}`);await Vo(t,q.dirname(e.file))}}async function ww(e,t){let r=Date.now()+dw;for(;;){let i=await vw(e,t);if(!await gw(i))return i;if(await Wu(i),Date.now()>=r)throw new Error(`Native lock coordinator is busy: ${e.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function yw(e){let t=an.get(e)??Promise.resolve(),r,i=new Promise(a=>{r=a}),n=t.then(()=>i);return an.set(e,n),await t,()=>{r(),an.get(e)===n&&an.delete(e)}}async function zu(e,t,r){let i=q.resolve(e.locksDir),n=Hu.getStore();if(n?.has(i))return r();let a=await yw(i);try{let o=await ww(e,t),s=new Map(n??[]);return s.set(i,o),await Hu.run(s,async()=>{try{return await r()}finally{await Wu(o)}})}finally{a()}}async function sn(e,t,r){return zu(e,`acquire ${t}`,async()=>{let i=await T(e.runtimeDir,e.locksDir);await ee.mkdir(i,{recursive:!0});let n=await T(e.runtimeDir,q.join(i,fw(t))),a=Fu(r),o=await qu(n,a);return{file:n,nativeRoot:e.runtimeDir,locksDir:i,owner:a,identity:o}})}async function cn(e){await ye(e.file)&&await zu({runtimeDir:e.nativeRoot,locksDir:e.locksDir},`release ${q.basename(e.file)}`,async()=>{let t=await ye(e.file);if(!t)return;if(t.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!Mo(t.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);let r=q.join(e.locksDir,Bu);await Vo(t,r)})}function Nw(e){try{return process.kill(e,0),!0}catch(t){let r=t.code;return r==="ESRCH"?!1:r==="EPERM"?!0:null}}async function Ju(e){return Vu(await ye(e))}import Yo from"node:path";import Qw from"node:path";import Qu from"node:path";import{createHash as bw}from"crypto";function le(e){throw new TypeError(`Value is not valid canonical JSON: ${e}`)}function kw(e,t){t.has(e)&&le("cyclic structures are not supported"),t.add(e);try{let r=Object.keys(e);for(let i=0;i<e.length;i+=1)Object.prototype.hasOwnProperty.call(e,i)||le("sparse arrays are not supported");return(r.length!==e.length||r.some((i,n)=>i!==String(n)))&&le("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(e).length>0&&le("symbol properties are not supported"),`[${e.map(i=>Fo(i,t)).join(",")}]`}finally{t.delete(e)}}function Sw(e,t){let r=Object.getPrototypeOf(e);r!==Object.prototype&&r!==null&&le("only plain objects are supported"),t.has(e)&&le("cyclic structures are not supported"),Object.getOwnPropertySymbols(e).length>0&&le("symbol properties are not supported"),t.add(e);try{let i=Object.getOwnPropertyDescriptors(e);return`{${Object.keys(e).sort().map(o=>{let s=i[o];return(!s||!("value"in s))&&le("accessor properties are not supported"),`${JSON.stringify(o)}:${Fo(s.value,t)}`}).join(",")}}`}finally{t.delete(e)}}function Fo(e,t){if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"string":return JSON.stringify(e);case"number":return Number.isFinite(e)||le("numbers must be finite"),JSON.stringify(Object.is(e,-0)?0:e);case"object":return Array.isArray(e)?kw(e,t):Sw(e,t);case"bigint":case"function":case"symbol":case"undefined":return le(`${typeof e} values are not supported`)}return le("unsupported value type")}function qo(e){return Fo(e,new Set)}function U(e,t){if(e.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(e))throw new TypeError("Canonical hash tag must not contain a line break");return bw("sha256").update(`${e}
147
+ ${qo(t)}`).digest("hex")}var Ew="comet.native.acceptance.v1";var OE=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),un=Object.freeze({maxCriteria:1024});function Ku(e){let t=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(e);return t?{level:t[1].length,text:t[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function Gu(e,t){let r=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(e);if(!r)return t;let i=r[1][0];return t===null?{marker:i,length:r[1].length}:i===t.marker&&r[1].length>=t.length&&r[2].trim().length===0?null:t}function Uu(e){return e.includes("-->")||e.includes("--!>")}function*ln(e){let t=null,r=!1,i=null,n=new Set(["code","pre","script","style","svg","template"]),a=e.replace(/\r\n?/gu,`
148
148
  `),o=0,s=0;for(;o<=a.length;){let c=a.indexOf(`
149
- `,o),l=c===-1?a.slice(o):a.slice(o,c);if(yield{line:l,body:e===null&&!r&&i===null,index:s},s+=1,e!==null)e=Gu(l,e);else if(r)Uu(l)&&(r=!1);else if(i!==null)new RegExp(`</${i}\\s*>`,"iu").test(l)&&(i=null);else{let u=Gu(l,null);if(u!==null)e=u;else{let d=l.trimStart();if(d.startsWith("<!--")&&!Uu(d))r=!0;else{let h=/^<([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/u.exec(d);h&&n.has(h[1].toLowerCase())&&!d.startsWith("</")&&!d.endsWith("/>")&&!new RegExp(`</${h[1]}\\s*>`,"iu").test(d)&&(i=h[1])}}}if(c===-1)break;o=c+1}}function Er(t){return t.normalize("NFC").replace(/\s+/gu," ").trim()}function Yu(t,e,r,i=[],n="content-hash"){let a=Er(r),o=e.replaceAll("\\","/").trim(),s=i.map(Er);if(a.length===0)throw new Error(`${t} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${t} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${Y(bw,{kind:t,source:o,context:s,text:a})}`:"",kind:t,source:o,context:s,text:a}}function Xu(t,e,r="content-hash"){let i=new Set;for(let n of t){let a=r==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(i.has(a))throw new Error(`${e} contains duplicate acceptance criteria`);i.add(a)}return t}function kw(t){let e=null,r=null,i=0,n=0;for(let{line:a,body:o,index:s}of ln(t)){n=s+1;let c=o?Ku(a):null;c?.level===1&&(xo(c.text)==="acceptanceExamples"?(i+=1,i===1&&(e=s+1)):e!==null&&r===null&&(r=s))}if(i===0||e===null)return null;if(i!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:e,end:r??n}}function Wo(t,e="brief.md",r=un.maxCriteria,i="content-hash"){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native brief acceptance budget is invalid");let n=kw(t);if(n===null)return[];let a=null;for(let{line:l,body:f,index:u}of ln(t)){if(u<n.start||u>=n.end)continue;let d=f?/^( {0,3})[-*+][ \t]+/u.exec(l):null;if(d===null)continue;let h=d[1].length;a=a===null?h:Math.min(a,h)}let o=[],s=null,c=()=>{if(s!==null){if(o.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);o.push(s)}};for(let{line:l,body:f,index:u}of ln(t)){if(u<n.start||u>=n.end)continue;let d=f?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(l):null;d&&d[1].length===a?(c(),s=[d[2]]):s!==null&&s.push(l)}return c(),Xu(o.map(l=>Yu("brief-example",e,l.join(`
150
- `),[],i)),"Brief",i)}function zo(t,e="spec.md",r=un.maxCriteria,i="content-hash"){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native specification acceptance budget is invalid");let n=[],a=[],o=null,s=()=>{if(o!==null){if(n.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);n.push(Yu("spec-scenario",e,[o.title,...o.body].join(`
151
- `),o.context,i)),o=null}};for(let{line:c,body:l}of ln(t)){let f=l?Ku(c):null,u=f?/^Scenario\s*:\s*(.*)$/iu.exec(f.text):null;if(u){for(s();a.at(-1)&&a.at(-1).level>=f.level;)a.pop();let d=Er(u[1]);if(d.length===0)throw new Error("Scenario title must not be empty");o={level:f.level,title:d,body:[],context:a.map(h=>h.text)}}else if(f){for(o!==null&&f.level<=o.level?s():o!==null&&o.body.push(c);a.at(-1)&&a.at(-1).level>=f.level;)a.pop();a.push(f)}else o!==null&&l&&o.body.push(c)}return s(),Xu(n,"Specification",i)}var Sw=/^A[1-9]\d*$/u;function Zu(t,e){if(t.length===0||t!==t.trim()||t.includes("\\")||Qu.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||Qu.posix.normalize(t)!==t||t==="."||t.endsWith("/"))throw new Error(`${e} must be a normalized change-relative ref`);return t}function Ew(t,e){return t.localeCompare(e,"en")}function Jo(t){let e=Zu(t.briefSource??"brief.md","Native brief source"),r=[...t.specs??[]].sort((a,o)=>Ew(a.capability,o.capability));if(new Set(r.map(a=>a.capability)).size!==r.length)throw new Error("Native acceptance sources contain duplicate capabilities");let i=Wo(t.briefMarkdown,e,Number.MAX_SAFE_INTEGER,"none").map(({source:a,text:o})=>({source:a,text:o}));for(let a of r){let o=Zu(a.source,`Native spec source for ${a.capability}`);i.push(...zo(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})))}let n=new Set;for(let a of i){a.text=Er(a.text);let o=`${a.source}\0${a.text}`;if(n.has(o))throw new Error(`Native acceptance contains a duplicate criterion: ${a.text}`);n.add(o)}if(i.length===0)throw new Error("Native change must define at least one acceptance criterion");return i.map((a,o)=>({id:`A${o+1}`,source:a.source,text:a.text}))}function ed(t){let e=t.map(({id:r})=>r);if(new Set(e).size!==e.length)throw new Error("Native acceptance IDs must be unique");for(let r=0;r<e.length;r+=1)if(!Sw.test(e[r])||e[r]!==`A${r+1}`)throw new Error("Native acceptance IDs must be the contiguous sequence A1..An")}var pn=Bt(xt(),1);import{promises as Cw}from"node:fs";var xw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Pw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Rw=/^A[1-9][0-9]*$/u,Aw=/^[a-f0-9]{64}$/u,_w=new Set(["schema","name","language","phase","status","state_version","brief","children_contract_hash","coordination_mode","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),fn=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"};function W(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function z(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 B(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 Go(t,e){return t===null?null:B(t,e)}function Iw(t,e){let r=B(t,e);if(!Aw.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function Tt(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function I(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 Tw(t,e){return t===null?null:I(t,e,Number.MIN_SAFE_INTEGER)}function $(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Ne(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function hn(t,e){return Ne(t,e,(r,i)=>B(r,`${e}[${i}]`))}function ct(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function jt(t,e){let r=B(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function Uo(t,e,r=!1){let i=B(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 te(t,e){let r=W(t,e);return z(r,new Set(["text","truncated"]),e),{text:B(r.text,`${e}.text`,{empty:!0}),truncated:Tt(r.truncated,`${e}.truncated`)}}function jw(t,e){let r=`Native spec_changes[${e}]`,i=W(t,r);z(i,new Set(["capability","operation","source"]),r);let n=B(i.capability,`${r}.capability`);if(!Pw.test(n))throw new Error(`${r}.capability is invalid`);let a=$(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:Uo(i.source,`${r}.source`);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`);return{capability:n,operation:a,source:o}}function $w(t){let e="Native workspace",r=W(t,e);z(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=$(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=Go(r.change_branch,`${e}.change_branch`),a=Go(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:$(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 Ow(t){let e="Native loop",r=W(t,e);z(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=hn(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);ct(i,`${e}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:$(r.stop_reason,["budget","stalled"],`${e}.stop_reason`);return{stage:$(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:I(r.goal_cycle,`${e}.goal_cycle`,1),iteration:I(r.iteration,`${e}.iteration`),attempt:I(r.attempt,`${e}.attempt`),retry_epoch:I(r.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:I(r.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:I(r.no_progress_count,`${e}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:I(r.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:i,next_action:Go(r.next_action,`${e}.next_action`)}}function Hw(t,e){let r=`Native acceptance[${e}]`,i=W(t,r);z(i,new Set(["id","source","text","result","reason"]),r);let n=B(i.id,`${r}.id`);if(!Rw.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:Uo(i.source,`${r}.source`),text:B(i.text,`${r}.text`),result:$(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:te(i.reason,`${r}.reason`)}}function Dw(t,e){let r=`Native builder_handoff.checks[${e}]`,i=W(t,r);return z(i,new Set(["name","result","note"]),r),{name:te(i.name,`${r}.name`),result:$(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:te(i.note,`${r}.note`)}}function Lw(t){let e="Native builder_handoff",r=W(t,e);z(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),e);let i=hn(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);ct(i,`${e}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:W(r.review,`${e}.review`);return n&&z(n,new Set(["status","summary","reviewer_execution_ref"]),`${e}.review`),{candidate_id:B(r.candidate_id,`${e}.candidate_id`),identity_provider:B(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:B(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:I(r.iteration,`${e}.iteration`,1),summary:te(r.summary,`${e}.summary`),addressed_acceptance_ids:i,checks:Ne(r.checks,`${e}.checks`,Dw),checks_truncated:Tt(r.checks_truncated,`${e}.checks_truncated`),known_limits:Ne(r.known_limits,`${e}.known_limits`,(a,o)=>te(a,`${e}.known_limits[${o}]`)),known_limits_truncated:Tt(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:$(n.status,["passed"],`${e}.review.status`),summary:te(n.summary,`${e}.review.summary`),reviewer_execution_ref:B(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:jt(r.submitted_at,`${e}.submitted_at`)}}function Bw(t,e){let r=`Native blockers[${e}]`,i=W(t,r);z(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=hn(i.acceptance_ids,`${r}.acceptance_ids`);return ct(n,`${r}.acceptance_ids`),{owner:$(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:te(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:$(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function Vw(t,e){let r=`Native verification.checks[${e}]`,i=W(t,r);return z(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:B(i.id,`${r}.id`),name:te(i.name,`${r}.name`),argv_display:Ne(i.argv_display,`${r}.argv_display`,(n,a)=>te(n,`${r}.argv_display[${a}]`)),argv_truncated:Tt(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:Uo(i.cwd_ref,`${r}.cwd_ref`,!0),status:$(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:Tw(i.exit_code,`${r}.exit_code`),duration_ms:I(i.duration_ms,`${r}.duration_ms`)}}function Mw(t){let e="Native verification",r=W(t,e);z(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let i=Ne(r.checks,`${e}.checks`,Vw);ct(i.map(a=>a.id),`${e}.checks IDs`);let n=B(r.identity_provider,`${e}.identity_provider`);return{candidate_id:B(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:B(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:I(r.iteration,`${e}.iteration`,1),attempt:I(r.attempt,`${e}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":$(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:$(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:te(r.summary,`${e}.summary`),risks:Ne(r.risks,`${e}.risks`,(a,o)=>te(a,`${e}.risks[${o}]`)),risks_truncated:Tt(r.risks_truncated,`${e}.risks_truncated`),completed_at:jt(r.completed_at,`${e}.completed_at`)}}function Fw(t,e){let r=`Native history[${e}]`,i=W(t,r);z(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=hn(i.unresolved_ids,`${r}.unresolved_ids`);return ct(n,`${r}.unresolved_ids`),{goal_cycle:I(i.goal_cycle,`${r}.goal_cycle`,1),iteration:I(i.iteration,`${r}.iteration`),attempt:I(i.attempt,`${r}.attempt`),outcome:$(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:te(i.summary,`${r}.summary`),completed_at:jt(i.completed_at,`${r}.completed_at`)}}function qw(t){let e="Native history_overflow.outcome_counts",r=W(t,e),i=["pass","fail","blocked","execution-error","recovery"];return z(r,new Set(i),e),{pass:I(r.pass,`${e}.pass`),fail:I(r.fail,`${e}.fail`),blocked:I(r.blocked,`${e}.blocked`),"execution-error":I(r["execution-error"],`${e}.execution-error`),recovery:I(r.recovery,`${e}.recovery`)}}function Ww(t){let e="Native history_overflow",r=W(t,e);z(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let i=I(r.dropped_entries,`${e}.dropped_entries`),n=r.first_dropped_at===null?null:jt(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:jt(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=qw(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 zw(t){let e=new Set(t.acceptance.map(r=>r.id));for(let r of t.loop.previous_unresolved_ids)if(!e.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);for(let r of t.blockers)for(let i of r.acceptance_ids)if(!e.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(t.builder_handoff){if(!(t.builder_handoff.iteration===t.loop.iteration||t.phase==="build"&&t.loop.stage==="repairing"&&t.builder_handoff.iteration===t.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(t.builder_handoff.review?.reviewer_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(t.verification){if(!t.builder_handoff)throw new Error("Native verification requires a builder handoff");if(t.verification.candidate_id!==t.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(t.verification.identity_provider!==t.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(t.verification.assurance)!==(t.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(t.verification.assurance==="semantic-verification-unavailable"&&t.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(t.verification.assurance==="user-confirmed-degraded"&&t.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(t.verification.verifier_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=t.verification.iteration===t.loop.iteration&&t.verification.attempt===t.loop.attempt,n=t.phase==="build"&&t.loop.stage==="repairing"&&t.verification.iteration===t.loop.iteration-1&&t.verification.iteration===t.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Jw(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 lt(t){let e=W(t,"Native portable state");if(z(e,_w,"Native portable state"),e.schema!==pt)throw new Error(`Native portable state schema must be ${pt}`);let r=B(e.name,"Native state name");if(!xw.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=Ne(e.spec_changes,"Native spec_changes",jw);ct(i.map(s=>s.capability),"Native spec change capabilities");let n=Ne(e.acceptance,"Native acceptance",Hw);ct(n.map(s=>s.id),"Native acceptance IDs");let a=Ne(e.history,"Native history",Fw);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:pt,name:r,language:$(e.language,["en","zh-CN"],"Native state language"),phase:$(e.phase,["shape","build","verify","archive"],"Native state phase"),status:$(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:I(e.state_version,"Native state_version",1),brief:"brief.md",...e.children_contract_hash===void 0?{}:{children_contract_hash:Iw(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:$(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:$w(e.workspace),loop:Ow(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Lw(e.builder_handoff),blockers:Ne(e.blockers,"Native blockers",Bw),verification:e.verification===null?null:Mw(e.verification),history:a,history_overflow:Ww(e.history_overflow),verification_result:$(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:$(e.verification_report,["verification.md"],"Native verification_report"),archived:Tt(e.archived,"Native archived"),created_at:jt(e.created_at,"Native created_at")};return zw(o),Jw(o),o}function Gw(t,e){let r=(0,pn.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 Ae(t){let e=await Cw.readFile(t,"utf8");return lt(Gw(e,"Native portable state"))}async function mn(t,e,r={}){let i=lt(e);await pe(t,(0,pn.stringify)(i),r)}var dn=new Map;async function Uw(t,e){let r=dn.get(t)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);dn.set(t,a),await r;try{return await e()}finally{i(),dn.get(t)===a&&dn.delete(t)}}async function rd(t){return Uw(t.file,async()=>{let e=I(t.expectedStateVersion,"Native expected state version",1),r=lt(t.next);if(r.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await Ae(t.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==e)throw new fn(e,i.state_version);return await mn(t.file,r,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await Ae(t.file);if(n.state_version!==e)throw new fn(e,n.state_version)}}),r})}function Kw(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function vn(t,e=16384){if(typeof t!="string")throw new Error("Native portable text must be a string");if(Kw(e),Buffer.byteLength(t,"utf8")<=e)return{text:t,truncated:!1};let r="",i=0;for(let n of t){let a=Buffer.byteLength(n,"utf8");if(i+a>e)break;r+=n,i+=a}return{text:r,truncated:!0}}var _e="comet.native.v3",be="comet.native.v2",ke="comet.native.v1";var gn="comet.native.portable-migration.v1",Xw=new Set(["schema","id","change","fromSchema","status","createdAt"]),Qw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Zw=/^[a-z0-9][a-z0-9-]{7,127}$/u,ey=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),ty=new Set([ke,be,_e]);function ry(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function iy(t,e){let r=t instanceof Date?new Date(t.valueOf()):new Date(t);if(Number.isNaN(r.valueOf()))throw new Error(`${e} must be a valid timestamp`);return r.toISOString()}function ny(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let r=new Date(t);if(Number.isNaN(r.valueOf())||r.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function ay(t){return t.schema===ke?Cr(t):t.schema===be?xr(t):Pr(t)}function oy(t){return Yw.posix.normalize(t.replaceAll("\\","/"))}function sy(t){return t.spec_changes.map(e=>e.operation==="remove"?{capability:e.capability,operation:"remove",source:null}:{capability:e.capability,operation:e.operation==="replace"?"modify":"create",source:oy(e.source)})}function cy(t){return t==="shape"?"shape":"build"}function ly(t,e){return t==="zh-CN"?e==="shape"?"继续澄清并确认验收项":"重新提交候选实现":e==="shape"?"Continue clarification and confirm acceptance":"Submit a fresh implementation candidate"}function uy(t,e,r){return t==="zh-CN"?`从旧版 ${e} ${r} 状态恢复;旧版 Loop、验证结论和运行记录未继承。`:`Recovered from legacy ${e} ${r} state; prior Loop, verification results, and execution records were not inherited.`}function id(t){let e=ay(t.state);ed(t.acceptance);let r=cy(e.phase),i=r==="shape"?0:1,n=iy(t.migratedAt??`${e.created_at}T00:00:00.000Z`,"Native portable migration time"),a=t.acceptance.map(o=>({id:o.id,source:o.source,text:o.text,result:"pending",reason:null}));return lt({schema:pt,name:e.name,language:e.language,phase:r,status:"active",state_version:1,brief:"brief.md",spec_changes:sy(e),workspace:t.workspace,loop:{stage:r==="shape"?"shape":"building",goal_cycle:1,iteration:i,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:ly(e.language,r)},acceptance:a,builder_handoff:null,blockers:[],verification:null,history:[{goal_cycle:1,iteration:i,attempt:0,outcome:"recovery",unresolved_ids:a.map(({id:o})=>o),summary:vn(uy(e.language,e.schema,e.phase)),completed_at:n}],history_overflow:Vn(),verification_result:"pending",verification_report:null,archived:!1,created_at:`${e.created_at}T00:00:00.000Z`})}function Ko(t){let e=ry(t,"Native portable migration transaction"),r=Object.keys(e).filter(i=>!Xw.has(i));if(r.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${r.join(", ")}`);if(e.schema!==gn)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!Zw.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!Qw.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!ty.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!ey.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:gn,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:ny(e.createdAt,"Native portable migration transaction createdAt")}}function nd(t){switch(Ko(t).status){case"prepared":return{action:"commit-portable-yaml",fromStatus:"prepared",nextStatus:"yaml-committed"};case"yaml-committed":return{action:"cleanup-legacy-runtime",fromStatus:"yaml-committed",nextStatus:"legacy-cleanup"};case"legacy-cleanup":return{action:"commit-transaction",fromStatus:"legacy-cleanup",nextStatus:"committed"};case"committed":return{action:"done",fromStatus:"committed",nextStatus:null}}}var ad="comet.native.archive-transaction.v4",od="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",dy=new RegExp(`^portable-archive-(${od})\\.json$`,"u"),fy=new RegExp(`^portable-migration-(${od})\\.json$`,"u"),py=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,hy=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,my=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),vy=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),gy=new Set(["capability","operation","source","content"]),sd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function cd(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ld(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(", ")}`);if(Object.keys(t).length!==e.size)throw new Error(`${r} fields are invalid`)}function wy(t,e){let r=`Native portable Archive spec_changes[${e}]`,i=cd(t,r);if(ld(i,gy,r),typeof i.capability!="string"||!sd.test(i.capability))throw new Error(`${r}.capability is invalid`);if(!["create","modify","remove"].includes(String(i.operation)))throw new Error(`${r}.operation is invalid`);let n=i.operation;if(n==="remove"){if(i.source!==null||i.content!==null)throw new Error(`${r} remove requires source and content null`);return{capability:i.capability,operation:n,source:null,content:null}}if(typeof i.source!="string"||i.source.length===0||i.source.includes("\\")||i.source.startsWith("/")||/^[A-Za-z]:/u.test(i.source)||i.source.split("/").some(a=>a==="."||a===".."))throw new Error(`${r}.${n} source is invalid`);if(typeof i.content!="string")throw new Error(`${r}.${n} content is invalid`);return{capability:i.capability,operation:n,source:i.source,content:i.content}}function yy(t){let e=cd(t,"Native portable Archive transaction");if(ld(e,vy,"Native portable Archive transaction"),e.schema!==ad)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!py.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!sd.test(e.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(e.start_state_version)||Number(e.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof e.archive_ref!="string"||!hy.test(e.archive_ref)||!e.archive_ref.endsWith(`-${e.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof e.status!="string"||!my.has(e.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let r=e.spec_changes.map(wy);if(new Set(r.map(({capability:n})=>n)).size!==r.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>r.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof e.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let i=new Date(e.created_at);if(Number.isNaN(i.valueOf())||i.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:ad,id:e.id,change:e.change,start_state_version:Number(e.start_state_version),archive_ref:e.archive_ref,status:e.status,next_spec_index:Number(e.next_spec_index),spec_changes:r,created_at:e.created_at}}function wn(t){let e=dy.exec(t);if(e)return{kind:"archive",change:e[1]};let r=fy.exec(t);return r?{kind:"migration",change:r[1]}:null}function yn(t,e){let r=`${e.kind==="archive"?"portable-archive":"portable-migration"}-${e.change}.json`,i=wn(r);if(!i||i.kind!==e.kind||i.change!==e.change)throw new Error(`Invalid Native portable transaction change: ${e.change}`);return Yo.join(t.transactionsDir,r)}async function Xo(t,e){let r=wn(e);if(!r)return null;let i=await M({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(i.text),a=Yo.join(t.transactionsDir,e);if(r.kind==="archive"){let s=yy(n);if(s.change!==r.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:r.change,file:a,journal:s}}let o=Ko(n);if(o.change!==r.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:r.change,file:a,journal:o}}async function Qo(t,e){let r=yn(t,e);try{return await Xo(t,Yo.basename(r))}catch(i){if(i.code==="ENOENT")return null;throw i}}function ud(t){return t.kind==="archive"||t.journal.status!=="committed"}import Ie from"path";import{TextDecoder as Py}from"util";import{createHash as Ny}from"node:crypto";import{constants as Nn,promises as ue}from"node:fs";import de from"node:path";function kn(t,e){let r=de.relative(t,e);return r===""||!de.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${de.sep}`)}function by(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function ky(t,e){return _({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Sy(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function bn(t,e){return _({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Zo(t,e){let r=await ue.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await ue.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function Ey(t,e,r){let i=de.resolve(t),n=de.resolve(e);if(!kn(i,n))throw new Error(`${r} is outside its managed root`);let a=[await Zo(i,r)],o=i;for(let s of de.relative(i,n).split(de.sep).filter(Boolean)){await ut(a,r),o=de.join(o,s);let c=await Zo(o,r);if(!kn(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await ut(a,r),a}async function ut(t,e){for(let r of t){let i=await ue.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!ky(r,i)||await ue.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function Cy(t,e,r){let i=[],n=0,a=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let o=e+1-n,{bytesRead:s}=await t.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,n>e)throw new Error(`${r} exceeds ${e} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function $t(t){let e=by(t.maxBytes),r=de.resolve(t.file),i=await Ey(t.root,de.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(f=>Zo(de.resolve(f),t.label)));await t.hooks?.afterParentChainCaptured?.(),await ut(i,t.label);let a=await ue.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(a.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let o=Sy(a),s=await ue.realpath(r);if(!kn(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(f=>kn(f.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?Nn.O_RDONLY:Nn.O_RDONLY|Nn.O_NOFOLLOW|Nn.O_NONBLOCK,l=await ue.open(r,c);try{let f=await l.stat();await t.hooks?.afterOpen?.();let[u,d]=await Promise.all([ue.lstat(r),ue.realpath(r)]);if(await ut(i,t.label),await ut(n,t.label),!f.isFile()||!u.isFile()||u.isSymbolicLink()||d!==s||!bn(o,f)||!bn(o,u))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let h=await Cy(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[v,p,m]=await Promise.all([l.stat(),ue.lstat(r),ue.realpath(r)]);if(await ut(i,t.label),await ut(n,t.label),!p.isFile()||p.isSymbolicLink()||m!==s||!bn(o,v)||!bn(o,p))throw new Error(`${t.label} changed while reading`);return{bytes:h,hash:Ny("sha256").update(h).digest("hex"),size:h.length}}finally{await l.close()}}var Ry=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),Ay=new Set(["id","type","source","target","staged","backup"]),_y=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Iy=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var pd=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var Ty=256*1024,mC=1024*1024,vC=16*1024;var gC=64*1024*1024;var jy=new Py("utf-8",{fatal:!0});function En(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Cn(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 hd(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function es(t,e){if(typeof t!="string"||t.length===0||Ie.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function Sn(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function dd(t,e){if(es(t,e),t.includes("\\")||t!==Ie.posix.normalize(t)||t.split("/").includes(".")||t.endsWith("/")||Buffer.byteLength(t,"utf8")>1024)throw new Error(`${e} must be a normalized Native-relative ref`)}function $y(t,e){let r=En(t,`transaction operations[${e}]`);if(Cn(r,Ay,`transaction operations[${e}]`),typeof r.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(r.id))throw new Error(`transaction operations[${e}].id is invalid`);if(r.type!=="write"&&r.type!=="remove"&&r.type!=="move")throw new Error(`transaction operation ${r.id} has an invalid type`);es(r.target,`transaction operation ${r.id} target`);for(let i of["source","staged","backup"])r[i]!==void 0&&es(r[i],`transaction operation ${r.id} ${i}`);if(r.type==="write"){if(r.staged===void 0||r.source!==void 0)throw new Error(`write operation ${r.id} requires staged and forbids source`)}else if(r.type==="remove"){if(r.source!==void 0||r.staged!==void 0)throw new Error(`remove operation ${r.id} forbids source and staged`)}else if(r.source===void 0||r.staged!==void 0||r.backup!==void 0)throw new Error(`move operation ${r.id} requires source and forbids staged and backup`);return r}function md(t){let e=En(t,"Native Archive transaction journal");if(Cn(e,_y,"Native Archive transaction journal"),e.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native Archive transaction id is invalid");if(e.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof e.status!="string"||!pd.has(e.status))throw new Error("Native Archive transaction status is invalid");if(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change))throw new Error("Native Archive transaction change name is invalid");if(!hd(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Sn(e.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(e.operations)||e.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let r=e.operations.map((s,c)=>{let l=En(s,`Archive transaction operations[${c}]`);if(Cn(l,Iy,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);dd(l.target,`Archive transaction operation ${l.id} target`);for(let f of["source","staged","backup"])l[f]!==void 0&&dd(l[f],`Archive transaction operation ${l.id} ${f}`);if(l.expectedTargetHash!==null&&Sn(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(Sn(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);Sn(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),i=r.map(s=>s.id);if(new Set(i).size!==i.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=r.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${e.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${e.change}$`,"u").test(a[0].target)||r.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of r.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:r}}function Oy(t){let e=En(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return md(e);if(Cn(e,Ry,"Native transaction journal"),e.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native transaction id is invalid");if(e.kind!=="archive"&&e.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof e.status!="string"||!pd.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!Ie.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!Ie.isAbsolute(e.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(e.change!==void 0&&(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change)))throw new Error("Native transaction change name is invalid");if(!hd(e.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(e.operations))throw new Error("Native transaction operations must be an array");let r=e.operations.map($y),i=r.map(n=>n.id);if(new Set(i).size!==i.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:e.id,kind:e.kind,status:e.status,projectRoot:e.projectRoot,nativeRoot:e.nativeRoot,...typeof e.change=="string"?{change:e.change}:{},createdAt:e.createdAt,operations:r}}function Hy(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return Ie.join(t.transactionsDir,e)}function vd(t,e){let r=Hy(t,e);return{directory:r,journal:Ie.join(r,"transaction.json"),events:Ie.join(r,"events.jsonl"),staged:Ie.join(r,"staged"),backups:Ie.join(r,"backups")}}async function rs(t,e){let r=vd(t,e);return await Promise.all(Object.values(r).map(i=>T(t.runtimeDir,i))),r}async function is(t,e,r={}){let i=await rs(t,e),n=await $t({root:t.runtimeDir,file:i.journal,maxBytes:Ty,label:`Native transaction journal ${e}`,hooks:r.hooks}),a=JSON.parse(jy.decode(n.bytes)),o=Oy(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}async function By(t,e,r){let i;try{i=await Dy.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await is(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of i)if(wn(n.name))try{let a=await Xo(t,n.name);if(!a||r?.kind===a.kind&&r.change===a.change)continue;if(ud(a))return!0}catch{return!0}return!1}async function Vy(t,e){let r=Date.now()+5e3,i=Ly.join(t.locksDir,"root-move.lock");for(;;)try{return await sn(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Ju(i);if(o.status==="missing")continue;if(o.status!=="active"||Date.now()>=r)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function X(t,e,r,i){let n=await Vy(t,e);try{if(await nn(t.projectRoot),await By(t,i?.allowedTransactionId,i?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await r()}finally{await cn(n)}}import{createHash as My}from"crypto";function re(t){return My("sha256").update(t).digest("hex")}var LC={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024};var BC=8*1024*1024;var VC=64*1024,MC=64*1024;var FC={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},qC={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};var WC=(1n<<256n)-1n;var Uy=Bt(xt(),1);var ox=4*1024*1024;var Ky=null;function Yy(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function gd(t,e){return(...r)=>{let i=Ky;if(i===null)return e(...r);let n=Yy(`async:${t}`,r),a=i.entries.get(n);if(a)return a.value;let o=e(...r).catch(s=>{throw i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}var dx=gd("hookWritePolicy",async t=>(await $o(t))?.hook??{allow_paths:[]});var cP=256*1024;var bP={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};import Ot from"node:path";var Rr=/^[a-f0-9]{64}$/u,yd=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,Qy=16*1024,HP=process.platform;function Zy(t,e){let r=Ot.relative(t,e);return Ot.isAbsolute(r)||r===".."||r.startsWith(`..${Ot.sep}`)?null:r.replaceAll("\\","/")||"."}function kd(t){return Array.from(t).some(e=>{let r=e.codePointAt(0)??0;return r<=31||r===127})}function Sd(t,e){if(t.length===0||kd(t)||t.includes("\\")||Ot.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=Ot.posix.normalize(t);if(r!==t||r===".."||r.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return r}function eN(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 ns(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||kd(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function tN(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(ns(t.changeBranch,"Native workspace change branch"),ns(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 rN(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"||!yd.test(e.baseCommit)||typeof e.targetCommit!="string"||!yd.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");ns(e.targetBranch,"Native workspace Git target branch")}function iN(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"||!Rr.test(String(e.projectRootId))||!Rr.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");eN(e.capturedAt),Sd(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&&!Rr.test(String(e.projectRootPathId))||a&&!Rr.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!Rr.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&rN(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(tN(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 nN(t,e){return Ot.join(ve(t,e),"workspace.json")}function aN(t,e){let r=nN(t,e),i=ge(t,r),n=Zy(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:Sd(n,"Native workspace file ref")}}async function oN(t,e){try{let r=aN(t,e),i=await M({root:r.root,ref:r.ref,maxBytes:Qy});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Ar(t,e){let r=await oN(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(iN(r),r)}var Cd=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],cN=new Set(Cd),xd=new Set([...Cd,"minimum_runtime_version","revision"]),lN=new Set([...xd,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),uN=new Set(["capability","operation","source","base_hash"]),dN=new Set(["shape","build","verify","archive"]),fN=new Set(["implicit","confirmed"]),pN=new Set(["pending","pass","fail"]),dt="comet-state.yaml",os=/^[a-f0-9]{64}$/u,Pd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,hN=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,ss=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"},Dt=class extends Error{constructor(r,i){super(r!==_e||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"},xn=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"},_r=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"},Pn=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"},cR=qi("en");function Tr(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Rd(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 us(t){if(!Pd.test(t))throw new Error(`Invalid Native change name: ${t}`)}function mN(t){if(!Pd.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Ad(t,e){if(t.length===0||Ht.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function vN(t,e){let r=Tr(t,`spec_changes[${e}]`);if(Rd(r,uN,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(mN(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"&&Ad(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"||!os.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"||!os.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 gN(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 ds(t,e){if(Rd(t,e,dt),typeof t.name!="string")throw new Error("Native change name is required");if(us(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"||!dN.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&&!fN.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(vN),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"||!pN.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"&&Ad(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!gN(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 Cr(t){let e=Tr(t,dt);if(e.schema!==ke)throw new Error(`Expected ${ke}`);return{schema:ke,...ds(e,cN)}}function Ir(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function as(t,e,r){if(t===null)return null;let i=typeof t=="string"?hN.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 wN(t){if(t==null)return null;if(typeof t!="string"||!os.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function yN(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 xr(t){let e=Tr(t,dt);if(e.schema!==be)throw new Error(`Expected ${be}`);if(Ir(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${be} minimum_runtime_version must be 2`);return{schema:be,minimum_runtime_version:2,revision:Ir(e.revision,"Native v2 revision"),...ds(e,xd)}}function Pr(t){let e=Tr(t,dt);if(e.schema!==_e){if(e.schema===ke||e.schema===be){let o=e.schema===ke?Cr(e):xr(e);throw new ss(o.name,o.schema)}throw new Dt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=Ir(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Dt(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=Ir(e.revision,"Native revision"),n=ds(e,lN),a=wN(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:_e,minimum_runtime_version:3,revision:i,verification_protocol:yN(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:as(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:as(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:as(e.partial_allowance,"Native partial_allowance","allowances")}}function NN(t){let e=Tr(t,dt);if(e.schema===ke){let n=Cr(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${_e}`}}if(e.schema===be){let n=xr(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${_e}`}}if(e.schema!==_e){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 Dt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=Ir(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new Dt(e.schema,r).message};let i=Pr(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}function Se(t,e){us(e);let r=Ht.join(t.changesDir,e);if(!F(t.changesDir,r))throw new Error("Native change path escaped");return r}async function bN(t,e=Ht.dirname(t)){let r=Ht.relative(e,t).split(Ht.sep).join("/"),i=await M({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,ls.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 _d(t,e){let r=Ht.join(Se(t,e),dt);await T(t.nativeRoot,r);let i=NN(await bN(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return i}import{promises as $d}from"node:fs";import On from"node:path";var xN=Bt(xt(),1);var uR=8*1024*1024;var Rn=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};var qR=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");import{promises as TN}from"node:fs";import $r from"node:path";function An(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function _n(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 Ee(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 Td(t,e){return t===null?null:Ee(t,e)}function Tn(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 jN(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 $N(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function In(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function fs(t,e){if(t===null)return null;let r=Ee(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function ps(t,e){let r=Ee(t,e);if(!$r.isAbsolute(r))throw new Error(`${e} must be absolute`);return $r.resolve(r)}function ON(t,e){let r=`Native local checks[${e}]`,i=An(t,r);if(_n(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),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((l,f)=>Ee(l,`${r}.argv[${f}]`,!0)),a=In(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=fs(i.startedAt,`${r}.startedAt`),s=fs(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=Tn(i.timeoutMs,`${r}.timeoutMs`);if(c<1)throw new Error(`${r}.timeoutMs must be positive`);return{id:Ee(i.id,`${r}.id`),name:Ee(i.name,`${r}.name`),operationId:Ee(i.operationId,`${r}.operationId`),status:a,repeatable:$N(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:Tn(i.executionCount,`${r}.executionCount`),argv:n,cwd:ps(i.cwd,`${r}.cwd`),exitCode:jN(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:Ee(i.log,`${r}.log`)}}function jd(t){let e="Native local execution state",r=An(t,e);if(_n(r,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),e),r.schema!==Vt)throw new Error(`Native local execution schema must be ${Vt}`);let i=An(r.workspace,"Native local workspace");_n(i,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(r.execution!==null){let o=An(r.execution,"Native local execution");_n(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=fs(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Ee(o.operationId,"Native local execution.operationId"),stage:In(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:In(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Td(o.executionId,"Native local execution.executionId"),status:In(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Tn(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(ON);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:Vt,change:Ee(r.change,"Native local change"),basedOnStateVersion:Tn(r.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:ps(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:ps(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Td(i.branch,"Native local workspace.branch")},execution:n,checks:a}}function jn(t){return jd({schema:Vt,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,workspace:{projectRoot:$r.resolve(t.projectRoot),worktreeRoot:$r.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null},execution:null,checks:[]})}async function $n(t,e,r={}){let i=jd(e);await TN.mkdir($r.dirname(t),{recursive:!0}),await U(t,i,r)}var Od=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,LN="comet-state.yaml",BN="state.json",b_=qi("en");function Hd(t,e){if(!Od.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=On.join(t.changesDir,e);if(!F(t.changesDir,r))throw new Error("Native change path escaped");return r}function Ye(t,e){return On.join(Hd(t,e),LN)}function hs(t,e){return On.join(Ue(t,e),BN)}async function Or(t,e){try{let r=await $d.readFile(Ye(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function VN(t){return ie(t).currentBranch}async function Dd(t,e){return Ae(Ye(t,e))}async function MN(t){let e=await rd({file:Ye(t.paths,t.previous.name),expectedStateVersion:t.previous.state_version,next:t.next,containedRoot:t.paths.nativeRoot});if(e.verification===null&&e.verification_report===null){let r=On.join(Hd(t.paths,e.name),"verification.md");await T(t.paths.nativeRoot,r),await $d.rm(r,{force:!0})}return e}async function Ld(t){if(!Od.test(t.capability))throw new Error(`Invalid Native capability: ${t.capability}`);return X(t.paths,`remove portable spec ${t.capability}`,async()=>{let e=await Dd(t.paths,t.name);if(e.archived)throw new Error(`Native change ${e.name} is already archived`);let r=e.spec_changes.filter(({capability:a})=>a!==t.capability),i={...e,phase:"shape",status:"active",state_version:e.state_version+1,spec_changes:[...r,{capability:t.capability,operation:"remove",source:null}].sort((a,o)=>a.capability.localeCompare(o.capability,"en")),acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,history:[],history_overflow:{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}},loop:{stage:"shape",goal_cycle:e.loop.goal_cycle+(e.phase==="shape"?0:1),iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"confirm-shape"}};delete i.children_contract_hash;let n=await MN({paths:t.paths,previous:e,next:i});return await $n(hs(t.paths,e.name),jn({portableState:n,projectRoot:t.paths.projectRoot,branch:VN(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n})}var Bd=["evidence.md","repair.md","archive.md","checkpoint.md"],WN="verification.md";async function zN(t,e){let r=await Qo(t,{kind:"migration",change:e});return r?.kind==="migration"?r.journal:null}async function Vd(t,e){await Hr.mkdir(t.transactionsDir,{recursive:!0}),await U(yn(t,{kind:"migration",change:e.change}),e,{containedRoot:t.runtimeDir})}async function Md(t,e,r={}){let i=r.removeVerificationReport===!1?Bd:[...Bd,WN];await Promise.all([Hr.rm(Ue(t,e),{recursive:!0,force:!0}),Hr.rm(Bo(t,e),{recursive:!0,force:!0}),...i.map(n=>Hr.rm(qN.join(Se(t,e),n),{force:!0}))])}async function Fd(t,e){await $n(hs(t,e.name),jn({portableState:e,projectRoot:t.projectRoot}),{containedRoot:t.runtimeDir})}async function qd(t,e){try{let r=await Ar(t,e);if(r?.schema==="comet.native.workspace.v3")return{isolation:r.isolation,change_branch:r.changeBranch,target_branch:r.targetBranch,finish:r.finish}}catch{}return{isolation:"current",change_branch:null,target_branch:null,finish:null}}function Wd(t,e){if(e.isolation==="current"&&e.change_branch===null)return;let r=ie(t.projectRoot);if(!r.isGitWorktree)throw new Error("Native legacy migration requires its bound Git branch or worktree");if(r.currentBranch!==e.change_branch)throw new Error(`Native legacy migration expected branch ${e.change_branch??"(missing)"}, current branch is ${r.currentBranch??"(detached)"}`);if(e.isolation==="worktree"&&!r.isSecondaryWorktree)throw new Error("Native legacy migration requires its bound linked worktree")}async function JN(t){let e=Se(t.paths,t.state.name),r=await M({root:e,ref:t.state.brief,maxBytes:null,includeHash:!1}),i=[];for(let n of t.state.spec_changes){if(n.operation==="remove"||!n.source)continue;let a=await M({root:e,ref:n.source,maxBytes:null,includeHash:!1});i.push({capability:n.capability,source:a.ref,markdown:a.text})}try{return Jo({briefMarkdown:r.text,specs:i})}catch(n){if(t.state.phase==="shape"&&n.message.includes("at least one acceptance"))return[];throw n}}async function zd(t,e){let r=await _d(t,e);if(!r.state)throw new Error(`Native legacy change ${e} is unreadable`);return r.state}async function Jd(t){return X(t.paths,`migrate ${t.name} to portable Native`,async()=>{let e=await zN(t.paths,t.name),r=await Or(t.paths,t.name)?await Ae(Ye(t.paths,t.name)):null;if(!e&&r)return await Md(t.paths,t.name,{removeVerificationReport:!1}),await Fd(t.paths,r),r;let i=null,n=null;for(e||(i=await zd(t.paths,t.name),n=await qd(t.paths,t.name),Wd(t.paths,n),e={schema:gn,id:FN(),change:i.name,fromSchema:i.schema,status:"prepared",createdAt:(t.now??new Date).toISOString()},await Vd(t.paths,e));;){let a=nd(e);if(a.action==="done")break;a.action==="commit-portable-yaml"?r||(i??=await zd(t.paths,t.name),n??=await qd(t.paths,t.name),Wd(t.paths,n),r=id({state:i,acceptance:await JN({paths:t.paths,state:i}),workspace:n,migratedAt:t.now}),await mn(Ye(t.paths,t.name),r,{containedRoot:t.paths.nativeRoot})):a.action==="cleanup-legacy-runtime"?await Md(t.paths,t.name):a.action==="commit-transaction"&&(r??=await Ae(Ye(t.paths,t.name)),await Fd(t.paths,r)),e={...e,status:a.nextStatus},await Vd(t.paths,e)}return await Hr.rm(yn(t.paths,{kind:"migration",change:t.name}),{force:!0}),r??Ae(Ye(t.paths,t.name))},{allowedPortableTransaction:{kind:"migration",change:t.name}})}import Lr from"path";import{realpathSync as Fb}from"fs";var Te={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Gd(t){return t?t.command?`${Te.next} ${t.command}`:t.ask_user?`${Te.next} ${t.ask_user}`:null:null}function Ud(t,e){let r=[t.summary],i=Gd(t.next);return i&&r.push(i),t.user_message&&r.push("",Te.relay,t.user_message),e!==void 0&&r.push("",Te.details,JSON.stringify(e,null,2)),`${r.join(`
149
+ `,o),l=c===-1?a.slice(o):a.slice(o,c);if(yield{line:l,body:t===null&&!r&&i===null,index:s},s+=1,t!==null)t=Gu(l,t);else if(r)Uu(l)&&(r=!1);else if(i!==null)new RegExp(`</${i}\\s*>`,"iu").test(l)&&(i=null);else{let u=Gu(l,null);if(u!==null)t=u;else{let d=l.trimStart();if(d.startsWith("<!--")&&!Uu(d))r=!0;else{let p=/^<([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/u.exec(d);p&&n.has(p[1].toLowerCase())&&!d.startsWith("</")&&!d.endsWith("/>")&&!new RegExp(`</${p[1]}\\s*>`,"iu").test(d)&&(i=p[1])}}}if(c===-1)break;o=c+1}}function Er(e){return e.normalize("NFC").replace(/\s+/gu," ").trim()}function Yu(e,t,r,i=[],n="content-hash"){let a=Er(r),o=t.replaceAll("\\","/").trim(),s=i.map(Er);if(a.length===0)throw new Error(`${e} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${e} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${U(Ew,{kind:e,source:o,context:s,text:a})}`:"",kind:e,source:o,context:s,text:a}}function Xu(e,t,r="content-hash"){let i=new Set;for(let n of e){let a=r==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(i.has(a))throw new Error(`${t} contains duplicate acceptance criteria`);i.add(a)}return e}function Cw(e){let t=null,r=null,i=0,n=0;for(let{line:a,body:o,index:s}of ln(e)){n=s+1;let c=o?Ku(a):null;c?.level===1&&(xo(c.text)==="acceptanceExamples"?(i+=1,i===1&&(t=s+1)):t!==null&&r===null&&(r=s))}if(i===0||t===null)return null;if(i!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:t,end:r??n}}function Wo(e,t="brief.md",r=un.maxCriteria,i="content-hash"){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native brief acceptance budget is invalid");let n=Cw(e);if(n===null)return[];let a=null;for(let{line:l,body:f,index:u}of ln(e)){if(u<n.start||u>=n.end)continue;let d=f?/^( {0,3})[-*+][ \t]+/u.exec(l):null;if(d===null)continue;let p=d[1].length;a=a===null?p:Math.min(a,p)}let o=[],s=null,c=()=>{if(s!==null){if(o.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);o.push(s)}};for(let{line:l,body:f,index:u}of ln(e)){if(u<n.start||u>=n.end)continue;let d=f?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(l):null;d&&d[1].length===a?(c(),s=[d[2]]):s!==null&&s.push(l)}return c(),Xu(o.map(l=>Yu("brief-example",t,l.join(`
150
+ `),[],i)),"Brief",i)}function zo(e,t="spec.md",r=un.maxCriteria,i="content-hash"){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native specification acceptance budget is invalid");let n=[],a=[],o=null,s=()=>{if(o!==null){if(n.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);n.push(Yu("spec-scenario",t,[o.title,...o.body].join(`
151
+ `),o.context,i)),o=null}};for(let{line:c,body:l}of ln(e)){let f=l?Ku(c):null,u=f?/^Scenario\s*:\s*(.*)$/iu.exec(f.text):null;if(u){for(s();a.at(-1)&&a.at(-1).level>=f.level;)a.pop();let d=Er(u[1]);if(d.length===0)throw new Error("Scenario title must not be empty");o={level:f.level,title:d,body:[],context:a.map(p=>p.text)}}else if(f){for(o!==null&&f.level<=o.level?s():o!==null&&o.body.push(c);a.at(-1)&&a.at(-1).level>=f.level;)a.pop();a.push(f)}else o!==null&&l&&o.body.push(c)}return s(),Xu(n,"Specification",i)}var xw=/^A[1-9]\d*$/u;function Zu(e,t){if(e.length===0||e!==e.trim()||e.includes("\\")||Qu.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||Qu.posix.normalize(e)!==e||e==="."||e.endsWith("/"))throw new Error(`${t} must be a normalized change-relative ref`);return e}function Pw(e,t){return e.localeCompare(t,"en")}function Jo(e){let t=Zu(e.briefSource??"brief.md","Native brief source"),r=[...e.specs??[]].sort((a,o)=>Pw(a.capability,o.capability));if(new Set(r.map(a=>a.capability)).size!==r.length)throw new Error("Native acceptance sources contain duplicate capabilities");let i=Wo(e.briefMarkdown,t,Number.MAX_SAFE_INTEGER,"none").map(({source:a,text:o})=>({source:a,text:o}));for(let a of r){let o=Zu(a.source,`Native spec source for ${a.capability}`);i.push(...zo(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})))}let n=new Set;for(let a of i){a.text=Er(a.text);let o=`${a.source}\0${a.text}`;if(n.has(o))throw new Error(`Native acceptance contains a duplicate criterion: ${a.text}`);n.add(o)}if(i.length===0)throw new Error("Native change must define at least one acceptance criterion");return i.map((a,o)=>({id:`A${o+1}`,source:a.source,text:a.text}))}function ed(e){let t=e.map(({id:r})=>r);if(new Set(t).size!==t.length)throw new Error("Native acceptance IDs must be unique");for(let r=0;r<t.length;r+=1)if(!xw.test(t[r])||t[r]!==`A${r+1}`)throw new Error("Native acceptance IDs must be the contiguous sequence A1..An")}var hn=Mt(Pt(),1);import{promises as Rw}from"node:fs";var Aw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,_w=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Iw=/^A[1-9][0-9]*$/u,Tw=/^[a-f0-9]{64}$/u,jw=new Set(["schema","name","language","phase","status","state_version","brief","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"]),fn=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"};function W(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function z(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function B(e,t,r){if(typeof e!="string"||!r?.empty&&e.length===0)throw new Error(`${t} must be ${r?.empty?"a string":"a non-empty string"}`);return e}function Go(e,t){return e===null?null:B(e,t)}function rd(e,t){let r=B(e,t);if(!Tw.test(r))throw new Error(`${t} must be a SHA-256 hash`);return r}function jt(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function I(e,t,r=0){if(!Number.isSafeInteger(e)||e<r)throw new Error(`${t} must be a safe integer greater than or equal to ${r}`);return e}function $w(e,t){return e===null?null:I(e,t,Number.MIN_SAFE_INTEGER)}function $(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} must be one of: ${t.join(", ")}`);return e}function Ne(e,t,r){if(!Array.isArray(e))throw new Error(`${t} must be an array`);return e.map((i,n)=>r(i,n))}function pn(e,t){return Ne(e,t,(r,i)=>B(r,`${t}[${i}]`))}function ct(e,t){if(new Set(e).size!==e.length)throw new Error(`${t} must be unique`)}function $t(e,t){let r=B(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO date or timestamp`);return r}function Uo(e,t,r=!1){let i=B(e,t);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${t} must be a portable relative path`);return i}function te(e,t){let r=W(e,t);return z(r,new Set(["text","truncated"]),t),{text:B(r.text,`${t}.text`,{empty:!0}),truncated:jt(r.truncated,`${t}.truncated`)}}function Ow(e,t){let r=`Native spec_changes[${t}]`,i=W(e,r);z(i,new Set(["capability","operation","source"]),r);let n=B(i.capability,`${r}.capability`);if(!_w.test(n))throw new Error(`${r}.capability is invalid`);let a=$(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:Uo(i.source,`${r}.source`);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`);return{capability:n,operation:a,source:o}}function Hw(e){let t="Native workspace",r=W(e,t);z(r,new Set(["isolation","change_branch","target_branch","finish"]),t);let i=$(r.isolation,["current","branch","worktree"],`${t}.isolation`),n=Go(r.change_branch,`${t}.change_branch`),a=Go(r.target_branch,`${t}.target_branch`),o=r.finish===null?null:$(r.finish,["merge","push","pull-request","keep"],`${t}.finish`);if(i==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(i==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(i!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:i,change_branch:n,target_branch:a,finish:o}}function Dw(e){let t="Native loop",r=W(e,t);z(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","stop_reason","execution_failure_count","previous_unresolved_ids","next_action"]),t);let i=pn(r.previous_unresolved_ids,`${t}.previous_unresolved_ids`);ct(i,`${t}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:$(r.stop_reason,["budget","stalled"],`${t}.stop_reason`);return{stage:$(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${t}.stage`),goal_cycle:I(r.goal_cycle,`${t}.goal_cycle`,1),iteration:I(r.iteration,`${t}.iteration`),attempt:I(r.attempt,`${t}.attempt`),retry_epoch:I(r.retry_epoch,`${t}.retry_epoch`),failed_iteration_count:I(r.failed_iteration_count,`${t}.failed_iteration_count`),no_progress_count:I(r.no_progress_count,`${t}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:I(r.execution_failure_count,`${t}.execution_failure_count`),previous_unresolved_ids:i,next_action:Go(r.next_action,`${t}.next_action`)}}function Lw(e,t){let r=`Native acceptance[${t}]`,i=W(e,r);z(i,new Set(["id","source","text","result","reason"]),r);let n=B(i.id,`${r}.id`);if(!Iw.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:Uo(i.source,`${r}.source`),text:B(i.text,`${r}.text`),result:$(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:te(i.reason,`${r}.reason`)}}function Bw(e,t){let r=`Native builder_handoff.checks[${t}]`,i=W(e,r);return z(i,new Set(["name","result","note"]),r),{name:te(i.name,`${r}.name`),result:$(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:te(i.note,`${r}.note`)}}function Mw(e){let t="Native builder_handoff",r=W(e,t);z(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),t);let i=pn(r.addressed_acceptance_ids,`${t}.addressed_acceptance_ids`);ct(i,`${t}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:W(r.review,`${t}.review`);return n&&z(n,new Set(["status","summary","reviewer_execution_ref"]),`${t}.review`),{candidate_id:B(r.candidate_id,`${t}.candidate_id`),identity_provider:B(r.identity_provider,`${t}.identity_provider`),builder_execution_ref:B(r.builder_execution_ref,`${t}.builder_execution_ref`),iteration:I(r.iteration,`${t}.iteration`,1),summary:te(r.summary,`${t}.summary`),addressed_acceptance_ids:i,checks:Ne(r.checks,`${t}.checks`,Bw),checks_truncated:jt(r.checks_truncated,`${t}.checks_truncated`),known_limits:Ne(r.known_limits,`${t}.known_limits`,(a,o)=>te(a,`${t}.known_limits[${o}]`)),known_limits_truncated:jt(r.known_limits_truncated,`${t}.known_limits_truncated`),review:n?{status:$(n.status,["passed"],`${t}.review.status`),summary:te(n.summary,`${t}.review.summary`),reviewer_execution_ref:B(n.reviewer_execution_ref,`${t}.review.reviewer_execution_ref`)}:null,submitted_at:$t(r.submitted_at,`${t}.submitted_at`)}}function Vw(e,t){let r=`Native blockers[${t}]`,i=W(e,r);z(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=pn(i.acceptance_ids,`${r}.acceptance_ids`);return ct(n,`${r}.acceptance_ids`),{owner:$(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:te(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:$(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function Fw(e,t){let r=`Native verification.checks[${t}]`,i=W(e,r);return z(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:B(i.id,`${r}.id`),name:te(i.name,`${r}.name`),argv_display:Ne(i.argv_display,`${r}.argv_display`,(n,a)=>te(n,`${r}.argv_display[${a}]`)),argv_truncated:jt(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:Uo(i.cwd_ref,`${r}.cwd_ref`,!0),status:$(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:$w(i.exit_code,`${r}.exit_code`),duration_ms:I(i.duration_ms,`${r}.duration_ms`)}}function qw(e){let t="Native verification",r=W(e,t);z(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),t);let i=Ne(r.checks,`${t}.checks`,Fw);ct(i.map(a=>a.id),`${t}.checks IDs`);let n=B(r.identity_provider,`${t}.identity_provider`);return{candidate_id:B(r.candidate_id,`${t}.candidate_id`),identity_provider:n,verifier_execution_ref:B(r.verifier_execution_ref,`${t}.verifier_execution_ref`),iteration:I(r.iteration,`${t}.iteration`,1),attempt:I(r.attempt,`${t}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":$(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${t}.assurance`),verdict:$(r.verdict,["pass","fail","blocked"],`${t}.verdict`),checks:i,summary:te(r.summary,`${t}.summary`),risks:Ne(r.risks,`${t}.risks`,(a,o)=>te(a,`${t}.risks[${o}]`)),risks_truncated:jt(r.risks_truncated,`${t}.risks_truncated`),completed_at:$t(r.completed_at,`${t}.completed_at`)}}function Ww(e,t){let r=`Native history[${t}]`,i=W(e,r);z(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=pn(i.unresolved_ids,`${r}.unresolved_ids`);return ct(n,`${r}.unresolved_ids`),{goal_cycle:I(i.goal_cycle,`${r}.goal_cycle`,1),iteration:I(i.iteration,`${r}.iteration`),attempt:I(i.attempt,`${r}.attempt`),outcome:$(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:te(i.summary,`${r}.summary`),completed_at:$t(i.completed_at,`${r}.completed_at`)}}function zw(e){let t="Native history_overflow.outcome_counts",r=W(e,t),i=["pass","fail","blocked","execution-error","recovery"];return z(r,new Set(i),t),{pass:I(r.pass,`${t}.pass`),fail:I(r.fail,`${t}.fail`),blocked:I(r.blocked,`${t}.blocked`),"execution-error":I(r["execution-error"],`${t}.execution-error`),recovery:I(r.recovery,`${t}.recovery`)}}function Jw(e){let t="Native history_overflow",r=W(e,t);z(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),t);let i=I(r.dropped_entries,`${t}.dropped_entries`),n=r.first_dropped_at===null?null:$t(r.first_dropped_at,`${t}.first_dropped_at`),a=r.last_dropped_at===null?null:$t(r.last_dropped_at,`${t}.last_dropped_at`);if(i===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(i>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=zw(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 Gw(e){let t=new Set(e.acceptance.map(r=>r.id));for(let r of e.loop.previous_unresolved_ids)if(!t.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of e.builder_handoff?.addressed_acceptance_ids??[])if(!t.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);for(let r of e.blockers)for(let i of r.acceptance_ids)if(!t.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(e.builder_handoff){if(!(e.builder_handoff.iteration===e.loop.iteration||e.phase==="build"&&e.loop.stage==="repairing"&&e.builder_handoff.iteration===e.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(e.builder_handoff.review?.reviewer_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(e.verification){if(!e.builder_handoff)throw new Error("Native verification requires a builder handoff");if(e.verification.candidate_id!==e.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(e.verification.identity_provider!==e.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(e.verification.assurance)!==(e.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(e.verification.assurance==="semantic-verification-unavailable"&&e.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(e.verification.assurance==="user-confirmed-degraded"&&e.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(e.verification.verifier_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=e.verification.iteration===e.loop.iteration&&e.verification.attempt===e.loop.attempt,n=e.phase==="build"&&e.loop.stage==="repairing"&&e.verification.iteration===e.loop.iteration-1&&e.verification.iteration===e.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Uw(e){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[e.phase].has(e.loop.stage))throw new Error(`Native loop stage ${e.loop.stage} is invalid for phase ${e.phase}`);let r=e.status==="await-user"?"await-user":e.status==="blocked"?"blocked":e.status==="done"?"done":null;if(r!==null&&e.loop.stage!==r)throw new Error(`Native status ${e.status} requires loop stage ${r}`);if(e.status==="active"&&["await-user","blocked","done"].includes(e.loop.stage))throw new Error(`Native active status cannot use loop stage ${e.loop.stage}`);if(e.archived!==(e.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(e.archived&&e.phase!=="archive")throw new Error("Native archived state must be in Archive");if(e.verification_result==="pass"){if(e.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(e.acceptance.some(i=>i.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(e.verification.checks.some(i=>i.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(e.verification?.assurance==="semantic-verification-unavailable"&&(e.phase!=="verify"||e.status!=="await-user"||e.verification_result!=="blocked"||e.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(e.verification_report!==null&&e.verification===null)throw new Error("Native verification report requires persisted verification")}function lt(e){let t=W(e,"Native portable state");if(z(t,jw,"Native portable state"),t.schema!==ht)throw new Error(`Native portable state schema must be ${ht}`);let r=B(t.name,"Native state name");if(!Aw.test(r))throw new Error("Native state name is invalid");if(t.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let i=Ne(t.spec_changes,"Native spec_changes",Ow);ct(i.map(s=>s.capability),"Native spec change capabilities");let n=Ne(t.acceptance,"Native acceptance",Lw);ct(n.map(s=>s.id),"Native acceptance IDs");let a=Ne(t.history,"Native history",Ww);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:ht,name:r,language:$(t.language,["en","zh-CN"],"Native state language"),phase:$(t.phase,["shape","build","verify","archive"],"Native state phase"),status:$(t.status,["active","await-user","blocked","done"],"Native state status"),state_version:I(t.state_version,"Native state_version",1),brief:"brief.md",...t.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:rd(t.shape_confirmation_hash,"Native Shape confirmation hash")},...t.children_contract_hash===void 0?{}:{children_contract_hash:rd(t.children_contract_hash,"Native children contract hash")},...t.coordination_mode===void 0?{}:{coordination_mode:$(t.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:Hw(t.workspace),loop:Dw(t.loop),acceptance:n,builder_handoff:t.builder_handoff===null?null:Mw(t.builder_handoff),blockers:Ne(t.blockers,"Native blockers",Vw),verification:t.verification===null?null:qw(t.verification),history:a,history_overflow:Jw(t.history_overflow),verification_result:$(t.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:t.verification_report===null?null:$(t.verification_report,["verification.md"],"Native verification_report"),archived:jt(t.archived,"Native archived"),created_at:$t(t.created_at,"Native created_at")};return Gw(o),Uw(o),o}function Kw(e,t){let r=(0,hn.parseDocument)(e,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`${t} is invalid YAML: ${r.errors[0].message}`);return r.toJS({mapAsMap:!1})}async function _e(e){let t=await Rw.readFile(e,"utf8");return lt(Kw(t,"Native portable state"))}async function mn(e,t,r={}){let i=lt(t);await he(e,(0,hn.stringify)(i),r)}var dn=new Map;async function Yw(e,t){let r=dn.get(e)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);dn.set(e,a),await r;try{return await t()}finally{i(),dn.get(e)===a&&dn.delete(e)}}async function id(e){return Yw(e.file,async()=>{let t=I(e.expectedStateVersion,"Native expected state version",1),r=lt(e.next);if(r.state_version!==t+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await _e(e.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==t)throw new fn(t,i.state_version);return await mn(e.file,r,{...e.containedRoot?{containedRoot:e.containedRoot}:{},beforeCommit:async()=>{let n=await _e(e.file);if(n.state_version!==t)throw new fn(t,n.state_version)}}),r})}function Xw(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function vn(e,t=16384){if(typeof e!="string")throw new Error("Native portable text must be a string");if(Xw(t),Buffer.byteLength(e,"utf8")<=t)return{text:e,truncated:!1};let r="",i=0;for(let n of e){let a=Buffer.byteLength(n,"utf8");if(i+a>t)break;r+=n,i+=a}return{text:r,truncated:!0}}var Ie="comet.native.v3",be="comet.native.v2",ke="comet.native.v1";var gn="comet.native.portable-migration.v1",Zw=new Set(["schema","id","change","fromSchema","status","createdAt"]),ey=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,ty=/^[a-z0-9][a-z0-9-]{7,127}$/u,ry=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),iy=new Set([ke,be,Ie]);function ny(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function ay(e,t){let r=e instanceof Date?new Date(e.valueOf()):new Date(e);if(Number.isNaN(r.valueOf()))throw new Error(`${t} must be a valid timestamp`);return r.toISOString()}function oy(e,t){if(typeof e!="string")throw new Error(`${t} must be an ISO timestamp`);let r=new Date(e);if(Number.isNaN(r.valueOf())||r.toISOString()!==e)throw new Error(`${t} must be a canonical ISO timestamp`);return e}function sy(e){return e.schema===ke?Cr(e):e.schema===be?xr(e):Pr(e)}function cy(e){return Qw.posix.normalize(e.replaceAll("\\","/"))}function ly(e){return e.spec_changes.map(t=>t.operation==="remove"?{capability:t.capability,operation:"remove",source:null}:{capability:t.capability,operation:t.operation==="replace"?"modify":"create",source:cy(t.source)})}function uy(e){return e==="shape"?"shape":"build"}function dy(e,t){return e==="zh-CN"?t==="shape"?"继续澄清并确认验收项":"重新提交候选实现":t==="shape"?"Continue clarification and confirm acceptance":"Submit a fresh implementation candidate"}function fy(e,t,r){return e==="zh-CN"?`从旧版 ${t} ${r} 状态恢复;旧版 Loop、验证结论和运行记录未继承。`:`Recovered from legacy ${t} ${r} state; prior Loop, verification results, and execution records were not inherited.`}function nd(e){let t=sy(e.state);ed(e.acceptance);let r=uy(t.phase),i=r==="shape"?0:1,n=ay(e.migratedAt??`${t.created_at}T00:00:00.000Z`,"Native portable migration time"),a=e.acceptance.map(o=>({id:o.id,source:o.source,text:o.text,result:"pending",reason:null}));return lt({schema:ht,name:t.name,language:t.language,phase:r,status:"active",state_version:1,brief:"brief.md",spec_changes:ly(t),workspace:e.workspace,loop:{stage:r==="shape"?"shape":"building",goal_cycle:1,iteration:i,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:dy(t.language,r)},acceptance:a,builder_handoff:null,blockers:[],verification:null,history:[{goal_cycle:1,iteration:i,attempt:0,outcome:"recovery",unresolved_ids:a.map(({id:o})=>o),summary:vn(fy(t.language,t.schema,t.phase)),completed_at:n}],history_overflow:Mn(),verification_result:"pending",verification_report:null,archived:!1,created_at:`${t.created_at}T00:00:00.000Z`})}function Ko(e){let t=ny(e,"Native portable migration transaction"),r=Object.keys(t).filter(i=>!Zw.has(i));if(r.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${r.join(", ")}`);if(t.schema!==gn)throw new Error("Unsupported Native portable migration transaction schema");if(typeof t.id!="string"||!ty.test(t.id))throw new Error("Native portable migration transaction id is invalid");if(typeof t.change!="string"||!ey.test(t.change))throw new Error("Native portable migration transaction change is invalid");if(typeof t.fromSchema!="string"||!iy.has(t.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof t.status!="string"||!ry.has(t.status))throw new Error("Native portable migration transaction status is invalid");return{schema:gn,id:t.id,change:t.change,fromSchema:t.fromSchema,status:t.status,createdAt:oy(t.createdAt,"Native portable migration transaction createdAt")}}function ad(e){switch(Ko(e).status){case"prepared":return{action:"commit-portable-yaml",fromStatus:"prepared",nextStatus:"yaml-committed"};case"yaml-committed":return{action:"cleanup-legacy-runtime",fromStatus:"yaml-committed",nextStatus:"legacy-cleanup"};case"legacy-cleanup":return{action:"commit-transaction",fromStatus:"legacy-cleanup",nextStatus:"committed"};case"committed":return{action:"done",fromStatus:"committed",nextStatus:null}}}var od="comet.native.archive-transaction.v4",sd="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",hy=new RegExp(`^portable-archive-(${sd})\\.json$`,"u"),py=new RegExp(`^portable-migration-(${sd})\\.json$`,"u"),my=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,vy=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,gy=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),wy=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),yy=new Set(["capability","operation","source","content"]),cd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function ld(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function ud(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`);if(Object.keys(e).length!==t.size)throw new Error(`${r} fields are invalid`)}function Ny(e,t){let r=`Native portable Archive spec_changes[${t}]`,i=ld(e,r);if(ud(i,yy,r),typeof i.capability!="string"||!cd.test(i.capability))throw new Error(`${r}.capability is invalid`);if(!["create","modify","remove"].includes(String(i.operation)))throw new Error(`${r}.operation is invalid`);let n=i.operation;if(n==="remove"){if(i.source!==null||i.content!==null)throw new Error(`${r} remove requires source and content null`);return{capability:i.capability,operation:n,source:null,content:null}}if(typeof i.source!="string"||i.source.length===0||i.source.includes("\\")||i.source.startsWith("/")||/^[A-Za-z]:/u.test(i.source)||i.source.split("/").some(a=>a==="."||a===".."))throw new Error(`${r}.${n} source is invalid`);if(typeof i.content!="string")throw new Error(`${r}.${n} content is invalid`);return{capability:i.capability,operation:n,source:i.source,content:i.content}}function by(e){let t=ld(e,"Native portable Archive transaction");if(ud(t,wy,"Native portable Archive transaction"),t.schema!==od)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof t.id!="string"||!my.test(t.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof t.change!="string"||!cd.test(t.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(t.start_state_version)||Number(t.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof t.archive_ref!="string"||!vy.test(t.archive_ref)||!t.archive_ref.endsWith(`-${t.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof t.status!="string"||!gy.has(t.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let r=t.spec_changes.map(Ny);if(new Set(r.map(({capability:n})=>n)).size!==r.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(t.next_spec_index)||Number(t.next_spec_index)<0||Number(t.next_spec_index)>r.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof t.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let i=new Date(t.created_at);if(Number.isNaN(i.valueOf())||i.toISOString()!==t.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:od,id:t.id,change:t.change,start_state_version:Number(t.start_state_version),archive_ref:t.archive_ref,status:t.status,next_spec_index:Number(t.next_spec_index),spec_changes:r,created_at:t.created_at}}function wn(e){let t=hy.exec(e);if(t)return{kind:"archive",change:t[1]};let r=py.exec(e);return r?{kind:"migration",change:r[1]}:null}function yn(e,t){let r=`${t.kind==="archive"?"portable-archive":"portable-migration"}-${t.change}.json`,i=wn(r);if(!i||i.kind!==t.kind||i.change!==t.change)throw new Error(`Invalid Native portable transaction change: ${t.change}`);return Yo.join(e.transactionsDir,r)}async function Xo(e,t){let r=wn(t);if(!r)return null;let i=await V({root:e.transactionsDir,ref:t,maxBytes:null,includeHash:!1}),n=JSON.parse(i.text),a=Yo.join(e.transactionsDir,t);if(r.kind==="archive"){let s=by(n);if(s.change!==r.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:r.change,file:a,journal:s}}let o=Ko(n);if(o.change!==r.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:r.change,file:a,journal:o}}async function Qo(e,t){let r=yn(e,t);try{return await Xo(e,Yo.basename(r))}catch(i){if(i.code==="ENOENT")return null;throw i}}function dd(e){return e.kind==="archive"||e.journal.status!=="committed"}import Te from"path";import{TextDecoder as Ay}from"util";import{createHash as ky}from"node:crypto";import{constants as Nn,promises as ue}from"node:fs";import de from"node:path";function kn(e,t){let r=de.relative(e,t);return r===""||!de.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${de.sep}`)}function Sy(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native protected file byte limit must be a positive integer");return e}function Ey(e,t){return _({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Cy(e){return{dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs,ctimeMs:e.ctimeMs,mtimeMs:e.mtimeMs,size:e.size}}function bn(e,t){return _({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Zo(e,t){let r=await ue.lstat(e);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t} parent must be a real directory: ${e}`);return{path:e,realPath:await ue.realpath(e),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function xy(e,t,r){let i=de.resolve(e),n=de.resolve(t);if(!kn(i,n))throw new Error(`${r} is outside its managed root`);let a=[await Zo(i,r)],o=i;for(let s of de.relative(i,n).split(de.sep).filter(Boolean)){await ut(a,r),o=de.join(o,s);let c=await Zo(o,r);if(!kn(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await ut(a,r),a}async function ut(e,t){for(let r of e){let i=await ue.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!Ey(r,i)||await ue.realpath(r.path)!==r.realPath)throw new Error(`${t} parent changed during I/O: ${r.path}`)}}async function Py(e,t,r){let i=[],n=0,a=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let o=t+1-n,{bytesRead:s}=await e.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,n>t)throw new Error(`${r} exceeds ${t} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function Ot(e){let t=Sy(e.maxBytes),r=de.resolve(e.file),i=await xy(e.root,de.dirname(r),e.label),n=await Promise.all((e.forbiddenRoots??[]).map(f=>Zo(de.resolve(f),e.label)));await e.hooks?.afterParentChainCaptured?.(),await ut(i,e.label);let a=await ue.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);if(a.size>t)throw new Error(`${e.label} exceeds ${t} bytes`);let o=Cy(a),s=await ue.realpath(r);if(!kn(i[0].realPath,s))throw new Error(`${e.label} resolves outside its managed root`);if(n.some(f=>kn(f.realPath,s)))throw new Error(`${e.label} resolves inside an excluded root`);let c=process.platform==="win32"?Nn.O_RDONLY:Nn.O_RDONLY|Nn.O_NOFOLLOW|Nn.O_NONBLOCK,l=await ue.open(r,c);try{let f=await l.stat();await e.hooks?.afterOpen?.();let[u,d]=await Promise.all([ue.lstat(r),ue.realpath(r)]);if(await ut(i,e.label),await ut(n,e.label),!f.isFile()||!u.isFile()||u.isSymbolicLink()||d!==s||!bn(o,f)||!bn(o,u))throw new Error(`${e.label} changed while opening`);await e.hooks?.beforeRead?.();let p=await Py(l,t,e.label);await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),ue.lstat(r),ue.realpath(r)]);if(await ut(i,e.label),await ut(n,e.label),!h.isFile()||h.isSymbolicLink()||m!==s||!bn(o,v)||!bn(o,h))throw new Error(`${e.label} changed while reading`);return{bytes:p,hash:ky("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}var _y=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),Iy=new Set(["id","type","source","target","staged","backup"]),Ty=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),jy=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var pd=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var $y=256*1024,wC=1024*1024,yC=16*1024;var NC=64*1024*1024;var Oy=new Ay("utf-8",{fatal:!0});function En(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Cn(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function md(e){if(typeof e!="string")return!1;let t=new Date(e);return!Number.isNaN(t.valueOf())&&t.toISOString()===e}function es(e,t){if(typeof e!="string"||e.length===0||Te.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native root`)}function Sn(e,t){if(typeof e!="string"||!/^[a-f0-9]{64}$/u.test(e))throw new Error(`${t} must be a SHA-256 hash`)}function fd(e,t){if(es(e,t),e.includes("\\")||e!==Te.posix.normalize(e)||e.split("/").includes(".")||e.endsWith("/")||Buffer.byteLength(e,"utf8")>1024)throw new Error(`${t} must be a normalized Native-relative ref`)}function Hy(e,t){let r=En(e,`transaction operations[${t}]`);if(Cn(r,Iy,`transaction operations[${t}]`),typeof r.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(r.id))throw new Error(`transaction operations[${t}].id is invalid`);if(r.type!=="write"&&r.type!=="remove"&&r.type!=="move")throw new Error(`transaction operation ${r.id} has an invalid type`);es(r.target,`transaction operation ${r.id} target`);for(let i of["source","staged","backup"])r[i]!==void 0&&es(r[i],`transaction operation ${r.id} ${i}`);if(r.type==="write"){if(r.staged===void 0||r.source!==void 0)throw new Error(`write operation ${r.id} requires staged and forbids source`)}else if(r.type==="remove"){if(r.source!==void 0||r.staged!==void 0)throw new Error(`remove operation ${r.id} forbids source and staged`)}else if(r.source===void 0||r.staged!==void 0||r.backup!==void 0)throw new Error(`move operation ${r.id} requires source and forbids staged and backup`);return r}function vd(e){let t=En(e,"Native Archive transaction journal");if(Cn(t,Ty,"Native Archive transaction journal"),t.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native Archive transaction id is invalid");if(t.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof t.status!="string"||!pd.has(t.status))throw new Error("Native Archive transaction status is invalid");if(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change))throw new Error("Native Archive transaction change name is invalid");if(!md(t.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Sn(t.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(t.operations)||t.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let r=t.operations.map((s,c)=>{let l=En(s,`Archive transaction operations[${c}]`);if(Cn(l,jy,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);fd(l.target,`Archive transaction operation ${l.id} target`);for(let f of["source","staged","backup"])l[f]!==void 0&&fd(l[f],`Archive transaction operation ${l.id} ${f}`);if(l.expectedTargetHash!==null&&Sn(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(Sn(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);Sn(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),i=r.map(s=>s.id);if(new Set(i).size!==i.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${t.id}`,a=r.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${t.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${t.change}$`,"u").test(a[0].target)||r.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of r.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:t.id,kind:"archive",status:t.status,change:t.change,createdAt:t.createdAt,preflightHash:t.preflightHash,operations:r}}function Dy(e){let t=En(e,"Native transaction journal");if(t.schema==="comet.native.transaction.v2")return vd(t);if(Cn(t,_y,"Native transaction journal"),t.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native transaction id is invalid");if(t.kind!=="archive"&&t.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof t.status!="string"||!pd.has(t.status))throw new Error("Native transaction status is invalid");if(typeof t.projectRoot!="string"||!Te.isAbsolute(t.projectRoot)||typeof t.nativeRoot!="string"||!Te.isAbsolute(t.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(t.change!==void 0&&(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change)))throw new Error("Native transaction change name is invalid");if(!md(t.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(t.operations))throw new Error("Native transaction operations must be an array");let r=t.operations.map(Hy),i=r.map(n=>n.id);if(new Set(i).size!==i.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:t.id,kind:t.kind,status:t.status,projectRoot:t.projectRoot,nativeRoot:t.nativeRoot,...typeof t.change=="string"?{change:t.change}:{},createdAt:t.createdAt,operations:r}}function Ly(e,t){if(!/^[a-f0-9-]{8,}$/u.test(t))throw new Error(`Invalid Native transaction id: ${t}`);return Te.join(e.transactionsDir,t)}function gd(e,t){let r=Ly(e,t);return{directory:r,journal:Te.join(r,"transaction.json"),events:Te.join(r,"events.jsonl"),staged:Te.join(r,"staged"),backups:Te.join(r,"backups")}}async function rs(e,t){let r=gd(e,t);return await Promise.all(Object.values(r).map(i=>T(e.runtimeDir,i))),r}async function is(e,t,r={}){let i=await rs(e,t),n=await Ot({root:e.runtimeDir,file:i.journal,maxBytes:$y,label:`Native transaction journal ${t}`,hooks:r.hooks}),a=JSON.parse(Oy.decode(n.bytes)),o=Dy(a);if(o.id!==t)throw new Error(`Invalid Native transaction journal: ${t}`);return o}async function Vy(e,t,r){let i;try{i=await By.readdir(e.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await is(e,n.name);if(a.id!==t&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of i)if(wn(n.name))try{let a=await Xo(e,n.name);if(!a||r?.kind===a.kind&&r.change===a.change)continue;if(dd(a))return!0}catch{return!0}return!1}async function Fy(e,t){let r=Date.now()+5e3,i=My.join(e.locksDir,"root-move.lock");for(;;)try{return await sn(e,"root-move",t)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Ju(i);if(o.status==="missing")continue;if(o.status!=="active"||Date.now()>=r)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function X(e,t,r,i){let n=await Fy(e,t);try{if(await nn(e.projectRoot),await Vy(e,i?.allowedTransactionId,i?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await r()}finally{await cn(n)}}import{createHash as qy}from"crypto";function re(e){return qy("sha256").update(e).digest("hex")}var VC={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024};var FC=8*1024*1024;var qC=64*1024,WC=64*1024;var zC={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},JC={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};var GC=(1n<<256n)-1n;var Yy=Mt(Pt(),1);var lx=4*1024*1024;var Xy=null;function Qy(e,t){let r=e;for(let i of t)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function wd(e,t){return(...r)=>{let i=Xy;if(i===null)return t(...r);let n=Qy(`async:${e}`,r),a=i.entries.get(n);if(a)return a.value;let o=t(...r).catch(s=>{throw i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}var px=wd("hookWritePolicy",async e=>(await $o(e))?.hook??{allow_paths:[]});var dP=256*1024;var EP={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};import Ht from"node:path";var Rr=/^[a-f0-9]{64}$/u,Nd=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,eN=16*1024,BP=process.platform;function tN(e,t){let r=Ht.relative(e,t);return Ht.isAbsolute(r)||r===".."||r.startsWith(`..${Ht.sep}`)?null:r.replaceAll("\\","/")||"."}function Sd(e){return Array.from(e).some(t=>{let r=t.codePointAt(0)??0;return r<=31||r===127})}function Ed(e,t){if(e.length===0||Sd(e)||e.includes("\\")||Ht.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes(".."))throw new Error(`${t} must be a portable project-relative path`);let r=Ht.posix.normalize(e);if(r!==e||r===".."||r.startsWith("../"))throw new Error(`${t} must be a normalized project-relative path`);return r}function rN(e){if(typeof e!="string")throw new Error("Native workspace capturedAt is invalid");let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw new Error("Native workspace capturedAt is invalid");return e}function ns(e,t){if(e===null)return null;if(typeof e!="string"||e.length===0||e.trim()!==e||Sd(e))throw new Error(`${t} must be a non-empty branch name or null`);return e}function iN(e){if(!new Set(["current","branch","worktree"]).has(e.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(ns(e.changeBranch,"Native workspace change branch"),ns(e.targetBranch,"Native workspace target branch"),(e.isolation==="branch"||e.isolation==="worktree")&&(e.changeBranch===null||e.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function nN(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace Git provenance must be an object");let t=e,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(t).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(t.provider!=="git"||typeof t.baseCommit!="string"||!Nd.test(t.baseCommit)||typeof t.targetCommit!="string"||!Nd.test(t.targetCommit))throw new Error("Native workspace Git provenance is invalid");ns(t.targetBranch,"Native workspace Git target branch")}function aN(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace identity must be an object");let t=e,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(t).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(t.schema!=="comet.native.workspace.v2"&&t.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(t.capturedRevision)||t.capturedRevision<1||typeof t.nativeRootRef!="string"||!Rr.test(String(t.projectRootId))||!Rr.test(String(t.nativeRootId)))throw new Error("Native workspace identity is invalid");rN(t.capturedAt),Ed(t.nativeRootRef,"Native workspace root ref");let n=t.projectRootPathId!==void 0,a=t.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!Rr.test(String(t.projectRootPathId))||a&&!Rr.test(String(t.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(t.sessionHash!==void 0&&!Rr.test(String(t.sessionHash)))throw new Error("Native workspace session hash is invalid");if(t.git!==void 0&&nN(t.git),t.schema==="comet.native.workspace.v2"){if(t.isolation!==void 0||t.changeBranch!==void 0||t.targetBranch!==void 0||t.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof t.isolation!="string"||t.changeBranch===void 0||t.targetBranch===void 0||t.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(iN(t),t.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(t.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function oN(e,t){return Ht.join(ve(e,t),"workspace.json")}function sN(e,t){let r=oN(e,t),i=ge(e,r),n=tN(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:Ed(n,"Native workspace file ref")}}async function cN(e,t){try{let r=sN(e,t),i=await V({root:r.root,ref:r.ref,maxBytes:eN});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Ar(e,t){let r=await cN(e,t);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(aN(r),r)}var xd=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],uN=new Set(xd),Pd=new Set([...xd,"minimum_runtime_version","revision"]),dN=new Set([...Pd,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),fN=new Set(["capability","operation","source","base_hash"]),hN=new Set(["shape","build","verify","archive"]),pN=new Set(["implicit","confirmed"]),mN=new Set(["pending","pass","fail"]),dt="comet-state.yaml",os=/^[a-f0-9]{64}$/u,Rd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,vN=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,ss=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"},Lt=class extends Error{constructor(r,i){super(r!==Ie||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"},xn=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"},_r=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"},Pn=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"},dR=qi("en");function Tr(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Ad(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function us(e){if(!Rd.test(e))throw new Error(`Invalid Native change name: ${e}`)}function gN(e){if(!Rd.test(e))throw new Error(`Invalid Native capability id: ${e}`)}function _d(e,t){if(e.length===0||Dt.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native change`)}function wN(e,t){let r=Tr(e,`spec_changes[${t}]`);if(Ad(r,fN,`spec_changes[${t}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(gN(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"&&_d(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"||!os.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"||!os.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 yN(e){return/^\d{4}-\d{2}-\d{2}$/u.test(e)?new Date(`${e}T00:00:00.000Z`).toISOString().slice(0,10)===e:!1}function ds(e,t){if(Ad(e,t,dt),typeof e.name!="string")throw new Error("Native change name is required");if(us(e.name),e.language!=="en"&&e.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof e.phase!="string"||!hN.has(e.phase))throw new Error("Native change phase is invalid");if(e.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(e.approval!==null&&!pN.has(e.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native spec_changes must be an array");let r=e.spec_changes.map(wN),i=r.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(i.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(i)].join(", ")}`);if(typeof e.verification_result!="string"||!mN.has(e.verification_result))throw new Error("Native verification_result is invalid");if(e.verification_report!==null&&typeof e.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof e.verification_report=="string"&&_d(e.verification_report,"Native verification_report"),typeof e.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof e.created_at!="string"||!yN(e.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(e.run_id!==null&&(typeof e.run_id!="string"||e.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:e.name,language:e.language,phase:e.phase,brief:"brief.md",approval:e.approval,spec_changes:r,verification_result:e.verification_result,verification_report:e.verification_report,archived:e.archived,created_at:e.created_at,run_id:e.run_id}}function Cr(e){let t=Tr(e,dt);if(t.schema!==ke)throw new Error(`Expected ${ke}`);return{schema:ke,...ds(t,uN)}}function Ir(e,t){if(!Number.isSafeInteger(e)||e<1)throw new Error(`${t} must be a positive integer`);return e}function as(e,t,r){if(e===null)return null;let i=typeof e=="string"?vN.exec(e):null;if(!i||i[1]!==r)throw new Error(`${t} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return e}function NN(e){if(e==null)return null;if(typeof e!="string"||!os.test(e))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return e}function bN(e){if(e===void 0)return"legacy-v1";if(e!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return e}function xr(e){let t=Tr(e,dt);if(t.schema!==be)throw new Error(`Expected ${be}`);if(Ir(t.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${be} minimum_runtime_version must be 2`);return{schema:be,minimum_runtime_version:2,revision:Ir(t.revision,"Native v2 revision"),...ds(t,Pd)}}function Pr(e){let t=Tr(e,dt);if(t.schema!==Ie){if(t.schema===ke||t.schema===be){let o=t.schema===ke?Cr(t):xr(t);throw new ss(o.name,o.schema)}throw new Lt(typeof t.schema=="string"?t.schema:"(missing)",typeof t.minimum_runtime_version=="number"?t.minimum_runtime_version:null)}let r=Ir(t.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Lt(t.schema,r);if(r!==3)throw new Error(`Native ${t.schema} minimum_runtime_version must be ${3}`);let i=Ir(t.revision,"Native revision"),n=ds(t,dN),a=NN(t.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Ie,minimum_runtime_version:3,revision:i,verification_protocol:bN(t.verification_protocol),...n,approved_contract_hash:a,implementation_scope:as(t.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:as(t.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:as(t.partial_allowance,"Native partial_allowance","allowances")}}function kN(e){let t=Tr(e,dt);if(t.schema===ke){let n=Cr(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Ie}`}}if(t.schema===be){let n=xr(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Ie}`}}if(t.schema!==Ie){let n=typeof t.minimum_runtime_version=="number"&&Number.isSafeInteger(t.minimum_runtime_version)?t.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof t.schema=="string"?t.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new Lt(typeof t.schema=="string"?t.schema:"(missing)",n).message}}let r=Ir(t.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:t.schema,minimumRuntimeVersion:r,state:null,message:new Lt(t.schema,r).message};let i=Pr(t);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}function Se(e,t){us(t);let r=Dt.join(e.changesDir,t);if(!F(e.changesDir,r))throw new Error("Native change path escaped");return r}async function SN(e,t=Dt.dirname(e)){let r=Dt.relative(t,e).split(Dt.sep).join("/"),i=await V({root:t,ref:r,maxBytes:null,includeHash:!1}),n=(0,ls.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${e}: ${n.errors[0].message}`);return n.toJS()}async function Id(e,t){let r=Dt.join(Se(e,t),dt);await T(e.nativeRoot,r);let i=kN(await SN(r,e.nativeRoot));if(i.state&&i.state.name!==t)throw new Error(`Native change directory/name mismatch: ${t}`);return i}import{promises as Od}from"node:fs";import On from"node:path";var CN=["outcome","scope","nonGoals","acceptanceExamples"],yR=[...CN,"constraints","decisions","openQuestions","verificationExpectations"];var _N=Mt(Pt(),1);var bR=8*1024*1024;var Rn=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};var eA=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");import{promises as HN}from"node:fs";import $r from"node:path";function An(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function _n(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Ee(e,t,r=!1){if(typeof e!="string"||!r&&e.length===0)throw new Error(`${t} must be ${r?"a string":"a non-empty string"}`);return e}function jd(e,t){return e===null?null:Ee(e,t)}function Tn(e,t,r=0){if(!Number.isSafeInteger(e)||e<r)throw new Error(`${t} must be a safe integer greater than or equal to ${r}`);return e}function DN(e,t){if(e===null)return null;if(!Number.isSafeInteger(e))throw new Error(`${t} must be null or a safe integer`);return e}function LN(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function In(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} must be one of: ${t.join(", ")}`);return e}function fs(e,t){if(e===null)return null;let r=Ee(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO timestamp`);return r}function hs(e,t){let r=Ee(e,t);if(!$r.isAbsolute(r))throw new Error(`${t} must be absolute`);return $r.resolve(r)}function BN(e,t){let r=`Native local checks[${t}]`,i=An(e,r);if(_n(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),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((l,f)=>Ee(l,`${r}.argv[${f}]`,!0)),a=In(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=fs(i.startedAt,`${r}.startedAt`),s=fs(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=Tn(i.timeoutMs,`${r}.timeoutMs`);if(c<1)throw new Error(`${r}.timeoutMs must be positive`);return{id:Ee(i.id,`${r}.id`),name:Ee(i.name,`${r}.name`),operationId:Ee(i.operationId,`${r}.operationId`),status:a,repeatable:LN(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:Tn(i.executionCount,`${r}.executionCount`),argv:n,cwd:hs(i.cwd,`${r}.cwd`),exitCode:DN(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:Ee(i.log,`${r}.log`)}}function $d(e){let t="Native local execution state",r=An(e,t);if(_n(r,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),t),r.schema!==Vt)throw new Error(`Native local execution schema must be ${Vt}`);let i=An(r.workspace,"Native local workspace");_n(i,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(r.execution!==null){let o=An(r.execution,"Native local execution");_n(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=fs(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Ee(o.operationId,"Native local execution.operationId"),stage:In(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:In(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:jd(o.executionId,"Native local execution.executionId"),status:In(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Tn(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(BN);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:Vt,change:Ee(r.change,"Native local change"),basedOnStateVersion:Tn(r.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:hs(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:hs(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:jd(i.branch,"Native local workspace.branch")},execution:n,checks:a}}function jn(e){return $d({schema:Vt,change:e.portableState.name,basedOnStateVersion:e.portableState.state_version,workspace:{projectRoot:$r.resolve(e.projectRoot),worktreeRoot:$r.resolve(e.worktreeRoot??e.projectRoot),branch:e.branch??null},execution:null,checks:[]})}async function $n(e,t,r={}){let i=$d(t);await HN.mkdir($r.dirname(e),{recursive:!0}),await K(e,i,r)}var Hd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,FN="comet-state.yaml",qN="state.json",H_=qi("en");function Dd(e,t){if(!Hd.test(t))throw new Error(`Invalid Native change name: ${t}`);let r=On.join(e.changesDir,t);if(!F(e.changesDir,r))throw new Error("Native change path escaped");return r}function Qe(e,t){return On.join(Dd(e,t),FN)}function ps(e,t){return On.join(Ye(e,t),qN)}async function Or(e,t){try{let r=await Od.readFile(Qe(e,t),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function WN(e){return ie(e).currentBranch}async function Ld(e,t){return _e(Qe(e,t))}async function zN(e){let t=await id({file:Qe(e.paths,e.previous.name),expectedStateVersion:e.previous.state_version,next:e.next,containedRoot:e.paths.nativeRoot});if(t.verification===null&&t.verification_report===null){let r=On.join(Dd(e.paths,t.name),"verification.md");await T(e.paths.nativeRoot,r),await Od.rm(r,{force:!0})}return t}async function Bd(e){if(!Hd.test(e.capability))throw new Error(`Invalid Native capability: ${e.capability}`);return X(e.paths,`remove portable spec ${e.capability}`,async()=>{let t=await Ld(e.paths,e.name);if(t.archived)throw new Error(`Native change ${t.name} is already archived`);let r=t.spec_changes.filter(({capability:a})=>a!==e.capability),i={...t,phase:"shape",status:"active",state_version:t.state_version+1,spec_changes:[...r,{capability:e.capability,operation:"remove",source:null}].sort((a,o)=>a.capability.localeCompare(o.capability,"en")),acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,history:[],history_overflow:{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}},loop:{stage:"shape",goal_cycle:t.loop.goal_cycle+(t.phase==="shape"?0:1),iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"prepare-shape-confirmation"}};delete i.shape_confirmation_hash,delete i.children_contract_hash;let n=await zN({paths:e.paths,previous:t,next:i});return await $n(ps(e.paths,t.name),jn({portableState:n,projectRoot:e.paths.projectRoot,branch:WN(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),n})}var Md=["evidence.md","repair.md","archive.md","checkpoint.md"],UN="verification.md";async function KN(e,t){let r=await Qo(e,{kind:"migration",change:t});return r?.kind==="migration"?r.journal:null}async function Vd(e,t){await Hr.mkdir(e.transactionsDir,{recursive:!0}),await K(yn(e,{kind:"migration",change:t.change}),t,{containedRoot:e.runtimeDir})}async function Fd(e,t,r={}){let i=r.removeVerificationReport===!1?Md:[...Md,UN];await Promise.all([Hr.rm(Ye(e,t),{recursive:!0,force:!0}),Hr.rm(Bo(e,t),{recursive:!0,force:!0}),...i.map(n=>Hr.rm(GN.join(Se(e,t),n),{force:!0}))])}async function qd(e,t){await $n(ps(e,t.name),jn({portableState:t,projectRoot:e.projectRoot}),{containedRoot:e.runtimeDir})}async function Wd(e,t){try{let r=await Ar(e,t);if(r?.schema==="comet.native.workspace.v3")return{isolation:r.isolation,change_branch:r.changeBranch,target_branch:r.targetBranch,finish:r.finish}}catch{}return{isolation:"current",change_branch:null,target_branch:null,finish:null}}function zd(e,t){if(t.isolation==="current"&&t.change_branch===null)return;let r=ie(e.projectRoot);if(!r.isGitWorktree)throw new Error("Native legacy migration requires its bound Git branch or worktree");if(r.currentBranch!==t.change_branch)throw new Error(`Native legacy migration expected branch ${t.change_branch??"(missing)"}, current branch is ${r.currentBranch??"(detached)"}`);if(t.isolation==="worktree"&&!r.isSecondaryWorktree)throw new Error("Native legacy migration requires its bound linked worktree")}async function YN(e){let t=Se(e.paths,e.state.name),r=await V({root:t,ref:e.state.brief,maxBytes:null,includeHash:!1}),i=[];for(let n of e.state.spec_changes){if(n.operation==="remove"||!n.source)continue;let a=await V({root:t,ref:n.source,maxBytes:null,includeHash:!1});i.push({capability:n.capability,source:a.ref,markdown:a.text})}try{return Jo({briefMarkdown:r.text,specs:i})}catch(n){if(e.state.phase==="shape"&&n.message.includes("at least one acceptance"))return[];throw n}}async function Jd(e,t){let r=await Id(e,t);if(!r.state)throw new Error(`Native legacy change ${t} is unreadable`);return r.state}async function Gd(e){return X(e.paths,`migrate ${e.name} to portable Native`,async()=>{let t=await KN(e.paths,e.name),r=await Or(e.paths,e.name)?await _e(Qe(e.paths,e.name)):null;if(!t&&r)return await Fd(e.paths,e.name,{removeVerificationReport:!1}),await qd(e.paths,r),r;let i=null,n=null;for(t||(i=await Jd(e.paths,e.name),n=await Wd(e.paths,e.name),zd(e.paths,n),t={schema:gn,id:JN(),change:i.name,fromSchema:i.schema,status:"prepared",createdAt:(e.now??new Date).toISOString()},await Vd(e.paths,t));;){let a=ad(t);if(a.action==="done")break;a.action==="commit-portable-yaml"?r||(i??=await Jd(e.paths,e.name),n??=await Wd(e.paths,e.name),zd(e.paths,n),r=nd({state:i,acceptance:await YN({paths:e.paths,state:i}),workspace:n,migratedAt:e.now}),await mn(Qe(e.paths,e.name),r,{containedRoot:e.paths.nativeRoot})):a.action==="cleanup-legacy-runtime"?await Fd(e.paths,e.name):a.action==="commit-transaction"&&(r??=await _e(Qe(e.paths,e.name)),await qd(e.paths,r)),t={...t,status:a.nextStatus},await Vd(e.paths,t)}return await Hr.rm(yn(e.paths,{kind:"migration",change:e.name}),{force:!0}),r??_e(Qe(e.paths,e.name))},{allowedPortableTransaction:{kind:"migration",change:e.name}})}import Lr from"path";import{realpathSync as Wb}from"fs";var je={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Ud(e){return e?e.command?`${je.next} ${e.command}`:e.ask_user?`${je.next} ${e.ask_user}`:null:null}function Kd(e,t){let r=[e.summary],i=Ud(e.next);return i&&r.push(i),e.user_message&&r.push("",je.relay,e.user_message),t!==void 0&&r.push("",je.details,JSON.stringify(t,null,2)),`${r.join(`
152
152
  `)}
153
- `}function Kd(t,e,r){let i=[t.summary],n=Gd(t.next);return n&&i.push(n),t.user_message&&i.push("",Te.relay,t.user_message),i.push("",`${Te.detail} ${e}`),r!==void 0&&i.push("",Te.details,JSON.stringify(r,null,2)),i.join(`
154
- `)}var UN=["outcome","scope","nonGoals","acceptanceExamples"],iI=[...UN,"constraints","decisions","openQuestions","verificationExpectations"];var KN=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});var Yd=1024*1024;var Qd="scoped-text-safety",YN=1,XN=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var QN="comet.native.checker-policy.v1";var yI=Y(QN,{policy:Qd,version:YN,limits:XN,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var ZN=["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"],NI=new Set(ZN);var rb=Yd,DI=3*rb;var Zd={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:[]},nb=re("comet-native-runtime:v3:scope-reopen"),uT=[{skillVersion:"3",skillHash:re("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:re("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:re("comet-native-runtime:v1")}];var tf=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],WT=new Set(tf),db=new Set([...tf,"minimum_runtime_version","revision"]),zT=new Set([...db,"operation"]),JT=512*1024,fb=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),GT=new Set([...fb,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var QT={maxAcceptanceCriteria:un.maxCriteria};var ij={maxSpecs:64,maxFileBytes:Wr,maxTotalBytes:4*1024*1024};import{execFile as bb}from"node:child_process";import{promisify as kb}from"node:util";var pj={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var $j=512*1024;var Dr=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};var i$=64*1024;var n$=3600*1e3;var a$=kb(bb);var Hn=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}};var W$={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var eO=16*1024*1024,tO=256*1024,rO=16*1024;var cO=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var dO=16*1024;var SO=16*1024;var p0=16*1024*1024,Dn=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"},Ln=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"};function C(t,e,r){return t==="zh-CN"?r:e}var ms={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function af(t,e){return typeof t=="string"&&ms[t]?C(e,ms[t].en,ms[t].zh):typeof t=="string"?t:""}function vs(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 Rb(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 of(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 sf(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 gs(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function Ab(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 _b(t,e,r){let i=gs(t),n=[];r&&n.push(r);let a=C(i,`Change ${t.change}`,`需求 ${t.change}`),o=af(t.phase,i),s=Ab(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(of(e,i));let c=t.userCommunication,l=cf(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function cf(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:C(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function Ib(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function Tb(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=af(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=vs(t.acceptance)?`${C(e,", ",",")}${of(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function jb(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 $b(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 Ob(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=Hb(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 Hb(t){return sf(t)?cf(t,gs(t)):void 0}function lf(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if($b(e))return Ob(e);if(Ib(e)){let i=jb(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=>Tb(a,i))].join(`
155
- `)}}let r=e.continuation;if(sf(r))return _b(r,Db(e),Lb(e,gs(r)));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 Db(t){if(vs(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(vs(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return Rb(r.acceptance)}return null}function Lb(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 uf(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}var df=["--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."],ys=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec remove Record a complete capability removal intent.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","check <change-name> Run the read-only Native verification check.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:df,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] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:"comet native spec remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page, 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 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> [--confirmed] [--coordination-mode multi-session|single-session] [--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker] [--max-parallel <n>] [--expected-state-version <n>] [--expected-action <action>]
156
- comet native next <change-name> --runner-input <json-file>`,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 Shape or an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Required when confirming a multi-child Supervisor Shape.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits, review. review fields: status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," 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)."],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','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]
157
- comet native archive <change-name> [--confirmed] [--serial-first <current-change>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Inspect readiness without rerunning verification.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness plus continuation, or the completed Archive transaction and workspace finish result; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function ws(t,e){return`${t}:
158
- ${e.map(r=>` ${r}`).join(`
159
- `)}`}function Bb(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return ys[r]||e.length>1&&ys[e[0]]?.subcommands?r:e[0]}function Vb(t=[]){let e=Bb(t),r=ys[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.subcommands&&i.push("",ws("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...df];return n&&n.length>0&&i.push("",ws("Options",n)),i.push("",`Output:
160
- ${r.output}`),r.examples&&i.push("",ws("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
153
+ `}function Yd(e,t,r){let i=[e.summary],n=Ud(e.next);return n&&i.push(n),e.user_message&&i.push("",je.relay,e.user_message),i.push("",`${je.detail} ${t}`),r!==void 0&&i.push("",je.details,JSON.stringify(r,null,2)),i.join(`
154
+ `)}var XN=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});var Xd=1024*1024;var Zd="scoped-text-safety",QN=1,ZN=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var eb="comet.native.checker-policy.v1";var xI=U(eb,{policy:Zd,version:QN,limits:ZN,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var tb=["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"],PI=new Set(tb);var nb=Xd,WI=3*nb;var ef={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:[]},ob=re("comet-native-runtime:v3:scope-reopen"),gT=[{skillVersion:"3",skillHash:re("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:re("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:re("comet-native-runtime:v1")}];var rf=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],XT=new Set(rf),hb=new Set([...rf,"minimum_runtime_version","revision"]),QT=new Set([...hb,"operation"]),ZT=512*1024,pb=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),ej=new Set([...pb,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var aj={maxAcceptanceCriteria:un.maxCriteria};var uj={maxSpecs:64,maxFileBytes:Wr,maxTotalBytes:4*1024*1024};import{execFile as Sb}from"node:child_process";import{promisify as Eb}from"node:util";var Nj={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var Vj=512*1024;var Dr=class extends Error{recovery;constructor(t,r){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=r}};var u$=64*1024;var d$=3600*1e3;var f$=Eb(Sb);var Hn=class extends Error{details;constructor(t){let r=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=t}};var X$={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var sO=16*1024*1024,cO=256*1024,lO=16*1024;var mO=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var wO=16*1024;var _O=16*1024;var N0=16*1024*1024,Dn=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"},Ln=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"};function C(e,t,r){return e==="zh-CN"?r:t}var ms={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function of(e,t){return typeof e=="string"&&ms[e]?C(t,ms[e].en,ms[e].zh):typeof e=="string"?e:""}function vs(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&typeof t.passed=="number"&&typeof t.failed=="number"&&typeof t.blocked=="number"&&typeof t.pending=="number"}function _b(e){let t={total:e.length,passed:0,failed:0,blocked:0,pending:0};for(let r of e){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;t[i]+=1}return t}function sf(e,t){let r=[];e.failed>0&&r.push(C(t,`${e.failed} failed`,`${e.failed} 项失败`)),e.blocked>0&&r.push(C(t,`${e.blocked} blocked`,`${e.blocked} 项受阻`)),e.pending>0&&r.push(C(t,`${e.pending} pending`,`${e.pending} 项待验`));let i=C(t,`acceptance ${e.passed}/${e.total} passed`,`验收 ${e.passed}/${e.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function cf(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;if(typeof t.change!="string"||t.disposition!=="continue"&&t.disposition!=="await-user"&&t.disposition!=="blocked"&&t.disposition!=="done"||t.commandArgs!==null&&t.commandArgs!==void 0&&!Array.isArray(t.commandArgs))return!1;let r=t.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function gs(e){return/[\u4e00-\u9fff]/u.test(e.userCommunication.agentInstruction)?"zh-CN":"en"}function Ib(e,t,r){return e==="done"?C(r,"complete","已完成"):e==="await-user"?C(r,"waiting for a user decision","等待用户决定"):e==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):t?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function Tb(e,t,r){let i=gs(e),n=[];r&&n.push(r);let a=C(i,`Change ${e.change}`,`需求 ${e.change}`),o=of(e.phase,i),s=Ib(e.disposition,e.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),t&&t.total>0&&n.push(sf(t,i));let c=e.userCommunication,l=lf(e,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function lf(e,t){let r=e.userCommunication;if(e.disposition==="await-user"&&r.required)return{ask_user:C(t,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(e.commandArgs&&e.commandArgs.length>0)return{command:e.commandArgs.join(" ")};if(e.disposition==="done")return{ask_user:C(t,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(e.disposition==="blocked")return{ask_user:C(t,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function jb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&Array.isArray(t.items)}function $b(e,t){let r=typeof e.name=="string"?e.name:"(unnamed)",i=of(e.phase,t),n=e.status==="await-user"?C(t,"waiting for a user decision","等待用户决定"):e.status==="blocked"?C(t,"paused","已暂停"):e.status==="done"?C(t,"complete","已完成"):C(t,"in progress","进行中"),a=vs(e.acceptance)?`${C(t,", ",",")}${sf(e.acceptance,t)}`:"";return` ${r} · ${i||String(e.phase??"?")} · ${n}${a}`}function Ob(e){for(let t of e){let r=t.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function Hb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.healthy!="boolean"?!1:t.findings===void 0||Array.isArray(t.findings)}function Db(e){if(e.healthy){let i=e.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=Lb(e.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(e.findings)?e.findings.length:0;return{summary:C("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:C("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function Lb(e){return cf(e)?lf(e,gs(e)):void 0}function uf(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;if(Hb(t))return Db(t);if(jb(t)){let i=Ob(t.items);return{summary:[t.total===t.items.length?C(i,`Native changes (${t.total})`,`Native 需求列表(共 ${t.total} 条)`):C(i,`Native changes (showing ${t.items.length} of ${t.total})`,`Native 需求列表(显示 ${t.items.length}/${t.total} 条)`),...t.items.map(a=>$b(a,i))].join(`
155
+ `)}}let r=t.continuation;if(cf(r))return Tb(r,Bb(t),Mb(t,gs(r)));if(typeof t.artifactRoot=="string"&&typeof t.nativeRoot=="string"){let i=t.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in t;return{summary:C(i,n?`Comet Native artifacts live under ${t.artifactRoot} (state root: ${t.nativeRoot}).`:`Initialized Comet Native at ${t.nativeRoot} (artifacts: ${t.artifactRoot}).`,n?`Comet Native 产物位于 ${t.artifactRoot}(状态根目录:${t.nativeRoot})。`:`Comet Native 已初始化于 ${t.nativeRoot}(产物目录:${t.artifactRoot})。`)}}}function Bb(e){if(vs(e.acceptance))return e.acceptance;let t=e.state;if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;if(vs(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return _b(r.acceptance)}return null}function Mb(e,t){if(e.selected!==void 0&&typeof e.selected=="string")return C(t,`Selected ${e.selected}.`,`已选择需求 ${e.selected}。`);let r=e.migration;return r&&typeof r=="object"&&r.completed===!0?C(t,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function df(e){let r=e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};switch(e.code){case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}var ff=["--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."],ys=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec remove Record a complete capability removal intent.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","check <change-name> Run the read-only Native verification check.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:ff,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] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:"comet native spec remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page, 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 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>]
156
+ 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>]
157
+ comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm the persisted Shape boundary with both expected guards, or confirm an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Select how a multi-child Supervisor proceeds while preparing its Shape confirmation; final Shape confirmation is a later, separate step.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits, review. review fields: status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," 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)."],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]
158
+ comet native archive <change-name> [--confirmed] [--serial-first <current-change>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Run the complete read-only Archive and workspace-finish readiness check; it persists only an explicit --finish choice.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness, every blocker, and the exact next continuation, or the completed Archive transaction and workspace finish result. Execute the returned confirmed command only after ready is true; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function ws(e,t){return`${e}:
159
+ ${t.map(r=>` ${r}`).join(`
160
+ `)}`}function Vb(e){let t=e.filter(i=>i!=="--help");if(t.length===0)return"";let r=t.slice(0,2).join(" ");return ys[r]||t.length>1&&ys[t[0]]?.subcommands?r:t[0]}function Fb(e=[]){let t=Vb(e),r=ys[t];if(!r)throw new Error(`Unknown Native help topic: ${t}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.subcommands&&i.push("",ws("Commands",r.subcommands));let n=t===""?r.options:[...r.options??[],...ff];return n&&n.length>0&&i.push("",ws("Options",n)),i.push("",`Output:
161
+ ${r.output}`),r.examples&&i.push("",ws("Examples",r.examples)),t===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:t,usage:`${i.join(`
161
162
  `)}
162
- `}}var Mb=Vb().usage;var T0=10*1024*1024,Ce=class extends Error{};function bs(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new Ce(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function pf(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new Ce(`${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 Ce(`${e} requires a value`);return t.splice(i,2),n}function hf(t){if(t.length>0)throw new Ce(`Unexpected argument: ${t[0]}`)}function Bn(t,e){let r=t.shift();if(!r||r.startsWith("--"))throw new Ce(`${e} is required`);return r}function Ns(t,e){let r=Lr.normalize(ff(t)),i=Lr.normalize(ff(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function ff(t){let e=Lr.resolve(t);try{return Fb.native(e)}catch{return e}}function qb(t){let e=Lr.resolve(t),r=ie(process.cwd());if(!r.isSecondaryWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null)return e;let i=ie(e);return!i.isGitWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null||!Ns(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||Ns(r.currentWorktreeRoot,i.currentWorktreeRoot)?e:Ns(process.cwd(),r.currentWorktreeRoot)?Lr.resolve(process.cwd()):r.currentWorktreeRoot}async function mf(t){return t?qb(t):tn(process.cwd())}async function vf(t){let e=await $u({startPath:t,allowMissingConfig:!1});return{config:e.config,paths:e.paths}}function gf(t){return JSON.stringify(t,null,2)+`
163
- `}function wf(t,e,r){return{command:t,exitCode:0,data:e,text:r??gf(e)}}function Wb(t,e){if(e instanceof Ce)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof Dn)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 Ln)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof xn)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 _r)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 Rn)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof Pn)return{command:t,exitCode:65,data:{change:e.change,complete:!1,omittedCount:e.omittedCount,omittedByReason:e.omittedByReason,samplePaths:e.samplePaths,sampleTruncated:e.sampleTruncated,effectiveLimits:e.effectiveLimits,policyHash:e.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:e.message}};if(e instanceof Hn)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof Dr)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 yf(t,e){let r=Wb(t,e),i=r.error;if(!i)return r;let n=uf({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function Nf(t,e,r=!1){let i=t.envelope??lf(t.data);return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,...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}})+`
164
- `}:t.error?{exitCode:t.exitCode,stderr:i?Kd(i,t.error.message,r?t.data:void 0):t.error.message}:i?{exitCode:t.exitCode,stdout:Ud(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==gf(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
165
- ${Te.details}
166
- ${JSON.stringify(t.data,null,2)}
167
- `}:{exitCode:t.exitCode,stdout:t.text}}async function bf(t,e){let r=Bn(t,"spec subcommand");if(r!=="remove")throw new Ce(`Unknown spec command: ${r}`);let i=Bn(t,"change name"),n=Bn(t,"capability");hf(t);let{paths:a}=await vf(e);await Or(a,i)||await Jd({paths:a,name:i});let o=await Ld({paths:a,name:i,capability:n});return wf("spec remove",{...o,continuation:Ps(o)},`Marked Native capability ${n} for removal in ${i}
168
- `)}async function kf(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{bs(n,"--json"),bs(n,"--verbose"),c=pf(n,"--project-root");let u=[...n,...a],d=await mf(c);l=await e(u,d)}catch(u){l=yf(t,u)}let f=Nf(l,o,s);return f.stdout&&process.stdout.write(f.stdout),f.stderr&&process.stderr.write(f.stderr+(f.stderr.endsWith(`
163
+ `}}var qb=Fb().usage;var B0=10*1024*1024,Ce=class extends Error{};function bs(e,t){let r=e.flatMap((i,n)=>i===t?[n]:[]);if(r.length>1)throw new Ce(`${t} may only be provided once`);return r.length===0?!1:(e.splice(r[0],1),!0)}function pf(e,t){let r=e.flatMap((a,o)=>a===t?[o]:[]);if(r.length>1)throw new Ce(`${t} may only be provided once`);if(r.length===0)return;let i=r[0],n=e[i+1];if(n===void 0||n.startsWith("--"))throw new Ce(`${t} requires a value`);return e.splice(i,2),n}function mf(e){if(e.length>0)throw new Ce(`Unexpected argument: ${e[0]}`)}function Bn(e,t){let r=e.shift();if(!r||r.startsWith("--"))throw new Ce(`${t} is required`);return r}function Ns(e,t){let r=Lr.normalize(hf(e)),i=Lr.normalize(hf(t));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function hf(e){let t=Lr.resolve(e);try{return Wb.native(t)}catch{return t}}function zb(e){let t=Lr.resolve(e),r=ie(process.cwd());if(!r.isSecondaryWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null)return t;let i=ie(t);return!i.isGitWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null||!Ns(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||Ns(r.currentWorktreeRoot,i.currentWorktreeRoot)?t:Ns(process.cwd(),r.currentWorktreeRoot)?Lr.resolve(process.cwd()):r.currentWorktreeRoot}async function vf(e){return e?zb(e):tn(process.cwd())}async function gf(e){let t=await $u({startPath:e,allowMissingConfig:!1});return{config:t.config,paths:t.paths}}function wf(e){return JSON.stringify(e,null,2)+`
164
+ `}function yf(e,t,r){return{command:e,exitCode:0,data:t,text:r??wf(t)}}function Jb(e,t){if(t instanceof Ce)return{command:e,exitCode:64,error:{code:"usage",message:t.message}};if(t instanceof Dn)return{command:e,exitCode:73,data:{capability:t.capability,expectedHash:t.expectedHash,actualHash:t.actualHash,canonicalPath:t.canonicalPath},error:{code:"conflict",message:t.message}};if(t instanceof Ln)return{command:e,exitCode:73,data:t.preflight,error:{code:"conflict",message:t.message}};if(t instanceof xn)return{command:e,exitCode:73,data:{change:t.change,expectedRevision:t.expectedRevision,actualRevision:t.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:t.message}};if(t instanceof _r)return{command:e,exitCode:73,data:{requestedIsolation:t.requestedIsolation,activeChanges:t.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:t.message}};if(t instanceof Rn)return{command:e,exitCode:73,data:{preparation:t.preparation},error:{code:"workspace-preparation-incomplete",message:t.message}};if(t instanceof Pn)return{command:e,exitCode:65,data:{change:t.change,complete:!1,omittedCount:t.omittedCount,omittedByReason:t.omittedByReason,samplePaths:t.samplePaths,sampleTruncated:t.sampleTruncated,effectiveLimits:t.effectiveLimits,policyHash:t.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:t.message}};if(t instanceof Hn)return{command:e,exitCode:65,data:{receiptBindingFailures:t.details},error:{code:"invalid-data",message:t.message}};if(t instanceof Dr)return{command:e,exitCode:65,data:t.recovery,error:{code:"implementation-scope-stale",message:t.message}};if(t instanceof Error){let r=t.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:e,exitCode:70,error:{code:"internal",message:t.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(t.message);return{command:e,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:t.message}}}return{command:e,exitCode:70,error:{code:"internal",message:String(t)}}}function Nf(e,t){let r=Jb(e,t),i=r.error;if(!i)return r;let n=df({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function bf(e,t,r=!1){let i=e.envelope??uf(e.data);return t?{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,...i===void 0?{}:{summary:i.summary,...i.next===void 0?{}:{next:i.next},...i.user_message===void 0?{}:{user_message:i.user_message}},...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
165
+ `}:e.error?{exitCode:e.exitCode,stderr:i?Yd(i,e.error.message,r?e.data:void 0):e.error.message}:i?{exitCode:e.exitCode,stdout:Kd(i,r?e.data:void 0)}:r&&e.text!==void 0&&e.data!==void 0&&e.text!==wf(e.data)?{exitCode:e.exitCode,stdout:`${e.text}
166
+ ${je.details}
167
+ ${JSON.stringify(e.data,null,2)}
168
+ `}:{exitCode:e.exitCode,stdout:e.text}}async function kf(e,t){let r=Bn(e,"spec subcommand");if(r!=="remove")throw new Ce(`Unknown spec command: ${r}`);let i=Bn(e,"change name"),n=Bn(e,"capability");mf(e);let{paths:a}=await gf(t);await Or(a,i)||await Gd({paths:a,name:i});let o=await Bd({paths:a,name:i,capability:n});return yf("spec remove",{...o,continuation:Ps(o)},`Marked Native capability ${n} for removal in ${i}
169
+ `)}async function Sf(e,t,r=process.argv.slice(2)){let i=r.indexOf("--"),n=i<0?[...r]:r.slice(0,i),a=i<0?[]:r.slice(i),o=n.includes("--json"),s=n.includes("--verbose"),c,l;try{bs(n,"--json"),bs(n,"--verbose"),c=pf(n,"--project-root");let u=[...n,...a],d=await vf(c);l=await t(u,d)}catch(u){l=Nf(e,u)}let f=bf(l,o,s);return f.stdout&&process.stdout.write(f.stdout),f.stderr&&process.stderr.write(f.stderr+(f.stderr.endsWith(`
169
170
  `)?"":`
170
- `)),f.exitCode}process.exitCode=await kf("spec",bf);
171
+ `)),f.exitCode}process.exitCode=await Sf("spec",kf);