@rpamis/comet 0.4.0-rc.2 → 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 (419) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +2 -1
  3. package/assets/manifest.json +1 -1
  4. package/assets/skills/comet/scripts/comet-archive.mjs +55 -55
  5. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +56 -56
  6. package/assets/skills/comet/scripts/comet-guard.mjs +80 -80
  7. package/assets/skills/comet/scripts/comet-handoff.mjs +69 -69
  8. package/assets/skills/comet/scripts/comet-hook-guard.mjs +47 -47
  9. package/assets/skills/comet/scripts/comet-hook-router.mjs +140 -137
  10. package/assets/skills/comet/scripts/comet-resume-probe.mjs +57 -57
  11. package/assets/skills/comet/scripts/comet-runtime.mjs +133 -133
  12. package/assets/skills/comet/scripts/comet-state.mjs +73 -73
  13. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +25 -25
  14. package/assets/skills/comet-native/SKILL.md +8 -9
  15. package/assets/skills/comet-native/reference/artifacts.md +1 -2
  16. package/assets/skills/comet-native/reference/clarification.md +6 -6
  17. package/assets/skills/comet-native/reference/commands.md +5 -2
  18. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +120 -119
  19. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +136 -135
  20. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +77 -76
  21. package/assets/skills/comet-native/scripts/comet-native-init.mjs +61 -60
  22. package/assets/skills/comet-native/scripts/comet-native-new.mjs +128 -127
  23. package/assets/skills/comet-native/scripts/comet-native-next.mjs +133 -132
  24. package/assets/skills/comet-native/scripts/comet-native-root.mjs +70 -69
  25. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +170 -169
  26. package/assets/skills/comet-native/scripts/comet-native-select.mjs +112 -111
  27. package/assets/skills/comet-native/scripts/comet-native-show.mjs +102 -101
  28. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +110 -109
  29. package/assets/skills/comet-native/scripts/comet-native-status.mjs +108 -107
  30. package/assets/skills-zh/comet-native/SKILL.md +8 -9
  31. package/assets/skills-zh/comet-native/reference/artifacts.md +1 -2
  32. package/assets/skills-zh/comet-native/reference/clarification.md +6 -6
  33. package/assets/skills-zh/comet-native/reference/commands.md +5 -2
  34. package/dist/app/commands/bundle.d.ts.map +1 -1
  35. package/dist/app/commands/bundle.js.map +1 -1
  36. package/dist/app/commands/dashboard.d.ts +1 -1
  37. package/dist/app/commands/dashboard.js +1 -1
  38. package/dist/app/commands/doctor.d.ts.map +1 -1
  39. package/dist/app/commands/doctor.js +1 -1
  40. package/dist/app/commands/doctor.js.map +1 -1
  41. package/dist/app/commands/init.js +2 -2
  42. package/dist/app/commands/init.js.map +1 -1
  43. package/dist/app/commands/platform-select-prompt.d.ts.map +1 -1
  44. package/dist/app/commands/platform-select-prompt.js +1 -0
  45. package/dist/app/commands/platform-select-prompt.js.map +1 -1
  46. package/dist/app/commands/update.d.ts.map +1 -1
  47. package/dist/app/commands/update.js +12 -5
  48. package/dist/app/commands/update.js.map +1 -1
  49. package/dist/domains/agent-learning/policy-compiler.d.ts.map +1 -1
  50. package/dist/domains/agent-learning/policy-compiler.js.map +1 -1
  51. package/dist/domains/agent-learning/types.d.ts.map +1 -1
  52. package/dist/domains/agent-learning/types.js.map +1 -1
  53. package/dist/domains/bundle/authoring.d.ts.map +1 -1
  54. package/dist/domains/bundle/authoring.js.map +1 -1
  55. package/dist/domains/bundle/next-action.d.ts.map +1 -1
  56. package/dist/domains/bundle/next-action.js.map +1 -1
  57. package/dist/domains/bundle/readiness-user-summary.d.ts.map +1 -1
  58. package/dist/domains/bundle/readiness-user-summary.js.map +1 -1
  59. package/dist/domains/bundle/types.d.ts.map +1 -1
  60. package/dist/domains/comet-classic/classic-layout-initialization.d.ts.map +1 -1
  61. package/dist/domains/comet-classic/classic-layout-initialization.js.map +1 -1
  62. package/dist/domains/comet-entry/current-selection.d.ts.map +1 -1
  63. package/dist/domains/comet-entry/current-selection.js.map +1 -1
  64. package/dist/domains/comet-entry/init-workflow.d.ts.map +1 -1
  65. package/dist/domains/comet-entry/init-workflow.js.map +1 -1
  66. package/dist/domains/comet-entry/types.d.ts.map +1 -1
  67. package/dist/domains/comet-memory/personal-memory.d.ts.map +1 -1
  68. package/dist/domains/comet-memory/personal-memory.js +41 -0
  69. package/dist/domains/comet-memory/personal-memory.js.map +1 -1
  70. package/dist/domains/comet-memory/types.d.ts +7 -0
  71. package/dist/domains/comet-memory/types.d.ts.map +1 -1
  72. package/dist/domains/comet-memory/types.js.map +1 -1
  73. package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
  74. package/dist/domains/comet-native/native-archive-command.js +114 -19
  75. package/dist/domains/comet-native/native-archive-command.js.map +1 -1
  76. package/dist/domains/comet-native/native-artifacts.d.ts +1 -0
  77. package/dist/domains/comet-native/native-artifacts.d.ts.map +1 -1
  78. package/dist/domains/comet-native/native-artifacts.js +53 -2
  79. package/dist/domains/comet-native/native-artifacts.js.map +1 -1
  80. package/dist/domains/comet-native/native-atomic-file.d.ts +1 -0
  81. package/dist/domains/comet-native/native-atomic-file.d.ts.map +1 -1
  82. package/dist/domains/comet-native/native-atomic-file.js +19 -0
  83. package/dist/domains/comet-native/native-atomic-file.js.map +1 -1
  84. package/dist/domains/comet-native/native-children.d.ts +2 -0
  85. package/dist/domains/comet-native/native-children.d.ts.map +1 -1
  86. package/dist/domains/comet-native/native-children.js +16 -4
  87. package/dist/domains/comet-native/native-children.js.map +1 -1
  88. package/dist/domains/comet-native/native-cli-help.js +7 -7
  89. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  90. package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
  91. package/dist/domains/comet-native/native-doctor-command.d.ts.map +1 -1
  92. package/dist/domains/comet-native/native-doctor-command.js +41 -1
  93. package/dist/domains/comet-native/native-doctor-command.js.map +1 -1
  94. package/dist/domains/comet-native/native-evidence-storage.d.ts.map +1 -1
  95. package/dist/domains/comet-native/native-evidence-storage.js.map +1 -1
  96. package/dist/domains/comet-native/native-lock.d.ts.map +1 -1
  97. package/dist/domains/comet-native/native-lock.js +10 -1
  98. package/dist/domains/comet-native/native-lock.js.map +1 -1
  99. package/dist/domains/comet-native/native-loop-runtime.d.ts +4 -0
  100. package/dist/domains/comet-native/native-loop-runtime.d.ts.map +1 -1
  101. package/dist/domains/comet-native/native-loop-runtime.js +50 -5
  102. package/dist/domains/comet-native/native-loop-runtime.js.map +1 -1
  103. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  104. package/dist/domains/comet-native/native-next-command.js +64 -7
  105. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  106. package/dist/domains/comet-native/native-output-language.d.ts.map +1 -1
  107. package/dist/domains/comet-native/native-output-language.js.map +1 -1
  108. package/dist/domains/comet-native/native-portable-archive.d.ts.map +1 -1
  109. package/dist/domains/comet-native/native-portable-archive.js +17 -1
  110. package/dist/domains/comet-native/native-portable-archive.js.map +1 -1
  111. package/dist/domains/comet-native/native-portable-continuation.d.ts +11 -4
  112. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  113. package/dist/domains/comet-native/native-portable-continuation.js +201 -44
  114. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  115. package/dist/domains/comet-native/native-portable-migration.d.ts.map +1 -1
  116. package/dist/domains/comet-native/native-portable-migration.js.map +1 -1
  117. package/dist/domains/comet-native/native-portable-recovery.d.ts +2 -1
  118. package/dist/domains/comet-native/native-portable-recovery.d.ts.map +1 -1
  119. package/dist/domains/comet-native/native-portable-recovery.js +28 -3
  120. package/dist/domains/comet-native/native-portable-recovery.js.map +1 -1
  121. package/dist/domains/comet-native/native-portable-runtime.d.ts +28 -1
  122. package/dist/domains/comet-native/native-portable-runtime.d.ts.map +1 -1
  123. package/dist/domains/comet-native/native-portable-runtime.js +276 -14
  124. package/dist/domains/comet-native/native-portable-runtime.js.map +1 -1
  125. package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
  126. package/dist/domains/comet-native/native-portable-state.js +6 -0
  127. package/dist/domains/comet-native/native-portable-state.js.map +1 -1
  128. package/dist/domains/comet-native/native-portable-status.d.ts +5 -0
  129. package/dist/domains/comet-native/native-portable-status.d.ts.map +1 -1
  130. package/dist/domains/comet-native/native-portable-status.js +21 -1
  131. package/dist/domains/comet-native/native-portable-status.js.map +1 -1
  132. package/dist/domains/comet-native/native-portable-types.d.ts +1 -0
  133. package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
  134. package/dist/domains/comet-native/native-portable-types.js.map +1 -1
  135. package/dist/domains/comet-native/native-runner-input.d.ts.map +1 -1
  136. package/dist/domains/comet-native/native-runner-input.js +26 -31
  137. package/dist/domains/comet-native/native-runner-input.js.map +1 -1
  138. package/dist/domains/comet-native/native-schema-migration.d.ts.map +1 -1
  139. package/dist/domains/comet-native/native-schema-migration.js.map +1 -1
  140. package/dist/domains/comet-native/native-supervisor-overlay.d.ts +30 -0
  141. package/dist/domains/comet-native/native-supervisor-overlay.d.ts.map +1 -0
  142. package/dist/domains/comet-native/native-supervisor-overlay.js +202 -0
  143. package/dist/domains/comet-native/native-supervisor-overlay.js.map +1 -0
  144. package/dist/domains/comet-native/native-supervisor.d.ts +11 -1
  145. package/dist/domains/comet-native/native-supervisor.d.ts.map +1 -1
  146. package/dist/domains/comet-native/native-supervisor.js +68 -3
  147. package/dist/domains/comet-native/native-supervisor.js.map +1 -1
  148. package/dist/domains/comet-native/native-types.d.ts +1 -0
  149. package/dist/domains/comet-native/native-types.d.ts.map +1 -1
  150. package/dist/domains/comet-native/native-verification-receipt.d.ts.map +1 -1
  151. package/dist/domains/comet-native/native-verification-receipt.js.map +1 -1
  152. package/dist/domains/comet-native/native-workspace-finish.d.ts +12 -1
  153. package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -1
  154. package/dist/domains/comet-native/native-workspace-finish.js +77 -22
  155. package/dist/domains/comet-native/native-workspace-finish.js.map +1 -1
  156. package/dist/domains/comet-native/native-workspace.d.ts.map +1 -1
  157. package/dist/domains/comet-native/native-workspace.js.map +1 -1
  158. package/dist/domains/comet-plugin/integration.d.ts +2 -0
  159. package/dist/domains/comet-plugin/integration.d.ts.map +1 -1
  160. package/dist/domains/comet-plugin/integration.js +10 -6
  161. package/dist/domains/comet-plugin/integration.js.map +1 -1
  162. package/dist/domains/dashboard/collector.js +1 -1
  163. package/dist/domains/dashboard/default-plugin-host.d.ts +3 -0
  164. package/dist/domains/dashboard/default-plugin-host.d.ts.map +1 -1
  165. package/dist/domains/dashboard/default-plugin-host.js +38 -4
  166. package/dist/domains/dashboard/default-plugin-host.js.map +1 -1
  167. package/dist/domains/dashboard/native-adapter.d.ts.map +1 -1
  168. package/dist/domains/dashboard/native-adapter.js.map +1 -1
  169. package/dist/domains/dashboard/web/assets/abnfDiagram-VCTEODGH-Bql0JkFh.js +1 -0
  170. package/dist/domains/dashboard/web/assets/arc-CCUY9L8x.js +1 -0
  171. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-F2w5dggy.js +1 -0
  172. package/dist/domains/dashboard/web/assets/architectureDiagram-5GKGNRK7-iYP_D3CC.js +36 -0
  173. package/dist/domains/dashboard/web/assets/array-BifhSqXX.js +1 -0
  174. package/dist/domains/dashboard/web/assets/blockDiagram-I7D4REHJ-DyW07-ad.js +129 -0
  175. package/dist/domains/dashboard/web/assets/browser-CgwPGwaV.js +107 -0
  176. package/dist/domains/dashboard/web/assets/c4Diagram-7LVT6UL2-DDD_Y9Gj.js +38 -0
  177. package/dist/domains/dashboard/web/assets/channel-DLABCQMO.js +1 -0
  178. package/dist/domains/dashboard/web/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  179. package/dist/domains/dashboard/web/assets/chunk-4HAMMTFA-cZryt4d4.js +62 -0
  180. package/dist/domains/dashboard/web/assets/{chunk-5VM5RSS4-CopXcnFA.js → chunk-5VM5RSS4-ZNzvKenW.js} +2 -2
  181. package/dist/domains/dashboard/web/assets/chunk-75Z2AOVW-Ciqzt_fM.js +2 -0
  182. package/dist/domains/dashboard/web/assets/chunk-DU6HZSFF-0EtIdyLT.js +125 -0
  183. package/dist/domains/dashboard/web/assets/chunk-F27PBJKO-B09yMHfO.js +1 -0
  184. package/dist/domains/dashboard/web/assets/chunk-FOHPRMQF-DHwB1DNv.js +161 -0
  185. package/dist/domains/dashboard/web/assets/chunk-GMAD6QVW-D_hJqXpD.js +72 -0
  186. package/dist/domains/dashboard/web/assets/chunk-GVQU2GXP-DIvLb3as.js +1 -0
  187. package/dist/domains/dashboard/web/assets/chunk-IMKFNOWR-B_oII0H5.js +231 -0
  188. package/dist/domains/dashboard/web/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  189. package/dist/domains/dashboard/web/assets/chunk-L3NEJ4N5-BALKwnUb.js +1 -0
  190. package/dist/domains/dashboard/web/assets/chunk-OSK3NFVY-zA0G74ff.js +10 -0
  191. package/dist/domains/dashboard/web/assets/chunk-P2QGCYS3-B9FFBdWw.js +1 -0
  192. package/dist/domains/dashboard/web/assets/chunk-POPQ4Y6H-Fwh05sRj.js +1 -0
  193. package/dist/domains/dashboard/web/assets/chunk-PWAF6VOD-cCaczJjE.js +1 -0
  194. package/dist/domains/dashboard/web/assets/chunk-SHT3W25Y-ffjS5Q53.js +168 -0
  195. package/dist/domains/dashboard/web/assets/chunk-SVP7TREG-IDmA7lw7.js +88 -0
  196. package/dist/domains/dashboard/web/assets/chunk-TICWLB2K-8Gmmm4In.js +206 -0
  197. package/dist/domains/dashboard/web/assets/chunk-XXDRQBXY-DS9V6N2-.js +1 -0
  198. package/dist/domains/dashboard/web/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  199. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-DJ9Y8TBe.js +1 -0
  200. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-DJ9Y8TBe.js +1 -0
  201. package/dist/domains/dashboard/web/assets/cose-bilkent-JH36ORCC-DTBreOtW.js +1 -0
  202. package/dist/domains/dashboard/web/assets/cynefin-OW5HDTMX-DQuEyCa9.js +1 -0
  203. package/dist/domains/dashboard/web/assets/cynefinDiagram-5FMLGOSQ-Bb0YxnR5.js +62 -0
  204. package/dist/domains/dashboard/web/assets/cytoscape.esm-CGd-uY3x.js +321 -0
  205. package/dist/domains/dashboard/web/assets/dagre-GXQ25YYZ-DCdqnZ1z.js +4 -0
  206. package/dist/domains/dashboard/web/assets/dagre-PrKaheQc.js +1 -0
  207. package/dist/domains/dashboard/web/assets/defaultLocale-BFoDCU3G.js +1 -0
  208. package/dist/domains/dashboard/web/assets/demo-DrJ2uuUL.js +456 -0
  209. package/dist/domains/dashboard/web/assets/diagram-S7CK7UJ4-CBO5Oebq.js +30 -0
  210. package/dist/domains/dashboard/web/assets/diagram-UQ7AKVKN-Do5KGiae.js +41 -0
  211. package/dist/domains/dashboard/web/assets/diagram-VSXAHHWV-4Xskky28.js +3 -0
  212. package/dist/domains/dashboard/web/assets/diagram-VX7I27RA-DHaxCMg1.js +24 -0
  213. package/dist/domains/dashboard/web/assets/diagram-Z3DM3KII-_b0C8RCs.js +24 -0
  214. package/dist/domains/dashboard/web/assets/dist-D_v6faRz.js +1 -0
  215. package/dist/domains/dashboard/web/assets/ebnfDiagram-PWID7BFC-BlWWQsBx.js +1 -0
  216. package/dist/domains/dashboard/web/assets/erDiagram-RLTQ6QDP-CaZks0yu.js +99 -0
  217. package/dist/domains/dashboard/web/assets/es-DMM6Y5Bv.js +10 -0
  218. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-LE_eXkBk.js +1 -0
  219. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-Dhg9N1uf.js +1 -0
  220. package/dist/domains/dashboard/web/assets/ganttDiagram-EL5Y4UJY-BSjOQ_Cg.js +292 -0
  221. package/dist/domains/dashboard/web/assets/gitGraph-4MIJSDKK-DYwq3-1L.js +1 -0
  222. package/dist/domains/dashboard/web/assets/gitGraphDiagram-WWUBYQGX-oVngpACZ.js +106 -0
  223. package/dist/domains/dashboard/web/assets/graphlib-DS17s2tU.js +1 -0
  224. package/dist/domains/dashboard/web/assets/index-7epoYLF6.js +261 -0
  225. package/dist/domains/dashboard/web/assets/index-C5iz4lns.css +1 -0
  226. package/dist/domains/dashboard/web/assets/info-A6RAGUB7-CLoje88f.js +1 -0
  227. package/dist/domains/dashboard/web/assets/infoDiagram-27XIBGKW-sS6zp9EL.js +2 -0
  228. package/dist/domains/dashboard/web/assets/init-C-OQMol4.js +1 -0
  229. package/dist/domains/dashboard/web/assets/ishikawaDiagram-5VMMS53U-kETJqqgb.js +70 -0
  230. package/dist/domains/dashboard/web/assets/journeyDiagram-3NMN7TZE-ByJPB5Tw.js +139 -0
  231. package/dist/domains/dashboard/web/assets/kanban-definition-UXKFOSKX-JKqPn1FZ.js +89 -0
  232. package/dist/domains/dashboard/web/assets/katex-CXMH3UgJ.js +257 -0
  233. package/dist/domains/dashboard/web/assets/line-CnHo6lWD.js +1 -0
  234. package/dist/domains/dashboard/web/assets/linear-B2pLEjo4.js +1 -0
  235. package/dist/domains/dashboard/web/assets/marked.esm-BtJme7Pf.js +65 -0
  236. package/dist/domains/dashboard/web/assets/mermaid-parser.core-OtNk5rQN.js +7 -0
  237. package/dist/domains/dashboard/web/assets/mermaid.core-D1ElL3aM.js +44 -0
  238. package/dist/domains/dashboard/web/assets/mindmap-definition-YA3MSWOX-BxJqN_qn.js +96 -0
  239. package/dist/domains/dashboard/web/assets/ordinal-BDEzSJ7C.js +1 -0
  240. package/dist/domains/dashboard/web/assets/packet-AYTQ26CC-DM9DL0wE.js +1 -0
  241. package/dist/domains/dashboard/web/assets/path-fybaL0A-.js +1 -0
  242. package/dist/domains/dashboard/web/assets/pegDiagram-XKGWAZYB-BDe-x6aH.js +1 -0
  243. package/dist/domains/dashboard/web/assets/pie-WAS4IAKB-ClmkkApZ.js +1 -0
  244. package/dist/domains/dashboard/web/assets/pieDiagram-E7YTZNPT-DSFQ6yQn.js +39 -0
  245. package/dist/domains/dashboard/web/assets/purify.es-ChwZkWde.js +3 -0
  246. package/dist/domains/dashboard/web/assets/quadrantDiagram-AXDQQJYC-CV2lLCpu.js +7 -0
  247. package/dist/domains/dashboard/web/assets/radar-RG4KPBEZ-BduOvwgQ.js +1 -0
  248. package/dist/domains/dashboard/web/assets/railroad-74A4TZTK-BYnUo_HE.js +1 -0
  249. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CPiOAGi2.js +1 -0
  250. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-DOuNY-jw.js +1 -0
  251. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-DjNccNww.js +1 -0
  252. package/dist/domains/dashboard/web/assets/railroadDiagram-O6MQD6OU-Y0OnScVm.js +1 -0
  253. package/dist/domains/dashboard/web/assets/requirementDiagram-BXWQKSXE-Dqs0b-_F.js +84 -0
  254. package/dist/domains/dashboard/web/assets/rough.esm-Dy-Kn_BL.js +1 -0
  255. package/dist/domains/dashboard/web/assets/sankeyDiagram-P5KCCOFB-DafYyCgJ.js +40 -0
  256. package/dist/domains/dashboard/web/assets/sequenceDiagram-WJ2MYXX4-DEu4sb48.js +162 -0
  257. package/dist/domains/dashboard/web/assets/sizeCapture-INFHLROL-B0uUizjq.js +1 -0
  258. package/dist/domains/dashboard/web/assets/src-je_XM8Ul.js +1 -0
  259. package/dist/domains/dashboard/web/assets/stateDiagram-D77RDMKH-vHbZoYCK.js +1 -0
  260. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-C4dywNHK.js +1 -0
  261. package/dist/domains/dashboard/web/assets/swimlanes-42K2YHIH-DxEqhoUX.js +1 -0
  262. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-CHhHUVep.js +8 -0
  263. package/dist/domains/dashboard/web/assets/timeline-definition-24CTP7MA-B4XpTytf.js +120 -0
  264. package/dist/domains/dashboard/web/assets/treeView-Q6P3EWNA-CrismRW3.js +1 -0
  265. package/dist/domains/dashboard/web/assets/treemap-WGGIJYW6-BGFmknIY.js +1 -0
  266. package/dist/domains/dashboard/web/assets/vennDiagram-4TSXK5OY-DphMzj7N.js +34 -0
  267. package/dist/domains/dashboard/web/assets/wardley-WFR3VGLG-DmeLufag.js +1 -0
  268. package/dist/domains/dashboard/web/assets/wardleyDiagram-VM6X3IG4-BUDxONKk.js +78 -0
  269. package/dist/domains/dashboard/web/assets/xychartDiagram-S5SC5T6Z-BjqVHkW2.js +7 -0
  270. package/dist/domains/dashboard/web/index.html +16 -16
  271. package/dist/domains/factory/artifacts.d.ts.map +1 -1
  272. package/dist/domains/factory/artifacts.js.map +1 -1
  273. package/dist/domains/factory/types.d.ts.map +1 -1
  274. package/dist/domains/integrations/codegraph.d.ts.map +1 -1
  275. package/dist/domains/integrations/codegraph.js.map +1 -1
  276. package/dist/domains/project-knowledge/deterministic-extractors.d.ts.map +1 -1
  277. package/dist/domains/project-knowledge/deterministic-extractors.js +7 -6
  278. package/dist/domains/project-knowledge/deterministic-extractors.js.map +1 -1
  279. package/dist/domains/project-knowledge/index-store.d.ts +1 -1
  280. package/dist/domains/project-knowledge/index-store.d.ts.map +1 -1
  281. package/dist/domains/project-knowledge/index-store.js +19 -10
  282. package/dist/domains/project-knowledge/index-store.js.map +1 -1
  283. package/dist/domains/project-knowledge/learning.d.ts +1 -0
  284. package/dist/domains/project-knowledge/learning.d.ts.map +1 -1
  285. package/dist/domains/project-knowledge/learning.js +27 -8
  286. package/dist/domains/project-knowledge/learning.js.map +1 -1
  287. package/dist/domains/project-knowledge/local-provider.d.ts +1 -0
  288. package/dist/domains/project-knowledge/local-provider.d.ts.map +1 -1
  289. package/dist/domains/project-knowledge/local-provider.js +26 -1
  290. package/dist/domains/project-knowledge/local-provider.js.map +1 -1
  291. package/dist/domains/project-knowledge/local-store.d.ts +23 -1
  292. package/dist/domains/project-knowledge/local-store.d.ts.map +1 -1
  293. package/dist/domains/project-knowledge/local-store.js +179 -22
  294. package/dist/domains/project-knowledge/local-store.js.map +1 -1
  295. package/dist/domains/project-knowledge/plugin.d.ts.map +1 -1
  296. package/dist/domains/project-knowledge/plugin.js +55 -8
  297. package/dist/domains/project-knowledge/plugin.js.map +1 -1
  298. package/dist/domains/project-knowledge/records.d.ts +2 -0
  299. package/dist/domains/project-knowledge/records.d.ts.map +1 -1
  300. package/dist/domains/project-knowledge/records.js +8 -0
  301. package/dist/domains/project-knowledge/records.js.map +1 -1
  302. package/dist/domains/project-knowledge/types.d.ts +16 -0
  303. package/dist/domains/project-knowledge/types.d.ts.map +1 -1
  304. package/dist/domains/skill/platform-inspect.d.ts +1 -1
  305. package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
  306. package/dist/domains/skill/platform-inspect.js +50 -10
  307. package/dist/domains/skill/platform-inspect.js.map +1 -1
  308. package/dist/domains/skill/platform-install.d.ts +10 -5
  309. package/dist/domains/skill/platform-install.d.ts.map +1 -1
  310. package/dist/domains/skill/platform-install.js +107 -17
  311. package/dist/domains/skill/platform-install.js.map +1 -1
  312. package/dist/domains/skill/uninstall.d.ts.map +1 -1
  313. package/dist/domains/skill/uninstall.js +38 -61
  314. package/dist/domains/skill/uninstall.js.map +1 -1
  315. package/dist/domains/workflow-contract/contained-atomic-write.d.ts +1 -0
  316. package/dist/domains/workflow-contract/contained-atomic-write.d.ts.map +1 -1
  317. package/dist/domains/workflow-contract/contained-atomic-write.js +19 -0
  318. package/dist/domains/workflow-contract/contained-atomic-write.js.map +1 -1
  319. package/dist/domains/workflow-contract/global-config.d.ts +8 -0
  320. package/dist/domains/workflow-contract/global-config.d.ts.map +1 -1
  321. package/dist/domains/workflow-contract/global-config.js +25 -0
  322. package/dist/domains/workflow-contract/global-config.js.map +1 -1
  323. package/dist/domains/workflow-contract/index.d.ts +1 -1
  324. package/dist/domains/workflow-contract/index.d.ts.map +1 -1
  325. package/dist/domains/workflow-contract/index.js +1 -1
  326. package/dist/domains/workflow-contract/index.js.map +1 -1
  327. package/dist/domains/workflow-contract/project-config.d.ts +1 -1
  328. package/dist/domains/workflow-contract/project-config.d.ts.map +1 -1
  329. package/dist/domains/workflow-contract/project-config.js +1 -0
  330. package/dist/domains/workflow-contract/project-config.js.map +1 -1
  331. package/dist/domains/workflow-contract/protected-project-path.d.ts +4 -1
  332. package/dist/domains/workflow-contract/protected-project-path.d.ts.map +1 -1
  333. package/dist/domains/workflow-contract/protected-project-path.js +25 -1
  334. package/dist/domains/workflow-contract/protected-project-path.js.map +1 -1
  335. package/dist/domains/workflow-contract/types.d.ts.map +1 -1
  336. package/dist/platform/fs/race-safe-read.d.ts +14 -0
  337. package/dist/platform/fs/race-safe-read.d.ts.map +1 -1
  338. package/dist/platform/fs/race-safe-read.js +81 -0
  339. package/dist/platform/fs/race-safe-read.js.map +1 -1
  340. package/dist/platform/install/platforms.d.ts +4 -0
  341. package/dist/platform/install/platforms.d.ts.map +1 -1
  342. package/dist/platform/install/platforms.js +15 -3
  343. package/dist/platform/install/platforms.js.map +1 -1
  344. package/dist/platform/paths/project-knowledge-storage.d.ts +1 -1
  345. package/dist/platform/paths/project-knowledge-storage.d.ts.map +1 -1
  346. package/dist/platform/paths/project-knowledge-storage.js +9 -4
  347. package/dist/platform/paths/project-knowledge-storage.js.map +1 -1
  348. package/eval/local/tasks/comet-classic-layout-lifecycle/environment/current-comet-package.json +13 -13
  349. package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/environment/current-comet-package.json +13 -13
  350. package/package.json +24 -24
  351. package/dist/domains/dashboard/web/assets/abnfDiagram-N423BO3Z-BkUJc7LK.js +0 -1
  352. package/dist/domains/dashboard/web/assets/arc-DY4Y9tSO.js +0 -1
  353. package/dist/domains/dashboard/web/assets/architectureDiagram-T3A2C74G-7wC9YZS-.js +0 -36
  354. package/dist/domains/dashboard/web/assets/blockDiagram-VBNYF7ZC-Biqe-SaL.js +0 -132
  355. package/dist/domains/dashboard/web/assets/c4Diagram-5PPSVZJV-CccUFD1S.js +0 -10
  356. package/dist/domains/dashboard/web/assets/channel-DnRvSkOm.js +0 -1
  357. package/dist/domains/dashboard/web/assets/chunk-2GRJ4B5K-BUL4dDxo.js +0 -1
  358. package/dist/domains/dashboard/web/assets/chunk-2Q5K7J3B-BnKtDH9O.js +0 -1
  359. package/dist/domains/dashboard/web/assets/chunk-5RXB4S5H-C9pHQ1n3.js +0 -231
  360. package/dist/domains/dashboard/web/assets/chunk-6Q2QTUOP-CxrbngCi.js +0 -88
  361. package/dist/domains/dashboard/web/assets/chunk-GF5L2VYU-01mzgCUh.js +0 -206
  362. package/dist/domains/dashboard/web/assets/chunk-JWPE2WC7-wTiZVDvw.js +0 -1
  363. package/dist/domains/dashboard/web/assets/chunk-KBJHAD2P-Bxdv5bl-.js +0 -1
  364. package/dist/domains/dashboard/web/assets/chunk-RYQCIY6F-B5vF9l9A.js +0 -1
  365. package/dist/domains/dashboard/web/assets/chunk-XXDRQBXY-Dra3NnDp.js +0 -1
  366. package/dist/domains/dashboard/web/assets/classDiagram-JCYQIIEL-D3E-rgaQ.js +0 -1
  367. package/dist/domains/dashboard/web/assets/classDiagram-v2-OCEON4UE-D3E-rgaQ.js +0 -1
  368. package/dist/domains/dashboard/web/assets/cose-bilkent-JH36ORCC-DC96ge-n.js +0 -1
  369. package/dist/domains/dashboard/web/assets/cynefin-VYW2F7L2-Tt_NiopT.js +0 -166
  370. package/dist/domains/dashboard/web/assets/cynefinDiagram-MW4NZA55-BQ5__1hv.js +0 -62
  371. package/dist/domains/dashboard/web/assets/cytoscape.esm-D3_iZ_3b.js +0 -321
  372. package/dist/domains/dashboard/web/assets/dagre-VZM6K2ZE-Cr2zq3ro.js +0 -4
  373. package/dist/domains/dashboard/web/assets/defaultLocale-DX6XiGOO.js +0 -1
  374. package/dist/domains/dashboard/web/assets/demo-lxXhgJ9-.js +0 -456
  375. package/dist/domains/dashboard/web/assets/diagram-7IWD3JNH-BRpYDwPl.js +0 -30
  376. package/dist/domains/dashboard/web/assets/diagram-B4RE2ZJO-D7u-VBxW.js +0 -3
  377. package/dist/domains/dashboard/web/assets/diagram-LBJQPF4R-CHYuv2JD.js +0 -24
  378. package/dist/domains/dashboard/web/assets/diagram-Q27KOJAE-CV3ZE8Q3.js +0 -24
  379. package/dist/domains/dashboard/web/assets/diagram-UB23O5K3-co_OsTiQ.js +0 -41
  380. package/dist/domains/dashboard/web/assets/ebnfDiagram-BXEA7PRR-CETcWswS.js +0 -1
  381. package/dist/domains/dashboard/web/assets/erDiagram-JOGREHBK-edkItb7Z.js +0 -85
  382. package/dist/domains/dashboard/web/assets/flowDiagram-UKHOOZJN-D_oFJtSf.js +0 -156
  383. package/dist/domains/dashboard/web/assets/ganttDiagram-PKOTCBZU-CFjLVoA1.js +0 -292
  384. package/dist/domains/dashboard/web/assets/gitGraphDiagram-DS77QQ5N-BfD0tiKH.js +0 -106
  385. package/dist/domains/dashboard/web/assets/graph-DOmOIIwC.js +0 -1
  386. package/dist/domains/dashboard/web/assets/index-BzyqCfMb.css +0 -1
  387. package/dist/domains/dashboard/web/assets/index-CCKHH_A9.js +0 -10
  388. package/dist/domains/dashboard/web/assets/index-D8dxsTJY.js +0 -271
  389. package/dist/domains/dashboard/web/assets/index-DlSYK56b.js +0 -139
  390. package/dist/domains/dashboard/web/assets/infoDiagram-6WML65LV-Cx6xa9DS.js +0 -2
  391. package/dist/domains/dashboard/web/assets/init-Gi6I4Gst.js +0 -1
  392. package/dist/domains/dashboard/web/assets/ishikawaDiagram-WSZJBQD7-BjNLyyv_.js +0 -70
  393. package/dist/domains/dashboard/web/assets/journeyDiagram-NVQOT4AX-D2n9vrhx.js +0 -139
  394. package/dist/domains/dashboard/web/assets/kanban-definition-27J2QSJJ-kJL7v018.js +0 -89
  395. package/dist/domains/dashboard/web/assets/katex-HP8lGamR.js +0 -257
  396. package/dist/domains/dashboard/web/assets/layout-D-LzfAck.js +0 -1
  397. package/dist/domains/dashboard/web/assets/linear-CeHtd5-l.js +0 -1
  398. package/dist/domains/dashboard/web/assets/map-DxJ2ADlA.js +0 -1
  399. package/dist/domains/dashboard/web/assets/marked.esm-DECB3bxB.js +0 -64
  400. package/dist/domains/dashboard/web/assets/mermaid.core-B0EPSHs2.js +0 -306
  401. package/dist/domains/dashboard/web/assets/mindmap-definition-FAOFIHXS-bQQWINF4.js +0 -96
  402. package/dist/domains/dashboard/web/assets/ordinal-Cboi1Yqb.js +0 -1
  403. package/dist/domains/dashboard/web/assets/pegDiagram-VL7TDLO6-LxLY1W7W.js +0 -1
  404. package/dist/domains/dashboard/web/assets/pieDiagram-7S7Q4E2Y-BMDQqvuT.js +0 -39
  405. package/dist/domains/dashboard/web/assets/purify.es-Cz4mVeUR.js +0 -3
  406. package/dist/domains/dashboard/web/assets/quadrantDiagram-CIZ2JOQS-XWYjcuZN.js +0 -7
  407. package/dist/domains/dashboard/web/assets/railroadDiagram-AXF67PYL-p-OlQTa7.js +0 -1
  408. package/dist/domains/dashboard/web/assets/requirementDiagram-LRYGKXZP-BL4N8Vsl.js +0 -84
  409. package/dist/domains/dashboard/web/assets/sankeyDiagram-W5VNT64P-Btu-o6LN.js +0 -40
  410. package/dist/domains/dashboard/web/assets/sequenceDiagram-SI44F4Z6-9HpdQQ47.js +0 -162
  411. package/dist/domains/dashboard/web/assets/sizeCapture-X5ZJPWSS-5AnBiBHD.js +0 -1
  412. package/dist/domains/dashboard/web/assets/stateDiagram-OKZ733FA-Dv8IDsai.js +0 -1
  413. package/dist/domains/dashboard/web/assets/stateDiagram-v2-UEYNNEHI-DxOMyFOm.js +0 -1
  414. package/dist/domains/dashboard/web/assets/swimlanes-SLNWSIFB-BfJcN7dK.js +0 -2
  415. package/dist/domains/dashboard/web/assets/swimlanesDiagram-ULZ7WXOC-BnHRSbDk.js +0 -8
  416. package/dist/domains/dashboard/web/assets/timeline-definition-Z64GVDOM-DEOuEHi5.js +0 -120
  417. package/dist/domains/dashboard/web/assets/vennDiagram-T6HMQDX7-BqsGpwgo.js +0 -34
  418. package/dist/domains/dashboard/web/assets/wardleyDiagram-T6FBY63Y-CXlOp9so.js +0 -78
  419. package/dist/domains/dashboard/web/assets/xychartDiagram-ELKLHX3M-DyqqtC9X.js +0 -7
@@ -1,166 +1,167 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var Wd=Object.create;var ts=Object.defineProperty;var zd=Object.getOwnPropertyDescriptor;var Jd=Object.getOwnPropertyNames;var Gd=Object.getPrototypeOf,Ud=Object.prototype.hasOwnProperty;var Hr=(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 b=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Kd=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Jd(e))!Ud.call(t,n)&&n!==r&&ts(t,n,{get:()=>e[n],enumerable:!(i=zd(e,n))||i.enumerable});return t};var Dt=(t,e,r)=>(r=t!=null?Wd(Gd(t)):{},Kd(e||!t||!t.__esModule?ts(r,"default",{value:t,enumerable:!0}):r,t));var P=b(V=>{"use strict";var Nn=Symbol.for("yaml.alias"),rs=Symbol.for("yaml.document"),Dr=Symbol.for("yaml.map"),is=Symbol.for("yaml.pair"),bn=Symbol.for("yaml.scalar"),Lr=Symbol.for("yaml.seq"),be=Symbol.for("yaml.node.type"),Yd=t=>!!t&&typeof t=="object"&&t[be]===Nn,Xd=t=>!!t&&typeof t=="object"&&t[be]===rs,Qd=t=>!!t&&typeof t=="object"&&t[be]===Dr,Zd=t=>!!t&&typeof t=="object"&&t[be]===is,ns=t=>!!t&&typeof t=="object"&&t[be]===bn,ef=t=>!!t&&typeof t=="object"&&t[be]===Lr;function as(t){if(t&&typeof t=="object")switch(t[be]){case Dr:case Lr:return!0}return!1}function tf(t){if(t&&typeof t=="object")switch(t[be]){case Nn:case Dr:case bn:case Lr:return!0}return!1}var rf=t=>(ns(t)||as(t))&&!!t.anchor;V.ALIAS=Nn;V.DOC=rs;V.MAP=Dr;V.NODE_TYPE=be;V.PAIR=is;V.SCALAR=bn;V.SEQ=Lr;V.hasAnchor=rf;V.isAlias=Yd;V.isCollection=as;V.isDocument=Xd;V.isMap=Qd;V.isNode=tf;V.isPair=Zd;V.isScalar=ns;V.isSeq=ef});var Lt=b(kn=>{"use strict";var H=P(),J=Symbol("break visit"),os=Symbol("skip children"),pe=Symbol("remove node");function Br(t,e){let r=ss(e);H.isDocument(t)?ft(null,t.contents,r,Object.freeze([t]))===pe&&(t.contents=null):ft(null,t,r,Object.freeze([]))}Br.BREAK=J;Br.SKIP=os;Br.REMOVE=pe;function ft(t,e,r,i){let n=cs(t,e,r,i);if(H.isNode(n)||H.isPair(n))return ls(t,i,n),ft(t,n,r,i);if(typeof n!="symbol"){if(H.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=ft(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===J)return J;o===pe&&(e.items.splice(a,1),a-=1)}}}else if(H.isPair(e)){i=Object.freeze(i.concat(e));let a=ft("key",e.key,r,i);if(a===J)return J;a===pe&&(e.key=null);let o=ft("value",e.value,r,i);if(o===J)return J;o===pe&&(e.value=null)}}return n}async function Mr(t,e){let r=ss(e);H.isDocument(t)?await pt(null,t.contents,r,Object.freeze([t]))===pe&&(t.contents=null):await pt(null,t,r,Object.freeze([]))}Mr.BREAK=J;Mr.SKIP=os;Mr.REMOVE=pe;async function pt(t,e,r,i){let n=await cs(t,e,r,i);if(H.isNode(n)||H.isPair(n))return ls(t,i,n),pt(t,n,r,i);if(typeof n!="symbol"){if(H.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await pt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===J)return J;o===pe&&(e.items.splice(a,1),a-=1)}}}else if(H.isPair(e)){i=Object.freeze(i.concat(e));let a=await pt("key",e.key,r,i);if(a===J)return J;a===pe&&(e.key=null);let o=await pt("value",e.value,r,i);if(o===J)return J;o===pe&&(e.value=null)}}return n}function ss(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 cs(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(H.isMap(e))return r.Map?.(t,e,i);if(H.isSeq(e))return r.Seq?.(t,e,i);if(H.isPair(e))return r.Pair?.(t,e,i);if(H.isScalar(e))return r.Scalar?.(t,e,i);if(H.isAlias(e))return r.Alias?.(t,e,i)}function ls(t,e,r){let i=e[e.length-1];if(H.isCollection(i))i.items[t]=r;else if(H.isPair(i))t==="key"?i.key=r:i.value=r;else if(H.isDocument(i))i.contents=r;else{let n=H.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}kn.visit=Br;kn.visitAsync=Mr});var Sn=b(ds=>{"use strict";var us=P(),nf=Lt(),af={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},of=t=>t.replace(/[!,[\]{}]/g,e=>af[e]),Bt=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+of(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&&us.isNode(e.contents)){let a={};nf.visit(e.contents,(o,s)=>{us.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
- `)}};Bt.defaultYaml={explicit:!1,version:"1.2"};Bt.defaultTags={"!!":"tag:yaml.org,2002:"};ds.Directives=Bt});var Vr=b(Mt=>{"use strict";var fs=P(),sf=Lt();function cf(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 ps(t){let e=new Set;return sf.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function hs(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function lf(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=ps(t));let o=hs(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(fs.isScalar(o.node)||fs.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}}Mt.anchorIsValid=cf;Mt.anchorNames=ps;Mt.createNodeAnchors=lf;Mt.findNewAnchor=hs});var En=b(ms=>{"use strict";function Vt(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=Vt(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=Vt(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=Vt(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=Vt(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}ms.applyReviver=Vt});var Ae=b(gs=>{"use strict";var uf=P();function vs(t,e,r){if(Array.isArray(t))return t.map((i,n)=>vs(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!uf.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}gs.toJS=vs});var Fr=b(ys=>{"use strict";var df=En(),ws=P(),ff=Ae(),Cn=class{constructor(e){Object.defineProperty(this,ws.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(!ws.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=ff.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?df.applyReviver(a,{"":s},"",s):s}};ys.NodeBase=Cn});var Ft=b(Ns=>{"use strict";var pf=Vr(),hf=Lt(),ht=P(),mf=Fr(),vf=Ae(),xn=class extends mf.NodeBase{constructor(e){super(ht.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=[],hf.visit(e,{Node:(a,o)=>{(ht.isAlias(o)||ht.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||(vf.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=qr(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(pf.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 qr(t,e,r){if(ht.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(ht.isCollection(e)){let i=0;for(let n of e.items){let a=qr(t,n,r);a>i&&(i=a)}return i}else if(ht.isPair(e)){let i=qr(t,e.key,r),n=qr(t,e.value,r);return Math.max(i,n)}return 1}Ns.Alias=xn});var $=b(Pn=>{"use strict";var gf=P(),wf=Fr(),yf=Ae(),Nf=t=>!t||typeof t!="function"&&typeof t!="object",_e=class extends wf.NodeBase{constructor(e){super(gf.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:yf.toJS(this.value,e,r)}toString(){return String(this.value)}};_e.BLOCK_FOLDED="BLOCK_FOLDED";_e.BLOCK_LITERAL="BLOCK_LITERAL";_e.PLAIN="PLAIN";_e.QUOTE_DOUBLE="QUOTE_DOUBLE";_e.QUOTE_SINGLE="QUOTE_SINGLE";Pn.Scalar=_e;Pn.isScalarValue=Nf});var qt=b(ks=>{"use strict";var bf=Ft(),Ye=P(),bs=$(),kf="tag:yaml.org,2002:";function Sf(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 Ef(t,e,r){if(Ye.isDocument(t)&&(t=t.contents),Ye.isNode(t))return t;if(Ye.isPair(t)){let d=r.schema[Ye.MAP].createNode?.(r.schema,null,r);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects: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 bf.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=kf+e.slice(2));let l=Sf(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new bs.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?o[Ye.MAP]:Symbol.iterator in Object(t)?o[Ye.SEQ]:o[Ye.MAP]}a&&(a(l),delete r.onTagObj);let u=l?.createNode?l.createNode(r.schema,t,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,t,r):new bs.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}ks.createNode=Ef});var zr=b(Wr=>{"use strict";var Cf=qt(),he=P(),xf=Fr();function Rn(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 Cf.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 Ss=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,An=class extends xf.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=>he.isNode(i)||he.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(Ss(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(he.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,Rn(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(he.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&&he.isScalar(a)?a.value:a:he.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!he.isPair(r))return!1;let i=r.value;return i==null||e&&he.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 he.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(he.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,Rn(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Wr.Collection=An;Wr.collectionFromPath=Rn;Wr.isEmptyPath=Ss});var Wt=b(Jr=>{"use strict";var Pf=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function _n(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Rf=(t,e,r)=>t.endsWith(`
6
- `)?_n(r,e):r.includes(`
4
+ var zd=Object.create;var es=Object.defineProperty;var Jd=Object.getOwnPropertyDescriptor;var Gd=Object.getOwnPropertyNames;var Ud=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty;var Dr=(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 b=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Yd=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Gd(e))!Kd.call(t,n)&&n!==r&&es(t,n,{get:()=>e[n],enumerable:!(i=Jd(e,n))||i.enumerable});return t};var Vt=(t,e,r)=>(r=t!=null?zd(Ud(t)):{},Yd(e||!t||!t.__esModule?es(r,"default",{value:t,enumerable:!0}):r,t));var P=b(F=>{"use strict";var kn=Symbol.for("yaml.alias"),ts=Symbol.for("yaml.document"),Lr=Symbol.for("yaml.map"),rs=Symbol.for("yaml.pair"),Sn=Symbol.for("yaml.scalar"),Br=Symbol.for("yaml.seq"),be=Symbol.for("yaml.node.type"),Xd=t=>!!t&&typeof t=="object"&&t[be]===kn,Qd=t=>!!t&&typeof t=="object"&&t[be]===ts,Zd=t=>!!t&&typeof t=="object"&&t[be]===Lr,ef=t=>!!t&&typeof t=="object"&&t[be]===rs,is=t=>!!t&&typeof t=="object"&&t[be]===Sn,tf=t=>!!t&&typeof t=="object"&&t[be]===Br;function ns(t){if(t&&typeof t=="object")switch(t[be]){case Lr:case Br:return!0}return!1}function rf(t){if(t&&typeof t=="object")switch(t[be]){case kn:case Lr:case Sn:case Br:return!0}return!1}var nf=t=>(is(t)||ns(t))&&!!t.anchor;F.ALIAS=kn;F.DOC=ts;F.MAP=Lr;F.NODE_TYPE=be;F.PAIR=rs;F.SCALAR=Sn;F.SEQ=Br;F.hasAnchor=nf;F.isAlias=Xd;F.isCollection=ns;F.isDocument=Qd;F.isMap=Zd;F.isNode=rf;F.isPair=ef;F.isScalar=is;F.isSeq=tf});var Mt=b(En=>{"use strict";var H=P(),J=Symbol("break visit"),as=Symbol("skip children"),he=Symbol("remove node");function Vr(t,e){let r=os(e);H.isDocument(t)?ht(null,t.contents,r,Object.freeze([t]))===he&&(t.contents=null):ht(null,t,r,Object.freeze([]))}Vr.BREAK=J;Vr.SKIP=as;Vr.REMOVE=he;function ht(t,e,r,i){let n=ss(t,e,r,i);if(H.isNode(n)||H.isPair(n))return cs(t,i,n),ht(t,n,r,i);if(typeof n!="symbol"){if(H.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=ht(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(H.isPair(e)){i=Object.freeze(i.concat(e));let a=ht("key",e.key,r,i);if(a===J)return J;a===he&&(e.key=null);let o=ht("value",e.value,r,i);if(o===J)return J;o===he&&(e.value=null)}}return n}async function Mr(t,e){let r=os(e);H.isDocument(t)?await pt(null,t.contents,r,Object.freeze([t]))===he&&(t.contents=null):await pt(null,t,r,Object.freeze([]))}Mr.BREAK=J;Mr.SKIP=as;Mr.REMOVE=he;async function pt(t,e,r,i){let n=await ss(t,e,r,i);if(H.isNode(n)||H.isPair(n))return cs(t,i,n),pt(t,n,r,i);if(typeof n!="symbol"){if(H.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await pt(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(H.isPair(e)){i=Object.freeze(i.concat(e));let a=await pt("key",e.key,r,i);if(a===J)return J;a===he&&(e.key=null);let o=await pt("value",e.value,r,i);if(o===J)return J;o===he&&(e.value=null)}}return n}function os(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 ss(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(H.isMap(e))return r.Map?.(t,e,i);if(H.isSeq(e))return r.Seq?.(t,e,i);if(H.isPair(e))return r.Pair?.(t,e,i);if(H.isScalar(e))return r.Scalar?.(t,e,i);if(H.isAlias(e))return r.Alias?.(t,e,i)}function cs(t,e,r){let i=e[e.length-1];if(H.isCollection(i))i.items[t]=r;else if(H.isPair(i))t==="key"?i.key=r:i.value=r;else if(H.isDocument(i))i.contents=r;else{let n=H.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}En.visit=Vr;En.visitAsync=Mr});var Cn=b(us=>{"use strict";var ls=P(),af=Mt(),of={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},sf=t=>t.replace(/[!,[\]{}]/g,e=>of[e]),Ft=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+sf(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&&ls.isNode(e.contents)){let a={};af.visit(e.contents,(o,s)=>{ls.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
+ `)}};Ft.defaultYaml={explicit:!1,version:"1.2"};Ft.defaultTags={"!!":"tag:yaml.org,2002:"};us.Directives=Ft});var Fr=b(qt=>{"use strict";var ds=P(),cf=Mt();function lf(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 cf.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function hs(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function uf(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=fs(t));let o=hs(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(ds.isScalar(o.node)||ds.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}}qt.anchorIsValid=lf;qt.anchorNames=fs;qt.createNodeAnchors=uf;qt.findNewAnchor=hs});var xn=b(ps=>{"use strict";function Wt(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=Wt(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=Wt(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=Wt(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=Wt(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}ps.applyReviver=Wt});var _e=b(vs=>{"use strict";var df=P();function ms(t,e,r){if(Array.isArray(t))return t.map((i,n)=>ms(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!df.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}vs.toJS=ms});var qr=b(ws=>{"use strict";var ff=xn(),gs=P(),hf=_e(),Pn=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=hf.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?ff.applyReviver(a,{"":s},"",s):s}};ws.NodeBase=Pn});var zt=b(ys=>{"use strict";var pf=Fr(),mf=Mt(),mt=P(),vf=qr(),gf=_e(),Rn=class extends vf.NodeBase{constructor(e){super(mt.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=[],mf.visit(e,{Node:(a,o)=>{(mt.isAlias(o)||mt.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||(gf.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=Wr(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(pf.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 Wr(t,e,r){if(mt.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(mt.isCollection(e)){let i=0;for(let n of e.items){let a=Wr(t,n,r);a>i&&(i=a)}return i}else if(mt.isPair(e)){let i=Wr(t,e.key,r),n=Wr(t,e.value,r);return Math.max(i,n)}return 1}ys.Alias=Rn});var $=b(An=>{"use strict";var wf=P(),yf=qr(),Nf=_e(),bf=t=>!t||typeof t!="function"&&typeof t!="object",Ie=class extends yf.NodeBase{constructor(e){super(wf.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:Nf.toJS(this.value,e,r)}toString(){return String(this.value)}};Ie.BLOCK_FOLDED="BLOCK_FOLDED";Ie.BLOCK_LITERAL="BLOCK_LITERAL";Ie.PLAIN="PLAIN";Ie.QUOTE_DOUBLE="QUOTE_DOUBLE";Ie.QUOTE_SINGLE="QUOTE_SINGLE";An.Scalar=Ie;An.isScalarValue=bf});var Jt=b(bs=>{"use strict";var kf=zt(),Qe=P(),Ns=$(),Sf="tag:yaml.org,2002:";function Ef(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 Cf(t,e,r){if(Qe.isDocument(t)&&(t=t.contents),Qe.isNode(t))return t;if(Qe.isPair(t)){let u=r.schema[Qe.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 kf.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=Sf+e.slice(2));let l=Ef(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new Ns.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?o[Qe.MAP]:Symbol.iterator in Object(t)?o[Qe.SEQ]:o[Qe.MAP]}a&&(a(l),delete r.onTagObj);let d=l?.createNode?l.createNode(r.schema,t,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,t,r):new Ns.Scalar(t);return e?d.tag=e:l.default||(d.tag=l.tag),c&&(c.node=d),d}bs.createNode=Cf});var Jr=b(zr=>{"use strict";var xf=Jt(),pe=P(),Pf=qr();function _n(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 xf.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 ks=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,In=class extends Pf.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=>pe.isNode(i)||pe.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(ks(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(pe.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,_n(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(pe.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&&pe.isScalar(a)?a.value:a:pe.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!pe.isPair(r))return!1;let i=r.value;return i==null||e&&pe.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 pe.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(pe.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,_n(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};zr.Collection=In;zr.collectionFromPath=_n;zr.isEmptyPath=ks});var Gt=b(Gr=>{"use strict";var Rf=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Tn(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Af=(t,e,r)=>t.endsWith(`
6
+ `)?Tn(r,e):r.includes(`
7
7
  `)?`
8
- `+_n(r,e):(t.endsWith(" ")?"":" ")+r;Jr.indentComment=_n;Jr.lineComment=Rf;Jr.stringifyComment=Pf});var Cs=b(zt=>{"use strict";var Af="flow",In="block",Gr="quoted";function _f(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=[],u={},d=n-e.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):d=n-i);let f,m,v=!1,p=-1,h=-1,N=-1;r===In&&(p=Es(t,p,e.length),p!==-1&&(d=p+c));for(let g;g=t[p+=1];){if(r===Gr&&g==="\\"){switch(h=p,t[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}N=p}if(g===`
9
- `)r===In&&(p=Es(t,p,e.length)),d=p+e.length+c,f=void 0;else{if(g===" "&&m&&m!==" "&&m!==`
10
- `&&m!==" "){let S=t[p+1];S&&S!==" "&&S!==`
11
- `&&S!==" "&&(f=p)}if(p>=d)if(f)l.push(f),d=f+c,f=void 0;else if(r===Gr){for(;m===" "||m===" ";)m=g,g=t[p+=1],v=!0;let S=p>N+1?p-2:h-1;if(u[S])return t;l.push(S),u[S]=!0,d=S+c,f=void 0}else v=!0}m=g}if(v&&s&&s(),l.length===0)return t;o&&o();let w=t.slice(0,l[0]);for(let g=0;g<l.length;++g){let S=l[g],E=l[g+1]||t.length;S===0?w=`
12
- ${e}${t.slice(0,E)}`:(r===Gr&&u[S]&&(w+=`${t[S]}\\`),w+=`
13
- ${e}${t.slice(S+1,E)}`)}return w}function Es(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}zt.FOLD_BLOCK=In;zt.FOLD_FLOW=Af;zt.FOLD_QUOTED=Gr;zt.foldFlowLines=_f});var Gt=b(xs=>{"use strict";var ae=$(),Ie=Cs(),Kr=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Yr=t=>/^(%|---|\.\.\.)/m.test(t);function If(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 Jt(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(Yr(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 u=r.substr(c+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=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
+ `+Tn(r,e):(t.endsWith(" ")?"":" ")+r;Gr.indentComment=Tn;Gr.lineComment=Af;Gr.stringifyComment=Rf});var Es=b(Ut=>{"use strict";var _f="flow",jn="block",Ur="quoted";function If(t,e,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return t;n<a&&(a=0);let c=Math.max(1+a,1+n-e.length);if(t.length<=c)return t;let l=[],d={},u=n-e.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):u=n-i);let f,m,v=!1,h=-1,p=-1,N=-1;r===jn&&(h=Ss(t,h,e.length),h!==-1&&(u=h+c));for(let g;g=t[h+=1];){if(r===Ur&&g==="\\"){switch(p=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}N=h}if(g===`
9
+ `)r===jn&&(h=Ss(t,h,e.length)),u=h+e.length+c,f=void 0;else{if(g===" "&&m&&m!==" "&&m!==`
10
+ `&&m!==" "){let S=t[h+1];S&&S!==" "&&S!==`
11
+ `&&S!==" "&&(f=h)}if(h>=u)if(f)l.push(f),u=f+c,f=void 0;else if(r===Ur){for(;m===" "||m===" ";)m=g,g=t[h+=1],v=!0;let S=h>N+1?h-2:p-1;if(d[S])return t;l.push(S),d[S]=!0,u=S+c,f=void 0}else v=!0}m=g}if(v&&s&&s(),l.length===0)return t;o&&o();let w=t.slice(0,l[0]);for(let g=0;g<l.length;++g){let S=l[g],E=l[g+1]||t.length;S===0?w=`
12
+ ${e}${t.slice(0,E)}`:(r===Ur&&d[S]&&(w+=`${t[S]}\\`),w+=`
13
+ ${e}${t.slice(S+1,E)}`)}return w}function Ss(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}Ut.FOLD_BLOCK=jn;Ut.FOLD_FLOW=_f;Ut.FOLD_QUOTED=Ur;Ut.foldFlowLines=If});var Yt=b(Cs=>{"use strict";var ae=$(),Te=Es(),Yr=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Xr=t=>/^(%|---|\.\.\.)/m.test(t);function Tf(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 Kt(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(Xr(t)?" ":""),o="",s=0;for(let c=0,l=r[c];l;l=r[++c])if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n"&&(o+=r.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(r[c+1]){case"u":{o+=r.slice(s,c);let d=r.substr(c+2,4);switch(d){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:d.substr(0,2)==="00"?o+="\\x"+d.substr(2):o+=r.substr(c,6)}c+=5,s=c+1}break;case"n":if(i||r[c+2]==='"'||r.length<n)c+=1;else{for(o+=r.slice(s,c)+`
16
16
 
17
17
  `;r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"';)o+=`
18
- `,c+=2;o+=a,r[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+r.slice(s):r,i?o:Ie.foldFlowLines(o,a,Ie.FOLD_QUOTED,Kr(e,!1))}function Tn(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(t))return Jt(t,e);let r=e.indent||(Yr(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${r}`)+"'";return e.implicitKey?i:Ie.foldFlowLines(i,r,Ie.FOLD_FLOW,Kr(e,!1))}function mt(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=Jt;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=Tn:a&&!n?i=Jt:i=r?Tn:Jt}return i(t,e)}var jn;try{jn=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:Te.foldFlowLines(o,a,Te.FOLD_QUOTED,Yr(e,!1))}function $n(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(t))return Kt(t,e);let r=e.indent||(Xr(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${r}`)+"'";return e.implicitKey?i:Te.foldFlowLines(i,r,Te.FOLD_FLOW,Yr(e,!1))}function vt(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=Kt;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=$n:a&&!n?i=Kt:i=r?$n:Kt}return i(t,e)}var On;try{On=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{jn=/\n+(?!\n|$)/g}function Ur({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 mt(r,i);let l=i.indent||(i.forceBlockIndent||Yr(r)?" ":""),u=o==="literal"?!0:o==="folded"||e===ae.Scalar.BLOCK_FOLDED?!1:e===ae.Scalar.BLOCK_LITERAL?!0:!If(r,c,l.length);if(!r)return u?`|
23
+ |$)`,"g")}catch{On=/\n+(?!\n|$)/g}function Kr({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 vt(r,i);let l=i.indent||(i.forceBlockIndent||Xr(r)?" ":""),d=o==="literal"?!0:o==="folded"||e===ae.Scalar.BLOCK_FOLDED?!1:e===ae.Scalar.BLOCK_LITERAL?!0:!Tf(r,c,l.length);if(!r)return d?`|
24
24
  `:`>
25
- `;let d,f;for(f=r.length;f>0;--f){let E=r[f-1];if(E!==`
25
+ `;let u,f;for(f=r.length;f>0;--f){let E=r[f-1];if(E!==`
26
26
  `&&E!==" "&&E!==" ")break}let m=r.substring(f),v=m.indexOf(`
27
- `);v===-1?d="-":r===m||v!==m.length-1?(d="+",a&&a()):d="",m&&(r=r.slice(0,-m.length),m[m.length-1]===`
28
- `&&(m=m.slice(0,-1)),m=m.replace(jn,`$&${l}`));let p=!1,h,N=-1;for(h=0;h<r.length;++h){let E=r[h];if(E===" ")p=!0;else if(E===`
29
- `)N=h;else break}let w=r.substring(0,N<h?N+1:h);w&&(r=r.substring(w.length),w=w.replace(/\n+/g,`$&${l}`));let S=(p?l?"2":"1":"")+d;if(t&&(S+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!u){let E=r.replace(/\n+/g,`
30
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),y=!1,C=Kr(i,!0);o!=="folded"&&e!==ae.Scalar.BLOCK_FOLDED&&(C.onOverflow=()=>{y=!0});let k=Ie.foldFlowLines(`${w}${E}${m}`,l,Ie.FOLD_BLOCK,C);if(!y)return`>${S}
27
+ `);v===-1?u="-":r===m||v!==m.length-1?(u="+",a&&a()):u="",m&&(r=r.slice(0,-m.length),m[m.length-1]===`
28
+ `&&(m=m.slice(0,-1)),m=m.replace(On,`$&${l}`));let h=!1,p,N=-1;for(p=0;p<r.length;++p){let E=r[p];if(E===" ")h=!0;else if(E===`
29
+ `)N=p;else break}let w=r.substring(0,N<p?N+1:p);w&&(r=r.substring(w.length),w=w.replace(/\n+/g,`$&${l}`));let S=(h?l?"2":"1":"")+u;if(t&&(S+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!d){let E=r.replace(/\n+/g,`
30
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),y=!1,C=Yr(i,!0);o!=="folded"&&e!==ae.Scalar.BLOCK_FOLDED&&(C.onOverflow=()=>{y=!0});let k=Te.foldFlowLines(`${w}${E}${m}`,l,Te.FOLD_BLOCK,C);if(!y)return`>${S}
31
31
  ${l}${k}`}return r=r.replace(/\n+/g,`$&${l}`),`|${S}
32
- ${l}${w}${r}${m}`}function Tf(t,e,r,i){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=e;if(s&&a.includes(`
33
- `)||u&&/[[\]{},]/.test(a))return mt(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
34
- `)?mt(a,e):Ur(t,e,r,i);if(!s&&!u&&n!==ae.Scalar.PLAIN&&a.includes(`
35
- `))return Ur(t,e,r,i);if(Yr(a)){if(c==="")return e.forceBlockIndent=!0,Ur(t,e,r,i);if(s&&c===l)return mt(a,e)}let d=a.replace(/\n+/g,`$&
36
- ${c}`);if(o){let f=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(d),{compat:m,tags:v}=e.doc.schema;if(v.some(f)||m?.some(f))return mt(a,e)}return s?d:Ie.foldFlowLines(d,c,Ie.FOLD_FLOW,Kr(e,!1))}function jf(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!==ae.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=ae.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case ae.Scalar.BLOCK_FOLDED:case ae.Scalar.BLOCK_LITERAL:return n||a?mt(o.value,e):Ur(o,e,r,i);case ae.Scalar.QUOTE_DOUBLE:return Jt(o.value,e);case ae.Scalar.QUOTE_SINGLE:return Tn(o.value,e);case ae.Scalar.PLAIN:return Tf(o,e,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:u,defaultStringType:d}=e.options,f=n&&u||d;if(l=c(f),l===null)throw new Error(`Unsupported default string type ${f}`)}return l}xs.stringifyString=jf});var Ut=b($n=>{"use strict";var $f=Vr(),Te=P(),Of=Wt(),Hf=Gt();function Df(t,e){let r=Object.assign({blockQuote:!0,commentString:Of.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 Lf(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(Te.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 Bf(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(Te.isScalar(t)||Te.isCollection(t))&&t.anchor;a&&$f.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 Mf(t,e,r,i){if(Te.isPair(t))return t.toString(e,r,i);if(Te.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=Te.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Lf(e.doc.schema.tags,a));let o=Bf(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):Te.isScalar(a)?Hf.stringifyString(a,e,r,i):a.toString(e,r,i);return o?Te.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${e.indent}${s}`:s}$n.createStringifyContext=Df;$n.stringify=Mf});var _s=b(As=>{"use strict";var ke=P(),Ps=$(),Rs=Ut(),Kt=Wt();function Vf({key:t,value:e},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=r,f=ke.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(ke.isCollection(t)||!ke.isNode(t)&&typeof t=="object"){let C="With simple keys, collection cannot be used as a key value";throw new Error(C)}}let m=!d&&(!t||f&&e==null&&!r.inFlow||ke.isCollection(t)||(ke.isScalar(t)?t.type===Ps.Scalar.BLOCK_FOLDED||t.type===Ps.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!m&&(d||!a),indent:s+c});let v=!1,p=!1,h=Rs.stringify(t,r,()=>v=!0,()=>p=!0);if(!m&&!r.inFlow&&h.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(r.inFlow){if(a||e==null)return v&&i&&i(),h===""?"?":m?`? ${h}`:h}else if(a&&!d||e==null&&m)return h=`? ${h}`,f&&!v?h+=Kt.lineComment(h,r.indent,l(f)):p&&n&&n(),h;v&&(f=null),m?(f&&(h+=Kt.lineComment(h,r.indent,l(f))),h=`? ${h}
38
- ${s}:`):(h=`${h}:`,f&&(h+=Kt.lineComment(h,r.indent,l(f))));let N,w,g;ke.isNode(e)?(N=!!e.spaceBefore,w=e.commentBefore,g=e.comment):(N=!1,w=null,g=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!m&&!f&&ke.isScalar(e)&&(r.indentAtStart=h.length+1),p=!1,!u&&c.length>=2&&!r.inFlow&&!m&&ke.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let S=!1,E=Rs.stringify(e,r,()=>S=!0,()=>p=!0),y=" ";if(f||N||w){if(y=N?`
32
+ ${l}${w}${r}${m}`}function jf(t,e,r,i){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:d}=e;if(s&&a.includes(`
33
+ `)||d&&/[[\]{},]/.test(a))return vt(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||d||!a.includes(`
34
+ `)?vt(a,e):Kr(t,e,r,i);if(!s&&!d&&n!==ae.Scalar.PLAIN&&a.includes(`
35
+ `))return Kr(t,e,r,i);if(Xr(a)){if(c==="")return e.forceBlockIndent=!0,Kr(t,e,r,i);if(s&&c===l)return vt(a,e)}let u=a.replace(/\n+/g,`$&
36
+ ${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:m,tags:v}=e.doc.schema;if(v.some(f)||m?.some(f))return vt(a,e)}return s?u:Te.foldFlowLines(u,c,Te.FOLD_FLOW,Yr(e,!1))}function $f(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!==ae.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=ae.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case ae.Scalar.BLOCK_FOLDED:case ae.Scalar.BLOCK_LITERAL:return n||a?vt(o.value,e):Kr(o,e,r,i);case ae.Scalar.QUOTE_DOUBLE:return Kt(o.value,e);case ae.Scalar.QUOTE_SINGLE:return $n(o.value,e);case ae.Scalar.PLAIN:return jf(o,e,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:d,defaultStringType:u}=e.options,f=n&&d||u;if(l=c(f),l===null)throw new Error(`Unsupported default string type ${f}`)}return l}Cs.stringifyString=$f});var Xt=b(Hn=>{"use strict";var Of=Fr(),je=P(),Hf=Gt(),Df=Yt();function Lf(t,e){let r=Object.assign({blockQuote:!0,commentString:Hf.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 Bf(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(je.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 Vf(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(je.isScalar(t)||je.isCollection(t))&&t.anchor;a&&Of.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 Mf(t,e,r,i){if(je.isPair(t))return t.toString(e,r,i);if(je.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let n,a=je.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Bf(e.doc.schema.tags,a));let o=Vf(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):je.isScalar(a)?Df.stringifyString(a,e,r,i):a.toString(e,r,i);return o?je.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${e.indent}${s}`:s}Hn.createStringifyContext=Lf;Hn.stringify=Mf});var As=b(Rs=>{"use strict";var ke=P(),xs=$(),Ps=Xt(),Qt=Gt();function Ff({key:t,value:e},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:u}}=r,f=ke.isNode(t)&&t.comment||null;if(u){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(ke.isCollection(t)||!ke.isNode(t)&&typeof t=="object"){let C="With simple keys, collection cannot be used as a key value";throw new Error(C)}}let m=!u&&(!t||f&&e==null&&!r.inFlow||ke.isCollection(t)||(ke.isScalar(t)?t.type===xs.Scalar.BLOCK_FOLDED||t.type===xs.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!m&&(u||!a),indent:s+c});let v=!1,h=!1,p=Ps.stringify(t,r,()=>v=!0,()=>h=!0);if(!m&&!r.inFlow&&p.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(r.inFlow){if(a||e==null)return v&&i&&i(),p===""?"?":m?`? ${p}`:p}else if(a&&!u||e==null&&m)return p=`? ${p}`,f&&!v?p+=Qt.lineComment(p,r.indent,l(f)):h&&n&&n(),p;v&&(f=null),m?(f&&(p+=Qt.lineComment(p,r.indent,l(f))),p=`? ${p}
38
+ ${s}:`):(p=`${p}:`,f&&(p+=Qt.lineComment(p,r.indent,l(f))));let N,w,g;ke.isNode(e)?(N=!!e.spaceBefore,w=e.commentBefore,g=e.comment):(N=!1,w=null,g=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!m&&!f&&ke.isScalar(e)&&(r.indentAtStart=p.length+1),h=!1,!d&&c.length>=2&&!r.inFlow&&!m&&ke.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let S=!1,E=Ps.stringify(e,r,()=>S=!0,()=>h=!0),y=" ";if(f||N||w){if(y=N?`
39
39
  `:"",w){let C=l(w);y+=`
40
- ${Kt.indentComment(C,r.indent)}`}E===""&&!r.inFlow?y===`
40
+ ${Qt.indentComment(C,r.indent)}`}E===""&&!r.inFlow?y===`
41
41
  `&&g&&(y=`
42
42
 
43
43
  `):y+=`
44
44
  ${r.indent}`}else if(!m&&ke.isCollection(e)){let C=E[0],k=E.indexOf(`
45
- `),_=k!==-1,L=r.inFlow??e.flow??e.items.length===0;if(_||!L){let Re=!1;if(_&&(C==="&"||C==="!")){let I=E.indexOf(" ");C==="&"&&I!==-1&&I<k&&E[I+1]==="!"&&(I=E.indexOf(" ",I+1)),(I===-1||k<I)&&(Re=!0)}Re||(y=`
45
+ `),_=k!==-1,L=r.inFlow??e.flow??e.items.length===0;if(_||!L){let Ae=!1;if(_&&(C==="&"||C==="!")){let I=E.indexOf(" ");C==="&"&&I!==-1&&I<k&&E[I+1]==="!"&&(I=E.indexOf(" ",I+1)),(I===-1||k<I)&&(Ae=!0)}Ae||(y=`
46
46
  ${r.indent}`)}}else(E===""||E[0]===`
47
- `)&&(y="");return h+=y+E,r.inFlow?S&&i&&i():g&&!S?h+=Kt.lineComment(h,r.indent,l(g)):p&&n&&n(),h}As.stringifyPair=Vf});var Hn=b(On=>{"use strict";var Is=Hr("process");function Ff(t,...e){t==="debug"&&console.log(...e)}function qf(t,e){(t==="debug"||t==="warn")&&(typeof Is.emitWarning=="function"?Is.emitWarning(e):console.warn(e))}On.debug=Ff;On.warn=qf});var ti=b(ei=>{"use strict";var Zr=P(),Ts=$(),Xr="<<",Qr={identify:t=>t===Xr||typeof t=="symbol"&&t.description===Xr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ts.Scalar(Symbol(Xr)),{addToJSMap:js}),stringify:()=>Xr},Wf=(t,e)=>(Qr.identify(e)||Zr.isScalar(e)&&(!e.type||e.type===Ts.Scalar.PLAIN)&&Qr.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===Qr.tag&&r.default);function js(t,e,r){let i=$s(t,r);if(Zr.isSeq(i))for(let n of i.items)Dn(t,e,n);else if(Array.isArray(i))for(let n of i)Dn(t,e,n);else Dn(t,e,i)}function Dn(t,e,r){let i=$s(t,r);if(!Zr.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 $s(t,e){return t&&Zr.isAlias(e)?e.resolve(t.doc,t):e}ei.addMergeToJSMap=js;ei.isMergeKey=Wf;ei.merge=Qr});var Bn=b(Ds=>{"use strict";var zf=Hn(),Os=ti(),Jf=Ut(),Hs=P(),Ln=Ae();function Gf(t,e,{key:r,value:i}){if(Hs.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(Os.isMergeKey(t,r))Os.addMergeToJSMap(t,e,i);else{let n=Ln.toJS(r,"",t);if(e instanceof Map)e.set(n,Ln.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=Uf(r,n,t),o=Ln.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 Uf(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(Hs.isNode(t)&&r?.doc){let i=Jf.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)+'..."'),zf.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)}Ds.addPairToJSMap=Gf});var je=b(Mn=>{"use strict";var Ls=qt(),Kf=_s(),Yf=Bn(),ri=P();function Xf(t,e,r){let i=Ls.createNode(t,void 0,r),n=Ls.createNode(e,void 0,r);return new ii(i,n)}var ii=class t{constructor(e,r=null){Object.defineProperty(this,ri.NODE_TYPE,{value:ri.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return ri.isNode(r)&&(r=r.clone(e)),ri.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return Yf.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?Kf.stringifyPair(this,e,r,i):JSON.stringify(this)}};Mn.Pair=ii;Mn.createPair=Xf});var Vn=b(Ms=>{"use strict";var Xe=P(),Bs=Ut(),ni=Wt();function Qf(t,e,r){return(e.inFlow??t.flow?ep:Zf)(t,e,r)}function Zf({comment:t,items:e},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,u=Object.assign({},r,{indent:a,type:null}),d=!1,f=[];for(let v=0;v<e.length;++v){let p=e[v],h=null;if(Xe.isNode(p))!d&&p.spaceBefore&&f.push(""),ai(r,f,p.commentBefore,d),p.comment&&(h=p.comment);else if(Xe.isPair(p)){let w=Xe.isNode(p.key)?p.key:null;w&&(!d&&w.spaceBefore&&f.push(""),ai(r,f,w.commentBefore,d))}d=!1;let N=Bs.stringify(p,u,()=>h=null,()=>d=!0);h&&(N+=ni.lineComment(N,a,l(h))),d&&h&&(d=!1),f.push(i+N)}let m;if(f.length===0)m=n.start+n.end;else{m=f[0];for(let v=1;v<f.length;++v){let p=f[v];m+=p?`
48
- ${c}${p}`:`
47
+ `)&&(y="");return p+=y+E,r.inFlow?S&&i&&i():g&&!S?p+=Qt.lineComment(p,r.indent,l(g)):h&&n&&n(),p}Rs.stringifyPair=Ff});var Ln=b(Dn=>{"use strict";var _s=Dr("process");function qf(t,...e){t==="debug"&&console.log(...e)}function Wf(t,e){(t==="debug"||t==="warn")&&(typeof _s.emitWarning=="function"?_s.emitWarning(e):console.warn(e))}Dn.debug=qf;Dn.warn=Wf});var ri=b(ti=>{"use strict";var ei=P(),Is=$(),Qr="<<",Zr={identify:t=>t===Qr||typeof t=="symbol"&&t.description===Qr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Is.Scalar(Symbol(Qr)),{addToJSMap:Ts}),stringify:()=>Qr},zf=(t,e)=>(Zr.identify(e)||ei.isScalar(e)&&(!e.type||e.type===Is.Scalar.PLAIN)&&Zr.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===Zr.tag&&r.default);function Ts(t,e,r){let i=js(t,r);if(ei.isSeq(i))for(let n of i.items)Bn(t,e,n);else if(Array.isArray(i))for(let n of i)Bn(t,e,n);else Bn(t,e,i)}function Bn(t,e,r){let i=js(t,r);if(!ei.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 js(t,e){return t&&ei.isAlias(e)?e.resolve(t.doc,t):e}ti.addMergeToJSMap=Ts;ti.isMergeKey=zf;ti.merge=Zr});var Mn=b(Hs=>{"use strict";var Jf=Ln(),$s=ri(),Gf=Xt(),Os=P(),Vn=_e();function Uf(t,e,{key:r,value:i}){if(Os.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if($s.isMergeKey(t,r))$s.addMergeToJSMap(t,e,i);else{let n=Vn.toJS(r,"",t);if(e instanceof Map)e.set(n,Vn.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=Kf(r,n,t),o=Vn.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 Kf(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(Os.isNode(t)&&r?.doc){let i=Gf.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)+'..."'),Jf.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)}Hs.addPairToJSMap=Uf});var $e=b(Fn=>{"use strict";var Ds=Jt(),Yf=As(),Xf=Mn(),ii=P();function Qf(t,e,r){let i=Ds.createNode(t,void 0,r),n=Ds.createNode(e,void 0,r);return new ni(i,n)}var ni=class t{constructor(e,r=null){Object.defineProperty(this,ii.NODE_TYPE,{value:ii.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return ii.isNode(r)&&(r=r.clone(e)),ii.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return Xf.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?Yf.stringifyPair(this,e,r,i):JSON.stringify(this)}};Fn.Pair=ni;Fn.createPair=Qf});var qn=b(Bs=>{"use strict";var Ze=P(),Ls=Xt(),ai=Gt();function Zf(t,e,r){return(e.inFlow??t.flow?th:eh)(t,e,r)}function eh({comment:t,items:e},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,d=Object.assign({},r,{indent:a,type:null}),u=!1,f=[];for(let v=0;v<e.length;++v){let h=e[v],p=null;if(Ze.isNode(h))!u&&h.spaceBefore&&f.push(""),oi(r,f,h.commentBefore,u),h.comment&&(p=h.comment);else if(Ze.isPair(h)){let w=Ze.isNode(h.key)?h.key:null;w&&(!u&&w.spaceBefore&&f.push(""),oi(r,f,w.commentBefore,u))}u=!1;let N=Ls.stringify(h,d,()=>p=null,()=>u=!0);p&&(N+=ai.lineComment(N,a,l(p))),u&&p&&(u=!1),f.push(i+N)}let m;if(f.length===0)m=n.start+n.end;else{m=f[0];for(let v=1;v<f.length;++v){let h=f[v];m+=h?`
48
+ ${c}${h}`:`
49
49
  `}}return t?(m+=`
50
- `+ni.indentComment(l(t),c),s&&s()):d&&o&&o(),m}function ep({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,u=0,d=[];for(let v=0;v<t.length;++v){let p=t[v],h=null;if(Xe.isNode(p))p.spaceBefore&&d.push(""),ai(e,d,p.commentBefore,!1),p.comment&&(h=p.comment);else if(Xe.isPair(p)){let w=Xe.isNode(p.key)?p.key:null;w&&(w.spaceBefore&&d.push(""),ai(e,d,w.commentBefore,!1),w.comment&&(l=!0));let g=Xe.isNode(p.value)?p.value:null;g?(g.comment&&(h=g.comment),g.commentBefore&&(l=!0)):p.value==null&&w?.comment&&(h=w.comment)}h&&(l=!0);let N=Bs.stringify(p,c,()=>h=null);l||(l=d.length>u||N.includes(`
51
- `)),v<t.length-1?N+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=d.reduce((w,g)=>w+g.length+2,2)+(N.length+2)>e.options.lineWidth)),l&&(N+=",")),h&&(N+=ni.lineComment(N,i,s(h))),d.push(N),u=d.length}let{start:f,end:m}=r;if(d.length===0)return f+m;if(!l){let v=d.reduce((p,h)=>p+h.length+2,2);l=e.options.lineWidth>0&&v>e.options.lineWidth}if(l){let v=f;for(let p of d)v+=p?`
52
- ${a}${n}${p}`:`
50
+ `+ai.indentComment(l(t),c),s&&s()):u&&o&&o(),m}function th({items:t},e,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;i+=a;let c=Object.assign({},e,{indent:i,inFlow:!0,type:null}),l=!1,d=0,u=[];for(let v=0;v<t.length;++v){let h=t[v],p=null;if(Ze.isNode(h))h.spaceBefore&&u.push(""),oi(e,u,h.commentBefore,!1),h.comment&&(p=h.comment);else if(Ze.isPair(h)){let w=Ze.isNode(h.key)?h.key:null;w&&(w.spaceBefore&&u.push(""),oi(e,u,w.commentBefore,!1),w.comment&&(l=!0));let g=Ze.isNode(h.value)?h.value:null;g?(g.comment&&(p=g.comment),g.commentBefore&&(l=!0)):h.value==null&&w?.comment&&(p=w.comment)}p&&(l=!0);let N=Ls.stringify(h,c,()=>p=null);l||(l=u.length>d||N.includes(`
51
+ `)),v<t.length-1?N+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((w,g)=>w+g.length+2,2)+(N.length+2)>e.options.lineWidth)),l&&(N+=",")),p&&(N+=ai.lineComment(N,i,s(p))),u.push(N),d=u.length}let{start:f,end:m}=r;if(u.length===0)return f+m;if(!l){let v=u.reduce((h,p)=>h+p.length+2,2);l=e.options.lineWidth>0&&v>e.options.lineWidth}if(l){let v=f;for(let h of u)v+=h?`
52
+ ${a}${n}${h}`:`
53
53
  `;return`${v}
54
- ${n}${m}`}else return`${f}${o}${d.join(" ")}${o}${m}`}function ai({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=ni.indentComment(e(i),t);r.push(a.trimStart())}}Ms.stringifyCollection=Qf});var Oe=b(qn=>{"use strict";var tp=Vn(),rp=Bn(),ip=zr(),$e=P(),oi=je(),np=$();function Yt(t,e){let r=$e.isScalar(e)?e.value:e;for(let i of t)if($e.isPair(i)&&(i.key===e||i.key===r||$e.isScalar(i.key)&&i.key.value===r))return i}var Fn=class extends ip.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super($e.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(oi.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;$e.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new oi.Pair(e,e?.value):i=new oi.Pair(e.key,e.value);let n=Yt(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);$e.isScalar(n.value)&&np.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=Yt(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=Yt(this.items,e)?.value;return(!r&&$e.isScalar(n)?n.value:n)??void 0}has(e){return!!Yt(this.items,e)}set(e,r){this.add(new oi.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)rp.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!$e.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})),tp.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};qn.YAMLMap=Fn;qn.findPair=Yt});var vt=b(Fs=>{"use strict";var ap=P(),Vs=Oe(),op={collection:"map",default:!0,nodeClass:Vs.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return ap.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>Vs.YAMLMap.from(t,e,r)};Fs.map=op});var He=b(qs=>{"use strict";var sp=qt(),cp=Vn(),lp=zr(),ci=P(),up=$(),dp=Ae(),Wn=class extends lp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ci.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=si(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=si(e);if(typeof i!="number")return;let n=this.items[i];return!r&&ci.isScalar(n)?n.value:n}has(e){let r=si(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=si(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];ci.isScalar(n)&&up.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(dp.toJS(a,String(n++),r));return i}toString(e,r,i){return e?cp.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(sp.createNode(s,void 0,i))}}return a}};function si(t){let e=ci.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}qs.YAMLSeq=Wn});var gt=b(zs=>{"use strict";var fp=P(),Ws=He(),pp={collection:"seq",default:!0,nodeClass:Ws.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return fp.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>Ws.YAMLSeq.from(t,e,r)};zs.seq=pp});var Xt=b(Js=>{"use strict";var hp=Gt(),mp={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),hp.stringifyString(t,e,r,i)}};Js.string=mp});var li=b(Ks=>{"use strict";var Gs=$(),Us={identify:t=>t==null,createNode:()=>new Gs.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Gs.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Us.test.test(t)?t:e.options.nullStr};Ks.nullTag=Us});var zn=b(Xs=>{"use strict";var vp=$(),Ys={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new vp.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&Ys.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};Xs.boolTag=Ys});var wt=b(Qs=>{"use strict";function gp({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}Qs.stringifyNumber=gp});var Gn=b(ui=>{"use strict";var wp=$(),Jn=wt(),yp={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:Jn.stringifyNumber},Np={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():Jn.stringifyNumber(t)}},bp={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 wp.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:Jn.stringifyNumber};ui.float=bp;ui.floatExp=Np;ui.floatNaN=yp});var Kn=b(fi=>{"use strict";var Zs=wt(),di=t=>typeof t=="bigint"||Number.isInteger(t),Un=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function ec(t,e,r){let{value:i}=t;return di(i)&&i>=0?r+i.toString(e):Zs.stringifyNumber(t)}var kp={identify:t=>di(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>Un(t,2,8,r),stringify:t=>ec(t,8,"0o")},Sp={identify:di,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>Un(t,0,10,r),stringify:Zs.stringifyNumber},Ep={identify:t=>di(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>Un(t,2,16,r),stringify:t=>ec(t,16,"0x")};fi.int=Sp;fi.intHex=Ep;fi.intOct=kp});var rc=b(tc=>{"use strict";var Cp=vt(),xp=li(),Pp=gt(),Rp=Xt(),Ap=zn(),Yn=Gn(),Xn=Kn(),_p=[Cp.map,Pp.seq,Rp.string,xp.nullTag,Ap.boolTag,Xn.intOct,Xn.int,Xn.intHex,Yn.floatNaN,Yn.floatExp,Yn.float];tc.schema=_p});var ac=b(nc=>{"use strict";var Ip=$(),Tp=vt(),jp=gt();function ic(t){return typeof t=="bigint"||Number.isInteger(t)}var pi=({value:t})=>JSON.stringify(t),$p=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:pi},{identify:t=>t==null,createNode:()=>new Ip.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:pi},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:pi},{identify:ic,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})=>ic(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:pi}],Op={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Hp=[Tp.map,jp.seq].concat($p,Op);nc.schema=Hp});var Zn=b(oc=>{"use strict";var Qt=Hr("buffer"),Qn=$(),Dp=Gt(),Lp={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Qt.Buffer=="function")return Qt.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 Qt.Buffer=="function")s=o instanceof Qt.Buffer?o.toString("base64"):Qt.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=Qn.Scalar.BLOCK_LITERAL),e!==Qn.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),u=new Array(l);for(let d=0,f=0;d<l;++d,f+=c)u[d]=s.substr(f,c);s=u.join(e===Qn.Scalar.BLOCK_LITERAL?`
55
- `:" ")}return Dp.stringifyString({comment:t,type:e,value:s},i,n,a)}};oc.binary=Lp});var vi=b(mi=>{"use strict";var hi=P(),ea=je(),Bp=$(),Mp=He();function sc(t,e){if(hi.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!hi.isPair(i)){if(hi.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new ea.Pair(new Bp.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
54
+ ${n}${m}`}else return`${f}${o}${u.join(" ")}${o}${m}`}function oi({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=ai.indentComment(e(i),t);r.push(a.trimStart())}}Bs.stringifyCollection=Zf});var He=b(zn=>{"use strict";var rh=qn(),ih=Mn(),nh=Jr(),Oe=P(),si=$e(),ah=$();function Zt(t,e){let r=Oe.isScalar(e)?e.value:e;for(let i of t)if(Oe.isPair(i)&&(i.key===e||i.key===r||Oe.isScalar(i.key)&&i.key.value===r))return i}var Wn=class extends nh.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Oe.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(si.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;Oe.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new si.Pair(e,e?.value):i=new si.Pair(e.key,e.value);let n=Zt(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);Oe.isScalar(n.value)&&ah.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=Zt(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=Zt(this.items,e)?.value;return(!r&&Oe.isScalar(n)?n.value:n)??void 0}has(e){return!!Zt(this.items,e)}set(e,r){this.add(new si.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)ih.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!Oe.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),rh.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};zn.YAMLMap=Wn;zn.findPair=Zt});var gt=b(Ms=>{"use strict";var oh=P(),Vs=He(),sh={collection:"map",default:!0,nodeClass:Vs.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return oh.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>Vs.YAMLMap.from(t,e,r)};Ms.map=sh});var De=b(Fs=>{"use strict";var ch=Jt(),lh=qn(),uh=Jr(),li=P(),dh=$(),fh=_e(),Jn=class extends uh.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(li.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=ci(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=ci(e);if(typeof i!="number")return;let n=this.items[i];return!r&&li.isScalar(n)?n.value:n}has(e){let r=ci(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=ci(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];li.isScalar(n)&&dh.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(fh.toJS(a,String(n++),r));return i}toString(e,r,i){return e?lh.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(ch.createNode(s,void 0,i))}}return a}};function ci(t){let e=li.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Fs.YAMLSeq=Jn});var wt=b(Ws=>{"use strict";var hh=P(),qs=De(),ph={collection:"seq",default:!0,nodeClass:qs.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return hh.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>qs.YAMLSeq.from(t,e,r)};Ws.seq=ph});var er=b(zs=>{"use strict";var mh=Yt(),vh={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),mh.stringifyString(t,e,r,i)}};zs.string=vh});var ui=b(Us=>{"use strict";var Js=$(),Gs={identify:t=>t==null,createNode:()=>new Js.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Js.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Gs.test.test(t)?t:e.options.nullStr};Us.nullTag=Gs});var Gn=b(Ys=>{"use strict";var gh=$(),Ks={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new gh.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&Ks.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};Ys.boolTag=Ks});var yt=b(Xs=>{"use strict";function wh({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}Xs.stringifyNumber=wh});var Kn=b(di=>{"use strict";var yh=$(),Un=yt(),Nh={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:Un.stringifyNumber},bh={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():Un.stringifyNumber(t)}},kh={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 yh.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:Un.stringifyNumber};di.float=kh;di.floatExp=bh;di.floatNaN=Nh});var Xn=b(hi=>{"use strict";var Qs=yt(),fi=t=>typeof t=="bigint"||Number.isInteger(t),Yn=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function Zs(t,e,r){let{value:i}=t;return fi(i)&&i>=0?r+i.toString(e):Qs.stringifyNumber(t)}var Sh={identify:t=>fi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>Yn(t,2,8,r),stringify:t=>Zs(t,8,"0o")},Eh={identify:fi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>Yn(t,0,10,r),stringify:Qs.stringifyNumber},Ch={identify:t=>fi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>Yn(t,2,16,r),stringify:t=>Zs(t,16,"0x")};hi.int=Eh;hi.intHex=Ch;hi.intOct=Sh});var tc=b(ec=>{"use strict";var xh=gt(),Ph=ui(),Rh=wt(),Ah=er(),_h=Gn(),Qn=Kn(),Zn=Xn(),Ih=[xh.map,Rh.seq,Ah.string,Ph.nullTag,_h.boolTag,Zn.intOct,Zn.int,Zn.intHex,Qn.floatNaN,Qn.floatExp,Qn.float];ec.schema=Ih});var nc=b(ic=>{"use strict";var Th=$(),jh=gt(),$h=wt();function rc(t){return typeof t=="bigint"||Number.isInteger(t)}var pi=({value:t})=>JSON.stringify(t),Oh=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:pi},{identify:t=>t==null,createNode:()=>new Th.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:pi},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:pi},{identify:rc,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})=>rc(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:pi}],Hh={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Dh=[jh.map,$h.seq].concat(Oh,Hh);ic.schema=Dh});var ta=b(ac=>{"use strict";var tr=Dr("buffer"),ea=$(),Lh=Yt(),Bh={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof tr.Buffer=="function")return tr.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 tr.Buffer=="function")s=o instanceof tr.Buffer?o.toString("base64"):tr.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=ea.Scalar.BLOCK_LITERAL),e!==ea.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),d=new Array(l);for(let u=0,f=0;u<l;++u,f+=c)d[u]=s.substr(f,c);s=d.join(e===ea.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return Lh.stringifyString({comment:t,type:e,value:s},i,n,a)}};ac.binary=Bh});var gi=b(vi=>{"use strict";var mi=P(),ra=$e(),Vh=$(),Mh=De();function oc(t,e){if(mi.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!mi.isPair(i)){if(mi.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new ra.Pair(new Vh.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]=hi.isPair(i)?i:new ea.Pair(i)}}else e("Expected a sequence for this tag");return t}function cc(t,e,r){let{replacer:i}=r,n=new Mp.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 Vp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:sc,createNode:cc};mi.createPairs=cc;mi.pairs=Vp;mi.resolvePairs=sc});var ia=b(ra=>{"use strict";var lc=P(),ta=Ae(),Zt=Oe(),Fp=He(),uc=vi(),Qe=class t extends Fp.YAMLSeq{constructor(){super(),this.add=Zt.YAMLMap.prototype.add.bind(this),this.delete=Zt.YAMLMap.prototype.delete.bind(this),this.get=Zt.YAMLMap.prototype.get.bind(this),this.has=Zt.YAMLMap.prototype.has.bind(this),this.set=Zt.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=ta.toJS(n.key,"",r),o=ta.toJS(n.value,a,r)):a=ta.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=uc.createPairs(e,r,i),a=new this;return a.items=n.items,a}};Qe.tag="tag:yaml.org,2002:omap";var qp={collection:"seq",identify:t=>t instanceof Map,nodeClass:Qe,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=uc.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 Qe,r)},createNode:(t,e,r)=>Qe.from(t,e,r)};ra.YAMLOMap=Qe;ra.omap=qp});var mc=b(na=>{"use strict";var dc=$();function fc({value:t,source:e},r){return e&&(t?pc:hc).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var pc={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new dc.Scalar(!0),stringify:fc},hc={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 dc.Scalar(!1),stringify:fc};na.falseTag=hc;na.trueTag=pc});var vc=b(gi=>{"use strict";var Wp=$(),aa=wt(),zp={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},Jp={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)}},Gp={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 Wp.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};gi.float=Gp;gi.floatExp=Jp;gi.floatNaN=zp});var wc=b(tr=>{"use strict";var gc=wt(),er=t=>typeof t=="bigint"||Number.isInteger(t);function wi(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 oa(t,e,r){let{value:i}=t;if(er(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return gc.stringifyNumber(t)}var Up={identify:er,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>wi(t,2,2,r),stringify:t=>oa(t,2,"0b")},Kp={identify:er,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>wi(t,1,8,r),stringify:t=>oa(t,8,"0")},Yp={identify:er,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>wi(t,0,10,r),stringify:gc.stringifyNumber},Xp={identify:er,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>wi(t,2,16,r),stringify:t=>oa(t,16,"0x")};tr.int=Yp;tr.intBin=Up;tr.intHex=Xp;tr.intOct=Kp});var ca=b(sa=>{"use strict";var bi=P(),yi=je(),Ni=Oe(),Ze=class t extends Ni.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;bi.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new yi.Pair(e.key,null):r=new yi.Pair(e,null),Ni.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=Ni.findPair(this.items,e);return!r&&bi.isPair(i)?bi.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=Ni.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new yi.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(yi.createPair(o,null,i));return a}};Ze.tag="tag:yaml.org,2002:set";var Qp={collection:"map",identify:t=>t instanceof Set,nodeClass:Ze,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>Ze.from(t,e,r),resolve(t,e){if(bi.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Ze,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};sa.YAMLSet=Ze;sa.set=Qp});var ua=b(ki=>{"use strict";var Zp=wt();function la(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 yc(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Zp.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 eh={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})=>la(t,r),stringify:yc},th={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=>la(t,!1),stringify:yc},Nc={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(Nc.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),u=e[8];if(u&&u!=="Z"){let d=la(u,!1);Math.abs(d)<30&&(d*=60),l-=6e4*d}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ki.floatTime=th;ki.intTime=eh;ki.timestamp=Nc});var Sc=b(kc=>{"use strict";var rh=vt(),ih=li(),nh=gt(),ah=Xt(),oh=Zn(),bc=mc(),da=vc(),Si=wc(),sh=ti(),ch=ia(),lh=vi(),uh=ca(),fa=ua(),dh=[rh.map,nh.seq,ah.string,ih.nullTag,bc.trueTag,bc.falseTag,Si.intBin,Si.intOct,Si.int,Si.intHex,da.floatNaN,da.floatExp,da.float,oh.binary,sh.merge,ch.omap,lh.pairs,uh.set,fa.intTime,fa.floatTime,fa.timestamp];kc.schema=dh});var jc=b(ma=>{"use strict";var Pc=vt(),fh=li(),Rc=gt(),ph=Xt(),hh=zn(),pa=Gn(),ha=Kn(),mh=rc(),vh=ac(),Ac=Zn(),rr=ti(),_c=ia(),Ic=vi(),Ec=Sc(),Tc=ca(),Ei=ua(),Cc=new Map([["core",mh.schema],["failsafe",[Pc.map,Rc.seq,ph.string]],["json",vh.schema],["yaml11",Ec.schema],["yaml-1.1",Ec.schema]]),xc={binary:Ac.binary,bool:hh.boolTag,float:pa.float,floatExp:pa.floatExp,floatNaN:pa.floatNaN,floatTime:Ei.floatTime,int:ha.int,intHex:ha.intHex,intOct:ha.intOct,intTime:Ei.intTime,map:Pc.map,merge:rr.merge,null:fh.nullTag,omap:_c.omap,pairs:Ic.pairs,seq:Rc.seq,set:Tc.set,timestamp:Ei.timestamp},gh={"tag:yaml.org,2002:binary":Ac.binary,"tag:yaml.org,2002:merge":rr.merge,"tag:yaml.org,2002:omap":_c.omap,"tag:yaml.org,2002:pairs":Ic.pairs,"tag:yaml.org,2002:set":Tc.set,"tag:yaml.org,2002:timestamp":Ei.timestamp};function wh(t,e,r){let i=Cc.get(e);if(i&&!t)return r&&!i.includes(rr.merge)?i.concat(rr.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Cc.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(rr.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?xc[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(xc).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}ma.coreKnownTags=gh;ma.getTags=wh});var wa=b($c=>{"use strict";var va=P(),yh=vt(),Nh=gt(),bh=Xt(),Ci=jc(),kh=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,ga=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Ci.getTags(e,"compat"):e?Ci.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Ci.coreKnownTags:{},this.tags=Ci.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,va.MAP,{value:yh.map}),Object.defineProperty(this,va.SCALAR,{value:bh.string}),Object.defineProperty(this,va.SEQ,{value:Nh.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?kh:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};$c.Schema=ga});var Hc=b(Oc=>{"use strict";var Sh=P(),ya=Ut(),ir=Wt();function Eh(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=ya.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(ir.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(Sh.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let u=a(t.contents.commentBefore);r.push(ir.indentComment(u,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=ya.stringify(t.contents,n,()=>s=null,c);s&&(l+=ir.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(ya.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
- `)?(r.push("..."),r.push(ir.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(ir.indentComment(a(c),"")))}return r.join(`
57
+ ${a.comment}`:i.comment}i=n}t.items[r]=mi.isPair(i)?i:new ra.Pair(i)}}else e("Expected a sequence for this tag");return t}function sc(t,e,r){let{replacer:i}=r,n=new Mh.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(ra.createPair(s,c,r))}return n}var Fh={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:oc,createNode:sc};vi.createPairs=sc;vi.pairs=Fh;vi.resolvePairs=oc});var aa=b(na=>{"use strict";var cc=P(),ia=_e(),rr=He(),qh=De(),lc=gi(),et=class t extends qh.YAMLSeq{constructor(){super(),this.add=rr.YAMLMap.prototype.add.bind(this),this.delete=rr.YAMLMap.prototype.delete.bind(this),this.get=rr.YAMLMap.prototype.get.bind(this),this.has=rr.YAMLMap.prototype.has.bind(this),this.set=rr.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(cc.isPair(n)?(a=ia.toJS(n.key,"",r),o=ia.toJS(n.value,a,r)):a=ia.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=lc.createPairs(e,r,i),a=new this;return a.items=n.items,a}};et.tag="tag:yaml.org,2002:omap";var Wh={collection:"seq",identify:t=>t instanceof Map,nodeClass:et,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=lc.resolvePairs(t,e),i=[];for(let{key:n}of r.items)cc.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new et,r)},createNode:(t,e,r)=>et.from(t,e,r)};na.YAMLOMap=et;na.omap=Wh});var pc=b(oa=>{"use strict";var uc=$();function dc({value:t,source:e},r){return e&&(t?fc:hc).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 uc.Scalar(!0),stringify:dc},hc={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 uc.Scalar(!1),stringify:dc};oa.falseTag=hc;oa.trueTag=fc});var mc=b(wi=>{"use strict";var zh=$(),sa=yt(),Jh={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:sa.stringifyNumber},Gh={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():sa.stringifyNumber(t)}},Uh={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 zh.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:sa.stringifyNumber};wi.float=Uh;wi.floatExp=Gh;wi.floatNaN=Jh});var gc=b(nr=>{"use strict";var vc=yt(),ir=t=>typeof t=="bigint"||Number.isInteger(t);function yi(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 ca(t,e,r){let{value:i}=t;if(ir(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return vc.stringifyNumber(t)}var Kh={identify:ir,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>yi(t,2,2,r),stringify:t=>ca(t,2,"0b")},Yh={identify:ir,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>yi(t,1,8,r),stringify:t=>ca(t,8,"0")},Xh={identify:ir,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>yi(t,0,10,r),stringify:vc.stringifyNumber},Qh={identify:ir,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>yi(t,2,16,r),stringify:t=>ca(t,16,"0x")};nr.int=Xh;nr.intBin=Kh;nr.intHex=Qh;nr.intOct=Yh});var ua=b(la=>{"use strict";var ki=P(),Ni=$e(),bi=He(),tt=class t extends bi.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;ki.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new Ni.Pair(e.key,null):r=new Ni.Pair(e,null),bi.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=bi.findPair(this.items,e);return!r&&ki.isPair(i)?ki.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=bi.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Ni.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(Ni.createPair(o,null,i));return a}};tt.tag="tag:yaml.org,2002:set";var Zh={collection:"map",identify:t=>t instanceof Set,nodeClass:tt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>tt.from(t,e,r),resolve(t,e){if(ki.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new tt,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};la.YAMLSet=tt;la.set=Zh});var fa=b(Si=>{"use strict";var ep=yt();function da(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 wc(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return ep.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 tp={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})=>da(t,r),stringify:wc},rp={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=>da(t,!1),stringify:wc},yc={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(yc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,a||0,o||0,s||0,c),d=e[8];if(d&&d!=="Z"){let u=da(d,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Si.floatTime=rp;Si.intTime=tp;Si.timestamp=yc});var kc=b(bc=>{"use strict";var ip=gt(),np=ui(),ap=wt(),op=er(),sp=ta(),Nc=pc(),ha=mc(),Ei=gc(),cp=ri(),lp=aa(),up=gi(),dp=ua(),pa=fa(),fp=[ip.map,ap.seq,op.string,np.nullTag,Nc.trueTag,Nc.falseTag,Ei.intBin,Ei.intOct,Ei.int,Ei.intHex,ha.floatNaN,ha.floatExp,ha.float,sp.binary,cp.merge,lp.omap,up.pairs,dp.set,pa.intTime,pa.floatTime,pa.timestamp];bc.schema=fp});var Tc=b(ga=>{"use strict";var xc=gt(),hp=ui(),Pc=wt(),pp=er(),mp=Gn(),ma=Kn(),va=Xn(),vp=tc(),gp=nc(),Rc=ta(),ar=ri(),Ac=aa(),_c=gi(),Sc=kc(),Ic=ua(),Ci=fa(),Ec=new Map([["core",vp.schema],["failsafe",[xc.map,Pc.seq,pp.string]],["json",gp.schema],["yaml11",Sc.schema],["yaml-1.1",Sc.schema]]),Cc={binary:Rc.binary,bool:mp.boolTag,float:ma.float,floatExp:ma.floatExp,floatNaN:ma.floatNaN,floatTime:Ci.floatTime,int:va.int,intHex:va.intHex,intOct:va.intOct,intTime:Ci.intTime,map:xc.map,merge:ar.merge,null:hp.nullTag,omap:Ac.omap,pairs:_c.pairs,seq:Pc.seq,set:Ic.set,timestamp:Ci.timestamp},wp={"tag:yaml.org,2002:binary":Rc.binary,"tag:yaml.org,2002:merge":ar.merge,"tag:yaml.org,2002:omap":Ac.omap,"tag:yaml.org,2002:pairs":_c.pairs,"tag:yaml.org,2002:set":Ic.set,"tag:yaml.org,2002:timestamp":Ci.timestamp};function yp(t,e,r){let i=Ec.get(e);if(i&&!t)return r&&!i.includes(ar.merge)?i.concat(ar.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Ec.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(ar.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Cc[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Cc).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}ga.coreKnownTags=wp;ga.getTags=yp});var Na=b(jc=>{"use strict";var wa=P(),Np=gt(),bp=wt(),kp=er(),xi=Tc(),Sp=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,ya=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?xi.getTags(e,"compat"):e?xi.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?xi.coreKnownTags:{},this.tags=xi.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,wa.MAP,{value:Np.map}),Object.defineProperty(this,wa.SCALAR,{value:kp.string}),Object.defineProperty(this,wa.SEQ,{value:bp.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Sp:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};jc.Schema=ya});var Oc=b($c=>{"use strict";var Ep=P(),ba=Xt(),or=Gt();function Cp(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=ba.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(or.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(Ep.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let d=a(t.contents.commentBefore);r.push(or.indentComment(d,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=ba.stringify(t.contents,n,()=>s=null,c);s&&(l+=or.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(ba.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
+ `)?(r.push("..."),r.push(or.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(or.indentComment(a(c),"")))}return r.join(`
59
59
  `)+`
60
- `}Oc.stringifyDocument=Eh});var nr=b(Dc=>{"use strict";var Ch=Ft(),yt=zr(),X=P(),xh=je(),Ph=Ae(),Rh=wa(),Ah=Hc(),Na=Vr(),_h=En(),Ih=qt(),ba=Sn(),ka=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,X.NODE_TYPE,{value:X.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 ba.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,{[X.NODE_TYPE]:{value:X.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=X.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Nt(this.contents)&&this.contents.add(e)}addIn(e,r){Nt(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=Na.anchorNames(this);e.anchor=!r||i.has(r)?Na.findNewAnchor(r||"a",i):r}return new Ch.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 h=w=>typeof w=="number"||w instanceof String||w instanceof Number,N=r.filter(h).map(String);N.length>0&&(r=r.concat(N)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:u}=i??{},{onAnchor:d,setAnchors:f,sourceObjects:m}=Na.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:m},p=Ih.createNode(e,u,v);return s&&X.isCollection(p)&&(p.flow=!0),f(),p}createPair(e,r,i={}){let n=this.createNode(e,null,i),a=this.createNode(r,null,i);return new xh.Pair(n,a)}delete(e){return Nt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return yt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Nt(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return X.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return yt.isEmptyPath(e)?!r&&X.isScalar(this.contents)?this.contents.value:this.contents:X.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return X.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return yt.isEmptyPath(e)?this.contents!==void 0:X.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=yt.collectionFromPath(this.schema,[e],r):Nt(this.contents)&&this.contents.set(e,r)}setIn(e,r){yt.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=yt.collectionFromPath(this.schema,Array.from(e),r):Nt(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 ba.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 ba.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 Rh.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=Ph.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:u}of s.anchors.values())a(u,l);return typeof o=="function"?_h.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 Ah.stringifyDocument(this,e)}};function Nt(t){if(X.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Dc.Document=ka});var sr=b(or=>{"use strict";var ar=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},Sa=class extends ar{constructor(e,r,i){super("YAMLParseError",e,r,i)}},Ea=class extends ar{constructor(e,r,i){super("YAMLWarning",e,r,i)}},Th=(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
+ `}$c.stringifyDocument=Cp});var sr=b(Hc=>{"use strict";var xp=zt(),Nt=Jr(),X=P(),Pp=$e(),Rp=_e(),Ap=Na(),_p=Oc(),ka=Fr(),Ip=xn(),Tp=Jt(),Sa=Cn(),Ea=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,X.NODE_TYPE,{value:X.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 Sa.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,{[X.NODE_TYPE]:{value:X.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=X.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){bt(this.contents)&&this.contents.add(e)}addIn(e,r){bt(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=ka.anchorNames(this);e.anchor=!r||i.has(r)?ka.findNewAnchor(r||"a",i):r}return new xp.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 p=w=>typeof w=="number"||w instanceof String||w instanceof Number,N=r.filter(p).map(String);N.length>0&&(r=r.concat(N)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:d}=i??{},{onAnchor:u,setAnchors:f,sourceObjects:m}=ka.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:m},h=Tp.createNode(e,d,v);return s&&X.isCollection(h)&&(h.flow=!0),f(),h}createPair(e,r,i={}){let n=this.createNode(e,null,i),a=this.createNode(r,null,i);return new Pp.Pair(n,a)}delete(e){return bt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Nt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):bt(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return X.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return Nt.isEmptyPath(e)?!r&&X.isScalar(this.contents)?this.contents.value:this.contents:X.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return X.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Nt.isEmptyPath(e)?this.contents!==void 0:X.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=Nt.collectionFromPath(this.schema,[e],r):bt(this.contents)&&this.contents.set(e,r)}setIn(e,r){Nt.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=Nt.collectionFromPath(this.schema,Array.from(e),r):bt(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 Sa.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 Sa.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 Ap.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=Rp.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:d}of s.anchors.values())a(d,l);return typeof o=="function"?Ip.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 _p.stringifyDocument(this,e)}};function bt(t){if(X.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Hc.Document=Ea});var ur=b(lr=>{"use strict";var cr=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},Ca=class extends cr{constructor(e,r,i){super("YAMLParseError",e,r,i)}},xa=class extends cr{constructor(e,r,i){super("YAMLWarning",e,r,i)}},jp=(t,e)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>e.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[i-2],e.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
61
61
  `),o=s+o}if(/[^ ]/.test(o)){let s=1,c=r.linePos[1];c?.line===i&&c.col>n&&(s=Math.max(1,Math.min(c.col-n,80-a)));let l=" ".repeat(a)+"^".repeat(s);r.message+=`:
62
62
 
63
63
  ${o}
64
64
  ${l}
65
- `}};or.YAMLError=ar;or.YAMLParseError=Sa;or.YAMLWarning=Ea;or.prettifyError=Th});var cr=b(Lc=>{"use strict";function jh(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d="",f="",m=!1,v=!1,p=null,h=null,N=null,w=null,g=null,S=null,E=null;for(let k of t)switch(v&&(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma"&&a(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),p&&(l&&k.type!=="comment"&&k.type!=="newline"&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),k.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&k.source.includes(" ")&&(p=k),u=!0;break;case"comment":{u||a(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=k.source.substring(1)||" ";d?d+=f+_:d=_,f="",l=!1;break}case"newline":l?d?d+=k.source:(!S||r!=="seq-item-ind")&&(c=!0):f+=k.source,l=!0,m=!0,(h||N)&&(w=k),u=!0;break;case"anchor":h&&a(k,"MULTIPLE_ANCHORS","A node can have at most one anchor"),k.source.endsWith(":")&&a(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=k,E??(E=k.offset),l=!1,u=!1,v=!0;break;case"tag":{N&&a(k,"MULTIPLE_TAGS","A node can have at most one tag"),N=k,E??(E=k.offset),l=!1,u=!1,v=!0;break}case r:(h||N)&&a(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`),S&&a(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${e??"collection"}`),S=k,l=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(e){g&&a(k,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),g=k,l=!1,u=!1;break}default:a(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),l=!1,u=!1}let y=t[t.length-1],C=y?y.offset+y.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:g,found:S,spaceBefore:c,comment:d,hasNewline:m,anchor:h,tag:N,newlineAfterProp:w,end:C,start:E??C}}Lc.resolveProps=jh});var xi=b(Bc=>{"use strict";function Ca(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(Ca(e.key)||Ca(e.value))return!0}return!1;default:return!0}}Bc.containsNewline=Ca});var xa=b(Mc=>{"use strict";var $h=xi();function Oh(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&$h.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Mc.flowIndentCheck=Oh});var Pa=b(Fc=>{"use strict";var Vc=P();function Hh(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||Vc.isScalar(a)&&Vc.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}Fc.mapIncludes=Hh});var Uc=b(Gc=>{"use strict";var qc=je(),Dh=Oe(),Wc=cr(),Lh=xi(),zc=xa(),Bh=Pa(),Jc="All mapping items must start at the same column";function Mh({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Dh.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let u of i.items){let{start:d,key:f,sep:m,value:v}=u,p=Wc.resolveProps(d,{indicator:"explicit-key-ind",next:f??m?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),h=!p.found;if(h){if(f&&(f.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==i.indent&&n(c,"BAD_INDENT",Jc)),!p.anchor&&!p.tag&&!m){l=p.end,p.comment&&(s.comment?s.comment+=`
67
- `+p.comment:s.comment=p.comment);continue}(p.newlineAfterProp||Lh.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==i.indent&&n(c,"BAD_INDENT",Jc);r.atKey=!0;let N=p.end,w=f?t(r,f,p,n):e(r,N,d,null,p,n);r.schema.compat&&zc.flowIndentCheck(i.indent,f,n),r.atKey=!1,Bh.mapIncludes(r,s.items,w)&&n(N,"DUPLICATE_KEY","Map keys must be unique");let g=Wc.resolveProps(m??[],{indicator:"map-value-ind",next:v,offset:w.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=g.end,g.found){h&&(v?.type==="block-map"&&!g.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&p.start<g.found.offset-1024&&n(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=v?t(r,v,g,n):e(r,c,m,null,g,n);r.schema.compat&&zc.flowIndentCheck(i.indent,v,n),c=S.range[2];let E=new qc.Pair(w,S);r.options.keepSourceTokens&&(E.srcToken=u),s.items.push(E)}else{h&&n(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),g.comment&&(w.comment?w.comment+=`
68
- `+g.comment:w.comment=g.comment);let S=new qc.Pair(w);r.options.keepSourceTokens&&(S.srcToken=u),s.items.push(S)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}Gc.resolveBlockMap=Mh});var Yc=b(Kc=>{"use strict";var Vh=He(),Fh=cr(),qh=xa();function Wh({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Vh.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:u,value:d}of i.items){let f=Fh.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?n(f.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=f.end,f.comment&&(s.comment=f.comment);continue}let m=d?t(r,d,f,n):e(r,f.end,u,null,f,n);r.schema.compat&&qh.flowIndentCheck(i.indent,d,n),c=m.range[2],s.items.push(m)}return s.range=[i.offset,c,l??c],s}Kc.resolveBlockSeq=Wh});var bt=b(Xc=>{"use strict";function zh(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 u=c.substring(1)||" ";n?n+=o+u:n=u,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}}Xc.resolveEnd=zh});var tl=b(el=>{"use strict";var Jh=P(),Gh=je(),Qc=Oe(),Uh=He(),Kh=bt(),Zc=cr(),Yh=xi(),Xh=Pa(),Ra="Block collections are not allowed within flow collections",Aa=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Qh({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Qc.YAMLMap:Uh.YAMLSeq),l=new c(r.schema);l.flow=!0;let u=r.atRoot;u&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let d=i.offset+i.start.source.length;for(let h=0;h<i.items.length;++h){let N=i.items[h],{start:w,key:g,sep:S,value:E}=N,y=Zc.resolveProps(w,{flow:s,indicator:"explicit-key-ind",next:g??S?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!y.found){if(!y.anchor&&!y.tag&&!S&&!E){h===0&&y.comma?n(y.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):h<i.items.length-1&&n(y.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),y.comment&&(l.comment?l.comment+=`
69
- `+y.comment:l.comment=y.comment),d=y.end;continue}!o&&r.options.strict&&Yh.containsNewline(g)&&n(g,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)y.comma&&n(y.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(y.comma||n(y.start,"MISSING_CHAR",`Missing , between ${s} items`),y.comment){let C="";e:for(let k of w)switch(k.type){case"comma":case"space":break;case"comment":C=k.source.substring(1);break e;default:break e}if(C){let k=l.items[l.items.length-1];Jh.isPair(k)&&(k=k.value??k.key),k.comment?k.comment+=`
70
- `+C:k.comment=C,y.comment=y.comment.substring(C.length+1)}}if(!o&&!S&&!y.found){let C=E?t(r,E,y,n):e(r,y.end,S,null,y,n);l.items.push(C),d=C.range[2],Aa(E)&&n(C.range,"BLOCK_IN_FLOW",Ra)}else{r.atKey=!0;let C=y.end,k=g?t(r,g,y,n):e(r,C,w,null,y,n);Aa(g)&&n(k.range,"BLOCK_IN_FLOW",Ra),r.atKey=!1;let _=Zc.resolveProps(S??[],{flow:s,indicator:"map-value-ind",next:E,offset:k.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(_.found){if(!o&&!y.found&&r.options.strict){if(S)for(let I of S){if(I===_.found)break;if(I.type==="newline"){n(I,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}y.start<_.found.offset-1024&&n(_.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?n(E,"MISSING_CHAR",`Missing space after : in ${s}`):n(_.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let L=E?t(r,E,_,n):_.found?e(r,_.end,S,null,_,n):null;L?Aa(E)&&n(L.range,"BLOCK_IN_FLOW",Ra):_.comment&&(k.comment?k.comment+=`
71
- `+_.comment:k.comment=_.comment);let Re=new Gh.Pair(k,L);if(r.options.keepSourceTokens&&(Re.srcToken=N),o){let I=l;Xh.mapIncludes(r,I.items,k)&&n(C,"DUPLICATE_KEY","Map keys must be unique"),I.items.push(Re)}else{let I=new Qc.YAMLMap(r.schema);I.flow=!0,I.items.push(Re);let es=(L??k).range;I.range=[k.range[0],es[1],es[2]],l.items.push(I)}d=L?L.range[2]:_.end}}let f=o?"}":"]",[m,...v]=i.end,p=d;if(m?.source===f)p=m.offset+m.source.length;else{let h=s[0].toUpperCase()+s.substring(1),N=u?`${h} must end with a ${f}`:`${h} in block collection must be sufficiently indented and end with a ${f}`;n(d,u?"MISSING_CHAR":"BAD_INDENT",N),m&&m.source.length!==1&&v.unshift(m)}if(v.length>0){let h=Kh.resolveEnd(v,p,r.options.strict,n);h.comment&&(l.comment?l.comment+=`
72
- `+h.comment:l.comment=h.comment),l.range=[i.offset,p,h.offset]}else l.range=[i.offset,p,p];return l}el.resolveFlowCollection=Qh});var il=b(rl=>{"use strict";var Zh=P(),em=$(),tm=Oe(),rm=He(),im=Uc(),nm=Yc(),am=tl();function _a(t,e,r,i,n,a){let o=r.type==="block-map"?im.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?nm.resolveBlockSeq(t,e,r,i,a):am.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 om(t,e,r,i,n){let a=i.tag,o=a?e.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:m}=i,v=f&&a?f.offset>a.offset?f:a:f??a;v&&(!m||m.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===tm.YAMLMap.tagName&&s==="map"||o===rm.YAMLSeq.tagName&&s==="seq")return _a(t,e,r,n,o);let c=e.schema.tags.find(f=>f.tag===o&&f.collection===s);if(!c){let f=e.schema.knownTags[o];if(f?.collection===s)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?n(a,"BAD_COLLECTION_TYPE",`${f.tag} used for ${s} collection, but expects ${f.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),_a(t,e,r,n,o)}let l=_a(t,e,r,n,o,c),u=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),e.options)??l,d=Zh.isNode(u)?u:new em.Scalar(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}rl.composeCollection=om});var Ta=b(nl=>{"use strict";var Ia=$();function sm(t,e,r){let i=e.offset,n=cm(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?Ia.Scalar.BLOCK_FOLDED:Ia.Scalar.BLOCK_LITERAL,o=e.source?lm(e.source):[],s=o.length;for(let p=o.length-1;p>=0;--p){let h=o[p][1];if(h===""||h==="\r")s=p;else break}if(s===0){let p=n.chomp==="+"&&o.length>0?`
73
- `.repeat(Math.max(1,o.length-1)):"",h=i+n.length;return e.source&&(h+=e.source.length),{value:p,type:a,comment:n.comment,range:[i,h,h]}}let c=e.indent+n.indent,l=e.offset+n.length,u=0;for(let p=0;p<s;++p){let[h,N]=o[p];if(N===""||N==="\r")n.indent===0&&h.length>c&&(c=h.length);else{h.length<c&&r(l+h.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=h.length),u=p,c===0&&!t.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=h.length+N.length+1}for(let p=o.length-1;p>=s;--p)o[p][0].length>c&&(s=p+1);let d="",f="",m=!1;for(let p=0;p<u;++p)d+=o[p][0].slice(c)+`
74
- `;for(let p=u;p<s;++p){let[h,N]=o[p];l+=h.length+N.length+1;let w=N[N.length-1]==="\r";if(w&&(N=N.slice(0,-1)),N&&h.length<c){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-N.length-(w?2:1),"BAD_INDENT",S),h=""}a===Ia.Scalar.BLOCK_LITERAL?(d+=f+h.slice(c)+N,f=`
75
- `):h.length>c||N[0]===" "?(f===" "?f=`
65
+ `}};lr.YAMLError=cr;lr.YAMLParseError=Ca;lr.YAMLWarning=xa;lr.prettifyError=jp});var dr=b(Dc=>{"use strict";function $p(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,d=s,u="",f="",m=!1,v=!1,h=null,p=null,N=null,w=null,g=null,S=null,E=null;for(let k of t)switch(v&&(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma"&&a(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&k.type!=="comment"&&k.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),k.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&k.source.includes(" ")&&(h=k),d=!0;break;case"comment":{d||a(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=k.source.substring(1)||" ";u?u+=f+_:u=_,f="",l=!1;break}case"newline":l?u?u+=k.source:(!S||r!=="seq-item-ind")&&(c=!0):f+=k.source,l=!0,m=!0,(p||N)&&(w=k),d=!0;break;case"anchor":p&&a(k,"MULTIPLE_ANCHORS","A node can have at most one anchor"),k.source.endsWith(":")&&a(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),p=k,E??(E=k.offset),l=!1,d=!1,v=!0;break;case"tag":{N&&a(k,"MULTIPLE_TAGS","A node can have at most one tag"),N=k,E??(E=k.offset),l=!1,d=!1,v=!0;break}case r:(p||N)&&a(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`),S&&a(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${e??"collection"}`),S=k,l=r==="seq-item-ind"||r==="explicit-key-ind",d=!1;break;case"comma":if(e){g&&a(k,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),g=k,l=!1,d=!1;break}default:a(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),l=!1,d=!1}let y=t[t.length-1],C=y?y.offset+y.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:g,found:S,spaceBefore:c,comment:u,hasNewline:m,anchor:p,tag:N,newlineAfterProp:w,end:C,start:E??C}}Dc.resolveProps=$p});var Pi=b(Lc=>{"use strict";function Pa(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(Pa(e.key)||Pa(e.value))return!0}return!1;default:return!0}}Lc.containsNewline=Pa});var Ra=b(Bc=>{"use strict";var Op=Pi();function Hp(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&Op.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Bc.flowIndentCheck=Hp});var Aa=b(Mc=>{"use strict";var Vc=P();function Dp(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||Vc.isScalar(a)&&Vc.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}Mc.mapIncludes=Dp});var Gc=b(Jc=>{"use strict";var Fc=$e(),Lp=He(),qc=dr(),Bp=Pi(),Wc=Ra(),Vp=Aa(),zc="All mapping items must start at the same column";function Mp({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Lp.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let d of i.items){let{start:u,key:f,sep:m,value:v}=d,h=qc.resolveProps(u,{indicator:"explicit-key-ind",next:f??m?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),p=!h.found;if(p){if(f&&(f.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==i.indent&&n(c,"BAD_INDENT",zc)),!h.anchor&&!h.tag&&!m){l=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Bp.containsNewline(f))&&n(f??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",zc);r.atKey=!0;let N=h.end,w=f?t(r,f,h,n):e(r,N,u,null,h,n);r.schema.compat&&Wc.flowIndentCheck(i.indent,f,n),r.atKey=!1,Vp.mapIncludes(r,s.items,w)&&n(N,"DUPLICATE_KEY","Map keys must be unique");let g=qc.resolveProps(m??[],{indicator:"map-value-ind",next:v,offset:w.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=g.end,g.found){p&&(v?.type==="block-map"&&!g.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<g.found.offset-1024&&n(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=v?t(r,v,g,n):e(r,c,m,null,g,n);r.schema.compat&&Wc.flowIndentCheck(i.indent,v,n),c=S.range[2];let E=new Fc.Pair(w,S);r.options.keepSourceTokens&&(E.srcToken=d),s.items.push(E)}else{p&&n(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),g.comment&&(w.comment?w.comment+=`
68
+ `+g.comment:w.comment=g.comment);let S=new Fc.Pair(w);r.options.keepSourceTokens&&(S.srcToken=d),s.items.push(S)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}Jc.resolveBlockMap=Mp});var Kc=b(Uc=>{"use strict";var Fp=De(),qp=dr(),Wp=Ra();function zp({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Fp.YAMLSeq,s=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let c=i.offset,l=null;for(let{start:d,value:u}of i.items){let f=qp.resolveProps(d,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||u)u?.type==="block-seq"?n(f.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=f.end,f.comment&&(s.comment=f.comment);continue}let m=u?t(r,u,f,n):e(r,f.end,d,null,f,n);r.schema.compat&&Wp.flowIndentCheck(i.indent,u,n),c=m.range[2],s.items.push(m)}return s.range=[i.offset,c,l??c],s}Uc.resolveBlockSeq=zp});var kt=b(Yc=>{"use strict";function Jp(t,e,r,i){let n="";if(t){let a=!1,o="";for(let s of t){let{source:c,type:l}=s;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";n?n+=o+d:n=d,o="";break}case"newline":n&&(o+=c),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}Yc.resolveEnd=Jp});var el=b(Zc=>{"use strict";var Gp=P(),Up=$e(),Xc=He(),Kp=De(),Yp=kt(),Qc=dr(),Xp=Pi(),Qp=Aa(),_a="Block collections are not allowed within flow collections",Ia=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Zp({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Xc.YAMLMap:Kp.YAMLSeq),l=new c(r.schema);l.flow=!0;let d=r.atRoot;d&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=i.offset+i.start.source.length;for(let p=0;p<i.items.length;++p){let N=i.items[p],{start:w,key:g,sep:S,value:E}=N,y=Qc.resolveProps(w,{flow:s,indicator:"explicit-key-ind",next:g??S?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!y.found){if(!y.anchor&&!y.tag&&!S&&!E){p===0&&y.comma?n(y.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):p<i.items.length-1&&n(y.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),y.comment&&(l.comment?l.comment+=`
69
+ `+y.comment:l.comment=y.comment),u=y.end;continue}!o&&r.options.strict&&Xp.containsNewline(g)&&n(g,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(p===0)y.comma&&n(y.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(y.comma||n(y.start,"MISSING_CHAR",`Missing , between ${s} items`),y.comment){let C="";e:for(let k of w)switch(k.type){case"comma":case"space":break;case"comment":C=k.source.substring(1);break e;default:break e}if(C){let k=l.items[l.items.length-1];Gp.isPair(k)&&(k=k.value??k.key),k.comment?k.comment+=`
70
+ `+C:k.comment=C,y.comment=y.comment.substring(C.length+1)}}if(!o&&!S&&!y.found){let C=E?t(r,E,y,n):e(r,y.end,S,null,y,n);l.items.push(C),u=C.range[2],Ia(E)&&n(C.range,"BLOCK_IN_FLOW",_a)}else{r.atKey=!0;let C=y.end,k=g?t(r,g,y,n):e(r,C,w,null,y,n);Ia(g)&&n(k.range,"BLOCK_IN_FLOW",_a),r.atKey=!1;let _=Qc.resolveProps(S??[],{flow:s,indicator:"map-value-ind",next:E,offset:k.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(_.found){if(!o&&!y.found&&r.options.strict){if(S)for(let I of S){if(I===_.found)break;if(I.type==="newline"){n(I,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}y.start<_.found.offset-1024&&n(_.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?n(E,"MISSING_CHAR",`Missing space after : in ${s}`):n(_.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let L=E?t(r,E,_,n):_.found?e(r,_.end,S,null,_,n):null;L?Ia(E)&&n(L.range,"BLOCK_IN_FLOW",_a):_.comment&&(k.comment?k.comment+=`
71
+ `+_.comment:k.comment=_.comment);let Ae=new Up.Pair(k,L);if(r.options.keepSourceTokens&&(Ae.srcToken=N),o){let I=l;Qp.mapIncludes(r,I.items,k)&&n(C,"DUPLICATE_KEY","Map keys must be unique"),I.items.push(Ae)}else{let I=new Xc.YAMLMap(r.schema);I.flow=!0,I.items.push(Ae);let Zo=(L??k).range;I.range=[k.range[0],Zo[1],Zo[2]],l.items.push(I)}u=L?L.range[2]:_.end}}let f=o?"}":"]",[m,...v]=i.end,h=u;if(m?.source===f)h=m.offset+m.source.length;else{let p=s[0].toUpperCase()+s.substring(1),N=d?`${p} must end with a ${f}`:`${p} in block collection must be sufficiently indented and end with a ${f}`;n(u,d?"MISSING_CHAR":"BAD_INDENT",N),m&&m.source.length!==1&&v.unshift(m)}if(v.length>0){let p=Yp.resolveEnd(v,h,r.options.strict,n);p.comment&&(l.comment?l.comment+=`
72
+ `+p.comment:l.comment=p.comment),l.range=[i.offset,h,p.offset]}else l.range=[i.offset,h,h];return l}Zc.resolveFlowCollection=Zp});var rl=b(tl=>{"use strict";var em=P(),tm=$(),rm=He(),im=De(),nm=Gc(),am=Kc(),om=el();function Ta(t,e,r,i,n,a){let o=r.type==="block-map"?nm.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?am.resolveBlockSeq(t,e,r,i,a):om.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 sm(t,e,r,i,n){let a=i.tag,o=a?e.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:m}=i,v=f&&a?f.offset>a.offset?f:a:f??a;v&&(!m||m.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===rm.YAMLMap.tagName&&s==="map"||o===im.YAMLSeq.tagName&&s==="seq")return Ta(t,e,r,n,o);let c=e.schema.tags.find(f=>f.tag===o&&f.collection===s);if(!c){let f=e.schema.knownTags[o];if(f?.collection===s)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?n(a,"BAD_COLLECTION_TYPE",`${f.tag} used for ${s} collection, but expects ${f.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Ta(t,e,r,n,o)}let l=Ta(t,e,r,n,o,c),d=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),e.options)??l,u=em.isNode(d)?d:new tm.Scalar(d);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}tl.composeCollection=sm});var $a=b(il=>{"use strict";var ja=$();function cm(t,e,r){let i=e.offset,n=lm(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?ja.Scalar.BLOCK_FOLDED:ja.Scalar.BLOCK_LITERAL,o=e.source?um(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let p=o[h][1];if(p===""||p==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
+ `.repeat(Math.max(1,o.length-1)):"",p=i+n.length;return e.source&&(p+=e.source.length),{value:h,type:a,comment:n.comment,range:[i,p,p]}}let c=e.indent+n.indent,l=e.offset+n.length,d=0;for(let h=0;h<s;++h){let[p,N]=o[h];if(N===""||N==="\r")n.indent===0&&p.length>c&&(c=p.length);else{p.length<c&&r(l+p.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=p.length),d=h,c===0&&!t.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=p.length+N.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let u="",f="",m=!1;for(let h=0;h<d;++h)u+=o[h][0].slice(c)+`
74
+ `;for(let h=d;h<s;++h){let[p,N]=o[h];l+=p.length+N.length+1;let w=N[N.length-1]==="\r";if(w&&(N=N.slice(0,-1)),N&&p.length<c){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-N.length-(w?2:1),"BAD_INDENT",S),p=""}a===ja.Scalar.BLOCK_LITERAL?(u+=f+p.slice(c)+N,f=`
75
+ `):p.length>c||N[0]===" "?(f===" "?f=`
76
76
  `:!m&&f===`
77
77
  `&&(f=`
78
78
 
79
- `),d+=f+h.slice(c)+N,f=`
79
+ `),u+=f+p.slice(c)+N,f=`
80
80
  `,m=!0):N===""?f===`
81
- `?d+=`
81
+ `?u+=`
82
82
  `:f=`
83
- `:(d+=f+N,f=" ",m=!1)}switch(n.chomp){case"-":break;case"+":for(let p=s;p<o.length;++p)d+=`
84
- `+o[p][0].slice(c);d[d.length-1]!==`
85
- `&&(d+=`
86
- `);break;default:d+=`
87
- `}let v=i+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[i,v,v]}}function cm({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 f=1;f<n.length;++f){let m=n[f];if(!s&&(m==="-"||m==="+"))s=m;else{let v=Number(m);!o&&v?o=v:c===-1&&(c=t+f)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,u="",d=n.length;for(let f=1;f<e.length;++f){let m=e[f];switch(m.type){case"space":l=!0;case"newline":d+=m.source.length;break;case"comment":r&&!l&&i(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=m.source.length,u=m.source.substring(1);break;case"error":i(m,"UNEXPECTED_TOKEN",m.message),d+=m.source.length;break;default:{let v=`Unexpected token in block scalar header: ${m.type}`;i(m,"UNEXPECTED_TOKEN",v);let p=m.source;p&&typeof p=="string"&&(d+=p.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function lm(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}nl.resolveBlockScalar=sm});var $a=b(ol=>{"use strict";var ja=$(),um=bt();function dm(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(f,m,v)=>r(i+f,m,v);switch(n){case"scalar":s=ja.Scalar.PLAIN,c=fm(a,l);break;case"single-quoted-scalar":s=ja.Scalar.QUOTE_SINGLE,c=pm(a,l);break;case"double-quoted-scalar":s=ja.Scalar.QUOTE_DOUBLE,c=hm(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 u=i+a.length,d=um.resolveEnd(o,u,e,r);return{value:c,type:s,comment:d.comment,range:[i,u,d.offset]}}function fm(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}`),al(t)}function pm(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),al(t.slice(1,-1)).replace(/''/g,"'")}function al(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
83
+ `:(u+=f+N,f=" ",m=!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
+ `&&(u+=`
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 lm({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 f=1;f<n.length;++f){let m=n[f];if(!s&&(m==="-"||m==="+"))s=m;else{let v=Number(m);!o&&v?o=v:c===-1&&(c=t+f)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,d="",u=n.length;for(let f=1;f<e.length;++f){let m=e[f];switch(m.type){case"space":l=!0;case"newline":u+=m.source.length;break;case"comment":r&&!l&&i(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=m.source.length,d=m.source.substring(1);break;case"error":i(m,"UNEXPECTED_TOKEN",m.message),u+=m.source.length;break;default:{let v=`Unexpected token in block scalar header: ${m.type}`;i(m,"UNEXPECTED_TOKEN",v);let h=m.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:d,length:u}}function um(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}il.resolveBlockScalar=cm});var Ha=b(al=>{"use strict";var Oa=$(),dm=kt();function fm(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(f,m,v)=>r(i+f,m,v);switch(n){case"scalar":s=Oa.Scalar.PLAIN,c=hm(a,l);break;case"single-quoted-scalar":s=Oa.Scalar.QUOTE_SINGLE,c=pm(a,l);break;case"double-quoted-scalar":s=Oa.Scalar.QUOTE_DOUBLE,c=mm(a,l);break;default:return r(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let d=i+a.length,u=dm.resolveEnd(o,d,e,r);return{value:c,type:s,comment:u.comment,range:[i,d,u.offset]}}function hm(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}`),nl(t)}function pm(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),nl(t.slice(1,-1)).replace(/''/g,"'")}function nl(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
88
88
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
89
89
  `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=e.exec(t);if(!i)return t;let n=i[1],a=" ",o=e.lastIndex;for(r.lastIndex=o;i=r.exec(t);)i[1]===""?a===`
90
90
  `?n+=a:a=`
91
- `:(n+=a+i[1],a=" "),o=r.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,i=s.exec(t),n+a+(i?.[1]??"")}function hm(t,e){let r="";for(let i=1;i<t.length-1;++i){let n=t[i];if(!(n==="\r"&&t[i+1]===`
91
+ `:(n+=a+i[1],a=" "),o=r.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,i=s.exec(t),n+a+(i?.[1]??"")}function mm(t,e){let r="";for(let i=1;i<t.length-1;++i){let n=t[i];if(!(n==="\r"&&t[i+1]===`
92
92
  `))if(n===`
93
- `){let{fold:a,offset:o}=mm(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=vm[a];if(o)r+=o;else if(a===`
93
+ `){let{fold:a,offset:o}=vm(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=gm[a];if(o)r+=o;else if(a===`
94
94
  `)for(a=t[i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="\r"&&t[i+1]===`
95
- `)for(a=t[++i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=gm(t,i+1,s,e),i+=s}else{let s=t.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=t[i+1];for(;o===" "||o===" ";)o=t[++i+1];o!==`
95
+ `)for(a=t[++i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=wm(t,i+1,s,e),i+=s}else{let s=t.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=t[i+1];for(;o===" "||o===" ";)o=t[++i+1];o!==`
96
96
  `&&!(o==="\r"&&t[i+2]===`
97
- `)&&(r+=i>a?t.slice(a,i+1):n)}else r+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function mm(t,e){let r="",i=t[e+1];for(;(i===" "||i===" "||i===`
97
+ `)&&(r+=i>a?t.slice(a,i+1):n)}else r+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function vm(t,e){let r="",i=t[e+1];for(;(i===" "||i===" "||i===`
98
98
  `||i==="\r")&&!(i==="\r"&&t[e+2]!==`
99
99
  `);)i===`
100
100
  `&&(r+=`
101
- `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var vm={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function gm(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=dm});var ll=b(cl=>{"use strict";var et=P(),sl=$(),wm=Ta(),ym=$a();function Nm(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?wm.resolveBlockScalar(t,e,i):ym.resolveFlowScalar(e,t.options.strict,i),c=r?t.directives.tagName(r.source,d=>i(r,"TAG_RESOLVE_FAILED",d)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[et.SCALAR]:c?l=bm(t.schema,n,c,r,i):e.type==="scalar"?l=km(t,n,e,i):l=t.schema[et.SCALAR];let u;try{let d=l.resolve(n,f=>i(r??e,"TAG_RESOLVE_FAILED",f),t.options);u=et.isScalar(d)?d:new sl.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);i(r??e,"TAG_RESOLVE_FAILED",f),u=new sl.Scalar(n)}return u.range=s,u.source=n,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function bm(t,e,r,i,n){if(r==="!")return t[et.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[et.SCALAR])}function km({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[et.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[et.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),u=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",u,!0)}}return o}cl.composeScalar=Nm});var dl=b(ul=>{"use strict";function Sm(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}ul.emptyScalarPosition=Sm});var hl=b(Ha=>{"use strict";var Em=Ft(),Cm=P(),xm=il(),fl=ll(),Pm=bt(),Rm=dl(),Am={composeNode:pl,composeEmptyNode:Oa};function pl(t,e,r,i){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,u=!0;switch(e.type){case"alias":l=_m(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=fl.composeScalar(t,e,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=xm.composeCollection(Am,t,e,r,i),s&&(l.anchor=s.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);i(e,"RESOURCE_EXHAUSTION",f)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",d),u=!1}}return l??(l=Oa(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&&(!Cm.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&&u&&(l.srcToken=e),l}function Oa(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let u={type:"scalar",offset:Rm.emptyScalarPosition(e,r,i),indent:-1,source:""},d=fl.composeScalar(t,u,s,l);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),a&&(d.comment=a,d.range[2]=c),d}function _m({options:t},{offset:e,source:r,end:i},n){let a=new Em.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=Pm.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}Ha.composeEmptyNode=Oa;Ha.composeNode=pl});var gl=b(vl=>{"use strict";var Im=nr(),ml=hl(),Tm=bt(),jm=cr();function $m(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new Im.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=jm.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?ml.composeNode(l,n,u,o):ml.composeEmptyNode(l,u.end,i,null,u,o);let d=c.contents.range[2],f=Tm.resolveEnd(a,d,!1,o);return f.comment&&(c.comment=f.comment),c.range=[r,d,f.offset],c}vl.composeDoc=$m});var La=b(Nl=>{"use strict";var Om=Hr("process"),Hm=Sn(),Dm=nr(),lr=sr(),wl=P(),Lm=gl(),Bm=bt();function ur(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 yl(t){let e="",r=!1,i=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":i?`
101
+ `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var gm={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function wm(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}}al.resolveFlowScalar=fm});var cl=b(sl=>{"use strict";var rt=P(),ol=$(),ym=$a(),Nm=Ha();function bm(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?ym.resolveBlockScalar(t,e,i):Nm.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[rt.SCALAR]:c?l=km(t.schema,n,c,r,i):e.type==="scalar"?l=Sm(t,n,e,i):l=t.schema[rt.SCALAR];let d;try{let u=l.resolve(n,f=>i(r??e,"TAG_RESOLVE_FAILED",f),t.options);d=rt.isScalar(u)?u:new ol.Scalar(u)}catch(u){let f=u instanceof Error?u.message:String(u);i(r??e,"TAG_RESOLVE_FAILED",f),d=new ol.Scalar(n)}return d.range=s,d.source=n,a&&(d.type=a),c&&(d.tag=c),l.format&&(d.format=l.format),o&&(d.comment=o),d}function km(t,e,r,i,n){if(r==="!")return t[rt.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[rt.SCALAR])}function Sm({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[rt.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[rt.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),d=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",d,!0)}}return o}sl.composeScalar=bm});var ul=b(ll=>{"use strict";function Em(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}ll.emptyScalarPosition=Em});var hl=b(La=>{"use strict";var Cm=zt(),xm=P(),Pm=rl(),dl=cl(),Rm=kt(),Am=ul(),_m={composeNode:fl,composeEmptyNode:Da};function fl(t,e,r,i){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,d=!0;switch(e.type){case"alias":l=Im(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=dl.composeScalar(t,e,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Pm.composeCollection(_m,t,e,r,i),s&&(l.anchor=s.source.substring(1))}catch(u){let f=u instanceof Error?u.message:String(u);i(e,"RESOURCE_EXHAUSTION",f)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",u),d=!1}}return l??(l=Da(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&&(!xm.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&i(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?l.comment=o:l.commentBefore=o),t.options.keepSourceTokens&&d&&(l.srcToken=e),l}function Da(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let d={type:"scalar",offset:Am.emptyScalarPosition(e,r,i),indent:-1,source:""},u=dl.composeScalar(t,d,s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function Im({options:t},{offset:e,source:r,end:i},n){let a=new Cm.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=Rm.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}La.composeEmptyNode=Da;La.composeNode=fl});var vl=b(ml=>{"use strict";var Tm=sr(),pl=hl(),jm=kt(),$m=dr();function Om(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new Tm.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=$m.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?pl.composeNode(l,n,d,o):pl.composeEmptyNode(l,d.end,i,null,d,o);let u=c.contents.range[2],f=jm.resolveEnd(a,u,!1,o);return f.comment&&(c.comment=f.comment),c.range=[r,u,f.offset],c}ml.composeDoc=Om});var Va=b(yl=>{"use strict";var Hm=Dr("process"),Dm=Cn(),Lm=sr(),fr=ur(),gl=P(),Bm=vl(),Vm=kt();function hr(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 wl(t){let e="",r=!1,i=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":i?`
103
103
 
104
104
  `:`
105
- `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:e,afterEmptyLine:i}}var Da=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=ur(r);a?this.warnings.push(new lr.YAMLWarning(o,i,n)):this.errors.push(new lr.YAMLParseError(o,i,n))},this.directives=new Hm.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=yl(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(wl.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];wl.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
105
+ `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:e,afterEmptyLine:i}}var Ba=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=hr(r);a?this.warnings.push(new fr.YAMLWarning(o,i,n)):this.errors.push(new fr.YAMLParseError(o,i,n))},this.directives=new Dm.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=wl(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}
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:yl(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(Om.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=ur(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=Lm.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 lr.YAMLParseError(ur(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 lr.YAMLParseError(ur(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=Bm.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 lr.YAMLParseError(ur(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 Dm.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}}};Nl.Composer=Da});var Sl=b(Pi=>{"use strict";var Mm=Ta(),Vm=$a(),Fm=sr(),bl=Gt();function qm(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 Fm.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Vm.resolveFlowScalar(t,e,i);case"block-scalar":return Mm.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function Wm(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=bl.stringifyString({type:o,value:t},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:i,source:`
108
+ ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)e.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)e.warnings.push(this.warnings[a])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:wl(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(Hm.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=hr(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=Bm.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 fr.YAMLParseError(hr(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 fr.YAMLParseError(hr(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=Vm.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 fr.YAMLParseError(hr(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 Lm.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}}};yl.Composer=Ba});var kl=b(Ri=>{"use strict";var Mm=$a(),Fm=Ha(),qm=ur(),Nl=Yt();function Wm(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 qm.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Fm.resolveFlowScalar(t,e,i);case"block-scalar":return Mm.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function zm(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=Nl.stringifyString({type:o,value:t},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:i,source:`
110
110
  `}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
111
- `),u=s.substring(0,l),d=s.substring(l+1)+`
112
- `,f=[{type:"block-scalar-header",offset:a,indent:i,source:u}];return kl(f,c)||f.push({type:"newline",offset:-1,indent:i,source:`
113
- `}),{type:"block-scalar",offset:a,indent:i,props:f,source:d}}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 zm(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=bl.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">":Jm(t,c);break;case'"':Ba(t,c,"double-quoted-scalar");break;case"'":Ba(t,c,"single-quoted-scalar");break;default:Ba(t,c,"scalar")}}function Jm(t,e){let r=e.indexOf(`
111
+ `),d=s.substring(0,l),u=s.substring(l+1)+`
112
+ `,f=[{type:"block-scalar-header",offset:a,indent:i,source:d}];return bl(f,c)||f.push({type:"newline",offset:-1,indent:i,source:`
113
+ `}),{type:"block-scalar",offset:a,indent:i,props:f,source:u}}case'"':return{type:"double-quoted-scalar",offset:a,indent:i,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:i,source:s,end:c};default:return{type:"scalar",offset:a,indent:i,source:s,end:c}}}function Jm(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=Nl.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">":Gm(t,c);break;case'"':Ma(t,c,"double-quoted-scalar");break;case"'":Ma(t,c,"single-quoted-scalar");break;default:Ma(t,c,"scalar")}}function Gm(t,e){let r=e.indexOf(`
114
114
  `),i=e.substring(0,r),n=e.substring(r+1)+`
115
- `;if(t.type==="block-scalar"){let a=t.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,t.source=n}else{let{offset:a}=t,o="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];kl(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 kl(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 Ba(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})}}}Pi.createScalarToken=Wm;Pi.resolveAsScalar=qm;Pi.setScalarValue=zm});var Cl=b(El=>{"use strict";var Gm=t=>"type"in t?Ai(t):Ri(t);function Ai(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=Ai(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=Ri(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=Ri(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=Ri(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 Ri({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Ai(e)),r)for(let a of r)n+=a.source;return i&&(n+=Ai(i)),n}El.stringify=Gm});var Al=b(Rl=>{"use strict";var Ma=Symbol("break visit"),Um=Symbol("skip children"),xl=Symbol("remove item");function tt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Pl(Object.freeze([]),t,e)}tt.BREAK=Ma;tt.SKIP=Um;tt.REMOVE=xl;tt.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};tt.parentCollection=(t,e)=>{let r=tt.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 Pl(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=Pl(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===Ma)return Ma;s===xl&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}Rl.visit=tt});var _i=b(G=>{"use strict";var Va=Sl(),Km=Cl(),Ym=Al(),Fa="\uFEFF",qa="",Wa="",za="",Xm=t=>!!t&&"items"in t,Qm=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function Zm(t){switch(t){case Fa:return"<BOM>";case qa:return"<DOC>";case Wa:return"<FLOW_END>";case za:return"<SCALAR>";default:return JSON.stringify(t)}}function ev(t){switch(t){case Fa:return"byte-order-mark";case qa:return"doc-mode";case Wa:return"flow-error-end";case za:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
+ `;if(t.type==="block-scalar"){let a=t.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,t.source=n}else{let{offset:a}=t,o="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];bl(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 bl(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 Ma(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})}}}Ri.createScalarToken=zm;Ri.resolveAsScalar=Wm;Ri.setScalarValue=Jm});var El=b(Sl=>{"use strict";var Um=t=>"type"in t?_i(t):Ai(t);function _i(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=_i(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=Ai(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=Ai(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=Ai(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 Ai({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=_i(e)),r)for(let a of r)n+=a.source;return i&&(n+=_i(i)),n}Sl.stringify=Um});var Rl=b(Pl=>{"use strict";var Fa=Symbol("break visit"),Km=Symbol("skip children"),Cl=Symbol("remove item");function it(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),xl(Object.freeze([]),t,e)}it.BREAK=Fa;it.SKIP=Km;it.REMOVE=Cl;it.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};it.parentCollection=(t,e)=>{let r=it.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 xl(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=xl(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===Fa)return Fa;s===Cl&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}Pl.visit=it});var Ii=b(G=>{"use strict";var qa=kl(),Ym=El(),Xm=Rl(),Wa="\uFEFF",za="",Ja="",Ga="",Qm=t=>!!t&&"items"in t,Zm=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function ev(t){switch(t){case Wa:return"<BOM>";case za:return"<DOC>";case Ja:return"<FLOW_END>";case Ga:return"<SCALAR>";default:return JSON.stringify(t)}}function tv(t){switch(t){case Wa:return"byte-order-mark";case za:return"doc-mode";case Ja:return"flow-error-end";case Ga: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=Va.createScalarToken;G.resolveAsScalar=Va.resolveAsScalar;G.setScalarValue=Va.setScalarValue;G.stringify=Km.stringify;G.visit=Ym.visit;G.BOM=Fa;G.DOCUMENT=qa;G.FLOW_END=Wa;G.SCALAR=za;G.isCollection=Xm;G.isScalar=Qm;G.prettyToken=Zm;G.tokenType=ev});var Ua=b(Il=>{"use strict";var dr=_i();function oe(t){switch(t){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var _l=new Set("0123456789ABCDEFabcdef"),tv=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ii=new Set(",[]{}"),rv=new Set(` ,[]{}
121
- \r `),Ja=t=>!t||rv.has(t),Ga=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
119
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}G.createScalarToken=qa.createScalarToken;G.resolveAsScalar=qa.resolveAsScalar;G.setScalarValue=qa.setScalarValue;G.stringify=Ym.stringify;G.visit=Xm.visit;G.BOM=Wa;G.DOCUMENT=za;G.FLOW_END=Ja;G.SCALAR=Ga;G.isCollection=Qm;G.isScalar=Zm;G.prettyToken=ev;G.tokenType=tv});var Ya=b(_l=>{"use strict";var pr=Ii();function oe(t){switch(t){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var Al=new Set("0123456789ABCDEFabcdef"),rv=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ti=new Set(",[]{}"),iv=new Set(` ,[]{}
121
+ \r `),Ua=t=>!t||iv.has(t),Ka=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
122
122
  `?!0:r==="\r"?this.buffer[e+1]===`
123
123
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let r=this.buffer[e];if(this.indentNext>0){let i=0;for(;r===" ";)r=this.buffer[++i+e];if(r==="\r"){let n=this.buffer[i+e+1];if(n===`
124
124
  `||!n&&!this.atEnd)return e+i+1}return r===`
125
125
  `||i>=this.indentNext||!r&&!this.atEnd?e+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&oe(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]===dr.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 dr.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==="...")&&oe(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&&!oe(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===":")&&oe(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(Ja),"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("..."))&&oe(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield dr.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(Ja),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||oe(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
126
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===pr.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 pr.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==="...")&&oe(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&&!oe(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===":")&&oe(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(Ua),"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("..."))&&oe(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield pr.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(Ua),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||oe(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
127
127
  `,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=i.indexOf(`
128
128
  `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>oe(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
129
129
  `:e=a,r=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
130
130
  `)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(e+1);if(a===-1)break;e=this.buffer.indexOf(`
131
131
  `,a)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
132
132
  `;)i=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let a=e-1,o=this.buffer[a];o==="\r"&&(o=this.buffer[--a]);let s=a;for(;o===" ";)o=this.buffer[--a];if(o===`
133
- `&&a>=this.pos&&a+1+r>s)e=a;else break}while(!0);return yield dr.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(oe(a)||e&&Ii.has(a))break;r=i}else if(oe(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
133
+ `&&a>=this.pos&&a+1+r>s)e=a;else break}while(!0);return yield pr.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(oe(a)||e&&Ti.has(a))break;r=i}else if(oe(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&&Ii.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&&Ii.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield dr.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(Ja),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(oe(i)||r&&Ii.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(;!oe(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(tv.has(r))r=this.buffer[++e];else if(r==="%"&&_l.has(this.buffer[e+1])&&_l.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
135
+ `,a=this.buffer[i+1]):r=i),a==="#"||e&&Ti.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&&Ti.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield pr.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(Ua),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(oe(i)||r&&Ti.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(;!oe(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(rv.has(r))r=this.buffer[++e];else if(r==="%"&&Al.has(this.buffer[e+1])&&Al.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
137
137
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
138
- `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||e&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let r=this.pos,i=this.buffer[r];for(;!e(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};Il.Lexer=Ga});var Ya=b(Tl=>{"use strict";var Ka=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}}}};Tl.LineCounter=Ka});var Qa=b(Dl=>{"use strict";var iv=Hr("process"),jl=_i(),nv=Ua();function De(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function $l(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 Hl(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 Ti(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 kt(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 ji(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 Ol(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!De(e.start,"explicit-key-ind")&&!De(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Hl(e.value)?e.value.end?ji(e.value.end,e.sep):e.value.end=e.sep:ji(e.start,e.sep),delete e.sep)}var Xa=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 nv.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,iv.env.LOG_TOKENS&&console.log("|",jl.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=jl.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"&&Ol(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&&$l(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":{$l(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=Ti(this.peek(2)),i=kt(r),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
138
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||e&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let r=this.pos,i=this.buffer[r];for(;!e(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};_l.Lexer=Ka});var Qa=b(Il=>{"use strict";var Xa=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}}}};Il.LineCounter=Xa});var eo=b(Hl=>{"use strict";var nv=Dr("process"),Tl=Ii(),av=Ya();function Le(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function jl(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Ol(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 ji(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 St(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 $i(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 $l(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Le(e.start,"explicit-key-ind")&&!Le(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Ol(e.value)?e.value.end?$i(e.value.end,e.sep):e.value.end=e.sep:$i(e.start,e.sep),delete e.sep)}var Za=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 av.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,nv.env.LOG_TOKENS&&console.log("|",Tl.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=Tl.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"&&$l(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&&jl(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":{jl(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let 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=ji(this.peek(2)),i=St(r),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
139
139
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
140
- `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){ji(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(De(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(Hl(r.key)&&!De(r.sep,"newline")){let o=kt(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(De(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=kt(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]}):De(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&&!De(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)){ji(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||De(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=Ti(i),a=kt(n);Ol(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
140
+ `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){$i(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(Le(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(Ol(r.key)&&!Le(r.sep,"newline")){let o=St(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(Le(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=St(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]}):Le(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&&!Le(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)){$i(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||Le(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=ji(i),a=St(n);$l(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
141
141
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
142
- `,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Ti(e),i=kt(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=Ti(e),i=kt(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())}}};Dl.Parser=Xa});var Fl=b(pr=>{"use strict";var Ll=La(),av=nr(),fr=sr(),ov=Hn(),sv=P(),cv=Ya(),Bl=Qa();function Ml(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new cv.LineCounter||null,prettyErrors:e}}function lv(t,e={}){let{lineCounter:r,prettyErrors:i}=Ml(e),n=new Bl.Parser(r?.addNewLine),a=new Ll.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(fr.prettifyError(t,r)),s.warnings.forEach(fr.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function Vl(t,e={}){let{lineCounter:r,prettyErrors:i}=Ml(e),n=new Bl.Parser(r?.addNewLine),a=new Ll.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 fr.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(fr.prettifyError(t,r)),o.warnings.forEach(fr.prettifyError(t,r))),o}function uv(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=Vl(t,r);if(!n)return null;if(n.warnings.forEach(a=>ov.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 dv(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 sv.isDocument(t)&&!i?t.toString(r):new av.Document(t,i,r).toString(r)}pr.parse=uv;pr.parseAllDocuments=lv;pr.parseDocument=Vl;pr.stringify=dv});var St=b(R=>{"use strict";var fv=La(),pv=nr(),hv=wa(),Za=sr(),mv=Ft(),Le=P(),vv=je(),gv=$(),wv=Oe(),yv=He(),Nv=_i(),bv=Ua(),kv=Ya(),Sv=Qa(),$i=Fl(),ql=Lt();R.Composer=fv.Composer;R.Document=pv.Document;R.Schema=hv.Schema;R.YAMLError=Za.YAMLError;R.YAMLParseError=Za.YAMLParseError;R.YAMLWarning=Za.YAMLWarning;R.Alias=mv.Alias;R.isAlias=Le.isAlias;R.isCollection=Le.isCollection;R.isDocument=Le.isDocument;R.isMap=Le.isMap;R.isNode=Le.isNode;R.isPair=Le.isPair;R.isScalar=Le.isScalar;R.isSeq=Le.isSeq;R.Pair=vv.Pair;R.Scalar=gv.Scalar;R.YAMLMap=wv.YAMLMap;R.YAMLSeq=yv.YAMLSeq;R.CST=Nv;R.Lexer=bv.Lexer;R.LineCounter=kv.LineCounter;R.Parser=Sv.Parser;R.parse=$i.parse;R.parseAllDocuments=$i.parseAllDocuments;R.parseDocument=$i.parseDocument;R.stringify=$i.stringify;R.visit=ql.visit;R.visitAsync=ql.visitAsync});var Ao=Dt(St(),1);import{promises as Zw}from"fs";import st from"path";import{execFileSync as Ev}from"child_process";import hr from"path";function Et(t,e){return Ev("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Cv(t,e){let r=hr.normalize(t),i=hr.normalize(e);return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Se(t){try{let e=hr.resolve(Et(t,["rev-parse","--show-toplevel"])),i=Et(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?hr.resolve(i.slice(9)):e,a=null;try{a=Et(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Cv(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function Wl(t){try{Et(t,["rev-parse","--is-inside-work-tree"]);let e=Et(t,["worktree","list","--porcelain"]).split(/\r?\n/u),r=[],i=null;for(let n of e)n.startsWith("worktree ")?(i&&r.push(i),i={root:hr.resolve(n.slice(9)),branch:null,detached:!1}):i&&n.startsWith("branch refs/heads/")?i.branch=n.slice(18):i&&n==="detached"&&(i.detached=!0);return i&&r.push(i),r}catch{return[]}}function Ct(t){return Wl(t).map(e=>e.root)}function mr(t,e){try{let r=Et(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(r)?r:null}catch{return null}}import{createHash as Av}from"node:crypto";import{promises as se}from"node:fs";import Q from"node:path";import{TextDecoder as _v}from"node:util";var xv=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Pv=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Rv(t){return t.toLowerCase().startsWith(".env")}function vr(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>Rv(i))?"environment-file":r.some(i=>Pv.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>xv.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}function Be(t){return t!==0&&t!==0n&&t!=="0"}function Ee(t,e){return Be(t.dev)&&Be(e.dev)&&Be(t.ino)&&Be(e.ino)}function T(t,e){let r=Be(t.dev)&&Be(e.dev);if(r&&t.dev!==e.dev)return!1;let i=Be(t.ino)&&Be(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var Hi=1024*1024;function eo(t,e){let r=Q.relative(t,e);return r===""||!Q.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Q.sep}`)}function Iv(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=vr(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 Tv(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function jv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Oi(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return Ee(r,i)?T(r,i):T(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function zl(t){let e=await se.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await se.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function $v(t,e){let r=Q.resolve(t),i=Q.resolve(e);if(!eo(r,i))throw new Error("Native artifact path is outside its root");let n=[await zl(r)],a=r;for(let o of Q.relative(r,i).split(Q.sep).filter(Boolean)){a=Q.join(a,o);let s=await zl(a);if(!eo(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Jl(t){for(let e of t){let r=await se.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!jv(e,r)||await se.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function B(t){let e=Iv(t.ref),r=t.maxBytes===null?null:Tv(t.maxBytes??Hi),i=Q.resolve(t.root,...e.split("/")),n=await $v(t.root,Q.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await se.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 se.realpath(i);if(!eo(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await se.open(i,"r");try{let[c,l,u]=await Promise.all([s.stat(),se.lstat(i),se.realpath(i)]);if(await Jl(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!Oi(a,c)||!Oi(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],f=0,m=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let g=r===null?m.length:r+1-f,S=await s.read(m,0,Math.min(m.length,g),null);if(S.bytesRead===0)break;if(f+=S.bytesRead,r!==null&&f>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);d.push(Buffer.from(m.subarray(0,S.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[v,p,h]=await Promise.all([s.stat(),se.lstat(i),se.realpath(i)]);if(await Jl(n),!p.isFile()||p.isSymbolicLink()||h!==o||!Oi(c,v)||!Oi(c,p))throw new Error(`Native artifact changed while reading: ${e}`);let N=Buffer.concat(d,f),w;try{w=new _v("utf-8",{fatal:!0}).decode(N)}catch(g){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:g})}return{ref:e,size:f,hash:t.includeHash===!1?null:Av("sha256").update(N).digest("hex"),text:w}}finally{await s.close()}}import{randomUUID as Ov}from"crypto";import{promises as F}from"fs";import ce from"path";function to(t,e){let r=ce.relative(t,e);return r===""||!ce.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ce.sep}`)}function Hv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function ro(t,e){return T({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function Dv(t,e){return ro(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Gl(t){let e=await F.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 F.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function gr(t){for(let e of t){let r=await F.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Hv(e,r)||await F.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Lv(t,e){let r=ce.resolve(t),i=ce.resolve(e);if(!to(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Gl(r)],a=ce.relative(r,i).split(ce.sep).filter(Boolean),o=r;for(let s of a){await gr(n),o=ce.join(o,s);try{await F.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Gl(o);if(!to(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await gr(n),n}async function Bv(t){let e;try{e=await F.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 Mv(t,e,r={}){let i=ce.dirname(t),n=r.containedRoot?await Lv(r.containedRoot,i):null;n||await F.mkdir(i,{recursive:!0});let a=ce.join(i,`.${ce.basename(t)}.${Ov()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await F.open(a,"wx"),s=await o.stat(),n){let[l,u]=await Promise.all([F.lstat(a),F.realpath(a)]);if(await gr(n),!l.isFile()||l.isSymbolicLink()||!ro(s,l)||!to(n[0].realPath,u))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(),!ro(s,c))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await r.beforeCommit?.(),n){await gr(n);let l=await F.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!Dv(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await F.link(a,t),await F.unlink(a)):await F.rename(a,t),await Bv(i)}catch(l){if(await o?.close(),!n)await F.rm(a,{force:!0});else try{await gr(n),await F.rm(a,{force:!0})}catch{}throw l}}async function Ce(t,e,r={}){await Mv(t,e,r)}async function le(t,e,r={}){await Ce(t,JSON.stringify(e,null,2)+`
143
- `,r)}var io={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:"验证预期"}},Vv={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:"结论"}},Fv={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:"结论"}},qv=new Map,Ul=new Map;for(let t of Object.keys(io)){for(let[e,r]of Object.entries(io[t]))qv.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Vv[t]))Ul.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Fv[t]))Ul.set(r.toLocaleLowerCase("en-US"),e)}function Wv(t,e){return io[t][e]}function Di(t){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${Wv(t,r)}
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=ji(e),i=St(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=ji(e),i=St(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())}}};Hl.Parser=Za});var Ml=b(vr=>{"use strict";var Dl=Va(),ov=sr(),mr=ur(),sv=Ln(),cv=P(),lv=Qa(),Ll=eo();function Bl(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new lv.LineCounter||null,prettyErrors:e}}function uv(t,e={}){let{lineCounter:r,prettyErrors:i}=Bl(e),n=new Ll.Parser(r?.addNewLine),a=new Dl.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(mr.prettifyError(t,r)),s.warnings.forEach(mr.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function Vl(t,e={}){let{lineCounter:r,prettyErrors:i}=Bl(e),n=new Ll.Parser(r?.addNewLine),a=new Dl.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 mr.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(mr.prettifyError(t,r)),o.warnings.forEach(mr.prettifyError(t,r))),o}function dv(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=Vl(t,r);if(!n)return null;if(n.warnings.forEach(a=>sv.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 fv(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 cv.isDocument(t)&&!i?t.toString(r):new ov.Document(t,i,r).toString(r)}vr.parse=dv;vr.parseAllDocuments=uv;vr.parseDocument=Vl;vr.stringify=fv});var Et=b(R=>{"use strict";var hv=Va(),pv=sr(),mv=Na(),to=ur(),vv=zt(),Be=P(),gv=$e(),wv=$(),yv=He(),Nv=De(),bv=Ii(),kv=Ya(),Sv=Qa(),Ev=eo(),Oi=Ml(),Fl=Mt();R.Composer=hv.Composer;R.Document=pv.Document;R.Schema=mv.Schema;R.YAMLError=to.YAMLError;R.YAMLParseError=to.YAMLParseError;R.YAMLWarning=to.YAMLWarning;R.Alias=vv.Alias;R.isAlias=Be.isAlias;R.isCollection=Be.isCollection;R.isDocument=Be.isDocument;R.isMap=Be.isMap;R.isNode=Be.isNode;R.isPair=Be.isPair;R.isScalar=Be.isScalar;R.isSeq=Be.isSeq;R.Pair=gv.Pair;R.Scalar=wv.Scalar;R.YAMLMap=yv.YAMLMap;R.YAMLSeq=Nv.YAMLSeq;R.CST=bv;R.Lexer=kv.Lexer;R.LineCounter=Sv.LineCounter;R.Parser=Ev.Parser;R.parse=Oi.parse;R.parseAllDocuments=Oi.parseAllDocuments;R.parseDocument=Oi.parseDocument;R.stringify=Oi.stringify;R.visit=Fl.visit;R.visitAsync=Fl.visitAsync});var Ao=Vt(Et(),1);import{promises as ey}from"fs";import lt from"path";import{execFileSync as Cv}from"child_process";import gr from"path";function Ct(t,e){return Cv("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function xv(t,e){let r=gr.normalize(t),i=gr.normalize(e);return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Se(t){try{let e=gr.resolve(Ct(t,["rev-parse","--show-toplevel"])),i=Ct(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?gr.resolve(i.slice(9)):e,a=null;try{a=Ct(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!xv(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function ql(t){try{Ct(t,["rev-parse","--is-inside-work-tree"]);let e=Ct(t,["worktree","list","--porcelain"]).split(/\r?\n/u),r=[],i=null;for(let n of e)n.startsWith("worktree ")?(i&&r.push(i),i={root:gr.resolve(n.slice(9)),branch:null,detached:!1}):i&&n.startsWith("branch refs/heads/")?i.branch=n.slice(18):i&&n==="detached"&&(i.detached=!0);return i&&r.push(i),r}catch{return[]}}function xt(t){return ql(t).map(e=>e.root)}function wr(t,e){try{let r=Ct(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(r)?r:null}catch{return null}}import{createHash as _v}from"node:crypto";import{promises as se}from"node:fs";import Q from"node:path";import{TextDecoder as Iv}from"node:util";var Pv=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Rv=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Av(t){return t.toLowerCase().startsWith(".env")}function yr(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>Av(i))?"environment-file":r.some(i=>Rv.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>Pv.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}function Ve(t){return t!==0&&t!==0n&&t!=="0"}function Ee(t,e){return Ve(t.dev)&&Ve(e.dev)&&Ve(t.ino)&&Ve(e.ino)}function T(t,e){let r=Ve(t.dev)&&Ve(e.dev);if(r&&t.dev!==e.dev)return!1;let i=Ve(t.ino)&&Ve(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var Di=1024*1024;function ro(t,e){let r=Q.relative(t,e);return r===""||!Q.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Q.sep}`)}function Tv(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=yr(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 jv(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function $v(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Hi(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return Ee(r,i)?T(r,i):T(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Wl(t){let e=await se.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await se.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Ov(t,e){let r=Q.resolve(t),i=Q.resolve(e);if(!ro(r,i))throw new Error("Native artifact path is outside its root");let n=[await Wl(r)],a=r;for(let o of Q.relative(r,i).split(Q.sep).filter(Boolean)){a=Q.join(a,o);let s=await Wl(a);if(!ro(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function zl(t){for(let e of t){let r=await se.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!$v(e,r)||await se.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function B(t){let e=Tv(t.ref),r=t.maxBytes===null?null:jv(t.maxBytes??Di),i=Q.resolve(t.root,...e.split("/")),n=await Ov(t.root,Q.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await se.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 se.realpath(i);if(!ro(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await se.open(i,"r");try{let[c,l,d]=await Promise.all([s.stat(),se.lstat(i),se.realpath(i)]);if(await zl(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||d!==o||!Hi(a,c)||!Hi(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let u=[],f=0,m=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let g=r===null?m.length:r+1-f,S=await s.read(m,0,Math.min(m.length,g),null);if(S.bytesRead===0)break;if(f+=S.bytesRead,r!==null&&f>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);u.push(Buffer.from(m.subarray(0,S.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[v,h,p]=await Promise.all([s.stat(),se.lstat(i),se.realpath(i)]);if(await zl(n),!h.isFile()||h.isSymbolicLink()||p!==o||!Hi(c,v)||!Hi(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let N=Buffer.concat(u,f),w;try{w=new Iv("utf-8",{fatal:!0}).decode(N)}catch(g){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:g})}return{ref:e,size:f,hash:t.includeHash===!1?null:_v("sha256").update(N).digest("hex"),text:w}}finally{await s.close()}}import{randomUUID as Hv}from"crypto";import{promises as V}from"fs";import ce from"path";function Li(t,e){let r=ce.relative(t,e);return r===""||!ce.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ce.sep}`)}function Dv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Bi(t,e){return T({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function Lv(t,e){return Bi(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Jl(t){let e=await V.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 V.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Pt(t){for(let e of t){let r=await V.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Dv(e,r)||await V.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Bv(t,e,r){let[i,n]=await Promise.all([V.lstat(t),V.realpath(t),r?Pt(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Bi(i,e)||r&&!Li(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function Vv(t,e){let r=ce.resolve(t),i=ce.resolve(e);if(!Li(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Jl(r)],a=ce.relative(r,i).split(ce.sep).filter(Boolean),o=r;for(let s of a){await Pt(n),o=ce.join(o,s);try{await V.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Jl(o);if(!Li(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await Pt(n),n}async function Mv(t){let e;try{e=await V.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 Fv(t,e,r={}){let i=ce.dirname(t),n=r.containedRoot?await Vv(r.containedRoot,i):null;n||await V.mkdir(i,{recursive:!0});let a=ce.join(i,`.${ce.basename(t)}.${Hv()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await V.open(a,"wx"),s=await o.stat(),n){let[l,d]=await Promise.all([V.lstat(a),V.realpath(a)]);if(await Pt(n),!l.isFile()||l.isSymbolicLink()||!Bi(s,l)||!Li(n[0].realPath,d))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof e=="string"?await o.writeFile(e,"utf8"):await o.writeFile(e),await o.sync(),c=await o.stat(),!Bi(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 Bv(a,c,n),await r.beforeCommit?.(),n){await Pt(n);let l=await V.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!Lv(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await V.link(a,t),await V.unlink(a)):await V.rename(a,t),await Mv(i)}catch(l){if(await o?.close(),!n)await V.rm(a,{force:!0});else try{await Pt(n),await V.rm(a,{force:!0})}catch{}throw l}}async function Ce(t,e,r={}){await Fv(t,e,r)}async function le(t,e,r={}){await Ce(t,JSON.stringify(e,null,2)+`
143
+ `,r)}var io={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:"验证预期"}},qv={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:"结论"}},Wv={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:"结论"}},zv=new Map,Gl=new Map;for(let t of Object.keys(io)){for(let[e,r]of Object.entries(io[t]))zv.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(qv[t]))Gl.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Wv[t]))Gl.set(r.toLocaleLowerCase("en-US"),e)}function Jv(t,e){return io[t][e]}function Vi(t){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${Jv(t,r)}
144
144
  `).join(`
145
- `)}var ao=Dt(St(),1);import Me from"path";var wr=64*1024,Bi=1024,Mi=64,Kl=1024,Yl=64,oo=5,Li={learning:!0,retrieval:!0},Zl={provider:"local"},zv=12e4,Xl=6e5,Jv=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/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/**"],Gv=["**/.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"],Uv=[...Jv,...Gv].sort((t,e)=>t.localeCompare(e,"en"));var K={include:["**/*"],exclude:[...Uv],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function Kv(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||Me.posix.isAbsolute(r)||Me.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 rt(t){let e=Kv(t,"native.artifact_root");return e.length===0?".":e.join("/")}function eu(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 Vi(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||Me.posix.isAbsolute(i)||Me.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 xe(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function tu(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 Fi(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>Bi)throw new Error(`${e} exceeds ${Bi} 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>Mi)throw new Error(`${e} contains more than ${Mi} wildcard tokens`);return t}function Ql(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=>Fi(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function no(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 Yv(t){if(t===void 0)return{...K,include:[...K.include],exclude:[...K.exclude]};let e=xe(t,"native.snapshot");return{include:Ql(e.include,"native.snapshot.include",K.include),exclude:Ql(e.exclude,"native.snapshot.exclude",K.exclude),max_files:no(e.max_files,K.max_files,"native.snapshot.max_files"),max_total_bytes:no(e.max_total_bytes,K.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:no(e.max_duration_ms,K.max_duration_ms,"native.snapshot.max_duration_ms")}}function Xv(t){if(t===void 0)return;let e=xe(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=xe(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,u=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:u}}return{id:r,fromArtifactRoot:rt(i),toArtifactRoot:rt(n),stage:a,...o?{cleanup:o}:{}}}function Qv(t){if(t===void 0)return;let e=xe(t,"native.finish");if(e.pull_request===void 0)return{};let r=xe(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(Me.posix.isAbsolute(i[0])||Me.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??zv;if(!Number.isSafeInteger(n)||n<1||n>Xl)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Xl}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function Zv(t,e={}){let r=xe(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??oo;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Xv(r.pending_root_move),c=Qv(r.finish);return{artifact_root:rt(i),language:tu(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Yv(r.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function eg(t){let e=xe(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:eu(e.artifact_layout),language:tu(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n}}function tg(t){let r=xe(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)=>Vi(i,`hook.allow_paths[${n}]`)))]}}function rg(t){if(t===void 0)return{...Li};let e=xe(t,"memory"),r=e.learning??Li.learning,i=e.retrieval??Li.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 so(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function ig(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")||Me.posix.isAbsolute(r)||Me.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>Kl)throw new Error(`${e} exceeds ${Kl} 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>Yl)throw new Error(`${e} contains more than ${Yl} wildcard tokens`);return r}function ng(t){let r=so(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)=>ig(i,`knowledge.local.include[${n}]`)))]}}function ag(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 og(t){let e=so(t,"knowledge.remote"),r=ag(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 sg(t){if(t===void 0)return{...Zl};let e=so(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:ng(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:og(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 cg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function lg(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 u=t.workflows??[t.default_workflow];if(!Array.isArray(u)||u.length===0||u.some(f=>f!=="native"&&f!=="classic"))throw new Error("workflows must contain native and/or classic");let d=[...new Set(u)];if(!d.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(d.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:d,ambient_resume:o,...e?{hook:e}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function yr(t,e={}){let r=(0,ao.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=cg(n.ambient_resume),o=n.hook===void 0?void 0:tg(n.hook),s=rg(n.memory),c=sg(n.knowledge),l=n.native===void 0?void 0:Zv(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=n.classic===void 0?void 0:eg(n.classic),d=lg(n,o,s,c,l,u,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:d,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...u?{classic:u}:{}}}function qi(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Li},knowledge:{...Zl},native:{artifact_root:rt(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:oo,snapshot:{...K,include:[...K.include],exclude:[...K.exclude]}}}}import{createHash as dg}from"crypto";import{promises as Ji}from"fs";import Ve from"path";import{constants as Wi,promises as it}from"fs";var me=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}};function co(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 Nr(t){return{dev:t.dev,ino:t.ino,birthtime:co(t)}}function zi(t,e){let r=Nr(t),i=Nr(e);return Ee(r,i)?T(r,i):T(r,i)&&co(t)===co(e)&&ru(t)===ru(e)&&t.size===e.size}async function br(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 it.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new me("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new me("too-large",`${i} exceeds ${e} bytes`);let o=await it.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:Nr(a)});let s=process.platform==="win32"?Wi.O_RDONLY:Wi.O_RDONLY|Wi.O_NOFOLLOW|Wi.O_NONBLOCK,c;try{c=await it.open(t,s)}catch(l){throw l.code==="ELOOP"?new me("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,u,d]=await Promise.all([c.stat({bigint:n}),it.lstat(t,{bigint:n}),it.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!zi(a,l)||!zi(a,u))throw new me("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:d,identity:Nr(l)}),await r.hooks?.afterOpen?.();let f=[],m=0,v=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let w=e+1-m,{bytesRead:g}=await c.read(v,0,Math.min(v.length,w),null);if(g===0)break;if(m+=g,m>e)throw new me("too-large",`${i} exceeds ${e} bytes`);f.push(Buffer.from(v.subarray(0,g)))}await r.hooks?.beforeFinalCheck?.();let[p,h,N]=await Promise.all([c.stat({bigint:n}),it.lstat(t,{bigint:n}),it.realpath(t)]);if(!h.isFile()||h.isSymbolicLink()||N!==o||!zi(a,p)||!zi(a,h))throw new me("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:N,identity:Nr(p)}),{bytes:Buffer.concat(f,m),stat:p,realPath:N}}finally{await c.close()}}function ug(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function lo(t,e){let r=Ve.relative(t,e);return r===""||!Ve.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ve.sep}`)}async function iu(t,e){let r=Ve.resolve(t),i=await Ji.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Ji.realpath(r)}async function nu(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=Ve.join(n,r[a]);let o;try{o=await Ji.lstat(n)}catch(u){if(ug(u))return{exists:!1,kind:"missing"};throw u}let s=Ve.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 Ji.realpath(n);if(!lo(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 xt(t,e,r){let i=Vi(e,r.label),n=Ve.resolve(t),a=await iu(n,r.label),o=i.split("/"),s=Ve.resolve(n,...o);if(!lo(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await nu(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:c.exists,kind:c.kind}}async function Fe(t,e,r,i){let n=await xt(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 iu(n.projectRoot,i.label);return br(n.target,r,{...i,verify:async(o,s)=>{if(!lo(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await nu(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var kr=".comet/config.yaml";function fg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Gi(t,e={}){return(await Ui(t,e)).document}async function pg(t){try{return(await Fe(t,kr,wr,{label:kr})).bytes}catch(e){if(fg(e))return null;throw e}}function hg(t){return t?{exists:!0,sha256:dg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Ui(t,e={}){let r=await pg(t);return{document:r?yr(r.toString("utf8"),e):null,identity:hg(r)}}async function uo(t){return(await Gi(t))?.config??null}var Zk=16*1024;import{existsSync as ou,promises as nt}from"fs";import A from"path";import yg from"os";var Ki=".comet/config.yaml",Ng=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function ho(t){try{return await nt.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function bg(t){try{let e=await nt.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Rt(t,e){let r=A.relative(t,e);return r===""||!A.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${A.sep}`)}async function Pt(t){let e=[],r=t;for(;!await ho(r);){let n=A.dirname(r);if(n===r)break;e.push(A.basename(r)),r=n}let i=await nt.realpath(r);return A.resolve(i,...e.reverse())}async function mo(t){try{return(await nt.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Yi(t){let e=A.resolve(t);try{(await nt.stat(e)).isDirectory()||(e=A.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=A.resolve(yg.homedir());for(;;){if(!(e===i&&r!==i)){let o=A.join(e,...Ki.split("/")),s=e===r||await bg(o);if(await ho(o)&&s)return e}if(await ho(A.join(e,".git")))return e;let a=A.dirname(e);if(a===e)return r;e=a}}function Xi(t){return rt(t)}async function kg(t,e){let r=Xi(e),i=A.resolve(t,...r.split("/")),n=await nt.realpath(t),a=await Pt(i);if(!Rt(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function at(t,e){let r=Xi(e),i=await kg(t,r),n=A.join(i,"comet");if(await mo(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([Pt(i),Pt(n)]);if(!Rt(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=A.resolve(t),c=A.join(s,".comet","runtime","native");if(await mo(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,u]=await Promise.all([nt.realpath(s),Pt(c)]);if(!Rt(l,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:A.join(t,...Ki.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:A.join(n,"specs"),changesDir:A.join(n,"changes"),archiveDir:A.join(n,"archive"),runtimeDir:c,changesRuntimeDir:A.join(c,"changes"),locksDir:A.join(c,"locks"),transactionsDir:A.join(c,"transactions")}}function su(t){if(!Ng.test(t))throw new Error(`Invalid Native change name: ${t}`)}function At(t,e){su(e);let r=A.join(t.changesRuntimeDir,e);if(!q(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function Sg(t,e){su(e);let r=A.join(t.changesDir,e,"runtime");if(!q(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Z(t,e){let r=At(t,e);if(ou(r))return r;let i=Sg(t,e);return ou(i)?i:r}function ve(t,e){let r=A.resolve(e);if(q(t.runtimeDir,r))return t.runtimeDir;if(q(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function q(t,e){return Rt(A.resolve(t),A.resolve(e))}async function D(t,e){let r=A.resolve(t),i=A.resolve(e);if(!Rt(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await mo(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([Pt(r),Pt(i)]);if(!Rt(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}var Qi=Fi;function Cg(t="docs",e="en"){return qi(t,e)}async function ge(t){let e=(await Gi(t))?.config??null;return e?.native?e:null}async function cu(t){let e=await Yi(t.startPath),r=await ge(e);if(!r&&t.allowMissingConfig===!1)throw new Error(`${Ki} 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?Xi(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??Cg(i??"docs"),a=await at(e,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}import{AsyncLocalStorage as xg}from"async_hooks";var ES=16*1024;var CS=new xg;import{createHash as Pg}from"crypto";function ue(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function Rg(t,e){e.has(t)&&ue("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)||ue("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&ue("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&ue("symbol properties are not supported"),`[${t.map(i=>vo(i,e)).join(",")}]`}finally{e.delete(t)}}function Ag(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&ue("only plain objects are supported"),e.has(t)&&ue("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&ue("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))&&ue("accessor properties are not supported"),`${JSON.stringify(o)}:${vo(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function vo(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)||ue("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?Rg(t,e):Ag(t,e);case"bigint":case"function":case"symbol":case"undefined":return ue(`${typeof t} values are not supported`)}return ue("unsupported value type")}function go(t){return vo(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 Pg("sha256").update(`${t}
146
- ${go(e)}`).digest("hex")}var IS=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),lu=Object.freeze({maxCriteria:1024});var yo=Dt(St(),1);import{promises as $g}from"node:fs";var Er="comet.native.v4";var uu=["multi-session","single-session"];var Og=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Hg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Dg=/^A[1-9][0-9]*$/u,Lg=/^[a-f0-9]{64}$/u,Bg=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"]);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 M(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 wo(t,e){return t===null?null:M(t,e)}function Mg(t,e){let r=M(t,e);if(!Lg.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function _t(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function j(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 Vg(t,e){return t===null?null:j(t,e,Number.MIN_SAFE_INTEGER)}function O(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function we(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function Zi(t,e){return we(t,e,(r,i)=>M(r,`${e}[${i}]`))}function ot(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function It(t,e){let r=M(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function No(t,e,r=!1){let i=M(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 ee(t,e){let r=W(t,e);return z(r,new Set(["text","truncated"]),e),{text:M(r.text,`${e}.text`,{empty:!0}),truncated:_t(r.truncated,`${e}.truncated`)}}function Fg(t,e){let r=`Native spec_changes[${e}]`,i=W(t,r);z(i,new Set(["capability","operation","source"]),r);let n=M(i.capability,`${r}.capability`);if(!Hg.test(n))throw new Error(`${r}.capability is invalid`);let a=O(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:No(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 qg(t){let e="Native workspace",r=W(t,e);z(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=O(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=wo(r.change_branch,`${e}.change_branch`),a=wo(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:O(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 Wg(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=Zi(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);ot(i,`${e}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:O(r.stop_reason,["budget","stalled"],`${e}.stop_reason`);return{stage:O(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:j(r.goal_cycle,`${e}.goal_cycle`,1),iteration:j(r.iteration,`${e}.iteration`),attempt:j(r.attempt,`${e}.attempt`),retry_epoch:j(r.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:j(r.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:j(r.no_progress_count,`${e}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:j(r.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:i,next_action:wo(r.next_action,`${e}.next_action`)}}function zg(t,e){let r=`Native acceptance[${e}]`,i=W(t,r);z(i,new Set(["id","source","text","result","reason"]),r);let n=M(i.id,`${r}.id`);if(!Dg.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:No(i.source,`${r}.source`),text:M(i.text,`${r}.text`),result:O(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:ee(i.reason,`${r}.reason`)}}function Jg(t,e){let r=`Native builder_handoff.checks[${e}]`,i=W(t,r);return z(i,new Set(["name","result","note"]),r),{name:ee(i.name,`${r}.name`),result:O(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:ee(i.note,`${r}.note`)}}function Gg(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=Zi(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);ot(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:M(r.candidate_id,`${e}.candidate_id`),identity_provider:M(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:M(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:j(r.iteration,`${e}.iteration`,1),summary:ee(r.summary,`${e}.summary`),addressed_acceptance_ids:i,checks:we(r.checks,`${e}.checks`,Jg),checks_truncated:_t(r.checks_truncated,`${e}.checks_truncated`),known_limits:we(r.known_limits,`${e}.known_limits`,(a,o)=>ee(a,`${e}.known_limits[${o}]`)),known_limits_truncated:_t(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:O(n.status,["passed"],`${e}.review.status`),summary:ee(n.summary,`${e}.review.summary`),reviewer_execution_ref:M(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:It(r.submitted_at,`${e}.submitted_at`)}}function Ug(t,e){let r=`Native blockers[${e}]`,i=W(t,r);z(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=Zi(i.acceptance_ids,`${r}.acceptance_ids`);return ot(n,`${r}.acceptance_ids`),{owner:O(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:ee(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:O(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function Kg(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:M(i.id,`${r}.id`),name:ee(i.name,`${r}.name`),argv_display:we(i.argv_display,`${r}.argv_display`,(n,a)=>ee(n,`${r}.argv_display[${a}]`)),argv_truncated:_t(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:No(i.cwd_ref,`${r}.cwd_ref`,!0),status:O(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:Vg(i.exit_code,`${r}.exit_code`),duration_ms:j(i.duration_ms,`${r}.duration_ms`)}}function Yg(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=we(r.checks,`${e}.checks`,Kg);ot(i.map(a=>a.id),`${e}.checks IDs`);let n=M(r.identity_provider,`${e}.identity_provider`);return{candidate_id:M(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:M(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:j(r.iteration,`${e}.iteration`,1),attempt:j(r.attempt,`${e}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":O(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:O(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:ee(r.summary,`${e}.summary`),risks:we(r.risks,`${e}.risks`,(a,o)=>ee(a,`${e}.risks[${o}]`)),risks_truncated:_t(r.risks_truncated,`${e}.risks_truncated`),completed_at:It(r.completed_at,`${e}.completed_at`)}}function Xg(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=Zi(i.unresolved_ids,`${r}.unresolved_ids`);return ot(n,`${r}.unresolved_ids`),{goal_cycle:j(i.goal_cycle,`${r}.goal_cycle`,1),iteration:j(i.iteration,`${r}.iteration`),attempt:j(i.attempt,`${r}.attempt`),outcome:O(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:ee(i.summary,`${r}.summary`),completed_at:It(i.completed_at,`${r}.completed_at`)}}function Qg(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:j(r.pass,`${e}.pass`),fail:j(r.fail,`${e}.fail`),blocked:j(r.blocked,`${e}.blocked`),"execution-error":j(r["execution-error"],`${e}.execution-error`),recovery:j(r.recovery,`${e}.recovery`)}}function Zg(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=j(r.dropped_entries,`${e}.dropped_entries`),n=r.first_dropped_at===null?null:It(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:It(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=Qg(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 ew(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 tw(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 Cr(t){let e=W(t,"Native portable state");if(z(e,Bg,"Native portable state"),e.schema!==Er)throw new Error(`Native portable state schema must be ${Er}`);let r=M(e.name,"Native state name");if(!Og.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=we(e.spec_changes,"Native spec_changes",Fg);ot(i.map(s=>s.capability),"Native spec change capabilities");let n=we(e.acceptance,"Native acceptance",zg);ot(n.map(s=>s.id),"Native acceptance IDs");let a=we(e.history,"Native history",Xg);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Er,name:r,language:O(e.language,["en","zh-CN"],"Native state language"),phase:O(e.phase,["shape","build","verify","archive"],"Native state phase"),status:O(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:j(e.state_version,"Native state_version",1),brief:"brief.md",...e.children_contract_hash===void 0?{}:{children_contract_hash:Mg(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:O(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:qg(e.workspace),loop:Wg(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Gg(e.builder_handoff),blockers:we(e.blockers,"Native blockers",Ug),verification:e.verification===null?null:Yg(e.verification),history:a,history_overflow:Zg(e.history_overflow),verification_result:O(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:O(e.verification_report,["verification.md"],"Native verification_report"),archived:_t(e.archived,"Native archived"),created_at:It(e.created_at,"Native created_at")};return ew(o),tw(o),o}function rw(t,e){let r=(0,yo.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 xr(t){let e=await $g.readFile(t,"utf8");return Cr(rw(e,"Native portable state"))}var qe="comet.native.v3",We="comet.native.v2",ze="comet.native.v1";var pu="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",eE=new RegExp(`^portable-archive-(${pu})\\.json$`,"u"),tE=new RegExp(`^portable-migration-(${pu})\\.json$`,"u");import{TextDecoder as uw}from"util";import{createHash as iw}from"node:crypto";import{constants as nn,promises as de}from"node:fs";import fe from"node:path";import{TextDecoder as nw}from"node:util";function on(t,e){let r=fe.relative(t,e);return r===""||!fe.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${fe.sep}`)}function aw(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function ow(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function sw(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function an(t,e){return T({...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 bo(t,e){let r=await de.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await de.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function hu(t,e,r){let i=fe.resolve(t),n=fe.resolve(e);if(!on(i,n))throw new Error(`${r} is outside its managed root`);let a=[await bo(i,r)],o=i;for(let s of fe.relative(i,n).split(fe.sep).filter(Boolean)){await Je(a,r),o=fe.join(o,s);let c=await bo(o,r);if(!on(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await Je(a,r),a}async function Je(t,e){for(let r of t){let i=await de.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!ow(r,i)||await de.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function cw(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 Tt(t){let e=aw(t.maxBytes),r=fe.resolve(t.file),i=await hu(t.root,fe.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(u=>bo(fe.resolve(u),t.label)));await t.hooks?.afterParentChainCaptured?.(),await Je(i,t.label);let a=await de.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=sw(a),s=await de.realpath(r);if(!on(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(u=>on(u.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 de.open(r,c);try{let u=await l.stat();await t.hooks?.afterOpen?.();let[d,f]=await Promise.all([de.lstat(r),de.realpath(r)]);if(await Je(i,t.label),await Je(n,t.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!an(o,u)||!an(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let m=await cw(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[v,p,h]=await Promise.all([l.stat(),de.lstat(r),de.realpath(r)]);if(await Je(i,t.label),await Je(n,t.label),!p.isFile()||p.isSymbolicLink()||h!==s||!an(o,v)||!an(o,p))throw new Error(`${t.label} changed while reading`);return{bytes:m,hash:iw("sha256").update(m).digest("hex"),size:m.length}}finally{await l.close()}}async function mu(t){let e=await Tt(t),r;try{r=new nw("utf-8",{fatal:!0}).decode(e.bytes)}catch(i){throw new Error(`${t.label} is not valid UTF-8`,{cause:i})}return{...e,text:r}}async function ko(t){let e=await hu(t.root,t.directory,t.label);return{verify:()=>Je(e,t.label)}}var gE=256*1024,wE=1024*1024,yE=16*1024;var NE=64*1024*1024;var bE=new uw("utf-8",{fatal:!0});import Co from"path";import{createHash as fw}from"crypto";function U(t){return fw("sha256").update(t).digest("hex")}var qE={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},hw=1e3,mw=8*1024*1024,vw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,gw=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),ww=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),yw=new Set(["schema","include","exclude","hash"]),Nw=new Set(["provider","gitSelection","physicalSelection","projection"]),bw=new Set(["provider","selection"]),kw=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),Sw=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),Ew=new Set(["schema","status","before","after"]),Cw=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),xw=new Set(["path","hash","size","type","gitObjectId"]),Pw=new Set(["path","size","type","reason"]),Rw=new Set(["ref","hash","count"]),Aw=new Set(["change-created","legacy-migration","explicit"]),_w=new Set(["file","directory","other"]),Iw=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),cn=/^[a-f0-9]{64}$/u,Tw=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var WE=64*1024,zE=64*1024;var JE={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},GE={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function sn(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var UE=(1n<<256n)-1n;function jw(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function $w(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
147
- `)}function Ow(t,e){return U(`comet.native.snapshot-policy.v1
148
- ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function Eo(t,e,r){let i=new Set(e),n=[...e];for(;n.length>0;){if(r&&!r())return null;let a=n.pop(),o=t[a];o&&(o.kind==="star"||o.kind==="globstar"||o.kind==="globstar-slash")&&!i.has(a+1)&&(i.add(a+1),n.push(a+1))}return i}function Hw(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function Nu(t){let e=Qi(t,"Native snapshot pattern"),r=[];for(let i=0;i<e.length;i+=1){let n=e[i];n==="*"&&e[i+1]==="*"?(i+=1,e[i+1]==="/"?(i+=1,r.push({kind:"globstar-slash"})):r.push({kind:"globstar"})):n==="*"?r.push({kind:"star"}):n==="?"?r.push({kind:"question"}):r.push({kind:"literal",value:n})}return(i,n)=>{let a=n?Hw(n):void 0;if(a&&!a())return!1;let o=Eo(r,new Set([0]),a);if(o===null)return!1;for(let s of i){if(a&&!a())return!1;let c=new Set;for(let l of o){if(a&&!a())return!1;let u=r[l];u&&(u.kind==="literal"&&u.value===s||u.kind==="question"&&s!=="/"?c.add(l+1):u.kind==="star"&&s!=="/"||u.kind==="globstar"?c.add(l):u.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(o=Eo(r,c,a),o===null||o.size===0)return!1}return Eo(r,o,a)?.has(r.length)??!1}}function Dw(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>Qi(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>Qi(n,"exclude")))].sort((n,a)=>n.localeCompare(a,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let i=Ow(e,r);if("hash"in t&&t.hash!==i)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:r,hash:i},includeMatchers:e.map(Nu),excludeMatchers:r.map(Nu),excludedDirectoryPrefixes:r.flatMap(n=>{if(!n.endsWith("/**"))return[];let a=n.slice(0,-3);return/[*?]/u.test(a)?[]:[a]}).sort((n,a)=>n.localeCompare(a,"en"))}}function te(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function re(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function $t(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function ye(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function Su(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let r=Co.posix.normalize(t);if(r!==t||Co.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function Lw(t,e){let r=te(t,`Native snapshot entry ${e}`);re(r,xw,`Native snapshot entry ${e}`);let i=Su(r.path,`Native snapshot entry ${e} path`);if(typeof r.hash!="string"||!cn.test(r.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(r.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:i,hash:r.hash,size:ye(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!Tw.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function Bw(t,e){let r=te(t,`Native snapshot omission ${e}`);if(re(r,Pw,`Native snapshot omission ${e}`),!_w.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!Iw.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:Su(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:ye(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function Mw(t){let e=te(t,"Native snapshot omission overflow");if(re(e,Rw,"Native snapshot omission overflow"),typeof e.hash!="string"||!cn.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let r=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==r)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:r,hash:e.hash,count:$t(e.count,"Native snapshot omission overflow count")}}function jt(t,e){let r=te(t,e);if(re(r,Sw,e),typeof r.hash!="string"||!cn.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let i=ye(r.recordCount,`${e} recordCount`),n=ye(r.storedRecordCount,`${e} storedRecordCount`),a=ye(r.stdoutBytes,`${e} stdoutBytes`);if(n>i||!r.overflow&&n!==i)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,recordCount:i,storedRecordCount:n,stdoutBytes:a,overflow:r.overflow}}function bu(t){let e=te(t,"Native Git selection evidence");if(re(e,kw,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let r=jt(e.stageBefore,"Native Git selection stageBefore"),i=jt(e.combined,"Native Git selection combined"),n=jt(e.stageAfter,"Native Git selection stageAfter"),a=jt(e.finalStageBefore,"Native Git selection finalStageBefore"),o=jt(e.finalCombined,"Native Git selection finalCombined"),s=jt(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(d=>d.overflow),l=!sn(r,n)||!sn(n,a)||!sn(i,o)||!sn(a,s),u=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==u)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:u,stageBefore:r,combined:i,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function ku(t,e){let r=te(t,e);if(re(r,Cw,e),typeof r.hash!="string"||!cn.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean"||typeof r.unstable!="boolean")throw new Error(`${e} flags are invalid`);let i=ye(r.visitedNodeCount,`${e} visitedNodeCount`),n=ye(r.recordCount,`${e} recordCount`),a=ye(r.storedRecordCount,`${e} storedRecordCount`),o=ye(r.encodedBytes,`${e} encodedBytes`);if(a>n||!r.overflow&&a!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,visitedNodeCount:i,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:r.overflow,unstable:r.unstable}}function Vw(t){let e=te(t,"Native physical selection evidence");if(re(e,Ew,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let r=ku(e.before,"Native physical selection before"),i=ku(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!jw(r,i);if(!n&&!a)throw new Error("Native physical selection evidence must describe an exceptional selection");let o=n&&a?"overflow-and-changed":n?"overflow":"changed";if(e.status!==o)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:o,before:r,after:i}}function Eu(t){let e=te(t,"Native content snapshot manifest");if(re(e,gw,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!Aw.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let y=te(e.capture,"Native content snapshot capture");if(re(y,Nw,"Native content snapshot capture"),y.provider!=="git"&&y.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let C=y.gitSelection===void 0?void 0:bu(y.gitSelection),k=y.physicalSelection===void 0?void 0:Vw(y.physicalSelection),_=null;if(y.projection!==void 0){let L=te(y.projection,"Native content snapshot projection");if(re(L,bw,"Native content snapshot projection"),L.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");_={provider:"git",...L.selection===void 0?{}:{selection:bu(L.selection)}}}if(y.provider==="git"){if(k||_)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",...C?{gitSelection:C}:{}}}else{if(C)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(k&&_)throw new Error("Native physical-tree capture cannot combine selection and projection");r=_?{provider:"physical-tree",projection:_}:{provider:"physical-tree",...k?{physicalSelection:k}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let i=te(e.limits,"Native content snapshot limits");re(i,ww,"Native content snapshot limits");let n={maxFiles:$t(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:$t(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:$t(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:$t(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:$t(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let y=te(e.policy,"Native snapshot policy");if(re(y,yw,"Native snapshot policy"),y.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(y.include)||!Array.isArray(y.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=Dw({include:y.include,exclude:y.exclude,hash:y.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let o=e.entries.map(Lw),s=e.omitted.map(Bw),c=ye(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:Mw(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(y=>y.size>n.maxFileBytes)||o.reduce((y,C)=>y+C.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(y=>y.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>hw||c<s.length)throw new Error("Native content snapshot omission count is invalid");let u=c-s.length;if(u===0&&l||u>0&&l?.count!==u)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let d=s.filter(y=>y.reason==="git-enumeration-limit"),f=s.filter(y=>y.reason==="git-selection-changed");for(let y of[...d,...f])if(y.path!=="."||y.size!==null||y.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(d.length>1||f.length>1)throw new Error("Native Git selection omissions must not be duplicated");let m=r?.provider==="git"?r.gitSelection:r?.projection?.selection,v=m?.status==="overflow"||m?.status==="overflow-and-changed",p=m?.status==="changed"||m?.status==="overflow-and-changed";if(v!==(d.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(p!==(f.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let h=s.filter(y=>y.reason==="physical-enumeration-limit"),N=s.filter(y=>y.reason==="physical-selection-changed");for(let y of[...h,...N])if(y.path!=="."||y.size!==null||y.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(h.length>1||N.length>1)throw new Error("Native physical selection omissions must not be duplicated");let w=r?.physicalSelection,g=w?.status==="overflow"||w?.status==="overflow-and-changed",S=w?.status==="changed"||w?.status==="overflow-and-changed";if(g!==(h.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(S!==(N.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");let E={schema:"comet.native.content-snapshot.v1",origin:e.origin,...r?{capture:r}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}};if($w(E)>n.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function Fw(t,e){if(!vw.test(e))throw new Error(`Invalid Native change name: ${e}`);return Co.join(Z(t,e),"baseline-manifest.json")}async function Cu(t,e){let r=Fw(t,e),i=ve(t,r);await D(i,r);try{let n=await mu({root:i,file:r,maxBytes:mw,label:"Native baseline snapshot manifest"});return Eu(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var Uw=Dt(St(),1);var uC=4*1024*1024;var Kw=null;function Yw(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function xu(t,e){return(...r)=>{let i=Kw;if(i===null)return e(...r);let n=Yw(`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 mC=xu("hookWritePolicy",async t=>(await uo(t))?.hook??{allow_paths:[]});var ux=256*1024;var Sx={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};var Dx=16*1024,Lx=process.platform;var Iu=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],ey=new Set(Iu),Tu=new Set([...Iu,"minimum_runtime_version","revision"]),ty=new Set([...Tu,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),ry=new Set(["capability","operation","source","base_hash"]),iy=new Set(["shape","build","verify","archive"]),ny=new Set(["implicit","confirmed"]),ay=new Set(["pending","pass","fail"]),ct="comet-state.yaml",Po=/^[a-f0-9]{64}$/u,ju=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,oy=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Ro=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"},Ue=class extends Error{constructor(r,i){super(r!==qe||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"},ln=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"},Pr=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"},un=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"},uP=Di("en");function Ar(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function $u(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 _r(t){if(!ju.test(t))throw new Error(`Invalid Native change name: ${t}`)}function sy(t){if(!ju.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Ou(t,e){if(t.length===0||st.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function cy(t,e){let r=Ar(t,`spec_changes[${e}]`);if($u(r,ry,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(sy(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"&&Ou(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"||!Po.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"||!Po.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 ly(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 _o(t,e){if($u(t,e,ct),typeof t.name!="string")throw new Error("Native change name is required");if(_r(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"||!iy.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&&!ny.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(cy),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"||!ay.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"&&Ou(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!ly(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:r,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function en(t){let e=Ar(t,ct);if(e.schema!==ze)throw new Error(`Expected ${ze}`);return{schema:ze,..._o(e,ey)}}function Rr(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function xo(t,e,r){if(t===null)return null;let i=typeof t=="string"?oy.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 uy(t){if(t==null)return null;if(typeof t!="string"||!Po.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function dy(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function tn(t){let e=Ar(t,ct);if(e.schema!==We)throw new Error(`Expected ${We}`);if(Rr(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${We} minimum_runtime_version must be 2`);return{schema:We,minimum_runtime_version:2,revision:Rr(e.revision,"Native v2 revision"),..._o(e,Tu)}}function rn(t){let e=Ar(t,ct);if(e.schema!==qe){if(e.schema===ze||e.schema===We){let o=e.schema===ze?en(e):tn(e);throw new Ro(o.name,o.schema)}throw new Ue(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=Rr(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Ue(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=Rr(e.revision,"Native revision"),n=_o(e,ty),a=uy(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:qe,minimum_runtime_version:3,revision:i,verification_protocol:dy(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:xo(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:xo(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:xo(e.partial_allowance,"Native partial_allowance","allowances")}}function fy(t){let e=Ar(t,ct);if(e.schema===ze){let n=en(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${qe}`}}if(e.schema===We){let n=tn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${qe}`}}if(e.schema!==qe){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 Ue(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=Rr(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new Ue(e.schema,r).message};let i=rn(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}function ie(t,e){_r(e);let r=st.join(t.changesDir,e);if(!q(t.changesDir,r))throw new Error("Native change path escaped");return r}async function Io(t,e){let r=Z(t,e),i=st.join(r,"schema-migration.json");await D(q(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await Zw.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function py(t,e=st.dirname(t)){let r=st.relative(e,t).split(st.sep).join("/"),i=await B({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,Ao.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 Hu(t,e){let r=st.join(ie(t,e),ct);await D(t.nativeRoot,r);let i=fy(await py(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await Io(t,e)?{status:"migration-required",schema:i.schema,minimumRuntimeVersion:i.minimumRuntimeVersion,state:i.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(i.status==="current"&&i.state&&await hy(t,i.state),i)}async function hy(t,e){if(await Cu(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}var Bo=Dt(St(),1);import{promises as Ku}from"node:fs";import ne from"node:path";import{execFileSync as my}from"node:child_process";var vy=3e4,gy=8*1024*1024,To=class extends Error{constructor(r,i,n){super(`git ${i.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=r;this.args=i;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr};function wy(t,e){try{return my("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:vy,maxBuffer:gy,windowsHide:!0})}catch(r){let i=typeof r.stderr=="string"?r.stderr.trim():Buffer.isBuffer(r.stderr)?r.stderr.toString("utf8").trim():"";throw new To(t,e,i)}}function dn(t,e){return wy(t,e).trim()}import $o from"node:path";import{promises as Du}from"node:fs";var fn=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};var jo="comet.native.supervisor.v2",Ny=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;function by(t){if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t))throw new Error(`Invalid Native Supervisor parent name: ${t}`);return`comet/supervisor/${t}/integration`}function ky(t,e){return $o.join(At(t,e),"supervisor")}function Lu(t,e){return $o.join(ky(t,e),"state.json")}function Bu(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native Supervisor state must be an object");let e=t;if(e.schema!==jo)throw new Error(`Native Supervisor state schema must be ${jo}`);if(!Number.isSafeInteger(e.stateVersion)||typeof e.stateVersion!="number"||e.stateVersion<1)throw new Error("Native Supervisor state version is invalid");if(typeof e.parent!="string"||!e.parent)throw new Error("Native Supervisor state parent is invalid");if(!e.integration||typeof e.integration!="object")throw new Error("Native Supervisor integration state is missing");for(let[n,a]of Object.entries(e.integration))if(typeof a!="string"||a.length===0)throw new Error(`Native Supervisor integration field ${n} is invalid`);if(Ir(e.integration.targetCommit,"Native Supervisor target commit"),Ir(e.integration.headCommit,"Native Supervisor integration head commit"),!Array.isArray(e.children))throw new Error("Native Supervisor children are invalid");if(!Array.isArray(e.history))throw new Error("Native Supervisor history is invalid");if(!e.finalVerification||!["pending","passed","failed","incomplete"].includes(e.finalVerification.status)||e.finalVerification.summary!==null&&typeof e.finalVerification.summary!="string")throw new Error("Native Supervisor final verification is invalid");if(e.finalVerification.layers){let n=e.finalVerification.layers;if(!["complete","incomplete"].includes(n.childVerification)||!["complete","incomplete"].includes(n.parentIntegration)||!Array.isArray(n.parentChecks)||!n.parentChecks.every(a=>typeof a=="string")||!Array.isArray(n.notRerun)||!n.notRerun.every(a=>typeof a=="string")||!Array.isArray(n.incomplete)||!n.incomplete.every(a=>typeof a=="string"))throw new Error("Native Supervisor final verification layers are invalid")}for(let n of e.history)if(!n||typeof n!="object"||typeof n.kind!="string"||typeof n.summary!="string"||typeof n.at!="string"||n.child!==null&&typeof n.child!="string"||n.runId!==null&&typeof n.runId!="string")throw new Error("Native Supervisor history event is invalid");let r=new Set,i=new Set;for(let n of e.children){if(!n||typeof n!="object"||typeof n.name!="string")throw new Error("Native Supervisor child state is invalid");if(r.has(n.name))throw new Error(`Native Supervisor child ${n.name} is duplicated`);if(r.add(n.name),!Array.isArray(n.dependsOn)||!n.dependsOn.every(a=>typeof a=="string"))throw new Error(`Native Supervisor child ${n.name} dependencies are invalid`);if(typeof n.summary!="string"&&n.summary!==null)throw new Error(`Native Supervisor child ${n.name} summary is invalid`);if(n.projectRoot!==void 0&&n.projectRoot!==null&&(typeof n.projectRoot!="string"||n.projectRoot.length===0))throw new Error(`Native Supervisor child ${n.name} projectRoot is invalid`);for(let[a,o]of[["base",n.baseCommit],["candidate",n.candidateCommit],["verified",n.verifiedCommit],["integration",n.integrationCommit]])o!==null&&Ir(o,`Native Supervisor child ${n.name} ${a} commit`);if(!Array.isArray(n.checks)||!Array.isArray(n.verification?.checks??[]))throw new Error(`Native Supervisor child ${n.name} evidence is invalid`);if(n.task!==null){if(!n.task||typeof n.task!="object")throw new Error(`Native Supervisor child ${n.name} task is invalid`);if(!["builder","verifier"].includes(n.task.role)||n.task.child!==n.name||typeof n.task.projectRoot!="string"||n.task.projectRoot.length===0||typeof n.task.runId!="string"||n.task.runId.length===0)throw new Error(`Native Supervisor child ${n.name} task identity is invalid`);if(Ir(n.task.baseCommit,`Native Supervisor child ${n.name} task base commit`),i.has(n.task.runId))throw new Error(`Native Supervisor task runId ${n.task.runId} is duplicated`);if(i.add(n.task.runId),n.task.role==="verifier"&&n.task.baseCommit!==n.candidateCommit)throw new Error(`Native Supervisor child ${n.name} verifier base commit is invalid`);if(n.task.projectRoot!==n.projectRoot)throw new Error(`Native Supervisor child ${n.name} task projectRoot is invalid`);if(n.task.role==="builder"&&n.status!=="active"||n.task.role==="verifier"&&!["active","needs-reverify"].includes(n.status))throw new Error(`Native Supervisor child ${n.name} task status is invalid`)}}}async function Oo(t,e){try{let r=await Du.readFile(Lu(t,e),"utf8"),i=JSON.parse(r);return Bu(i),i}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Ho(t,e){Bu(e),await Du.mkdir(t.changesRuntimeDir,{recursive:!0}),await le(Lu(t,e.parent),e,{containedRoot:t.changesRuntimeDir})}function Ir(t,e){if(!Ny.test(t))throw new Error(`${e} must be a Git commit`)}function Sy(t,e){t.history.push({...e,at:new Date().toISOString()}),t.history.length>256&&t.history.splice(0,t.history.length-256)}function Mu(t){Ir(t.targetCommit,"Native Supervisor target commit");let e=new Set(t.contract.children.map(({name:i})=>i)),r=t.contract.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.depends_on],status:i.depends_on.length===0?"ready":"pending",baseCommit:null,candidateCommit:null,verifiedCommit:null,integrationCommit:null,verification:null,checks:[],blocker:null,projectRoot:null,task:null}));for(let i of r)for(let n of i.dependsOn)if(!e.has(n))throw new Error(`Native Supervisor child ${i.name} depends on unknown child ${n}`);return{schema:jo,stateVersion:1,parent:t.parent,integration:{branch:t.integrationBranch,worktree:t.integrationWorktree,targetBranch:t.targetBranch,targetCommit:t.targetCommit,headCommit:t.targetCommit},children:r,history:[],finalVerification:{status:"pending",summary:null}}}async function Do(t){let e=by(t.parent),r=mr(t.paths.projectRoot,e);if(!r)return null;let i=mr(t.paths.projectRoot,t.targetBranch);if(!i)return null;let n=Ct(t.paths.projectRoot).map(o=>$o.resolve(o)).find(o=>Se(o).currentBranch===e);if(!n)return null;let a=Mu({parent:t.parent,targetBranch:t.targetBranch,targetCommit:i,integrationBranch:e,integrationWorktree:n,contract:t.contract});if(r!==i){for(let o of a.children)o.status=o.dependsOn.length===0?"blocked":"pending",o.blocker=o.status==="blocked"?"Supervisor Runtime was lost; portable Child verification evidence is required.":null;a.integration.headCommit=r}return Sy(a,{kind:"delivery-reconciled",child:null,runId:null,summary:"Supervisor state rebuilt from Git worktree facts"}),a}function Vu(t){let e=t.children.map(r=>({name:r.name,summary:r.summary,dependsOn:[...r.dependsOn],covers:[],status:r.status,phase:null,projectRoot:r.projectRoot??r.task?.projectRoot??null,message:r.blocker}));return{contractHash:null,confirmed:!0,parentBranch:t.integration.branch,children:e,readyChildren:e.filter(({status:r})=>r==="ready").map(({name:r})=>r),allDone:e.every(({status:r})=>r==="integrated"||r==="archived")}}var Fu="children.yaml",Tr="comet.native.children.v1",Ot="comet.native.children.v2",Yu=Ot,Ey=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,qu=new Set(["schema","children"]),Cy=new Set(["schema","acceptance_index","children"]),xy=new Set(["name","depends_on","covers"]),Py=new Set(["name","summary","depends_on"]),Ry=new Set(["name","depends_on","covers"]);function hn(t,e,r=""){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object${r}`);return t}function pn(t,e,r){let i=Object.keys(t).filter(a=>!e.has(a)),n=[...e].filter(a=>!(a in t));if(i.length>0||n.length>0){let a=[...n.length>0?[`missing ${n.join(", ")}`]:[],...i.length>0?[`unexpected ${i.join(", ")}`]:[],`expected ${[...e].join(", ")}`];throw new Error(`${r} fields are invalid: ${a.join("; ")}`)}}function Wu(t,e){if(!Array.isArray(t)||!t.every(r=>typeof r=="string"))throw new Error(`${e} must be an array of strings`);return[...new Set(t)].sort((r,i)=>r.localeCompare(i,"en"))}function Lo(t,e){let r=ne.normalize(ne.resolve(t)),i=ne.normalize(ne.resolve(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Ay(t){let e=new Map(t.map(a=>[a.name,a])),r=new Set,i=new Set,n=a=>{if(!i.has(a)){if(r.has(a))throw new Error(`Native children dependency cycle includes ${a}`);r.add(a);for(let o of e.get(a).depends_on)n(o);r.delete(a),i.add(a)}};for(let a of t)n(a.name)}function zu(t,e,r=e){let i=new Set(e);for(let o of t){let s=o.covers.filter(c=>!i.has(c));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(t.flatMap(o=>o.covers)),a=r.filter(o=>!n.has(o));if(a.length>0)throw new Error(`Native children do not cover parent acceptance: ${a.join(", ")}`)}function _y(t,e,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(t.schema===Yu&&t.acceptance_index){let n=r.requiredAcceptanceIds??e??[],a=Object.keys(t.acceptance_index);i.missing=n.filter(c=>!(c in t.acceptance_index)),i.extra=a.filter(c=>!n.includes(c));let o=new Map((r.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of n){let l=o.get(c),u=t.acceptance_index[c];l&&u&&(u.source!==l.source||u.text!==l.text)&&i.mismatched.push(c)}let s=new Set(a);for(let c of t.children)i.unknownCovers.push(...c.covers.filter(l=>!s.has(l)));return i.uncovered=a.filter(c=>!Ju(t.children,c)),Gu(i)?i:null}if(t.schema===Tr&&e){let n=new Set(e);for(let a of t.children)i.unknownCovers.push(...a.covers.filter(o=>!n.has(o)));return i.uncovered=e.filter(a=>!Ju(t.children,a)),Gu(i)?i:null}return null}function Ju(t,e){return t.some(r=>r.covers.includes(e))}function Gu(t){return t.missing.length>0||t.extra.length>0||t.mismatched.length>0||t.uncovered.length>0||t.unknownCovers.length>0}function Xu(t){let e=new Set(t.acceptance.filter(({source:r})=>r===t.brief).map(({id:r})=>r));if(t.loop.stage==="repairing"&&t.verification_result==="fail"){let r=[...t.history].reverse().find(({outcome:i})=>i==="fail");for(let i of r?.unresolved_ids??[])e.add(i)}return{acceptanceCatalog:t.acceptance,requiredAcceptanceIds:[...e]}}function Iy(t){let e=hn(t,"Native children acceptance_index",' keyed by acceptance ID, for example A1: { source: brief.md, text: "Full acceptance text" }'),r={};for(let[i,n]of Object.entries(e)){let a=hn(n,`Native children acceptance_index.${i}`);if(pn(a,new Set(["source","text"]),`Native children acceptance_index.${i}`),typeof a.source!="string"||a.source.length===0)throw new Error(`Native children acceptance_index.${i}.source must be a non-empty string`);if(typeof a.text!="string"||a.text.length===0)throw new Error(`Native children acceptance_index.${i}.text must be a non-empty string`);r[i]={source:a.source,text:a.text}}return r}function Ty(t,e,r){let i=r.requiredAcceptanceIds??e??[],n=Object.keys(t),a=i.filter(c=>!(c in t)),o=n.filter(c=>!i.includes(c));if(a.length>0||o.length>0)throw new Error(`Native children acceptance_index must match the required acceptance: missing ${a.join(", ")||"none"}; extra ${o.join(", ")||"none"}`);let s=new Map((r.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of i){let l=s.get(c);if(!l)continue;let u=t[c];if(u.source!==l.source||u.text!==l.text){let d=["source","text"].filter(f=>u[f]!==l[f]);throw new Error(`Native children acceptance_index.${c} does not match the acceptance catalog: copy ${d.join(", ")} exactly from the current acceptance catalog`)}}}function jy(t,e,r={}){let i=(0,Bo.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=hn(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==Tr&&a!==Ot)throw pn(n,qu,"Native children contract"),new Error(`Native children schema must be ${Tr} or ${Ot}`);let o=a===Tr?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(pn(n,o==="indexed-v2"?Cy:qu,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let c=n.children.map((f,m)=>{let v=hn(f,`Native child ${m}`);if(pn(v,o==="indexed-v2"?Ry:o==="summary-v2"?Py:xy,`Native ${s} child fields (child ${m})`),typeof v.name!="string"||!Ey.test(v.name))throw new Error(`Native child ${m} name is invalid`);let p=o==="summary-v2";if(p){if(typeof v.summary!="string"||v.summary.trim().length===0)throw new Error(`Native child ${v.name} summary must be a non-empty string`);if(v.summary.length>2e3)throw new Error(`Native child ${v.name} summary exceeds 2000 characters`)}return{name:v.name,summary:p?v.summary:null,depends_on:Wu(v.depends_on,`Native child ${v.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?Wu(v.covers,`Native child ${v.name} covers`):[]}}),l=c.map(({name:f})=>f);if(new Set(l).size!==l.length)throw new Error("Native child names must be unique");let u=new Set(l);for(let f of c){let m=f.depends_on.filter(v=>!u.has(v));if(m.length>0)throw new Error(`Native child ${f.name} depends on unknown child: ${m.join(", ")}`)}Ay(c);let d=r.policy==="advisory";if(a===Yu){if(o==="indexed-v2"){let f=Iy(n.acceptance_index);d||Ty(f,e,r);let m=Object.keys(f);return d||zu(c,m,m),{schema:Ot,acceptance_index:f,children:c}}return{schema:Ot,children:c}}return e&&!d&&zu(c,e),{schema:Tr,children:c}}async function Qu(t){let e=ne.join(t.changeDir,Fu);try{await Ku.lstat(e)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await B({root:t.changeDir,ref:Fu}),i=t.policy==="advisory",n=i?{...t.validation,policy:"advisory"}:t.validation??{},a=jy(r.text,t.acceptanceIds,n);return{contract:a,size:r.size,drift:i?_y(a,t.acceptanceIds,t.validation??{}):null}}function $y(t){let e=/^#\s+(?:Decisions|决策)\s*$/imu.exec(t);if(!e||e.index===void 0)return null;let r=t.slice(e.index+e[0].length);return r.split(/^#\s+/mu,1)[0]??r}function Oy(t){let e=$y(t);if(!e||!/Supervisor\s+Change/iu.test(e))return!1;let r=e.match(/^\s*[-*]\s+(?:Child\b|子任务\b|子 Change\b)/gimu),i=e.match(/\bChild\s+\d+\b/giu);return Math.max(r?.length??0,i?.length??0)>=2}async function Zu(t){try{let e=await B({root:t,ref:"brief.md",maxBytes:null,includeHash:!1});return Oy(e.text)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function ed(t){return Y("comet.native.parent-contract.v1",{acceptance:t.acceptance.map(({id:e,source:r,text:i})=>({id:e,source:r,text:i})),children:t.children})}async function Hy(t){let e=Ct(t.projectRoot);e.some(i=>Lo(i,t.projectRoot))||e.push(t.projectRoot);let r=[];for(let i of[...new Set(e.map(n=>ne.resolve(n)))]){let n=await ge(i);n&&r.push({projectRoot:i,paths:await at(i,n.native.artifact_root),parent:Lo(i,t.projectRoot)})}return r.some(({parent:i})=>i)||r.push({projectRoot:t.projectRoot,paths:t,parent:!0}),r}async function Dy(t,e){let r=ne.join(t.paths.changesDir,e,"comet-state.yaml");try{return await xr(r)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Ly(t,e){let r;try{r=await Ku.readdir(t.paths.archiveDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()||![...e].some(o=>n.name.endsWith(`-${o}`))))try{let o=ne.join(t.paths.archiveDir,n.name,"comet-state.yaml"),s=await xr(o);e.has(s.name)&&i.push({file:o,state:s})}catch{}return i}function By(t,e,r){let i=ne.relative(t.projectRoot,e);if(!i||i===".."||i.startsWith(`..${ne.sep}`))return null;let n=i.split(ne.sep).join("/");try{let a=(0,Bo.parseDocument)(dn(t.projectRoot,["show",`${r}:${n}`]),{uniqueKeys:!0});return a.errors.length>0?null:Cr(a.toJS({mapAsMap:!1}))}catch{return null}}function My(t,e,r){return t.workspace.isolation!=="worktree"||t.workspace.target_branch!==r||t.workspace.finish!==null&&t.workspace.finish!=="merge"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:`Native child ${t.name} must use a linked worktree targeting parent branch ${r??"(missing)"}`}:t.status==="blocked"||t.status==="await-user"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:t.blockers[0]?.reason.text??`Native child ${t.name} requires user resolution`}:{kind:"active",phase:t.phase,projectRoot:e.projectRoot,message:null}}function Uu(t,e){return t.status==="done"&&t.archived&&t.workspace.finish==="merge"&&t.workspace.target_branch===e}async function Mo(t){let e=ne.join(t.paths.changesDir,t.state.name),r=await Zu(e),i=await Qu({changeDir:e,validation:Xu(t.state),...t.state.acceptance.length>0?{acceptanceIds:t.state.acceptance.map(({id:h})=>h)}:{},policy:"advisory"});if(!i)return t.state.children_contract_hash?{...r?{coordinationChoiceRequired:!0}:{},contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:r?{coordinationChoiceRequired:!0,contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:null;let n=ed({acceptance:t.state.acceptance,children:i.contract}),a=t.state.workspace.change_branch,o=t.state.phase!=="shape"&&t.state.children_contract_hash===n&&!i.drift;if(i.contract.schema===Ot){let h=await Oo(t.paths,t.state.name);if(!h){let g=t.state.workspace.target_branch??t.state.workspace.change_branch;if(g){let S=await Do({paths:t.paths,parent:t.state.name,targetBranch:g,contract:i.contract});S&&(h=S,await Ho(t.paths,S))}}if(h){let g=Vu(h);return t.state.children_contract_hash!==n||i.drift?{...g,schema:i.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:n,confirmed:!1,readyChildren:[],allDone:!1,children:g.children.map(S=>({...S,message:i.drift?"Children acceptance index is stale; Shape confirmation is required":"Supervisor child plan changed; Shape confirmation is required"}))}:{...g,schema:i.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:n,confirmed:o}}let N=new Map(i.contract.children.map(g=>[g.name,g])),w=i.contract.children.map(g=>({name:g.name,summary:g.summary,dependsOn:[...g.depends_on],covers:[],status:o&&g.depends_on.every(S=>i.contract.children.filter(({name:E})=>E!==g.name).every(({name:E})=>E!==S))?"ready":"pending",phase:null,projectRoot:null,message:o?null:"Parent Shape confirmation is required"}));for(let g of w){if(g.status!=="ready")continue;N.get(g.name).depends_on.length>0&&(g.status="pending")}return{schema:i.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:n,confirmed:o,parentBranch:a,children:w,readyChildren:w.filter(({status:g})=>g==="ready").map(({name:g})=>g),allDone:!1}}let s=await Hy(t.paths),c=new Set(i.contract.children.map(({name:h})=>h)),l=new Map,u=new Map;for(let h of s){let N=h.parent&&a?`refs/heads/${a}`:"HEAD";for(let w of await Ly(h,c)){let g={...w,source:h,committedState:By(h,w.file,N)};l.set(w.state.name,[...l.get(w.state.name)??[],g])}for(let w of c){let g=await Dy(h,w);g&&u.set(w,[...u.get(w)??[],{source:h,state:g}])}}let d=new Map;for(let h of i.contract.children){let N=(l.get(h.name)??[]).find(({source:S,committedState:E})=>S.parent&&E?.name===h.name&&Uu(E,a));if(N){d.set(h.name,{kind:"done",phase:N.state.phase,projectRoot:N.source.projectRoot,message:null});continue}let w=l.get(h.name)?.[0];if(w){d.set(h.name,{kind:"blocked",phase:w.state.phase,projectRoot:w.source.projectRoot,message:`Native child ${h.name} is archived but not merged into parent branch ${a??"(missing)"}`});continue}let g=u.get(h.name)??[];g.length>1?d.set(h.name,{kind:"blocked",phase:null,projectRoot:null,message:`Native child ${h.name} has multiple active workspace owners`}):g[0]&&d.set(h.name,My(g[0].state,g[0].source,a))}let f=new Map(i.contract.children.map(h=>[h.name,h])),m=new Map,v=h=>{let N=m.get(h);if(N)return N;let w=f.get(h),S=w.depends_on.map(v).every(({status:L})=>L==="done"),E=d.get(h),y=E?.kind==="active"&&S?w.depends_on.filter(L=>!(l.get(L)??[]).some(({source:Re,committedState:I})=>Lo(Re.projectRoot,E.projectRoot)&&I?.name===L&&Uu(I,a))):[],C,k=E?.message??null;E?.kind==="done"?(C=S?"done":"blocked",S||(k=`Native child ${h} was merged before its dependencies`)):E?.kind==="active"?(C=S&&y.length===0?"active":"blocked",S?y.length>0&&(k=`Native child ${h} does not include merged dependencies: ${y.join(", ")}`):k=`Native child ${h} started before its dependencies merged`):E?.kind==="blocked"?C="blocked":(C=o&&S?"ready":"pending",o||(k="Parent Shape confirmation is required"));let _={name:h,summary:w.summary,dependsOn:[...w.depends_on],covers:[...w.covers],status:C,phase:E?.phase??null,projectRoot:E?.projectRoot??null,message:k};return m.set(h,_),_},p=i.contract.children.map(({name:h})=>v(h));return{schema:i.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:n,confirmed:o,parentBranch:a,children:p,readyChildren:p.filter(({status:h})=>h==="ready").map(({name:h})=>h),allDone:p.every(({status:h})=>h==="done")}}var YP={maxAcceptanceCriteria:lu.maxCriteria};var lt={maxSpecs:64,maxFileBytes:Hi,maxTotalBytes:4*1024*1024};import{promises as ud}from"fs";import dd from"path";var Vy=["outcome","scope","nonGoals","acceptanceExamples"],cR=[...Vy,"constraints","decisions","openQuestions","verificationExpectations"];var yR={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var rd=1024*1024;var nd={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:[]},qy=U("comet-native-runtime:v3:scope-reopen"),GR=[{skillVersion:"3",skillHash:U("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:U("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:U("comet-native-runtime:v1")}];var cd=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],xA=new Set(cd),Uy=new Set([...cd,"minimum_runtime_version","revision"]),PA=new Set([...Uy,"operation"]),RA=512*1024,Ky=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),AA=new Set([...Ky,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var fd=lt.maxSpecs*4;async function Yy(t,e){let r=dd.join(ie(t,e),"specs"),i;try{i=await ko({root:t.nativeRoot,directory:r,label:"Native proposed specs directory"})}catch(s){if(s.code==="ENOENT")return[];throw s}let n=[],a=0,o=await ud.opendir(r);try{for await(let s of o){if(a+=1,a>fd)throw new Error(`Native proposed specs directory exceeds ${fd} entries`);if(s.isSymbolicLink())throw new Error(`Proposed spec capability must not be a symbolic link: ${s.name}`);if(!s.isDirectory())continue;_r(s.name);let c=dd.join(r,s.name,"spec.md");await D(t.nativeRoot,c);let l;try{l=await ud.lstat(c)}catch(u){if(u.code==="ENOENT")continue;throw u}if(l.isSymbolicLink()||!l.isFile())throw new Error(`Proposed spec must be a regular file: ${s.name}`);if(n.push(s.name),n.length>lt.maxSpecs)throw new Error("Native proposed specs exceed the spec-count budget")}}finally{await o.close().catch(s=>{if(s.code!=="ERR_DIR_CLOSED")throw s})}return await i.verify(),n.sort()}async function md(t,e){let r=ie(t,e),i={},n=0;for(let a of await Yy(t,e)){let o=await B({root:r,ref:`specs/${a}/spec.md`,maxBytes:lt.maxFileBytes});if(n+=o.size,n>lt.maxTotalBytes)throw new Error("Native proposed specs exceed the total byte budget");i[a]=o.text}return i}function dt(t,e,r){return t.language==="zh-CN"?r:e}function Xy(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:dt(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:dt(t,"Reply A or B","回复 A 或 B"),agentInstruction:dt(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")return r(dt(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(dt(t,"Wait only while the dispatched Verifier task is still active. If it did not start, ended without a response, or is no longer available, immediately submit the matching verifier-unavailable or verifier-execution-error input. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","仅在已派发的独立验收任务仍在运行时等待。如果任务未启动、结束后没有返回结果或已经丢失,立即提交匹配的 verifier-unavailable 或 verifier-execution-error 输入。不要让用户恢复文件或进程,也不要向用户展示 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:null,agentInstruction:"向用户转述 message,并请用户明确选择是否接受只有自动检查的结果。不要把“继续”当作默认接受。"}:{required:!0,message:"Because independent verification is temporarily unavailable, only the automatic checks could be completed. You can accept the current check results or wait and retry when verification is available.",suggestedReply:null,agentInstruction:"Relay message and ask the user to explicitly choose whether to accept automatic checks only. Do not treat “Continue” as implicit acceptance."};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(dt(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 qo(t){return["comet","native","next",t.change,"--summary","<summary>",t.flag,"--expected-state-version",String(t.stateVersion),"--expected-action",t.action]}function mn(t,e){return{name:t,flag:e,valueKind:"text",required:!0,template:null}}function vd(t,e){return{name:t,flag:e,valueKind:"confirmation",required:!0,template:null}}function Qy(t,e,r){return{name:t,flag:e,valueKind:"choice",required:!0,template:null,choices:[...r]}}function Zy(t){return t?.coordinationChoiceRequired===!0||t?.schema==="comet.native.children.v2"&&t.children.length>=2}function eN(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 jr(t){return{name:t.name,stateVersion:t.stateVersion,expectedAction:t.expectedAction,commandArgs:qo({change:t.change,stateVersion:t.stateVersion,action:t.expectedAction,flag:t.flag}),requiredInputs:["summary",t.confirmationInput],inputOptions:[mn("summary","--summary"),vd(t.name,t.flag)]}}function Fo(t){return[jr({name:"revise-implementation",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),jr({name:"revise-requirements",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function gd(t,e){let r=Zy(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:Xy(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:[mn("summary","--summary")],commandAlternatives:[jr({name:"accept-result",change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...Fo({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:qo({change:t.name,stateVersion:t.state_version,action:"confirm-verifier-unavailable",flag:"--confirmed"}),requiredInputs:["summary","user-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction: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:[mn("summary","--summary")],commandAlternatives:[jr({name:"resolve-verifier-blocker",change:t.name,stateVersion:t.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...Fo({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:[mn("summary","--summary")],commandAlternatives:Fo({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?qo({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:eN({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?[Qy("coordination-mode","--coordination-mode",uu)]:[],vd("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} ${dt(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:[jr({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{promises as cN}from"node:fs";import wd from"node:path";var u_=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");var lN=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,uN="comet-state.yaml";var HI=Di("en");function Wo(t,e){if(!lN.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=wd.join(t.changesDir,e);if(!q(t.changesDir,r))throw new Error("Native change path escaped");return r}function yd(t,e){return wd.join(Wo(t,e),uN)}async function zo(t,e){try{let r=await cN.readFile(yd(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}async function Jo(t,e){return xr(yd(t,e))}import Or from"path";import{realpathSync as JN}from"fs";var Pe={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Nd(t){return t?t.command?`${Pe.next} ${t.command}`:t.ask_user?`${Pe.next} ${t.ask_user}`:null:null}function bd(t,e){let r=[t.summary],i=Nd(t.next);return i&&r.push(i),t.user_message&&r.push("",Pe.relay,t.user_message),e!==void 0&&r.push("",Pe.details,JSON.stringify(e,null,2)),`${r.join(`
145
+ `)}var ao=Vt(Et(),1);import Me from"path";var Nr=64*1024,Fi=1024,qi=64,Ul=1024,Kl=64,oo=5,Mi={learning:!0,retrieval:!0},Ql={provider:"local"},Gv=12e4,Yl=6e5,Uv=[".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/**"],Kv=["**/.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"],Yv=[...Uv,...Kv].sort((t,e)=>t.localeCompare(e,"en"));var Y={include:["**/*"],exclude:[...Yv],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function Xv(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||Me.posix.isAbsolute(r)||Me.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 nt(t){let e=Xv(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Zl(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 Wi(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||Me.posix.isAbsolute(i)||Me.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 xe(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function eu(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 zi(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>Fi)throw new Error(`${e} exceeds ${Fi} 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>qi)throw new Error(`${e} contains more than ${qi} wildcard tokens`);return t}function Xl(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=>zi(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function no(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 Qv(t){if(t===void 0)return{...Y,include:[...Y.include],exclude:[...Y.exclude]};let e=xe(t,"native.snapshot");return{include:Xl(e.include,"native.snapshot.include",Y.include),exclude:Xl(e.exclude,"native.snapshot.exclude",Y.exclude),max_files:no(e.max_files,Y.max_files,"native.snapshot.max_files"),max_total_bytes:no(e.max_total_bytes,Y.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:no(e.max_duration_ms,Y.max_duration_ms,"native.snapshot.max_duration_ms")}}function Zv(t){if(t===void 0)return;let e=xe(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=xe(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,d=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof d!="string"||!/^[a-f0-9]{64}$/u.test(d))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:d}}return{id:r,fromArtifactRoot:nt(i),toArtifactRoot:nt(n),stage:a,...o?{cleanup:o}:{}}}function eg(t){if(t===void 0)return;let e=xe(t,"native.finish");if(e.pull_request===void 0)return{};let r=xe(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(Me.posix.isAbsolute(i[0])||Me.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??Gv;if(!Number.isSafeInteger(n)||n<1||n>Yl)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Yl}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function tg(t,e={}){let r=xe(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??oo;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Zv(r.pending_root_move),c=eg(r.finish);return{artifact_root:nt(i),language:eu(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Qv(r.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function rg(t){let e=xe(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:Zl(e.artifact_layout),language:eu(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n}}function ig(t){let r=xe(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)=>Wi(i,`hook.allow_paths[${n}]`)))]}}function ng(t){if(t===void 0)return{...Mi};let e=xe(t,"memory"),r=e.learning??Mi.learning,i=e.retrieval??Mi.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 so(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function ag(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")||Me.posix.isAbsolute(r)||Me.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>Ul)throw new Error(`${e} exceeds ${Ul} 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>Kl)throw new Error(`${e} contains more than ${Kl} wildcard tokens`);return r}function og(t){let r=so(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)=>ag(i,`knowledge.local.include[${n}]`)))]}}function sg(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 cg(t){let e=so(t,"knowledge.remote"),r=sg(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 lg(t){if(t===void 0)return{...Ql};let e=so(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:og(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:cg(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 ug(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function dg(t,e,r,i,n,a,o,s){let c=t.schema!==void 0;if(!(c||t.default_workflow!==void 0||t.workflows!==void 0||!s.allowPartialProject&&t.native!==void 0)||s.allowPartialProject&&!c)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let d=t.workflows??[t.default_workflow];if(!Array.isArray(d)||d.length===0||d.some(f=>f!=="native"&&f!=="classic"))throw new Error("workflows must contain native and/or classic");let u=[...new Set(d)];if(!u.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(u.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:u,ambient_resume:o,...e?{hook:e}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function br(t,e={}){let r=(0,ao.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=ug(n.ambient_resume),o=n.hook===void 0?void 0:ig(n.hook),s=ng(n.memory),c=lg(n.knowledge),l=n.native===void 0?void 0:tg(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),d=n.classic===void 0?void 0:rg(n.classic),u=dg(n,o,s,c,l,d,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:u,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...d?{classic:d}:{}}}function Ji(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Mi},knowledge:{...Ql},native:{artifact_root:nt(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:oo,snapshot:{...Y,include:[...Y.include],exclude:[...Y.exclude]}}}}import{createHash as hg}from"crypto";import{promises as Ki}from"fs";import Fe from"path";import{constants as Gi,promises as at}from"fs";var me=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}};function co(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function tu(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function kr(t){return{dev:t.dev,ino:t.ino,birthtime:co(t)}}function Ui(t,e){let r=kr(t),i=kr(e);return Ee(r,i)?T(r,i):T(r,i)&&co(t)===co(e)&&tu(t)===tu(e)&&t.size===e.size}async function Sr(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 at.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new me("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new me("too-large",`${i} exceeds ${e} bytes`);let o=await at.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:kr(a)});let s=process.platform==="win32"?Gi.O_RDONLY:Gi.O_RDONLY|Gi.O_NOFOLLOW|Gi.O_NONBLOCK,c;try{c=await at.open(t,s)}catch(l){throw l.code==="ELOOP"?new me("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,d,u]=await Promise.all([c.stat({bigint:n}),at.lstat(t,{bigint:n}),at.realpath(t)]);if(!l.isFile()||!d.isFile()||d.isSymbolicLink()||u!==o||!Ui(a,l)||!Ui(a,d))throw new me("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:u,identity:kr(l)}),await r.hooks?.afterOpen?.();let f=[],m=0,v=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let w=e+1-m,{bytesRead:g}=await c.read(v,0,Math.min(v.length,w),null);if(g===0)break;if(m+=g,m>e)throw new me("too-large",`${i} exceeds ${e} bytes`);f.push(Buffer.from(v.subarray(0,g)))}await r.hooks?.beforeFinalCheck?.();let[h,p,N]=await Promise.all([c.stat({bigint:n}),at.lstat(t,{bigint:n}),at.realpath(t)]);if(!p.isFile()||p.isSymbolicLink()||N!==o||!Ui(a,h)||!Ui(a,p))throw new me("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:N,identity:kr(h)}),{bytes:Buffer.concat(f,m),stat:h,realPath:N}}finally{await c.close()}}function fg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function lo(t,e){let r=Fe.relative(t,e);return r===""||!Fe.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Fe.sep}`)}async function ru(t,e){let r=Fe.resolve(t),i=await Ki.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Ki.realpath(r)}async function iu(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=Fe.join(n,r[a]);let o;try{o=await Ki.lstat(n)}catch(d){if(fg(d))return{exists:!1,kind:"missing"};throw d}let s=Fe.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 Ki.realpath(n);if(!lo(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=Wi(e,r.label),n=Fe.resolve(t),a=await ru(n,r.label),o=i.split("/"),s=Fe.resolve(n,...o);if(!lo(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await iu(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:c.exists,kind:c.kind}}async function qe(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 ru(n.projectRoot,i.label);return Sr(n.target,r,{...i,verify:async(o,s)=>{if(!lo(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await iu(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var Er=".comet/config.yaml";function pg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Yi(t,e={}){return(await Xi(t,e)).document}async function mg(t){try{return(await qe(t,Er,Nr,{label:Er})).bytes}catch(e){if(pg(e))return null;throw e}}function vg(t){return t?{exists:!0,sha256:hg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Xi(t,e={}){let r=await mg(t);return{document:r?br(r.toString("utf8"),e):null,identity:vg(r)}}async function uo(t){return(await Yi(t))?.config??null}var iS=16*1024;import{existsSync as au,promises as ot}from"fs";import A from"path";import bg from"os";var Qi=".comet/config.yaml",kg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function po(t){try{return await ot.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Sg(t){try{let e=await ot.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=A.relative(t,e);return r===""||!A.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${A.sep}`)}async function At(t){let e=[],r=t;for(;!await po(r);){let n=A.dirname(r);if(n===r)break;e.push(A.basename(r)),r=n}let i=await ot.realpath(r);return A.resolve(i,...e.reverse())}async function mo(t){try{return(await ot.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Zi(t){let e=A.resolve(t);try{(await ot.stat(e)).isDirectory()||(e=A.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=A.resolve(bg.homedir());for(;;){if(!(e===i&&r!==i)){let o=A.join(e,...Qi.split("/")),s=e===r||await Sg(o);if(await po(o)&&s)return e}if(await po(A.join(e,".git")))return e;let a=A.dirname(e);if(a===e)return r;e=a}}function en(t){return nt(t)}async function Eg(t,e){let r=en(e),i=A.resolve(t,...r.split("/")),n=await ot.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 st(t,e){let r=en(e),i=await Eg(t,r),n=A.join(i,"comet");if(await mo(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=A.resolve(t),c=A.join(s,".comet","runtime","native");if(await mo(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,d]=await Promise.all([ot.realpath(s),At(c)]);if(!_t(l,d))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:A.join(t,...Qi.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:A.join(n,"specs"),changesDir:A.join(n,"changes"),archiveDir:A.join(n,"archive"),runtimeDir:c,changesRuntimeDir:A.join(c,"changes"),locksDir:A.join(c,"locks"),transactionsDir:A.join(c,"transactions")}}function ou(t){if(!kg.test(t))throw new Error(`Invalid Native change name: ${t}`)}function It(t,e){ou(e);let r=A.join(t.changesRuntimeDir,e);if(!q(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function Cg(t,e){ou(e);let r=A.join(t.changesDir,e,"runtime");if(!q(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Z(t,e){let r=It(t,e);if(au(r))return r;let i=Cg(t,e);return au(i)?i:r}function ve(t,e){let r=A.resolve(e);if(q(t.runtimeDir,r))return t.runtimeDir;if(q(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function q(t,e){return _t(A.resolve(t),A.resolve(e))}async function D(t,e){let r=A.resolve(t),i=A.resolve(e);if(!_t(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await mo(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}var tn=zi;function Pg(t="docs",e="en"){return Ji(t,e)}async function ge(t){let e=(await Yi(t))?.config??null;return e?.native?e:null}async function su(t){let e=await Zi(t.startPath),r=await ge(e);if(!r&&t.allowMissingConfig===!1)throw new Error(`${Qi} 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?en(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??Pg(i??"docs"),a=await st(e,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}import{AsyncLocalStorage as Rg}from"async_hooks";var RS=16*1024;var AS=new Rg;import{createHash as Ag}from"crypto";function ue(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function _g(t,e){e.has(t)&&ue("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)||ue("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&ue("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&ue("symbol properties are not supported"),`[${t.map(i=>vo(i,e)).join(",")}]`}finally{e.delete(t)}}function Ig(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&ue("only plain objects are supported"),e.has(t)&&ue("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&ue("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))&&ue("accessor properties are not supported"),`${JSON.stringify(o)}:${vo(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function vo(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)||ue("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?_g(t,e):Ig(t,e);case"bigint":case"function":case"symbol":case"undefined":return ue(`${typeof t} values are not supported`)}return ue("unsupported value type")}function go(t){return vo(t,new Set)}function U(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 Ag("sha256").update(`${t}
146
+ ${go(e)}`).digest("hex")}var OS=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),cu=Object.freeze({maxCriteria:1024});var yo=Vt(Et(),1);import{promises as Hg}from"node:fs";var xr="comet.native.v4";var lu=["multi-session","single-session"];var Dg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Lg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Bg=/^A[1-9][0-9]*$/u,Vg=/^[a-f0-9]{64}$/u,Mg=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"]);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 M(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 wo(t,e){return t===null?null:M(t,e)}function du(t,e){let r=M(t,e);if(!Vg.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 j(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 Fg(t,e){return t===null?null:j(t,e,Number.MIN_SAFE_INTEGER)}function O(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function we(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function rn(t,e){return we(t,e,(r,i)=>M(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=M(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function No(t,e,r=!1){let i=M(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 ee(t,e){let r=W(t,e);return z(r,new Set(["text","truncated"]),e),{text:M(r.text,`${e}.text`,{empty:!0}),truncated:Tt(r.truncated,`${e}.truncated`)}}function qg(t,e){let r=`Native spec_changes[${e}]`,i=W(t,r);z(i,new Set(["capability","operation","source"]),r);let n=M(i.capability,`${r}.capability`);if(!Lg.test(n))throw new Error(`${r}.capability is invalid`);let a=O(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:No(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 Wg(t){let e="Native workspace",r=W(t,e);z(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=O(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=wo(r.change_branch,`${e}.change_branch`),a=wo(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:O(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 zg(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=rn(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);ct(i,`${e}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:O(r.stop_reason,["budget","stalled"],`${e}.stop_reason`);return{stage:O(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:j(r.goal_cycle,`${e}.goal_cycle`,1),iteration:j(r.iteration,`${e}.iteration`),attempt:j(r.attempt,`${e}.attempt`),retry_epoch:j(r.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:j(r.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:j(r.no_progress_count,`${e}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:j(r.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:i,next_action:wo(r.next_action,`${e}.next_action`)}}function Jg(t,e){let r=`Native acceptance[${e}]`,i=W(t,r);z(i,new Set(["id","source","text","result","reason"]),r);let n=M(i.id,`${r}.id`);if(!Bg.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:No(i.source,`${r}.source`),text:M(i.text,`${r}.text`),result:O(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:ee(i.reason,`${r}.reason`)}}function Gg(t,e){let r=`Native builder_handoff.checks[${e}]`,i=W(t,r);return z(i,new Set(["name","result","note"]),r),{name:ee(i.name,`${r}.name`),result:O(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:ee(i.note,`${r}.note`)}}function Ug(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=rn(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:M(r.candidate_id,`${e}.candidate_id`),identity_provider:M(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:M(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:j(r.iteration,`${e}.iteration`,1),summary:ee(r.summary,`${e}.summary`),addressed_acceptance_ids:i,checks:we(r.checks,`${e}.checks`,Gg),checks_truncated:Tt(r.checks_truncated,`${e}.checks_truncated`),known_limits:we(r.known_limits,`${e}.known_limits`,(a,o)=>ee(a,`${e}.known_limits[${o}]`)),known_limits_truncated:Tt(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:O(n.status,["passed"],`${e}.review.status`),summary:ee(n.summary,`${e}.review.summary`),reviewer_execution_ref:M(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:jt(r.submitted_at,`${e}.submitted_at`)}}function Kg(t,e){let r=`Native blockers[${e}]`,i=W(t,r);z(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=rn(i.acceptance_ids,`${r}.acceptance_ids`);return ct(n,`${r}.acceptance_ids`),{owner:O(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:ee(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:O(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function Yg(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:M(i.id,`${r}.id`),name:ee(i.name,`${r}.name`),argv_display:we(i.argv_display,`${r}.argv_display`,(n,a)=>ee(n,`${r}.argv_display[${a}]`)),argv_truncated:Tt(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:No(i.cwd_ref,`${r}.cwd_ref`,!0),status:O(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:Fg(i.exit_code,`${r}.exit_code`),duration_ms:j(i.duration_ms,`${r}.duration_ms`)}}function Xg(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=we(r.checks,`${e}.checks`,Yg);ct(i.map(a=>a.id),`${e}.checks IDs`);let n=M(r.identity_provider,`${e}.identity_provider`);return{candidate_id:M(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:M(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:j(r.iteration,`${e}.iteration`,1),attempt:j(r.attempt,`${e}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":O(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:O(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:ee(r.summary,`${e}.summary`),risks:we(r.risks,`${e}.risks`,(a,o)=>ee(a,`${e}.risks[${o}]`)),risks_truncated:Tt(r.risks_truncated,`${e}.risks_truncated`),completed_at:jt(r.completed_at,`${e}.completed_at`)}}function Qg(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=rn(i.unresolved_ids,`${r}.unresolved_ids`);return ct(n,`${r}.unresolved_ids`),{goal_cycle:j(i.goal_cycle,`${r}.goal_cycle`,1),iteration:j(i.iteration,`${r}.iteration`),attempt:j(i.attempt,`${r}.attempt`),outcome:O(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:ee(i.summary,`${r}.summary`),completed_at:jt(i.completed_at,`${r}.completed_at`)}}function Zg(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:j(r.pass,`${e}.pass`),fail:j(r.fail,`${e}.fail`),blocked:j(r.blocked,`${e}.blocked`),"execution-error":j(r["execution-error"],`${e}.execution-error`),recovery:j(r.recovery,`${e}.recovery`)}}function ew(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=j(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=Zg(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 tw(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 rw(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 Pr(t){let e=W(t,"Native portable state");if(z(e,Mg,"Native portable state"),e.schema!==xr)throw new Error(`Native portable state schema must be ${xr}`);let r=M(e.name,"Native state name");if(!Dg.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=we(e.spec_changes,"Native spec_changes",qg);ct(i.map(s=>s.capability),"Native spec change capabilities");let n=we(e.acceptance,"Native acceptance",Jg);ct(n.map(s=>s.id),"Native acceptance IDs");let a=we(e.history,"Native history",Qg);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:xr,name:r,language:O(e.language,["en","zh-CN"],"Native state language"),phase:O(e.phase,["shape","build","verify","archive"],"Native state phase"),status:O(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:j(e.state_version,"Native state_version",1),brief:"brief.md",...e.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:du(e.shape_confirmation_hash,"Native Shape confirmation hash")},...e.children_contract_hash===void 0?{}:{children_contract_hash:du(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:O(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:Wg(e.workspace),loop:zg(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Ug(e.builder_handoff),blockers:we(e.blockers,"Native blockers",Kg),verification:e.verification===null?null:Xg(e.verification),history:a,history_overflow:ew(e.history_overflow),verification_result:O(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:O(e.verification_report,["verification.md"],"Native verification_report"),archived:Tt(e.archived,"Native archived"),created_at:jt(e.created_at,"Native created_at")};return tw(o),rw(o),o}function iw(t,e){let r=(0,yo.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 Rr(t){let e=await Hg.readFile(t,"utf8");return Pr(iw(e,"Native portable state"))}var We="comet.native.v3",ze="comet.native.v2",Je="comet.native.v1";var hu="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",nE=new RegExp(`^portable-archive-(${hu})\\.json$`,"u"),aE=new RegExp(`^portable-migration-(${hu})\\.json$`,"u");import{TextDecoder as dw}from"util";import{createHash as nw}from"node:crypto";import{constants as sn,promises as de}from"node:fs";import fe from"node:path";import{TextDecoder as aw}from"node:util";function ln(t,e){let r=fe.relative(t,e);return r===""||!fe.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${fe.sep}`)}function ow(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function sw(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function cw(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function cn(t,e){return T({...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 bo(t,e){let r=await de.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await de.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function pu(t,e,r){let i=fe.resolve(t),n=fe.resolve(e);if(!ln(i,n))throw new Error(`${r} is outside its managed root`);let a=[await bo(i,r)],o=i;for(let s of fe.relative(i,n).split(fe.sep).filter(Boolean)){await Ge(a,r),o=fe.join(o,s);let c=await bo(o,r);if(!ln(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await Ge(a,r),a}async function Ge(t,e){for(let r of t){let i=await de.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!sw(r,i)||await de.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function lw(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=ow(t.maxBytes),r=fe.resolve(t.file),i=await pu(t.root,fe.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(d=>bo(fe.resolve(d),t.label)));await t.hooks?.afterParentChainCaptured?.(),await Ge(i,t.label);let a=await de.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=cw(a),s=await de.realpath(r);if(!ln(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(d=>ln(d.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?sn.O_RDONLY:sn.O_RDONLY|sn.O_NOFOLLOW|sn.O_NONBLOCK,l=await de.open(r,c);try{let d=await l.stat();await t.hooks?.afterOpen?.();let[u,f]=await Promise.all([de.lstat(r),de.realpath(r)]);if(await Ge(i,t.label),await Ge(n,t.label),!d.isFile()||!u.isFile()||u.isSymbolicLink()||f!==s||!cn(o,d)||!cn(o,u))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let m=await lw(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[v,h,p]=await Promise.all([l.stat(),de.lstat(r),de.realpath(r)]);if(await Ge(i,t.label),await Ge(n,t.label),!h.isFile()||h.isSymbolicLink()||p!==s||!cn(o,v)||!cn(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:m,hash:nw("sha256").update(m).digest("hex"),size:m.length}}finally{await l.close()}}async function mu(t){let e=await $t(t),r;try{r=new aw("utf-8",{fatal:!0}).decode(e.bytes)}catch(i){throw new Error(`${t.label} is not valid UTF-8`,{cause:i})}return{...e,text:r}}async function ko(t){let e=await pu(t.root,t.directory,t.label);return{verify:()=>Ge(e,t.label)}}var bE=256*1024,kE=1024*1024,SE=16*1024;var EE=64*1024*1024;var CE=new dw("utf-8",{fatal:!0});import Co from"path";import{createHash as hw}from"crypto";function K(t){return hw("sha256").update(t).digest("hex")}var GE={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},mw=1e3,vw=8*1024*1024,gw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,ww=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),yw=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),Nw=new Set(["schema","include","exclude","hash"]),bw=new Set(["provider","gitSelection","physicalSelection","projection"]),kw=new Set(["provider","selection"]),Sw=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),Ew=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),Cw=new Set(["schema","status","before","after"]),xw=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),Pw=new Set(["path","hash","size","type","gitObjectId"]),Rw=new Set(["path","size","type","reason"]),Aw=new Set(["ref","hash","count"]),_w=new Set(["change-created","legacy-migration","explicit"]),Iw=new Set(["file","directory","other"]),Tw=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),dn=/^[a-f0-9]{64}$/u,jw=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var UE=64*1024,KE=64*1024;var YE={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},XE={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function un(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var QE=(1n<<256n)-1n;function $w(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function Ow(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
147
+ `)}function Hw(t,e){return K(`comet.native.snapshot-policy.v1
148
+ ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function Eo(t,e,r){let i=new Set(e),n=[...e];for(;n.length>0;){if(r&&!r())return null;let a=n.pop(),o=t[a];o&&(o.kind==="star"||o.kind==="globstar"||o.kind==="globstar-slash")&&!i.has(a+1)&&(i.add(a+1),n.push(a+1))}return i}function Dw(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function Nu(t){let e=tn(t,"Native snapshot pattern"),r=[];for(let i=0;i<e.length;i+=1){let n=e[i];n==="*"&&e[i+1]==="*"?(i+=1,e[i+1]==="/"?(i+=1,r.push({kind:"globstar-slash"})):r.push({kind:"globstar"})):n==="*"?r.push({kind:"star"}):n==="?"?r.push({kind:"question"}):r.push({kind:"literal",value:n})}return(i,n)=>{let a=n?Dw(n):void 0;if(a&&!a())return!1;let o=Eo(r,new Set([0]),a);if(o===null)return!1;for(let s of i){if(a&&!a())return!1;let c=new Set;for(let l of o){if(a&&!a())return!1;let d=r[l];d&&(d.kind==="literal"&&d.value===s||d.kind==="question"&&s!=="/"?c.add(l+1):d.kind==="star"&&s!=="/"||d.kind==="globstar"?c.add(l):d.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(o=Eo(r,c,a),o===null||o.size===0)return!1}return Eo(r,o,a)?.has(r.length)??!1}}function Lw(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>tn(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>tn(n,"exclude")))].sort((n,a)=>n.localeCompare(a,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let i=Hw(e,r);if("hash"in t&&t.hash!==i)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:r,hash:i},includeMatchers:e.map(Nu),excludeMatchers:r.map(Nu),excludedDirectoryPrefixes:r.flatMap(n=>{if(!n.endsWith("/**"))return[];let a=n.slice(0,-3);return/[*?]/u.test(a)?[]:[a]}).sort((n,a)=>n.localeCompare(a,"en"))}}function te(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function re(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function Ht(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function ye(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function Su(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let r=Co.posix.normalize(t);if(r!==t||Co.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function Bw(t,e){let r=te(t,`Native snapshot entry ${e}`);re(r,Pw,`Native snapshot entry ${e}`);let i=Su(r.path,`Native snapshot entry ${e} path`);if(typeof r.hash!="string"||!dn.test(r.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(r.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:i,hash:r.hash,size:ye(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!jw.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function Vw(t,e){let r=te(t,`Native snapshot omission ${e}`);if(re(r,Rw,`Native snapshot omission ${e}`),!Iw.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!Tw.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:Su(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:ye(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function Mw(t){let e=te(t,"Native snapshot omission overflow");if(re(e,Aw,"Native snapshot omission overflow"),typeof e.hash!="string"||!dn.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let r=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==r)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:r,hash:e.hash,count:Ht(e.count,"Native snapshot omission overflow count")}}function Ot(t,e){let r=te(t,e);if(re(r,Ew,e),typeof r.hash!="string"||!dn.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let i=ye(r.recordCount,`${e} recordCount`),n=ye(r.storedRecordCount,`${e} storedRecordCount`),a=ye(r.stdoutBytes,`${e} stdoutBytes`);if(n>i||!r.overflow&&n!==i)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,recordCount:i,storedRecordCount:n,stdoutBytes:a,overflow:r.overflow}}function bu(t){let e=te(t,"Native Git selection evidence");if(re(e,Sw,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let r=Ot(e.stageBefore,"Native Git selection stageBefore"),i=Ot(e.combined,"Native Git selection combined"),n=Ot(e.stageAfter,"Native Git selection stageAfter"),a=Ot(e.finalStageBefore,"Native Git selection finalStageBefore"),o=Ot(e.finalCombined,"Native Git selection finalCombined"),s=Ot(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(u=>u.overflow),l=!un(r,n)||!un(n,a)||!un(i,o)||!un(a,s),d=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==d)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:d,stageBefore:r,combined:i,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function ku(t,e){let r=te(t,e);if(re(r,xw,e),typeof r.hash!="string"||!dn.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean"||typeof r.unstable!="boolean")throw new Error(`${e} flags are invalid`);let i=ye(r.visitedNodeCount,`${e} visitedNodeCount`),n=ye(r.recordCount,`${e} recordCount`),a=ye(r.storedRecordCount,`${e} storedRecordCount`),o=ye(r.encodedBytes,`${e} encodedBytes`);if(a>n||!r.overflow&&a!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,visitedNodeCount:i,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:r.overflow,unstable:r.unstable}}function Fw(t){let e=te(t,"Native physical selection evidence");if(re(e,Cw,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let r=ku(e.before,"Native physical selection before"),i=ku(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!$w(r,i);if(!n&&!a)throw new Error("Native physical selection evidence must describe an exceptional selection");let o=n&&a?"overflow-and-changed":n?"overflow":"changed";if(e.status!==o)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:o,before:r,after:i}}function Eu(t){let e=te(t,"Native content snapshot manifest");if(re(e,ww,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!_w.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let y=te(e.capture,"Native content snapshot capture");if(re(y,bw,"Native content snapshot capture"),y.provider!=="git"&&y.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let C=y.gitSelection===void 0?void 0:bu(y.gitSelection),k=y.physicalSelection===void 0?void 0:Fw(y.physicalSelection),_=null;if(y.projection!==void 0){let L=te(y.projection,"Native content snapshot projection");if(re(L,kw,"Native content snapshot projection"),L.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");_={provider:"git",...L.selection===void 0?{}:{selection:bu(L.selection)}}}if(y.provider==="git"){if(k||_)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",...C?{gitSelection:C}:{}}}else{if(C)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(k&&_)throw new Error("Native physical-tree capture cannot combine selection and projection");r=_?{provider:"physical-tree",projection:_}:{provider:"physical-tree",...k?{physicalSelection:k}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let i=te(e.limits,"Native content snapshot limits");re(i,yw,"Native content snapshot limits");let n={maxFiles:Ht(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Ht(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Ht(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Ht(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:Ht(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let y=te(e.policy,"Native snapshot policy");if(re(y,Nw,"Native snapshot policy"),y.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(y.include)||!Array.isArray(y.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=Lw({include:y.include,exclude:y.exclude,hash:y.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let o=e.entries.map(Bw),s=e.omitted.map(Vw),c=ye(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:Mw(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(y=>y.size>n.maxFileBytes)||o.reduce((y,C)=>y+C.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(y=>y.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>mw||c<s.length)throw new Error("Native content snapshot omission count is invalid");let d=c-s.length;if(d===0&&l||d>0&&l?.count!==d)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let u=s.filter(y=>y.reason==="git-enumeration-limit"),f=s.filter(y=>y.reason==="git-selection-changed");for(let y of[...u,...f])if(y.path!=="."||y.size!==null||y.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(u.length>1||f.length>1)throw new Error("Native Git selection omissions must not be duplicated");let m=r?.provider==="git"?r.gitSelection:r?.projection?.selection,v=m?.status==="overflow"||m?.status==="overflow-and-changed",h=m?.status==="changed"||m?.status==="overflow-and-changed";if(v!==(u.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(h!==(f.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let p=s.filter(y=>y.reason==="physical-enumeration-limit"),N=s.filter(y=>y.reason==="physical-selection-changed");for(let y of[...p,...N])if(y.path!=="."||y.size!==null||y.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(p.length>1||N.length>1)throw new Error("Native physical selection omissions must not be duplicated");let w=r?.physicalSelection,g=w?.status==="overflow"||w?.status==="overflow-and-changed",S=w?.status==="changed"||w?.status==="overflow-and-changed";if(g!==(p.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(S!==(N.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");let E={schema:"comet.native.content-snapshot.v1",origin:e.origin,...r?{capture:r}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}};if(Ow(E)>n.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function qw(t,e){if(!gw.test(e))throw new Error(`Invalid Native change name: ${e}`);return Co.join(Z(t,e),"baseline-manifest.json")}async function Cu(t,e){let r=qw(t,e),i=ve(t,r);await D(i,r);try{let n=await mu({root:i,file:r,maxBytes:vw,label:"Native baseline snapshot manifest"});return Eu(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var Kw=Vt(Et(),1);var pC=4*1024*1024;var Yw=null;function Xw(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function xu(t,e){return(...r)=>{let i=Yw;if(i===null)return e(...r);let n=Xw(`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 yC=xu("hookWritePolicy",async t=>(await uo(t))?.hook??{allow_paths:[]});var vx=256*1024;var Ax={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};var qx=16*1024,Wx=process.platform;var Iu=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],ty=new Set(Iu),Tu=new Set([...Iu,"minimum_runtime_version","revision"]),ry=new Set([...Tu,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),iy=new Set(["capability","operation","source","base_hash"]),ny=new Set(["shape","build","verify","archive"]),ay=new Set(["implicit","confirmed"]),oy=new Set(["pending","pass","fail"]),ut="comet-state.yaml",Po=/^[a-f0-9]{64}$/u,ju=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,sy=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Ro=class extends Error{constructor(r,i){super(`Native change ${r} uses ${i}; run comet native doctor ${r} --repair before mutating it`);this.change=r;this.schema=i;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},Ke=class extends Error{constructor(r,i){super(r!==We||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"},fn=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"},Ar=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"},hn=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"},vP=Vi("en");function Ir(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function $u(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 Tr(t){if(!ju.test(t))throw new Error(`Invalid Native change name: ${t}`)}function cy(t){if(!ju.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Ou(t,e){if(t.length===0||lt.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function ly(t,e){let r=Ir(t,`spec_changes[${e}]`);if($u(r,iy,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(cy(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"&&Ou(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"||!Po.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"||!Po.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 uy(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 _o(t,e){if($u(t,e,ut),typeof t.name!="string")throw new Error("Native change name is required");if(Tr(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"||!ny.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&&!ay.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(ly),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"||!oy.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"&&Ou(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!uy(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 nn(t){let e=Ir(t,ut);if(e.schema!==Je)throw new Error(`Expected ${Je}`);return{schema:Je,..._o(e,ty)}}function _r(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function xo(t,e,r){if(t===null)return null;let i=typeof t=="string"?sy.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 dy(t){if(t==null)return null;if(typeof t!="string"||!Po.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function fy(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 an(t){let e=Ir(t,ut);if(e.schema!==ze)throw new Error(`Expected ${ze}`);if(_r(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${ze} minimum_runtime_version must be 2`);return{schema:ze,minimum_runtime_version:2,revision:_r(e.revision,"Native v2 revision"),..._o(e,Tu)}}function on(t){let e=Ir(t,ut);if(e.schema!==We){if(e.schema===Je||e.schema===ze){let o=e.schema===Je?nn(e):an(e);throw new Ro(o.name,o.schema)}throw new Ke(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=_r(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Ke(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=_r(e.revision,"Native revision"),n=_o(e,ry),a=dy(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:We,minimum_runtime_version:3,revision:i,verification_protocol:fy(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:xo(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:xo(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:xo(e.partial_allowance,"Native partial_allowance","allowances")}}function hy(t){let e=Ir(t,ut);if(e.schema===Je){let n=nn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${We}`}}if(e.schema===ze){let n=an(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${We}`}}if(e.schema!==We){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new Ke(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=_r(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new Ke(e.schema,r).message};let i=on(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}function ie(t,e){Tr(e);let r=lt.join(t.changesDir,e);if(!q(t.changesDir,r))throw new Error("Native change path escaped");return r}async function Io(t,e){let r=Z(t,e),i=lt.join(r,"schema-migration.json");await D(q(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await ey.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function py(t,e=lt.dirname(t)){let r=lt.relative(e,t).split(lt.sep).join("/"),i=await B({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,Ao.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 Hu(t,e){let r=lt.join(ie(t,e),ut);await D(t.nativeRoot,r);let i=hy(await py(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await Io(t,e)?{status:"migration-required",schema:i.schema,minimumRuntimeVersion:i.minimumRuntimeVersion,state:i.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(i.status==="current"&&i.state&&await my(t,i.state),i)}async function my(t,e){if(await Cu(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}var Bo=Vt(Et(),1);import{promises as Ku}from"node:fs";import ne from"node:path";import{execFileSync as vy}from"node:child_process";var gy=3e4,wy=8*1024*1024,To=class extends Error{constructor(r,i,n){super(`git ${i.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=r;this.args=i;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr};function yy(t,e){try{return vy("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:gy,maxBuffer:wy,windowsHide:!0})}catch(r){let i=typeof r.stderr=="string"?r.stderr.trim():Buffer.isBuffer(r.stderr)?r.stderr.toString("utf8").trim():"";throw new To(t,e,i)}}function pn(t,e){return yy(t,e).trim()}import $o from"node:path";import{promises as Du}from"node:fs";var mn=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};var jo="comet.native.supervisor.v2",by=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;function ky(t){if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t))throw new Error(`Invalid Native Supervisor parent name: ${t}`);return`comet/supervisor/${t}/integration`}function Sy(t,e){return $o.join(It(t,e),"supervisor")}function Lu(t,e){return $o.join(Sy(t,e),"state.json")}function Bu(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native Supervisor state must be an object");let e=t;if(e.schema!==jo)throw new Error(`Native Supervisor state schema must be ${jo}`);if(!Number.isSafeInteger(e.stateVersion)||typeof e.stateVersion!="number"||e.stateVersion<1)throw new Error("Native Supervisor state version is invalid");if(typeof e.parent!="string"||!e.parent)throw new Error("Native Supervisor state parent is invalid");if(!e.integration||typeof e.integration!="object")throw new Error("Native Supervisor integration state is missing");for(let[n,a]of Object.entries(e.integration))if(typeof a!="string"||a.length===0)throw new Error(`Native Supervisor integration field ${n} is invalid`);if(jr(e.integration.targetCommit,"Native Supervisor target commit"),jr(e.integration.headCommit,"Native Supervisor integration head commit"),!Array.isArray(e.children))throw new Error("Native Supervisor children are invalid");if(!Array.isArray(e.history))throw new Error("Native Supervisor history is invalid");if(!e.finalVerification||!["pending","passed","failed","incomplete"].includes(e.finalVerification.status)||e.finalVerification.summary!==null&&typeof e.finalVerification.summary!="string")throw new Error("Native Supervisor final verification is invalid");if(e.finalVerification.layers){let n=e.finalVerification.layers;if(!["complete","incomplete"].includes(n.childVerification)||!["complete","incomplete"].includes(n.parentIntegration)||!Array.isArray(n.parentChecks)||!n.parentChecks.every(a=>typeof a=="string")||!Array.isArray(n.notRerun)||!n.notRerun.every(a=>typeof a=="string")||!Array.isArray(n.incomplete)||!n.incomplete.every(a=>typeof a=="string"))throw new Error("Native Supervisor final verification layers are invalid")}for(let n of e.history)if(!n||typeof n!="object"||typeof n.kind!="string"||typeof n.summary!="string"||typeof n.at!="string"||n.child!==null&&typeof n.child!="string"||n.runId!==null&&typeof n.runId!="string")throw new Error("Native Supervisor history event is invalid");let r=new Set,i=new Set;for(let n of e.children){if(!n||typeof n!="object"||typeof n.name!="string")throw new Error("Native Supervisor child state is invalid");if(r.has(n.name))throw new Error(`Native Supervisor child ${n.name} is duplicated`);if(r.add(n.name),!Array.isArray(n.dependsOn)||!n.dependsOn.every(a=>typeof a=="string"))throw new Error(`Native Supervisor child ${n.name} dependencies are invalid`);if(typeof n.summary!="string"&&n.summary!==null)throw new Error(`Native Supervisor child ${n.name} summary is invalid`);if(n.projectRoot!==void 0&&n.projectRoot!==null&&(typeof n.projectRoot!="string"||n.projectRoot.length===0))throw new Error(`Native Supervisor child ${n.name} projectRoot is invalid`);for(let[a,o]of[["base",n.baseCommit],["candidate",n.candidateCommit],["verified",n.verifiedCommit],["integration",n.integrationCommit]])o!==null&&jr(o,`Native Supervisor child ${n.name} ${a} commit`);if(!Array.isArray(n.checks)||!Array.isArray(n.verification?.checks??[]))throw new Error(`Native Supervisor child ${n.name} evidence is invalid`);if(n.task!==null){if(!n.task||typeof n.task!="object")throw new Error(`Native Supervisor child ${n.name} task is invalid`);if(!["builder","verifier"].includes(n.task.role)||n.task.child!==n.name||typeof n.task.projectRoot!="string"||n.task.projectRoot.length===0||typeof n.task.runId!="string"||n.task.runId.length===0)throw new Error(`Native Supervisor child ${n.name} task identity is invalid`);if(jr(n.task.baseCommit,`Native Supervisor child ${n.name} task base commit`),i.has(n.task.runId))throw new Error(`Native Supervisor task runId ${n.task.runId} is duplicated`);if(i.add(n.task.runId),n.task.role==="verifier"&&n.task.baseCommit!==n.candidateCommit)throw new Error(`Native Supervisor child ${n.name} verifier base commit is invalid`);if(n.task.projectRoot!==n.projectRoot)throw new Error(`Native Supervisor child ${n.name} task projectRoot is invalid`);if(n.task.role==="builder"&&n.status!=="active"||n.task.role==="verifier"&&!["active","needs-reverify"].includes(n.status))throw new Error(`Native Supervisor child ${n.name} task status is invalid`)}}}async function Oo(t,e){try{let r=await Du.readFile(Lu(t,e),"utf8"),i=JSON.parse(r);return Bu(i),i}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Ho(t,e){Bu(e),await Du.mkdir(t.changesRuntimeDir,{recursive:!0}),await le(Lu(t,e.parent),e,{containedRoot:t.changesRuntimeDir})}function jr(t,e){if(!by.test(t))throw new Error(`${e} must be a Git commit`)}function Ey(t,e){t.history.push({...e,at:new Date().toISOString()}),t.history.length>256&&t.history.splice(0,t.history.length-256)}function Vu(t){jr(t.targetCommit,"Native Supervisor target commit");let e=new Set(t.contract.children.map(({name:i})=>i)),r=t.contract.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.depends_on],status:i.depends_on.length===0?"ready":"pending",baseCommit:null,candidateCommit:null,verifiedCommit:null,integrationCommit:null,verification:null,checks:[],blocker:null,projectRoot:null,task:null}));for(let i of r)for(let n of i.dependsOn)if(!e.has(n))throw new Error(`Native Supervisor child ${i.name} depends on unknown child ${n}`);return{schema:jo,stateVersion:1,parent:t.parent,integration:{branch:t.integrationBranch,worktree:t.integrationWorktree,targetBranch:t.targetBranch,targetCommit:t.targetCommit,headCommit:t.targetCommit},children:r,history:[],finalVerification:{status:"pending",summary:null}}}async function Do(t){let e=ky(t.parent),r=wr(t.paths.projectRoot,e);if(!r)return null;let i=wr(t.paths.projectRoot,t.targetBranch);if(!i)return null;let n=xt(t.paths.projectRoot).map(o=>$o.resolve(o)).find(o=>Se(o).currentBranch===e);if(!n)return null;let a=Vu({parent:t.parent,targetBranch:t.targetBranch,targetCommit:i,integrationBranch:e,integrationWorktree:n,contract:t.contract});if(r!==i){for(let o of a.children)o.status=o.dependsOn.length===0?"blocked":"pending",o.blocker=o.status==="blocked"?"Supervisor Runtime was lost; portable Child verification evidence is required.":null;a.integration.headCommit=r}return Ey(a,{kind:"delivery-reconciled",child:null,runId:null,summary:"Supervisor state rebuilt from Git worktree facts"}),a}function Mu(t){let e=t.children.map(r=>({name:r.name,summary:r.summary,dependsOn:[...r.dependsOn],covers:[],status:r.status,phase:null,projectRoot:r.projectRoot??r.task?.projectRoot??null,message:r.blocker}));return{contractHash:null,confirmed:!0,parentBranch:t.integration.branch,children:e,readyChildren:e.filter(({status:r})=>r==="ready").map(({name:r})=>r),allDone:e.every(({status:r})=>r==="integrated"||r==="archived")}}var Fu="children.yaml",$r="comet.native.children.v1",Dt="comet.native.children.v2",Yu=Dt,Cy=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,qu=new Set(["schema","children"]),xy=new Set(["schema","acceptance_index","children"]),Py=new Set(["name","depends_on","covers"]),Ry=new Set(["name","summary","depends_on"]),Ay=new Set(["name","depends_on","covers"]);function gn(t,e,r=""){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object${r}`);return t}function vn(t,e,r){let i=Object.keys(t).filter(a=>!e.has(a)),n=[...e].filter(a=>!(a in t));if(i.length>0||n.length>0){let a=[...n.length>0?[`missing ${n.join(", ")}`]:[],...i.length>0?[`unexpected ${i.join(", ")}`]:[],`expected ${[...e].join(", ")}`];throw new Error(`${r} fields are invalid: ${a.join("; ")}`)}}function Wu(t,e){if(!Array.isArray(t)||!t.every(r=>typeof r=="string"))throw new Error(`${e} must be an array of strings`);return[...new Set(t)].sort((r,i)=>r.localeCompare(i,"en"))}function Lo(t,e){let r=ne.normalize(ne.resolve(t)),i=ne.normalize(ne.resolve(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function _y(t){let e=new Map(t.map(a=>[a.name,a])),r=new Set,i=new Set,n=a=>{if(!i.has(a)){if(r.has(a))throw new Error(`Native children dependency cycle includes ${a}`);r.add(a);for(let o of e.get(a).depends_on)n(o);r.delete(a),i.add(a)}};for(let a of t)n(a.name)}function zu(t,e,r=e){let i=new Set(e);for(let o of t){let s=o.covers.filter(c=>!i.has(c));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(t.flatMap(o=>o.covers)),a=r.filter(o=>!n.has(o));if(a.length>0)throw new Error(`Native children do not cover parent acceptance: ${a.join(", ")}`)}function Iy(t,e,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(t.schema===Yu&&t.acceptance_index){let n=r.requiredAcceptanceIds??e??[],a=r.allowedAcceptanceIds??n,o=Object.keys(t.acceptance_index);i.missing=n.filter(l=>!(l in t.acceptance_index)),i.extra=o.filter(l=>!a.includes(l));let s=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of o){let d=s.get(l),u=t.acceptance_index[l];d&&u&&(u.source!==d.source||u.text!==d.text)&&i.mismatched.push(l)}let c=new Set(o);for(let l of t.children)i.unknownCovers.push(...l.covers.filter(d=>!c.has(d)));return i.uncovered=o.filter(l=>!Ju(t.children,l)),Gu(i)?i:null}if(t.schema===$r&&e){let n=new Set(e);for(let a of t.children)i.unknownCovers.push(...a.covers.filter(o=>!n.has(o)));return i.uncovered=e.filter(a=>!Ju(t.children,a)),Gu(i)?i:null}return null}function Ju(t,e){return t.some(r=>r.covers.includes(e))}function Gu(t){return t.missing.length>0||t.extra.length>0||t.mismatched.length>0||t.uncovered.length>0||t.unknownCovers.length>0}function Xu(t){let e=new Set(t.acceptance.map(({id:n})=>n)),r=new Set(t.acceptance.filter(({source:n})=>n===t.brief).map(({id:n})=>n)),i=new Set(r);for(let n of t.history.filter(({outcome:a})=>a==="fail"))for(let a of n.unresolved_ids)e.has(a)&&i.add(a);if(t.loop.stage==="repairing"&&t.verification_result==="fail"){let n=[...t.history].reverse().find(({outcome:a})=>a==="fail");for(let a of n?.unresolved_ids??[])r.add(a)}return{acceptanceCatalog:t.acceptance,requiredAcceptanceIds:[...r],allowedAcceptanceIds:[...i]}}function Ty(t){let e=gn(t,"Native children acceptance_index",' keyed by acceptance ID, for example A1: { source: brief.md, text: "Full acceptance text" }'),r={};for(let[i,n]of Object.entries(e)){let a=gn(n,`Native children acceptance_index.${i}`);if(vn(a,new Set(["source","text"]),`Native children acceptance_index.${i}`),typeof a.source!="string"||a.source.length===0)throw new Error(`Native children acceptance_index.${i}.source must be a non-empty string`);if(typeof a.text!="string"||a.text.length===0)throw new Error(`Native children acceptance_index.${i}.text must be a non-empty string`);r[i]={source:a.source,text:a.text}}return r}function jy(t,e,r){let i=r.requiredAcceptanceIds??e??[],n=r.allowedAcceptanceIds??i,a=Object.keys(t),o=i.filter(l=>!(l in t)),s=a.filter(l=>!n.includes(l));if(o.length>0||s.length>0)throw new Error(`Native children acceptance_index must match the required acceptance: missing ${o.join(", ")||"none"}; extra ${s.join(", ")||"none"}`);let c=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of a){let d=c.get(l);if(!d)continue;let u=t[l];if(u.source!==d.source||u.text!==d.text){let f=["source","text"].filter(m=>u[m]!==d[m]);throw new Error(`Native children acceptance_index.${l} does not match the acceptance catalog: copy ${f.join(", ")} exactly from the current acceptance catalog`)}}}function $y(t,e,r={}){let i=(0,Bo.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=gn(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==$r&&a!==Dt)throw vn(n,qu,"Native children contract"),new Error(`Native children schema must be ${$r} or ${Dt}`);let o=a===$r?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(vn(n,o==="indexed-v2"?xy:qu,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let c=n.children.map((f,m)=>{let v=gn(f,`Native child ${m}`);if(vn(v,o==="indexed-v2"?Ay:o==="summary-v2"?Ry:Py,`Native ${s} child fields (child ${m})`),typeof v.name!="string"||!Cy.test(v.name))throw new Error(`Native child ${m} name is invalid`);let h=o==="summary-v2";if(h){if(typeof v.summary!="string"||v.summary.trim().length===0)throw new Error(`Native child ${v.name} summary must be a non-empty string`);if(v.summary.length>2e3)throw new Error(`Native child ${v.name} summary exceeds 2000 characters`)}return{name:v.name,summary:h?v.summary:null,depends_on:Wu(v.depends_on,`Native child ${v.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?Wu(v.covers,`Native child ${v.name} covers`):[]}}),l=c.map(({name:f})=>f);if(new Set(l).size!==l.length)throw new Error("Native child names must be unique");let d=new Set(l);for(let f of c){let m=f.depends_on.filter(v=>!d.has(v));if(m.length>0)throw new Error(`Native child ${f.name} depends on unknown child: ${m.join(", ")}`)}_y(c);let u=r.policy==="advisory";if(a===Yu){if(o==="indexed-v2"){let f=Ty(n.acceptance_index);u||jy(f,e,r);let m=Object.keys(f);return u||zu(c,m,m),{schema:Dt,acceptance_index:f,children:c}}return{schema:Dt,children:c}}return e&&!u&&zu(c,e),{schema:$r,children:c}}async function Qu(t){let e=ne.join(t.changeDir,Fu);try{await Ku.lstat(e)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await B({root:t.changeDir,ref:Fu}),i=t.policy==="advisory",n=i?{...t.validation,policy:"advisory"}:t.validation??{},a=$y(r.text,t.acceptanceIds,n);return{contract:a,hash:r.hash,size:r.size,drift:i?Iy(a,t.acceptanceIds,t.validation??{}):null}}function Oy(t){let e=/^#\s+(?:Decisions|决策)\s*$/imu.exec(t);if(!e||e.index===void 0)return null;let r=t.slice(e.index+e[0].length);return r.split(/^#\s+/mu,1)[0]??r}function Hy(t){let e=Oy(t);if(!e||!/Supervisor\s+Change/iu.test(e))return!1;let r=e.match(/^\s*[-*]\s+(?:Child\b|子任务\b|子 Change\b)/gimu),i=e.match(/\bChild\s+\d+\b/giu);return Math.max(r?.length??0,i?.length??0)>=2}async function Zu(t){try{let e=await B({root:t,ref:"brief.md",maxBytes:null,includeHash:!1});return Hy(e.text)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function ed(t){return U("comet.native.parent-contract.v1",{acceptance:t.acceptance.map(({id:e,source:r,text:i})=>({id:e,source:r,text:i})),children:t.children})}async function Dy(t){let e=xt(t.projectRoot);e.some(i=>Lo(i,t.projectRoot))||e.push(t.projectRoot);let r=[];for(let i of[...new Set(e.map(n=>ne.resolve(n)))]){let n=await ge(i);n&&r.push({projectRoot:i,paths:await st(i,n.native.artifact_root),parent:Lo(i,t.projectRoot)})}return r.some(({parent:i})=>i)||r.push({projectRoot:t.projectRoot,paths:t,parent:!0}),r}async function Ly(t,e){let r=ne.join(t.paths.changesDir,e,"comet-state.yaml");try{return await Rr(r)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function By(t,e){let r;try{r=await Ku.readdir(t.paths.archiveDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()||![...e].some(o=>n.name.endsWith(`-${o}`))))try{let o=ne.join(t.paths.archiveDir,n.name,"comet-state.yaml"),s=await Rr(o);e.has(s.name)&&i.push({file:o,state:s})}catch{}return i}function Vy(t,e,r){let i=ne.relative(t.projectRoot,e);if(!i||i===".."||i.startsWith(`..${ne.sep}`))return null;let n=i.split(ne.sep).join("/");try{let a=(0,Bo.parseDocument)(pn(t.projectRoot,["show",`${r}:${n}`]),{uniqueKeys:!0});return a.errors.length>0?null:Pr(a.toJS({mapAsMap:!1}))}catch{return null}}function My(t,e,r){return t.workspace.isolation!=="worktree"||t.workspace.target_branch!==r||t.workspace.finish!==null&&t.workspace.finish!=="merge"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:`Native child ${t.name} must use a linked worktree targeting parent branch ${r??"(missing)"}`}:t.status==="blocked"||t.status==="await-user"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:t.blockers[0]?.reason.text??`Native child ${t.name} requires user resolution`}:{kind:"active",phase:t.phase,projectRoot:e.projectRoot,message:null}}function Uu(t,e){return t.status==="done"&&t.archived&&t.workspace.finish==="merge"&&t.workspace.target_branch===e}async function Vo(t){let e=ne.join(t.paths.changesDir,t.state.name),r=await Zu(e),i=await Qu({changeDir:e,validation:Xu(t.state),...t.state.acceptance.length>0?{acceptanceIds:t.state.acceptance.map(({id:p})=>p)}:{},policy:"advisory"});if(!i)return t.state.children_contract_hash?{...r?{coordinationChoiceRequired:!0}:{},contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:r?{coordinationChoiceRequired:!0,contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:null;let n=ed({acceptance:t.state.acceptance,children:i.contract}),a=t.state.workspace.change_branch,o=t.state.phase!=="shape"&&t.state.children_contract_hash===n&&!i.drift;if(i.contract.schema===Dt){let p=await Oo(t.paths,t.state.name);if(!p){let g=t.state.workspace.target_branch??t.state.workspace.change_branch;if(g){let S=await Do({paths:t.paths,parent:t.state.name,targetBranch:g,contract:i.contract});S&&(p=S,await Ho(t.paths,S))}}if(p){let g=Mu(p);return t.state.children_contract_hash!==n||i.drift?{...g,schema:i.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:n,confirmed:!1,readyChildren:[],allDone:!1,children:g.children.map(S=>({...S,message:i.drift?"Children acceptance index is stale; Shape confirmation is required":"Supervisor child plan changed; Shape confirmation is required"}))}:{...g,schema:i.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:n,confirmed:o}}let N=new Map(i.contract.children.map(g=>[g.name,g])),w=i.contract.children.map(g=>({name:g.name,summary:g.summary,dependsOn:[...g.depends_on],covers:[],status:o&&g.depends_on.every(S=>i.contract.children.filter(({name:E})=>E!==g.name).every(({name:E})=>E!==S))?"ready":"pending",phase:null,projectRoot:null,message:o?null:"Parent Shape confirmation is required"}));for(let g of w){if(g.status!=="ready")continue;N.get(g.name).depends_on.length>0&&(g.status="pending")}return{schema:i.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:n,confirmed:o,parentBranch:a,children:w,readyChildren:w.filter(({status:g})=>g==="ready").map(({name:g})=>g),allDone:!1}}let s=await Dy(t.paths),c=new Set(i.contract.children.map(({name:p})=>p)),l=new Map,d=new Map;for(let p of s){let N=p.parent&&a?`refs/heads/${a}`:"HEAD";for(let w of await By(p,c)){let g={...w,source:p,committedState:Vy(p,w.file,N)};l.set(w.state.name,[...l.get(w.state.name)??[],g])}for(let w of c){let g=await Ly(p,w);g&&d.set(w,[...d.get(w)??[],{source:p,state:g}])}}let u=new Map;for(let p of i.contract.children){let N=(l.get(p.name)??[]).find(({source:S,committedState:E})=>S.parent&&E?.name===p.name&&Uu(E,a));if(N){u.set(p.name,{kind:"done",phase:N.state.phase,projectRoot:N.source.projectRoot,message:null});continue}let w=l.get(p.name)?.[0];if(w){u.set(p.name,{kind:"blocked",phase:w.state.phase,projectRoot:w.source.projectRoot,message:`Native child ${p.name} is archived but not merged into parent branch ${a??"(missing)"}`});continue}let g=d.get(p.name)??[];g.length>1?u.set(p.name,{kind:"blocked",phase:null,projectRoot:null,message:`Native child ${p.name} has multiple active workspace owners`}):g[0]&&u.set(p.name,My(g[0].state,g[0].source,a))}let f=new Map(i.contract.children.map(p=>[p.name,p])),m=new Map,v=p=>{let N=m.get(p);if(N)return N;let w=f.get(p),S=w.depends_on.map(v).every(({status:L})=>L==="done"),E=u.get(p),y=E?.kind==="active"&&S?w.depends_on.filter(L=>!(l.get(L)??[]).some(({source:Ae,committedState:I})=>Lo(Ae.projectRoot,E.projectRoot)&&I?.name===L&&Uu(I,a))):[],C,k=E?.message??null;E?.kind==="done"?(C=S?"done":"blocked",S||(k=`Native child ${p} was merged before its dependencies`)):E?.kind==="active"?(C=S&&y.length===0?"active":"blocked",S?y.length>0&&(k=`Native child ${p} does not include merged dependencies: ${y.join(", ")}`):k=`Native child ${p} started before its dependencies merged`):E?.kind==="blocked"?C="blocked":(C=o&&S?"ready":"pending",o||(k="Parent Shape confirmation is required"));let _={name:p,summary:w.summary,dependsOn:[...w.depends_on],covers:[...w.covers],status:C,phase:E?.phase??null,projectRoot:E?.projectRoot??null,message:k};return m.set(p,_),_},h=i.contract.children.map(({name:p})=>v(p));return{schema:i.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:n,confirmed:o,parentBranch:a,children:h,readyChildren:h.filter(({status:p})=>p==="ready").map(({name:p})=>p),allDone:h.every(({status:p})=>p==="done")}}var rR={maxAcceptanceCriteria:cu.maxCriteria};var dt={maxSpecs:64,maxFileBytes:Di,maxTotalBytes:4*1024*1024};import{promises as ud}from"fs";import dd from"path";var Fy=["outcome","scope","nonGoals","acceptanceExamples"],pR=[...Fy,"constraints","decisions","openQuestions","verificationExpectations"];var CR={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var rd=1024*1024;var nd={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:[]},Wy=K("comet-native-runtime:v3:scope-reopen"),ZR=[{skillVersion:"3",skillHash:K("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:K("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:K("comet-native-runtime:v1")}];var cd=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],TA=new Set(cd),Ky=new Set([...cd,"minimum_runtime_version","revision"]),jA=new Set([...Ky,"operation"]),$A=512*1024,Yy=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),OA=new Set([...Yy,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var fd=dt.maxSpecs*4;async function Xy(t,e){let r=dd.join(ie(t,e),"specs"),i;try{i=await ko({root:t.nativeRoot,directory:r,label:"Native proposed specs directory"})}catch(s){if(s.code==="ENOENT")return[];throw s}let n=[],a=0,o=await ud.opendir(r);try{for await(let s of o){if(a+=1,a>fd)throw new Error(`Native proposed specs directory exceeds ${fd} entries`);if(s.isSymbolicLink())throw new Error(`Proposed spec capability must not be a symbolic link: ${s.name}`);if(!s.isDirectory())continue;Tr(s.name);let c=dd.join(r,s.name,"spec.md");await D(t.nativeRoot,c);let l;try{l=await ud.lstat(c)}catch(d){if(d.code==="ENOENT")continue;throw d}if(l.isSymbolicLink()||!l.isFile())throw new Error(`Proposed spec must be a regular file: ${s.name}`);if(n.push(s.name),n.length>dt.maxSpecs)throw new Error("Native proposed specs exceed the spec-count budget")}}finally{await o.close().catch(s=>{if(s.code!=="ERR_DIR_CLOSED")throw s})}return await i.verify(),n.sort()}async function md(t,e){let r=ie(t,e),i={},n=0;for(let a of await Xy(t,e)){let o=await B({root:r,ref:`specs/${a}/spec.md`,maxBytes:dt.maxFileBytes});if(n+=o.size,n>dt.maxTotalBytes)throw new Error("Native proposed specs exceed the total byte budget");i[a]=o.text}return i}function Pe(t,e,r){return t.language==="zh-CN"?r:e}function Qy(t,e){let r=i=>({required:!1,message:null,suggestedReply:null,agentInstruction:i});if(t.phase==="shape"&&t.status==="await-user"&&t.loop.next_action==="confirm-shape")return t.language==="zh-CN"?{required:!0,message:"Shape 已整理完成。请确认目标、范围、关键决定、验收标准和非目标是否准确;明确确认后才会进入 Build。",suggestedReply:"确认进入 Build",agentInstruction:"先用自然语言简要展示目标、范围、关键决定、验收标准和非目标,再转述 message 并等待用户明确确认。只有用户明确同意当前完整 Shape 时,才执行 commandAlternatives 中的 confirm-shape;补充或修改要求不算确认。不要展示机器状态或提前运行 --confirmed。"}:{required:!0,message:"Shape is ready. Confirm that the target, scope, key decisions, acceptance criteria, and non-goals are accurate; Build starts only after explicit confirmation.",suggestedReply:"Confirm and enter Build",agentInstruction:"First present a concise natural-language summary of the target, scope, key decisions, acceptance criteria, and non-goals. Then relay message and wait for explicit user confirmation. Run confirm-shape from commandAlternatives only when the user explicitly accepts the complete current Shape; additions or corrections are not confirmation. Do not expose machine state or run --confirmed early."};if(e&&t.phase==="shape"&&t.status==="active")return{required:!0,message:Pe(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:Pe(t,"Reply A or B","回复 A 或 B"),agentInstruction:Pe(t,"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(t.phase==="verify"&&t.status==="active"&&t.loop.stage==="verify-ready"&&t.loop.next_action!=="await-verifier-result")return r(Pe(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(Pe(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(Pe(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 Zy(t){let e=t.workspace.change_branch??"<change-branch>",r=t.workspace.target_branch??"<target-branch>";return t.language==="zh-CN"?{required:!0,message:`当前 change 位于 ${e},目标分支为 ${r}。请选择一次工作区收尾方式:A) 保留工作区;B) 本地合并;C) 推送分支;D) 推送并创建 PR;E) 暂不归档。选择 A-D 后 Runtime 会先执行完整 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 ${e} and targets ${r}. Choose one workspace finish: A) keep the workspace; B) merge locally; C) push the branch; D) push and create a PR; or E) defer Archive. For A-D, Runtime will run 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 eN(t){return[...[{finish:"keep",name:"keep-workspace",description:["保留当前分支和目录;完成归档提交,不合并、不推送、不创建 PR。","Keep the current branch and directory; create the archive commit without merging, pushing, or creating a PR."]},{finish:"merge",name:"merge-locally",description:["完成归档提交,并把 change 分支本地合并到目标分支;不推送、不创建 PR。","Create the archive commit and merge the change branch locally into the target branch without pushing or creating a PR."]},{finish:"push",name:"push-branch",description:["完成归档提交并推送 change 分支;不合并到目标分支、不创建 PR。","Create the archive commit and push the change branch without merging into the target branch or creating a PR."]},{finish:"pull-request",name:"push-pull-request",description:["完成归档提交、推送 change 分支,并以目标分支为基础创建 PR。","Create the archive commit, push the change branch, and create a PR against the target branch."]}].map(({finish:i,name:n,description:a})=>({name:n,stateVersion:t.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","archive",t.name,"--dry-run","--finish",i],requiredInputs:[],inputOptions:[],description:Pe(t,a[1],a[0])})),{name:"defer-archive",stateVersion:t.state_version,expectedAction:"archive-preview",commandArgs:null,requiredInputs:[],inputOptions:[],description:Pe(t,"Keep the current change and workspace without archiving; stop and resume later.","保留当前 change 和工作区,不执行归档;停止本次流程,稍后再继续。")}]}function gd(t){return["comet","native","next",t.change,"--summary","<summary>",t.flag,"--expected-state-version",String(t.stateVersion),"--expected-action",t.action]}function Bt(t,e){return{name:t,flag:e,valueKind:"text",required:!0,template:null}}function tN(t,e){return{name:t,flag:e,valueKind:"confirmation",required:!0,template:null}}function vd(t,e,r){return{name:t,flag:e,valueKind:"choice",required:!0,template:null,choices:[...r]}}function rN(t){return t?.coordinationChoiceRequired===!0||t?.schema==="comet.native.children.v2"&&t.children.length>=2}function iN(t){return["comet","native","next",t.change,"--summary","<summary>",...t.coordinationRequired?["--coordination-mode","<coordination-mode>"]:[],"--expected-state-version",String(t.stateVersion),"--expected-action","prepare-shape-confirmation"]}function Ye(t){return{name:t.name,stateVersion:t.stateVersion,expectedAction:t.expectedAction,commandArgs:gd({change:t.change,stateVersion:t.stateVersion,action:t.expectedAction,flag:t.flag}),requiredInputs:["summary",t.confirmationInput],inputOptions:[Bt("summary","--summary"),tN(t.name,t.flag)]}}function Fo(t){return[Ye({name:"revise-implementation",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),Ye({name:"revise-requirements",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function wd(t,e,r={}){let i=rN(e)&&t.coordination_mode===void 0,n=Qy(t,i),a={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[],requiresUserDecision:n.required,userCommunication:n},o=s=>({kind:s,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...a,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:o("none")};if(t.status==="await-user")return t.phase==="shape"&&t.loop.next_action==="confirm-shape"?{...a,disposition:"await-user",action:"confirm-shape",commandArgs:null,requiredInputs:["summary","shared-understanding-confirmation"],inputOptions:[Bt("summary","--summary")],commandAlternatives:[Ye({name:"confirm-shape",change:t.name,stateVersion:t.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"})],runnerAction:o("none")}:t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...a,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Bt("summary","--summary")],commandAlternatives:[Ye({name:"accept-result",change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...Fo({change:t.name,stateVersion:t.state_version})],runnerAction:o("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...a,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Bt("summary","--summary")],commandAlternatives:[Ye({name:"retry-verifier",change:t.name,stateVersion:t.state_version,expectedAction:"retry-verifier",flag:"--retry-verifier",confirmationInput:"user-decision"}),Ye({name:"confirm-verifier-unavailable",change:t.name,stateVersion:t.state_version,expectedAction:"confirm-verifier-unavailable",flag:"--confirmed",confirmationInput:"user-decision"})],runnerAction:o("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...a,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Bt("summary","--summary")],commandAlternatives:[Ye({name:"resolve-verifier-blocker",change:t.name,stateVersion:t.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...Fo({change:t.name,stateVersion:t.state_version})],runnerAction:o("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...a,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Bt("summary","--summary")],commandAlternatives:Fo({change:t.name,stateVersion:t.state_version}),runnerAction:o("none")}:{...a,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:o("none")};if(t.status==="blocked"){let s=t.blockers.some(({resolution_action:c})=>c==="retry-verifier");return{...a,disposition:"blocked",action:s?"retry-verifier":"none",commandArgs:s?gd({change:t.name,stateVersion:t.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:s?["summary"]:["repair-runtime"],inputOptions:s?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:o(s?"retry-verifier":"none")}}if(t.phase==="shape")return{...a,disposition:i?"await-user":"continue",action:"prepare-shape-confirmation",commandArgs:iN({change:t.name,stateVersion:t.state_version,coordinationRequired:i}),requiredInputs:["summary",...i?["coordination-choice"]:[]],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},...i?[vd("coordination-mode","--coordination-mode",lu)]:[]],runnerAction:o("none")};if(t.phase==="build"){if(e){if(!e.confirmed)return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.loop.stage==="repairing"&&t.verification_result==="fail")return{...a,disposition:"continue",action:"repair",commandArgs:null,requiredInputs:["repair-child"],inputOptions:[],runnerAction:o("none")};if(e.allDone)return{...a,disposition:"continue",action:"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<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=e.children.some(({status:l})=>l==="blocked"||l==="needs-reverify"),c=e.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: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:o("builder-handoff")}}if(t.phase==="verify"){let s=t.loop.next_action==="await-verifier-result",c=!!t.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} ${Pe(t,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:a.userCommunication,disposition:"continue",action:s?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[s?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:s?[{kind:"verifier-response",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[l]}},{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:c?[l]:[]}}],runnerAction:o(s?"await-verifier":"dispatch-verifier")}}if(t.phase==="archive"&&t.status==="active"&&t.loop.stage==="archive-ready"&&!t.archived){let s=r.archiveMode??"archive-ready",l=t.workspace.isolation!=="current"&&t.workspace.finish===null;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",t.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}:l?{...a,disposition:"await-user",action:"archive",commandArgs:null,requiredInputs:["workspace-finish"],inputOptions:[vd("finish","--finish",["keep","merge","push","pull-request"])],commandAlternatives:[...eN(t)],userCommunication:Zy(t),runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--dry-run"],requiredInputs:[],commandAlternatives:[Ye({name:"revise-requirements",change:t.name,stateVersion:t.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}import{promises as dN}from"node:fs";import yd from"node:path";var v_=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");var fN=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,hN="comet-state.yaml";var YI=Vi("en");function qo(t,e){if(!fN.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=yd.join(t.changesDir,e);if(!q(t.changesDir,r))throw new Error("Native change path escaped");return r}function Nd(t,e){return yd.join(qo(t,e),hN)}async function Wo(t,e){try{let r=await dN.readFile(Nd(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}async function zo(t,e){return Rr(Nd(t,e))}import Hr from"path";import{realpathSync as KN}from"fs";var Re={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function bd(t){return t?t.command?`${Re.next} ${t.command}`:t.ask_user?`${Re.next} ${t.ask_user}`:null:null}function kd(t,e){let r=[t.summary],i=bd(t.next);return i&&r.push(i),t.user_message&&r.push("",Re.relay,t.user_message),e!==void 0&&r.push("",Re.details,JSON.stringify(e,null,2)),`${r.join(`
149
149
  `)}
150
- `}function kd(t,e,r){let i=[t.summary],n=Nd(t.next);return n&&i.push(n),t.user_message&&i.push("",Pe.relay,t.user_message),i.push("",`${Pe.detail} ${e}`),r!==void 0&&i.push("",Pe.details,JSON.stringify(r,null,2)),i.join(`
151
- `)}var dN=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 Sd="scoped-text-safety",fN=1,pN=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var hN="comet.native.checker-policy.v1";var eT=Y(hN,{policy:Sd,version:fN,limits:pN,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var mN=["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"],tT=new Set(mN);var gN=rd,wT=3*gN;import{execFile as CN}from"node:child_process";import{promisify as xN}from"node:util";var TT=512*1024;var $r=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};var tj=64*1024;var rj=3600*1e3;var ij=xN(CN);var vn=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 Fj={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var Zj=16*1024*1024,e$=256*1024,t$=16*1024;var s$=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var u$=16*1024;var k$=16*1024;var fO=16*1024*1024,gn=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"},wn=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 x(t,e,r){return t==="zh-CN"?r:e}var Go={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Cd(t,e){return typeof t=="string"&&Go[t]?x(e,Go[t].en,Go[t].zh):typeof t=="string"?t:""}function Uo(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 TN(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 xd(t,e){let r=[];t.failed>0&&r.push(x(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(x(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(x(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=x(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Pd(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 Ko(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function jN(t,e,r){return t==="done"?x(r,"complete","已完成"):t==="await-user"?x(r,"waiting for a user decision","等待用户决定"):t==="blocked"?x(r,"paused: needs attention","已暂停,需要处理"):e?x(r,"waiting for a user decision","等待用户决定"):x(r,"ready to continue","可继续推进")}function $N(t,e,r){let i=Ko(t),n=[];r&&n.push(r);let a=x(i,`Change ${t.change}`,`需求 ${t.change}`),o=Cd(t.phase,i),s=jN(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(xd(e,i));let c=t.userCommunication,l=Rd(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Rd(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:x(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:x(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:x(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function ON(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function HN(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=Cd(t.phase,e),n=t.status==="await-user"?x(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?x(e,"paused","已暂停"):t.status==="done"?x(e,"complete","已完成"):x(e,"in progress","进行中"),a=Uo(t.acceptance)?`${x(e,", ",",")}${xd(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function DN(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 LN(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 BN(t){if(t.healthy){let i=t.repaired?x("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):x("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=MN(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:x("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:x("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function MN(t){return Pd(t)?Rd(t,Ko(t)):void 0}function Ad(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(LN(e))return BN(e);if(ON(e)){let i=DN(e.items);return{summary:[e.total===e.items.length?x(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):x(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>HN(a,i))].join(`
152
- `)}}let r=e.continuation;if(Pd(r))return $N(r,VN(e),FN(e,Ko(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:x(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 VN(t){if(Uo(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(Uo(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return TN(r.acceptance)}return null}function FN(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return x(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?x(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function _d(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"conflict":return{summary:x("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:x("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:x("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:x("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:x("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:x("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:x("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:x("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:x("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}var Id=["--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."],Xo=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:Id,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>]
153
- 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 blocked Verifier execution when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--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]
154
- 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 Yo(t,e){return`${t}:
150
+ `}function Sd(t,e,r){let i=[t.summary],n=bd(t.next);return n&&i.push(n),t.user_message&&i.push("",Re.relay,t.user_message),i.push("",`${Re.detail} ${e}`),r!==void 0&&i.push("",Re.details,JSON.stringify(r,null,2)),i.join(`
151
+ `)}var pN=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 Ed="scoped-text-safety",mN=1,vN=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var gN="comet.native.checker-policy.v1";var pT=U(gN,{policy:Ed,version:mN,limits:vN,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var wN=["contract-before-does-not-match-scope","implementation-before-does-not-match-scope","contract-changed-during-check","implementation-changed-during-check","contract-after-does-not-match-scope","implementation-after-does-not-match-scope"],mT=new Set(wN);var NN=rd,TT=3*NN;import{execFile as RN}from"node:child_process";import{promisify as AN}from"node:util";var JT=512*1024;var Or=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};var mj=64*1024;var vj=3600*1e3;var gj=AN(RN);var wn=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 r$={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var h$=16*1024*1024,p$=256*1024,m$=16*1024;var b$=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var E$=16*1024;var H$=16*1024;var xO=16*1024*1024,yn=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"},Nn=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 x(t,e,r){return t==="zh-CN"?r:e}var Jo={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function xd(t,e){return typeof t=="string"&&Jo[t]?x(e,Jo[t].en,Jo[t].zh):typeof t=="string"?t:""}function Go(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 ON(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 Pd(t,e){let r=[];t.failed>0&&r.push(x(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(x(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(x(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=x(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Rd(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 Uo(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function HN(t,e,r){return t==="done"?x(r,"complete","已完成"):t==="await-user"?x(r,"waiting for a user decision","等待用户决定"):t==="blocked"?x(r,"paused: needs attention","已暂停,需要处理"):e?x(r,"waiting for a user decision","等待用户决定"):x(r,"ready to continue","可继续推进")}function DN(t,e,r){let i=Uo(t),n=[];r&&n.push(r);let a=x(i,`Change ${t.change}`,`需求 ${t.change}`),o=xd(t.phase,i),s=HN(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(Pd(e,i));let c=t.userCommunication,l=Ad(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Ad(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:x(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:x(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:x(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function LN(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function BN(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=xd(t.phase,e),n=t.status==="await-user"?x(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?x(e,"paused","已暂停"):t.status==="done"?x(e,"complete","已完成"):x(e,"in progress","进行中"),a=Go(t.acceptance)?`${x(e,", ",",")}${Pd(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function VN(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 MN(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 FN(t){if(t.healthy){let i=t.repaired?x("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):x("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=qN(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:x("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:x("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function qN(t){return Rd(t)?Ad(t,Uo(t)):void 0}function _d(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(MN(e))return FN(e);if(LN(e)){let i=VN(e.items);return{summary:[e.total===e.items.length?x(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):x(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>BN(a,i))].join(`
152
+ `)}}let r=e.continuation;if(Rd(r))return DN(r,WN(e),zN(e,Uo(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:x(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 WN(t){if(Go(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(Go(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return ON(r.acceptance)}return null}function zN(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return x(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?x(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function Id(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"conflict":return{summary:x("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:x("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:x("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:x("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:x("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:x("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:x("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:x("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:x("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}var Td=["--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."],Yo=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:Td,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>]
153
+ 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>]
154
+ 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]
155
+ 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 Ko(t,e){return`${t}:
155
156
  ${e.map(r=>` ${r}`).join(`
156
- `)}`}function qN(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return Xo[r]||e.length>1&&Xo[e[0]]?.subcommands?r:e[0]}function WN(t=[]){let e=qN(t),r=Xo[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.subcommands&&i.push("",Yo("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...Id];return n&&n.length>0&&i.push("",Yo("Options",n)),i.push("",`Output:
157
- ${r.output}`),r.examples&&i.push("",Yo("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
157
+ `)}`}function JN(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return Yo[r]||e.length>1&&Yo[e[0]]?.subcommands?r:e[0]}function GN(t=[]){let e=JN(t),r=Yo[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.subcommands&&i.push("",Ko("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...Td];return n&&n.length>0&&i.push("",Ko("Options",n)),i.push("",`Output:
158
+ ${r.output}`),r.examples&&i.push("",Ko("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
158
159
  `)}
159
- `}}var zN=WN().usage;var jd=10*1024*1024,Ke=class extends Error{};function Zo(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new Ke(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function $d(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new Ke(`${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 Ke(`${e} requires a value`);return t.splice(i,2),n}function Od(t){if(t.length>0)throw new Ke(`Unexpected argument: ${t[0]}`)}function Hd(t,e){let r=t.shift();if(!r||r.startsWith("--"))throw new Ke(`${e} is required`);return r}function Qo(t,e){let r=Or.normalize(Td(t)),i=Or.normalize(Td(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Td(t){let e=Or.resolve(t);try{return JN.native(e)}catch{return e}}function GN(t){let e=Or.resolve(t),r=Se(process.cwd());if(!r.isSecondaryWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null)return e;let i=Se(e);return!i.isGitWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null||!Qo(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||Qo(r.currentWorktreeRoot,i.currentWorktreeRoot)?e:Qo(process.cwd(),r.currentWorktreeRoot)?Or.resolve(process.cwd()):r.currentWorktreeRoot}async function Dd(t){return t?GN(t):Yi(process.cwd())}async function Ld(t){let e=await cu({startPath:t,allowMissingConfig:!1});return{config:e.config,paths:e.paths}}function Bd(t){return JSON.stringify(t,null,2)+`
160
- `}function yn(t,e,r){return{command:t,exitCode:0,data:e,text:r??Bd(e)}}function UN(t,e){if(e instanceof Ke)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof gn)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 wn)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof ln)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 Pr)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 fn)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof un)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 vn)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof $r)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 Md(t,e){let r=UN(t,e),i=r.error;if(!i)return r;let n=_d({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function Vd(t,e,r=!1){let i=t.envelope??Ad(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}})+`
161
- `}: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:bd(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==Bd(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
162
- ${Pe.details}
160
+ `}}var UN=GN().usage;var $d=10*1024*1024,Xe=class extends Error{};function Qo(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new Xe(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function Od(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new Xe(`${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 Xe(`${e} requires a value`);return t.splice(i,2),n}function Hd(t){if(t.length>0)throw new Xe(`Unexpected argument: ${t[0]}`)}function Dd(t,e){let r=t.shift();if(!r||r.startsWith("--"))throw new Xe(`${e} is required`);return r}function Xo(t,e){let r=Hr.normalize(jd(t)),i=Hr.normalize(jd(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function jd(t){let e=Hr.resolve(t);try{return KN.native(e)}catch{return e}}function YN(t){let e=Hr.resolve(t),r=Se(process.cwd());if(!r.isSecondaryWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null)return e;let i=Se(e);return!i.isGitWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null||!Xo(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||Xo(r.currentWorktreeRoot,i.currentWorktreeRoot)?e:Xo(process.cwd(),r.currentWorktreeRoot)?Hr.resolve(process.cwd()):r.currentWorktreeRoot}async function Ld(t){return t?YN(t):Zi(process.cwd())}async function Bd(t){let e=await su({startPath:t,allowMissingConfig:!1});return{config:e.config,paths:e.paths}}function Vd(t){return JSON.stringify(t,null,2)+`
161
+ `}function bn(t,e,r){return{command:t,exitCode:0,data:e,text:r??Vd(e)}}function XN(t,e){if(e instanceof Xe)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof yn)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 Nn)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof fn)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 Ar)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 mn)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof hn)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 wn)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof Or)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 Md(t,e){let r=XN(t,e),i=r.error;if(!i)return r;let n=Id({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function Fd(t,e,r=!1){let i=t.envelope??_d(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}})+`
162
+ `}:t.error?{exitCode:t.exitCode,stderr:i?Sd(i,t.error.message,r?t.data:void 0):t.error.message}:i?{exitCode:t.exitCode,stdout:kd(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==Vd(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
163
+ ${Re.details}
163
164
  ${JSON.stringify(t.data,null,2)}
164
- `}:{exitCode:t.exitCode,stdout:t.text}}async function Fd(t,e){let r=Hd(t,"change name");Od(t);let{paths:i}=await Ld(e);if(await zo(i,r)){let u=await Jo(i,r),d=Wo(i,r),f=await B({root:d,ref:u.brief,maxBytes:null,includeHash:!1}),m=[];for(let p of u.spec_changes){if(p.source===null)continue;let h=await B({root:d,ref:p.source,maxBytes:null,includeHash:!1});m.push({capability:p.capability,operation:p.operation,source:p.source,content:h.text})}let v={state:u,brief:f.text,proposedSpecs:m,continuation:gd(u,await Mo({paths:i,state:u}))};return yn("show",v)}let n=await Hu(i,r);if(n.status==="migration-required")return yn("show",{name:r,schema:n.schema,minimumRuntimeVersion:n.minimumRuntimeVersion,migrationRequired:!0,message:n.message});if(n.status!=="current"||!n.state)throw new Ue(n.schema,n.minimumRuntimeVersion);let a=n.state,o=ie(i,r),s=await md(i,r),c=await B({root:o,ref:a.brief,maxBytes:lt.maxFileBytes}),l={state:a,brief:c.text,proposedSpecs:s};if(Buffer.byteLength(JSON.stringify(l),"utf8")>jd)throw new Error("Native show output exceeds its serialized byte budget");return yn("show",l)}async function qd(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{Zo(n,"--json"),Zo(n,"--verbose"),c=$d(n,"--project-root");let d=[...n,...a],f=await Dd(c);l=await e(d,f)}catch(d){l=Md(t,d)}let u=Vd(l,o,s);return u.stdout&&process.stdout.write(u.stdout),u.stderr&&process.stderr.write(u.stderr+(u.stderr.endsWith(`
165
+ `}:{exitCode:t.exitCode,stdout:t.text}}async function qd(t,e){let r=Dd(t,"change name");Hd(t);let{paths:i}=await Bd(e);if(await Wo(i,r)){let d=await zo(i,r),u=qo(i,r),f=await B({root:u,ref:d.brief,maxBytes:null,includeHash:!1}),m=[];for(let h of d.spec_changes){if(h.source===null)continue;let p=await B({root:u,ref:h.source,maxBytes:null,includeHash:!1});m.push({capability:h.capability,operation:h.operation,source:h.source,content:p.text})}let v={state:d,brief:f.text,proposedSpecs:m,continuation:wd(d,await Vo({paths:i,state:d}))};return bn("show",v)}let n=await Hu(i,r);if(n.status==="migration-required")return bn("show",{name:r,schema:n.schema,minimumRuntimeVersion:n.minimumRuntimeVersion,migrationRequired:!0,message:n.message});if(n.status!=="current"||!n.state)throw new Ke(n.schema,n.minimumRuntimeVersion);let a=n.state,o=ie(i,r),s=await md(i,r),c=await B({root:o,ref:a.brief,maxBytes:dt.maxFileBytes}),l={state:a,brief:c.text,proposedSpecs:s};if(Buffer.byteLength(JSON.stringify(l),"utf8")>$d)throw new Error("Native show output exceeds its serialized byte budget");return bn("show",l)}async function Wd(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{Qo(n,"--json"),Qo(n,"--verbose"),c=Od(n,"--project-root");let u=[...n,...a],f=await Ld(c);l=await e(u,f)}catch(u){l=Md(t,u)}let d=Fd(l,o,s);return d.stdout&&process.stdout.write(d.stdout),d.stderr&&process.stderr.write(d.stderr+(d.stderr.endsWith(`
165
166
  `)?"":`
166
- `)),u.exitCode}process.exitCode=await qd("show",Fd);
167
+ `)),d.exitCode}process.exitCode=await Wd("show",qd);