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

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 (423) hide show
  1. package/README.md +4 -651
  2. package/assets/manifest.json +1 -1
  3. package/assets/skills/comet/scripts/comet-archive.mjs +80 -80
  4. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +1 -1
  5. package/assets/skills/comet/scripts/comet-guard.mjs +102 -102
  6. package/assets/skills/comet/scripts/comet-handoff.mjs +82 -82
  7. package/assets/skills/comet/scripts/comet-hook-guard.mjs +69 -70
  8. package/assets/skills/comet/scripts/comet-hook-router.mjs +120 -121
  9. package/assets/skills/comet/scripts/comet-intent.mjs +6 -6
  10. package/assets/skills/comet/scripts/comet-resume-probe.mjs +48 -48
  11. package/assets/skills/comet/scripts/comet-runtime.mjs +174 -175
  12. package/assets/skills/comet/scripts/comet-state.mjs +105 -105
  13. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +17 -17
  14. package/assets/skills/comet-native/SKILL.md +6 -5
  15. package/assets/skills/comet-native/reference/commands.md +7 -6
  16. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +124 -118
  17. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +131 -125
  18. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +97 -90
  19. package/assets/skills/comet-native/scripts/comet-native-init.mjs +121 -115
  20. package/assets/skills/comet-native/scripts/comet-native-new.mjs +113 -107
  21. package/assets/skills/comet-native/scripts/comet-native-next.mjs +134 -128
  22. package/assets/skills/comet-native/scripts/comet-native-root.mjs +101 -95
  23. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +166 -159
  24. package/assets/skills/comet-native/scripts/comet-native-select.mjs +114 -108
  25. package/assets/skills/comet-native/scripts/comet-native-show.mjs +98 -92
  26. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +107 -101
  27. package/assets/skills/comet-native/scripts/comet-native-status.mjs +111 -105
  28. package/assets/skills-zh/comet-native/SKILL.md +6 -5
  29. package/assets/skills-zh/comet-native/reference/commands.md +7 -6
  30. package/dist/app/commands/bundle.d.ts.map +1 -1
  31. package/dist/app/commands/bundle.js.map +1 -1
  32. package/dist/app/commands/dashboard.d.ts +1 -1
  33. package/dist/app/commands/dashboard.js +1 -1
  34. package/dist/app/commands/doctor.d.ts.map +1 -1
  35. package/dist/app/commands/doctor.js +1 -1
  36. package/dist/app/commands/doctor.js.map +1 -1
  37. package/dist/app/commands/init.js +2 -2
  38. package/dist/app/commands/init.js.map +1 -1
  39. package/dist/app/commands/platform-select-prompt.d.ts.map +1 -1
  40. package/dist/app/commands/platform-select-prompt.js +1 -0
  41. package/dist/app/commands/platform-select-prompt.js.map +1 -1
  42. package/dist/app/commands/status.d.ts.map +1 -1
  43. package/dist/app/commands/status.js +49 -9
  44. package/dist/app/commands/status.js.map +1 -1
  45. package/dist/app/commands/update.d.ts.map +1 -1
  46. package/dist/app/commands/update.js +13 -49
  47. package/dist/app/commands/update.js.map +1 -1
  48. package/dist/domains/agent-learning/policy-compiler.d.ts.map +1 -1
  49. package/dist/domains/agent-learning/policy-compiler.js.map +1 -1
  50. package/dist/domains/agent-learning/types.d.ts.map +1 -1
  51. package/dist/domains/agent-learning/types.js.map +1 -1
  52. package/dist/domains/bundle/authoring.d.ts.map +1 -1
  53. package/dist/domains/bundle/authoring.js.map +1 -1
  54. package/dist/domains/bundle/next-action.d.ts.map +1 -1
  55. package/dist/domains/bundle/next-action.js.map +1 -1
  56. package/dist/domains/bundle/readiness-user-summary.d.ts.map +1 -1
  57. package/dist/domains/bundle/readiness-user-summary.js.map +1 -1
  58. package/dist/domains/bundle/types.d.ts.map +1 -1
  59. package/dist/domains/comet-classic/classic-archive.d.ts.map +1 -1
  60. package/dist/domains/comet-classic/classic-archive.js +15 -0
  61. package/dist/domains/comet-classic/classic-archive.js.map +1 -1
  62. package/dist/domains/comet-classic/classic-cli.d.ts +8 -0
  63. package/dist/domains/comet-classic/classic-cli.d.ts.map +1 -1
  64. package/dist/domains/comet-classic/classic-cli.js +10 -0
  65. package/dist/domains/comet-classic/classic-cli.js.map +1 -1
  66. package/dist/domains/comet-classic/classic-guard.d.ts.map +1 -1
  67. package/dist/domains/comet-classic/classic-guard.js +20 -0
  68. package/dist/domains/comet-classic/classic-guard.js.map +1 -1
  69. package/dist/domains/comet-classic/classic-handoff.d.ts.map +1 -1
  70. package/dist/domains/comet-classic/classic-handoff.js +13 -0
  71. package/dist/domains/comet-classic/classic-handoff.js.map +1 -1
  72. package/dist/domains/comet-classic/classic-hook-guard.d.ts.map +1 -1
  73. package/dist/domains/comet-classic/classic-hook-guard.js +14 -15
  74. package/dist/domains/comet-classic/classic-hook-guard.js.map +1 -1
  75. package/dist/domains/comet-classic/classic-layout-initialization.d.ts.map +1 -1
  76. package/dist/domains/comet-classic/classic-layout-initialization.js.map +1 -1
  77. package/dist/domains/comet-classic/classic-output-language.d.ts +73 -0
  78. package/dist/domains/comet-classic/classic-output-language.d.ts.map +1 -0
  79. package/dist/domains/comet-classic/classic-output-language.js +175 -0
  80. package/dist/domains/comet-classic/classic-output-language.js.map +1 -0
  81. package/dist/domains/comet-classic/classic-script-entry.d.ts.map +1 -1
  82. package/dist/domains/comet-classic/classic-script-entry.js +10 -0
  83. package/dist/domains/comet-classic/classic-script-entry.js.map +1 -1
  84. package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
  85. package/dist/domains/comet-classic/classic-state-command.js +43 -4
  86. package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
  87. package/dist/domains/comet-entry/current-selection.d.ts.map +1 -1
  88. package/dist/domains/comet-entry/current-selection.js.map +1 -1
  89. package/dist/domains/comet-entry/init-workflow.d.ts.map +1 -1
  90. package/dist/domains/comet-entry/init-workflow.js.map +1 -1
  91. package/dist/domains/comet-entry/project-status.d.ts.map +1 -1
  92. package/dist/domains/comet-entry/project-status.js +15 -3
  93. package/dist/domains/comet-entry/project-status.js.map +1 -1
  94. package/dist/domains/comet-entry/types.d.ts +5 -1
  95. package/dist/domains/comet-entry/types.d.ts.map +1 -1
  96. package/dist/domains/comet-memory/personal-memory.d.ts.map +1 -1
  97. package/dist/domains/comet-memory/personal-memory.js.map +1 -1
  98. package/dist/domains/comet-memory/types.d.ts.map +1 -1
  99. package/dist/domains/comet-memory/types.js.map +1 -1
  100. package/dist/domains/comet-native/native-atomic-file.d.ts +1 -0
  101. package/dist/domains/comet-native/native-atomic-file.d.ts.map +1 -1
  102. package/dist/domains/comet-native/native-atomic-file.js +19 -0
  103. package/dist/domains/comet-native/native-atomic-file.js.map +1 -1
  104. package/dist/domains/comet-native/native-children.d.ts +17 -0
  105. package/dist/domains/comet-native/native-children.d.ts.map +1 -1
  106. package/dist/domains/comet-native/native-children.js +86 -9
  107. package/dist/domains/comet-native/native-children.js.map +1 -1
  108. package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
  109. package/dist/domains/comet-native/native-cli-help.js +3 -2
  110. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  111. package/dist/domains/comet-native/native-cli-shared.d.ts +7 -1
  112. package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
  113. package/dist/domains/comet-native/native-cli-shared.js +51 -4
  114. package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
  115. package/dist/domains/comet-native/native-cli.d.ts.map +1 -1
  116. package/dist/domains/comet-native/native-cli.js +4 -2
  117. package/dist/domains/comet-native/native-cli.js.map +1 -1
  118. package/dist/domains/comet-native/native-evidence-storage.d.ts.map +1 -1
  119. package/dist/domains/comet-native/native-evidence-storage.js.map +1 -1
  120. package/dist/domains/comet-native/native-lock.d.ts.map +1 -1
  121. package/dist/domains/comet-native/native-lock.js +10 -1
  122. package/dist/domains/comet-native/native-lock.js.map +1 -1
  123. package/dist/domains/comet-native/native-loop-runtime.d.ts +4 -1
  124. package/dist/domains/comet-native/native-loop-runtime.d.ts.map +1 -1
  125. package/dist/domains/comet-native/native-loop-runtime.js +39 -6
  126. package/dist/domains/comet-native/native-loop-runtime.js.map +1 -1
  127. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  128. package/dist/domains/comet-native/native-next-command.js +36 -2
  129. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  130. package/dist/domains/comet-native/native-output-language.d.ts +69 -0
  131. package/dist/domains/comet-native/native-output-language.d.ts.map +1 -0
  132. package/dist/domains/comet-native/native-output-language.js +369 -0
  133. package/dist/domains/comet-native/native-output-language.js.map +1 -0
  134. package/dist/domains/comet-native/native-portable-archive.d.ts.map +1 -1
  135. package/dist/domains/comet-native/native-portable-archive.js +17 -1
  136. package/dist/domains/comet-native/native-portable-archive.js.map +1 -1
  137. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  138. package/dist/domains/comet-native/native-portable-continuation.js +70 -27
  139. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  140. package/dist/domains/comet-native/native-portable-migration.d.ts.map +1 -1
  141. package/dist/domains/comet-native/native-portable-migration.js.map +1 -1
  142. package/dist/domains/comet-native/native-portable-recovery.d.ts +1 -0
  143. package/dist/domains/comet-native/native-portable-recovery.d.ts.map +1 -1
  144. package/dist/domains/comet-native/native-portable-recovery.js +2 -2
  145. package/dist/domains/comet-native/native-portable-recovery.js.map +1 -1
  146. package/dist/domains/comet-native/native-portable-runtime.d.ts +22 -0
  147. package/dist/domains/comet-native/native-portable-runtime.d.ts.map +1 -1
  148. package/dist/domains/comet-native/native-portable-runtime.js +114 -4
  149. package/dist/domains/comet-native/native-portable-runtime.js.map +1 -1
  150. package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
  151. package/dist/domains/comet-native/native-portable-state.js +5 -0
  152. package/dist/domains/comet-native/native-portable-state.js.map +1 -1
  153. package/dist/domains/comet-native/native-portable-types.d.ts +3 -0
  154. package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
  155. package/dist/domains/comet-native/native-portable-types.js.map +1 -1
  156. package/dist/domains/comet-native/native-runner-input.d.ts +30 -28
  157. package/dist/domains/comet-native/native-runner-input.d.ts.map +1 -1
  158. package/dist/domains/comet-native/native-runner-input.js +19 -27
  159. package/dist/domains/comet-native/native-runner-input.js.map +1 -1
  160. package/dist/domains/comet-native/native-schema-migration.d.ts.map +1 -1
  161. package/dist/domains/comet-native/native-schema-migration.js.map +1 -1
  162. package/dist/domains/comet-native/native-script-entry.d.ts +5 -4
  163. package/dist/domains/comet-native/native-script-entry.d.ts.map +1 -1
  164. package/dist/domains/comet-native/native-script-entry.js +8 -16
  165. package/dist/domains/comet-native/native-script-entry.js.map +1 -1
  166. package/dist/domains/comet-native/native-status-discovery.d.ts +31 -1
  167. package/dist/domains/comet-native/native-status-discovery.d.ts.map +1 -1
  168. package/dist/domains/comet-native/native-status-discovery.js +46 -8
  169. package/dist/domains/comet-native/native-status-discovery.js.map +1 -1
  170. package/dist/domains/comet-native/native-supervisor.d.ts +11 -1
  171. package/dist/domains/comet-native/native-supervisor.d.ts.map +1 -1
  172. package/dist/domains/comet-native/native-supervisor.js +61 -0
  173. package/dist/domains/comet-native/native-supervisor.js.map +1 -1
  174. package/dist/domains/comet-native/native-types.d.ts.map +1 -1
  175. package/dist/domains/comet-native/native-verification-receipt.d.ts.map +1 -1
  176. package/dist/domains/comet-native/native-verification-receipt.js.map +1 -1
  177. package/dist/domains/comet-native/native-workspace.d.ts.map +1 -1
  178. package/dist/domains/comet-native/native-workspace.js.map +1 -1
  179. package/dist/domains/comet-plugin/integration.d.ts +2 -0
  180. package/dist/domains/comet-plugin/integration.d.ts.map +1 -1
  181. package/dist/domains/comet-plugin/integration.js +10 -6
  182. package/dist/domains/comet-plugin/integration.js.map +1 -1
  183. package/dist/domains/dashboard/collector.js +1 -1
  184. package/dist/domains/dashboard/default-plugin-host.d.ts +3 -0
  185. package/dist/domains/dashboard/default-plugin-host.d.ts.map +1 -1
  186. package/dist/domains/dashboard/default-plugin-host.js +38 -4
  187. package/dist/domains/dashboard/default-plugin-host.js.map +1 -1
  188. package/dist/domains/dashboard/native-adapter.d.ts.map +1 -1
  189. package/dist/domains/dashboard/native-adapter.js.map +1 -1
  190. package/dist/domains/dashboard/native-collector.d.ts.map +1 -1
  191. package/dist/domains/dashboard/native-collector.js +2 -0
  192. package/dist/domains/dashboard/native-collector.js.map +1 -1
  193. package/dist/domains/dashboard/web/assets/abnfDiagram-VCTEODGH-UcCx24DV.js +1 -0
  194. package/dist/domains/dashboard/web/assets/arc-n8qsRq7W.js +1 -0
  195. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-B5p4GzJf.js +1 -0
  196. package/dist/domains/dashboard/web/assets/architectureDiagram-5GKGNRK7-D4pJ8CU0.js +36 -0
  197. package/dist/domains/dashboard/web/assets/array-BifhSqXX.js +1 -0
  198. package/dist/domains/dashboard/web/assets/blockDiagram-I7D4REHJ-C7n-qrSQ.js +129 -0
  199. package/dist/domains/dashboard/web/assets/browser-CgwPGwaV.js +107 -0
  200. package/dist/domains/dashboard/web/assets/c4Diagram-7LVT6UL2-cMVrWYOm.js +38 -0
  201. package/dist/domains/dashboard/web/assets/channel-BZeSeXVb.js +1 -0
  202. package/dist/domains/dashboard/web/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  203. package/dist/domains/dashboard/web/assets/chunk-4HAMMTFA-CE5QrCQd.js +62 -0
  204. package/dist/domains/dashboard/web/assets/{chunk-5VM5RSS4-CopXcnFA.js → chunk-5VM5RSS4-ZNzvKenW.js} +2 -2
  205. package/dist/domains/dashboard/web/assets/chunk-75Z2AOVW-BtZqN-pM.js +2 -0
  206. package/dist/domains/dashboard/web/assets/chunk-DU6HZSFF-CChv0huc.js +125 -0
  207. package/dist/domains/dashboard/web/assets/chunk-F27PBJKO-CDT1ttJ8.js +1 -0
  208. package/dist/domains/dashboard/web/assets/chunk-FOHPRMQF-DHwB1DNv.js +161 -0
  209. package/dist/domains/dashboard/web/assets/chunk-GMAD6QVW-y5m6LMR7.js +72 -0
  210. package/dist/domains/dashboard/web/assets/chunk-GVQU2GXP-DkhKkaHd.js +1 -0
  211. package/dist/domains/dashboard/web/assets/chunk-IMKFNOWR-BaDSh7Jp.js +231 -0
  212. package/dist/domains/dashboard/web/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  213. package/dist/domains/dashboard/web/assets/chunk-L3NEJ4N5-B4ztH2fV.js +1 -0
  214. package/dist/domains/dashboard/web/assets/chunk-OSK3NFVY-BhX6NVzA.js +10 -0
  215. package/dist/domains/dashboard/web/assets/chunk-P2QGCYS3-BCNdGJkX.js +1 -0
  216. package/dist/domains/dashboard/web/assets/chunk-POPQ4Y6H-DwYVuiXw.js +1 -0
  217. package/dist/domains/dashboard/web/assets/chunk-PWAF6VOD-Cyg0IO0R.js +1 -0
  218. package/dist/domains/dashboard/web/assets/chunk-SHT3W25Y-BZ6skx8I.js +168 -0
  219. package/dist/domains/dashboard/web/assets/chunk-SVP7TREG-CLIGmSO0.js +88 -0
  220. package/dist/domains/dashboard/web/assets/chunk-TICWLB2K-BAQBbsn9.js +206 -0
  221. package/dist/domains/dashboard/web/assets/chunk-XXDRQBXY-D07UbEpV.js +1 -0
  222. package/dist/domains/dashboard/web/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  223. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-2fcinal6.js +1 -0
  224. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-2fcinal6.js +1 -0
  225. package/dist/domains/dashboard/web/assets/cose-bilkent-JH36ORCC-wIi0mUih.js +1 -0
  226. package/dist/domains/dashboard/web/assets/cynefin-OW5HDTMX-DBdxyuTN.js +1 -0
  227. package/dist/domains/dashboard/web/assets/cynefinDiagram-5FMLGOSQ-DzO3jXxV.js +62 -0
  228. package/dist/domains/dashboard/web/assets/cytoscape.esm-CGd-uY3x.js +321 -0
  229. package/dist/domains/dashboard/web/assets/dagre-GXQ25YYZ-CE7H_hZS.js +4 -0
  230. package/dist/domains/dashboard/web/assets/dagre-PrKaheQc.js +1 -0
  231. package/dist/domains/dashboard/web/assets/defaultLocale-BFoDCU3G.js +1 -0
  232. package/dist/domains/dashboard/web/assets/demo-DrJ2uuUL.js +456 -0
  233. package/dist/domains/dashboard/web/assets/diagram-S7CK7UJ4-jUGQk5n-.js +30 -0
  234. package/dist/domains/dashboard/web/assets/diagram-UQ7AKVKN-DaH_zW8T.js +41 -0
  235. package/dist/domains/dashboard/web/assets/diagram-VSXAHHWV-DmG80db0.js +3 -0
  236. package/dist/domains/dashboard/web/assets/diagram-VX7I27RA-ltQ6niKn.js +24 -0
  237. package/dist/domains/dashboard/web/assets/diagram-Z3DM3KII-x92ex4lK.js +24 -0
  238. package/dist/domains/dashboard/web/assets/dist-Cf0h0n6i.js +1 -0
  239. package/dist/domains/dashboard/web/assets/ebnfDiagram-PWID7BFC-CI2u976k.js +1 -0
  240. package/dist/domains/dashboard/web/assets/erDiagram-RLTQ6QDP-DKs90SRd.js +99 -0
  241. package/dist/domains/dashboard/web/assets/es-D7xGlyQk.js +10 -0
  242. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-uARcGZPD.js +1 -0
  243. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-DXL1E4Bl.js +1 -0
  244. package/dist/domains/dashboard/web/assets/ganttDiagram-EL5Y4UJY-D3z6G60S.js +292 -0
  245. package/dist/domains/dashboard/web/assets/gitGraph-4MIJSDKK-vT1UnORT.js +1 -0
  246. package/dist/domains/dashboard/web/assets/gitGraphDiagram-WWUBYQGX-BJmJ96jv.js +106 -0
  247. package/dist/domains/dashboard/web/assets/graphlib-DS17s2tU.js +1 -0
  248. package/dist/domains/dashboard/web/assets/index-BG3MF8re.js +261 -0
  249. package/dist/domains/dashboard/web/assets/index-C2Hlo7VZ.css +1 -0
  250. package/dist/domains/dashboard/web/assets/info-A6RAGUB7-DFeLqqen.js +1 -0
  251. package/dist/domains/dashboard/web/assets/infoDiagram-27XIBGKW-DxuY43XD.js +2 -0
  252. package/dist/domains/dashboard/web/assets/init-C-OQMol4.js +1 -0
  253. package/dist/domains/dashboard/web/assets/ishikawaDiagram-5VMMS53U-DxillfWQ.js +70 -0
  254. package/dist/domains/dashboard/web/assets/journeyDiagram-3NMN7TZE-BPngQ3ag.js +139 -0
  255. package/dist/domains/dashboard/web/assets/kanban-definition-UXKFOSKX-DHMLEGD4.js +89 -0
  256. package/dist/domains/dashboard/web/assets/katex-CXMH3UgJ.js +257 -0
  257. package/dist/domains/dashboard/web/assets/line-D31peBjo.js +1 -0
  258. package/dist/domains/dashboard/web/assets/linear-B7X50T2m.js +1 -0
  259. package/dist/domains/dashboard/web/assets/marked.esm-BtJme7Pf.js +65 -0
  260. package/dist/domains/dashboard/web/assets/mermaid-parser.core-CX3Pzygh.js +7 -0
  261. package/dist/domains/dashboard/web/assets/mermaid.core-DlMjBFb6.js +44 -0
  262. package/dist/domains/dashboard/web/assets/mindmap-definition-YA3MSWOX-BKuSGF75.js +96 -0
  263. package/dist/domains/dashboard/web/assets/ordinal-BDEzSJ7C.js +1 -0
  264. package/dist/domains/dashboard/web/assets/packet-AYTQ26CC-B1T8Bds9.js +1 -0
  265. package/dist/domains/dashboard/web/assets/path-fybaL0A-.js +1 -0
  266. package/dist/domains/dashboard/web/assets/pegDiagram-XKGWAZYB-BYgTNxLw.js +1 -0
  267. package/dist/domains/dashboard/web/assets/pie-WAS4IAKB-fqAjmoQw.js +1 -0
  268. package/dist/domains/dashboard/web/assets/pieDiagram-E7YTZNPT-BAO0Ufky.js +39 -0
  269. package/dist/domains/dashboard/web/assets/purify.es-ChwZkWde.js +3 -0
  270. package/dist/domains/dashboard/web/assets/quadrantDiagram-AXDQQJYC-SA_1-7DT.js +7 -0
  271. package/dist/domains/dashboard/web/assets/radar-RG4KPBEZ-Bl_UfUle.js +1 -0
  272. package/dist/domains/dashboard/web/assets/railroad-74A4TZTK-yj6dkiSy.js +1 -0
  273. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CvouMciM.js +1 -0
  274. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-CkYQEX72.js +1 -0
  275. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-B0uYr48F.js +1 -0
  276. package/dist/domains/dashboard/web/assets/railroadDiagram-O6MQD6OU-DqV18Y46.js +1 -0
  277. package/dist/domains/dashboard/web/assets/requirementDiagram-BXWQKSXE-Ca2K5LuT.js +84 -0
  278. package/dist/domains/dashboard/web/assets/rough.esm-Dy-Kn_BL.js +1 -0
  279. package/dist/domains/dashboard/web/assets/sankeyDiagram-P5KCCOFB-D9MKl-Nr.js +40 -0
  280. package/dist/domains/dashboard/web/assets/sequenceDiagram-WJ2MYXX4-CXfvIzRx.js +162 -0
  281. package/dist/domains/dashboard/web/assets/sizeCapture-INFHLROL-B0uUizjq.js +1 -0
  282. package/dist/domains/dashboard/web/assets/src-CquUPIQx.js +1 -0
  283. package/dist/domains/dashboard/web/assets/stateDiagram-D77RDMKH-B7iaZHW7.js +1 -0
  284. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-B6KoHQVe.js +1 -0
  285. package/dist/domains/dashboard/web/assets/swimlanes-42K2YHIH-OK-62yZl.js +1 -0
  286. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-CjdOls9K.js +8 -0
  287. package/dist/domains/dashboard/web/assets/timeline-definition-24CTP7MA-D0l01B1h.js +120 -0
  288. package/dist/domains/dashboard/web/assets/treeView-Q6P3EWNA-Bg5u_o3A.js +1 -0
  289. package/dist/domains/dashboard/web/assets/treemap-WGGIJYW6-x89ccozk.js +1 -0
  290. package/dist/domains/dashboard/web/assets/vennDiagram-4TSXK5OY-DV19Cqhv.js +34 -0
  291. package/dist/domains/dashboard/web/assets/wardley-WFR3VGLG-BWoeoVk5.js +1 -0
  292. package/dist/domains/dashboard/web/assets/wardleyDiagram-VM6X3IG4-D4fCpoIP.js +78 -0
  293. package/dist/domains/dashboard/web/assets/xychartDiagram-S5SC5T6Z-DALnOMLb.js +7 -0
  294. package/dist/domains/dashboard/web/index.html +2 -2
  295. package/dist/domains/factory/artifacts.d.ts.map +1 -1
  296. package/dist/domains/factory/artifacts.js.map +1 -1
  297. package/dist/domains/factory/types.d.ts.map +1 -1
  298. package/dist/domains/integrations/codegraph.d.ts.map +1 -1
  299. package/dist/domains/integrations/codegraph.js.map +1 -1
  300. package/dist/domains/project-knowledge/local-store.d.ts +21 -0
  301. package/dist/domains/project-knowledge/local-store.d.ts.map +1 -1
  302. package/dist/domains/project-knowledge/local-store.js +97 -0
  303. package/dist/domains/project-knowledge/local-store.js.map +1 -1
  304. package/dist/domains/project-knowledge/types.d.ts.map +1 -1
  305. package/dist/domains/skill/platform-inspect.d.ts +1 -1
  306. package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
  307. package/dist/domains/skill/platform-inspect.js +50 -10
  308. package/dist/domains/skill/platform-inspect.js.map +1 -1
  309. package/dist/domains/skill/platform-install.d.ts +10 -5
  310. package/dist/domains/skill/platform-install.d.ts.map +1 -1
  311. package/dist/domains/skill/platform-install.js +107 -17
  312. package/dist/domains/skill/platform-install.js.map +1 -1
  313. package/dist/domains/skill/uninstall.d.ts.map +1 -1
  314. package/dist/domains/skill/uninstall.js +38 -61
  315. package/dist/domains/skill/uninstall.js.map +1 -1
  316. package/dist/domains/workflow-contract/contained-atomic-write.d.ts +1 -0
  317. package/dist/domains/workflow-contract/contained-atomic-write.d.ts.map +1 -1
  318. package/dist/domains/workflow-contract/contained-atomic-write.js +19 -0
  319. package/dist/domains/workflow-contract/contained-atomic-write.js.map +1 -1
  320. package/dist/domains/workflow-contract/global-config.d.ts +8 -0
  321. package/dist/domains/workflow-contract/global-config.d.ts.map +1 -1
  322. package/dist/domains/workflow-contract/global-config.js +25 -0
  323. package/dist/domains/workflow-contract/global-config.js.map +1 -1
  324. package/dist/domains/workflow-contract/index.d.ts +1 -1
  325. package/dist/domains/workflow-contract/index.d.ts.map +1 -1
  326. package/dist/domains/workflow-contract/index.js +1 -1
  327. package/dist/domains/workflow-contract/index.js.map +1 -1
  328. package/dist/domains/workflow-contract/output-envelope.d.ts +59 -0
  329. package/dist/domains/workflow-contract/output-envelope.d.ts.map +1 -0
  330. package/dist/domains/workflow-contract/output-envelope.js +108 -0
  331. package/dist/domains/workflow-contract/output-envelope.js.map +1 -0
  332. package/dist/domains/workflow-contract/project-config.d.ts +1 -1
  333. package/dist/domains/workflow-contract/project-config.d.ts.map +1 -1
  334. package/dist/domains/workflow-contract/project-config.js +1 -0
  335. package/dist/domains/workflow-contract/project-config.js.map +1 -1
  336. package/dist/domains/workflow-contract/types.d.ts.map +1 -1
  337. package/dist/platform/install/platforms.d.ts +4 -0
  338. package/dist/platform/install/platforms.d.ts.map +1 -1
  339. package/dist/platform/install/platforms.js +15 -3
  340. package/dist/platform/install/platforms.js.map +1 -1
  341. package/dist/platform/paths/project-knowledge-storage.d.ts +1 -1
  342. package/dist/platform/paths/project-knowledge-storage.d.ts.map +1 -1
  343. package/dist/platform/paths/project-knowledge-storage.js +9 -4
  344. package/dist/platform/paths/project-knowledge-storage.js.map +1 -1
  345. package/dist/platform/version/version.d.ts +8 -0
  346. package/dist/platform/version/version.d.ts.map +1 -1
  347. package/dist/platform/version/version.js +58 -8
  348. package/dist/platform/version/version.js.map +1 -1
  349. package/eval/local/tasks/comet-classic-layout-lifecycle/environment/current-comet-package.json +13 -13
  350. package/eval/local/tasks/comet-native-wave-d-stagnation-stop/instruction.md +2 -0
  351. package/eval/local/tasks/comet-native-wave-d-stagnation-stop/task.toml +1 -0
  352. package/eval/local/tasks/comet-native-wave-d-stagnation-stop/validation/test_native_wave_d_stagnation_stop.py +37 -0
  353. package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/environment/current-comet-package.json +13 -13
  354. package/package.json +24 -24
  355. package/dist/domains/dashboard/web/assets/abnfDiagram-N423BO3Z-BkUJc7LK.js +0 -1
  356. package/dist/domains/dashboard/web/assets/arc-DY4Y9tSO.js +0 -1
  357. package/dist/domains/dashboard/web/assets/architectureDiagram-T3A2C74G-7wC9YZS-.js +0 -36
  358. package/dist/domains/dashboard/web/assets/blockDiagram-VBNYF7ZC-Biqe-SaL.js +0 -132
  359. package/dist/domains/dashboard/web/assets/c4Diagram-5PPSVZJV-CccUFD1S.js +0 -10
  360. package/dist/domains/dashboard/web/assets/channel-DnRvSkOm.js +0 -1
  361. package/dist/domains/dashboard/web/assets/chunk-2GRJ4B5K-BUL4dDxo.js +0 -1
  362. package/dist/domains/dashboard/web/assets/chunk-2Q5K7J3B-BnKtDH9O.js +0 -1
  363. package/dist/domains/dashboard/web/assets/chunk-5RXB4S5H-C9pHQ1n3.js +0 -231
  364. package/dist/domains/dashboard/web/assets/chunk-6Q2QTUOP-CxrbngCi.js +0 -88
  365. package/dist/domains/dashboard/web/assets/chunk-GF5L2VYU-01mzgCUh.js +0 -206
  366. package/dist/domains/dashboard/web/assets/chunk-JWPE2WC7-wTiZVDvw.js +0 -1
  367. package/dist/domains/dashboard/web/assets/chunk-KBJHAD2P-Bxdv5bl-.js +0 -1
  368. package/dist/domains/dashboard/web/assets/chunk-RYQCIY6F-B5vF9l9A.js +0 -1
  369. package/dist/domains/dashboard/web/assets/chunk-XXDRQBXY-Dra3NnDp.js +0 -1
  370. package/dist/domains/dashboard/web/assets/classDiagram-JCYQIIEL-D3E-rgaQ.js +0 -1
  371. package/dist/domains/dashboard/web/assets/classDiagram-v2-OCEON4UE-D3E-rgaQ.js +0 -1
  372. package/dist/domains/dashboard/web/assets/cose-bilkent-JH36ORCC-DC96ge-n.js +0 -1
  373. package/dist/domains/dashboard/web/assets/cynefin-VYW2F7L2-Tt_NiopT.js +0 -166
  374. package/dist/domains/dashboard/web/assets/cynefinDiagram-MW4NZA55-BQ5__1hv.js +0 -62
  375. package/dist/domains/dashboard/web/assets/cytoscape.esm-D3_iZ_3b.js +0 -321
  376. package/dist/domains/dashboard/web/assets/dagre-VZM6K2ZE-Cr2zq3ro.js +0 -4
  377. package/dist/domains/dashboard/web/assets/defaultLocale-DX6XiGOO.js +0 -1
  378. package/dist/domains/dashboard/web/assets/demo-lxXhgJ9-.js +0 -456
  379. package/dist/domains/dashboard/web/assets/diagram-7IWD3JNH-BRpYDwPl.js +0 -30
  380. package/dist/domains/dashboard/web/assets/diagram-B4RE2ZJO-D7u-VBxW.js +0 -3
  381. package/dist/domains/dashboard/web/assets/diagram-LBJQPF4R-CHYuv2JD.js +0 -24
  382. package/dist/domains/dashboard/web/assets/diagram-Q27KOJAE-CV3ZE8Q3.js +0 -24
  383. package/dist/domains/dashboard/web/assets/diagram-UB23O5K3-co_OsTiQ.js +0 -41
  384. package/dist/domains/dashboard/web/assets/ebnfDiagram-BXEA7PRR-CETcWswS.js +0 -1
  385. package/dist/domains/dashboard/web/assets/erDiagram-JOGREHBK-edkItb7Z.js +0 -85
  386. package/dist/domains/dashboard/web/assets/flowDiagram-UKHOOZJN-D_oFJtSf.js +0 -156
  387. package/dist/domains/dashboard/web/assets/ganttDiagram-PKOTCBZU-CFjLVoA1.js +0 -292
  388. package/dist/domains/dashboard/web/assets/gitGraphDiagram-DS77QQ5N-BfD0tiKH.js +0 -106
  389. package/dist/domains/dashboard/web/assets/graph-DOmOIIwC.js +0 -1
  390. package/dist/domains/dashboard/web/assets/index-BzyqCfMb.css +0 -1
  391. package/dist/domains/dashboard/web/assets/index-CCKHH_A9.js +0 -10
  392. package/dist/domains/dashboard/web/assets/index-D8dxsTJY.js +0 -271
  393. package/dist/domains/dashboard/web/assets/index-DlSYK56b.js +0 -139
  394. package/dist/domains/dashboard/web/assets/infoDiagram-6WML65LV-Cx6xa9DS.js +0 -2
  395. package/dist/domains/dashboard/web/assets/init-Gi6I4Gst.js +0 -1
  396. package/dist/domains/dashboard/web/assets/ishikawaDiagram-WSZJBQD7-BjNLyyv_.js +0 -70
  397. package/dist/domains/dashboard/web/assets/journeyDiagram-NVQOT4AX-D2n9vrhx.js +0 -139
  398. package/dist/domains/dashboard/web/assets/kanban-definition-27J2QSJJ-kJL7v018.js +0 -89
  399. package/dist/domains/dashboard/web/assets/katex-HP8lGamR.js +0 -257
  400. package/dist/domains/dashboard/web/assets/layout-D-LzfAck.js +0 -1
  401. package/dist/domains/dashboard/web/assets/linear-CeHtd5-l.js +0 -1
  402. package/dist/domains/dashboard/web/assets/map-DxJ2ADlA.js +0 -1
  403. package/dist/domains/dashboard/web/assets/marked.esm-DECB3bxB.js +0 -64
  404. package/dist/domains/dashboard/web/assets/mermaid.core-B0EPSHs2.js +0 -306
  405. package/dist/domains/dashboard/web/assets/mindmap-definition-FAOFIHXS-bQQWINF4.js +0 -96
  406. package/dist/domains/dashboard/web/assets/ordinal-Cboi1Yqb.js +0 -1
  407. package/dist/domains/dashboard/web/assets/pegDiagram-VL7TDLO6-LxLY1W7W.js +0 -1
  408. package/dist/domains/dashboard/web/assets/pieDiagram-7S7Q4E2Y-BMDQqvuT.js +0 -39
  409. package/dist/domains/dashboard/web/assets/purify.es-Cz4mVeUR.js +0 -3
  410. package/dist/domains/dashboard/web/assets/quadrantDiagram-CIZ2JOQS-XWYjcuZN.js +0 -7
  411. package/dist/domains/dashboard/web/assets/railroadDiagram-AXF67PYL-p-OlQTa7.js +0 -1
  412. package/dist/domains/dashboard/web/assets/requirementDiagram-LRYGKXZP-BL4N8Vsl.js +0 -84
  413. package/dist/domains/dashboard/web/assets/sankeyDiagram-W5VNT64P-Btu-o6LN.js +0 -40
  414. package/dist/domains/dashboard/web/assets/sequenceDiagram-SI44F4Z6-9HpdQQ47.js +0 -162
  415. package/dist/domains/dashboard/web/assets/sizeCapture-X5ZJPWSS-5AnBiBHD.js +0 -1
  416. package/dist/domains/dashboard/web/assets/stateDiagram-OKZ733FA-Dv8IDsai.js +0 -1
  417. package/dist/domains/dashboard/web/assets/stateDiagram-v2-UEYNNEHI-DxOMyFOm.js +0 -1
  418. package/dist/domains/dashboard/web/assets/swimlanes-SLNWSIFB-BfJcN7dK.js +0 -2
  419. package/dist/domains/dashboard/web/assets/swimlanesDiagram-ULZ7WXOC-BnHRSbDk.js +0 -8
  420. package/dist/domains/dashboard/web/assets/timeline-definition-Z64GVDOM-DEOuEHi5.js +0 -120
  421. package/dist/domains/dashboard/web/assets/vennDiagram-T6HMQDX7-BqsGpwgo.js +0 -34
  422. package/dist/domains/dashboard/web/assets/wardleyDiagram-T6FBY63Y-CXlOp9so.js +0 -78
  423. package/dist/domains/dashboard/web/assets/xychartDiagram-ELKLHX3M-DyqqtC9X.js +0 -7
@@ -1,77 +1,77 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var Sf=Object.create;var Cs=Object.defineProperty;var Ef=Object.getOwnPropertyDescriptor;var Cf=Object.getOwnPropertyNames;var xf=Object.getPrototypeOf,Pf=Object.prototype.hasOwnProperty;var Lr=(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 w=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Rf=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Cf(e))!Pf.call(t,n)&&n!==r&&Cs(t,n,{get:()=>e[n],enumerable:!(i=Ef(e,n))||i.enumerable});return t};var Ft=(t,e,r)=>(r=t!=null?Sf(xf(t)):{},Rf(e||!t||!t.__esModule?Cs(r,"default",{value:t,enumerable:!0}):r,t));var C=w(B=>{"use strict";var zn=Symbol.for("yaml.alias"),Ts=Symbol.for("yaml.document"),Fr=Symbol.for("yaml.map"),Is=Symbol.for("yaml.pair"),Jn=Symbol.for("yaml.scalar"),Vr=Symbol.for("yaml.seq"),Re=Symbol.for("yaml.node.type"),qf=t=>!!t&&typeof t=="object"&&t[Re]===zn,Wf=t=>!!t&&typeof t=="object"&&t[Re]===Ts,zf=t=>!!t&&typeof t=="object"&&t[Re]===Fr,Jf=t=>!!t&&typeof t=="object"&&t[Re]===Is,js=t=>!!t&&typeof t=="object"&&t[Re]===Jn,Gf=t=>!!t&&typeof t=="object"&&t[Re]===Vr;function $s(t){if(t&&typeof t=="object")switch(t[Re]){case Fr:case Vr:return!0}return!1}function Uf(t){if(t&&typeof t=="object")switch(t[Re]){case zn:case Fr:case Jn:case Vr:return!0}return!1}var Kf=t=>(js(t)||$s(t))&&!!t.anchor;B.ALIAS=zn;B.DOC=Ts;B.MAP=Fr;B.NODE_TYPE=Re;B.PAIR=Is;B.SCALAR=Jn;B.SEQ=Vr;B.hasAnchor=Kf;B.isAlias=qf;B.isCollection=$s;B.isDocument=Wf;B.isMap=zf;B.isNode=Uf;B.isPair=Jf;B.isScalar=js;B.isSeq=Gf});var qt=w(Gn=>{"use strict";var O=C(),z=Symbol("break visit"),Os=Symbol("skip children"),we=Symbol("remove node");function qr(t,e){let r=Hs(e);O.isDocument(t)?yt(null,t.contents,r,Object.freeze([t]))===we&&(t.contents=null):yt(null,t,r,Object.freeze([]))}qr.BREAK=z;qr.SKIP=Os;qr.REMOVE=we;function yt(t,e,r,i){let n=Ds(t,e,r,i);if(O.isNode(n)||O.isPair(n))return Bs(t,i,n),yt(t,n,r,i);if(typeof n!="symbol"){if(O.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=yt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===z)return z;o===we&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){i=Object.freeze(i.concat(e));let a=yt("key",e.key,r,i);if(a===z)return z;a===we&&(e.key=null);let o=yt("value",e.value,r,i);if(o===z)return z;o===we&&(e.value=null)}}return n}async function Wr(t,e){let r=Hs(e);O.isDocument(t)?await Nt(null,t.contents,r,Object.freeze([t]))===we&&(t.contents=null):await Nt(null,t,r,Object.freeze([]))}Wr.BREAK=z;Wr.SKIP=Os;Wr.REMOVE=we;async function Nt(t,e,r,i){let n=await Ds(t,e,r,i);if(O.isNode(n)||O.isPair(n))return Bs(t,i,n),Nt(t,n,r,i);if(typeof n!="symbol"){if(O.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await Nt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===z)return z;o===we&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){i=Object.freeze(i.concat(e));let a=await Nt("key",e.key,r,i);if(a===z)return z;a===we&&(e.key=null);let o=await Nt("value",e.value,r,i);if(o===z)return z;o===we&&(e.value=null)}}return n}function Hs(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function Ds(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(O.isMap(e))return r.Map?.(t,e,i);if(O.isSeq(e))return r.Seq?.(t,e,i);if(O.isPair(e))return r.Pair?.(t,e,i);if(O.isScalar(e))return r.Scalar?.(t,e,i);if(O.isAlias(e))return r.Alias?.(t,e,i)}function Bs(t,e,r){let i=e[e.length-1];if(O.isCollection(i))i.items[t]=r;else if(O.isPair(i))t==="key"?i.key=r:i.value=r;else if(O.isDocument(i))i.contents=r;else{let n=O.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Gn.visit=qr;Gn.visitAsync=Wr});var Un=w(Ms=>{"use strict";var Ls=C(),Yf=qt(),Xf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Qf=t=>t.replace(/[!,[\]{}]/g,e=>Xf[e]),Wt=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=e.match(/^(.*!)([^!]*)$/s);n||r(`The ${e} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,i]of Object.entries(this.tags))if(e.startsWith(i))return r+Qf(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={};Yf.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
- `)}};Wt.defaultYaml={explicit:!1,version:"1.2"};Wt.defaultTags={"!!":"tag:yaml.org,2002:"};Ms.Directives=Wt});var zr=w(zt=>{"use strict";var Fs=C(),Zf=qt();function eh(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 Vs(t){let e=new Set;return Zf.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function qs(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function th(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Vs(t));let o=qs(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(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}}zt.anchorIsValid=eh;zt.anchorNames=Vs;zt.createNodeAnchors=th;zt.findNewAnchor=qs});var Kn=w(Ws=>{"use strict";function Jt(t,e,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=Jt(t,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=Jt(t,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=Jt(t,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=Jt(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}Ws.applyReviver=Jt});var De=w(Js=>{"use strict";var rh=C();function zs(t,e,r){if(Array.isArray(t))return t.map((i,n)=>zs(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!rh.hasAnchor(t))return t.toJSON(e,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(t,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=t.toJSON(e,r);return r.onCreate&&r.onCreate(n),n}return typeof t=="bigint"&&!r?.keep?Number(t):t}Js.toJS=zs});var Jr=w(Us=>{"use strict";var ih=Kn(),Gs=C(),nh=De(),Yn=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=nh.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?ih.applyReviver(a,{"":s},"",s):s}};Us.NodeBase=Yn});var Gt=w(Ks=>{"use strict";var ah=zr(),oh=qt(),bt=C(),sh=Jr(),ch=De(),Xn=class extends sh.NodeBase{constructor(e){super(bt.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=[],oh.visit(e,{Node:(a,o)=>{(bt.isAlias(o)||bt.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||(ch.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=Gr(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(ah.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 Gr(t,e,r){if(bt.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(bt.isCollection(e)){let i=0;for(let n of e.items){let a=Gr(t,n,r);a>i&&(i=a)}return i}else if(bt.isPair(e)){let i=Gr(t,e.key,r),n=Gr(t,e.value,r);return Math.max(i,n)}return 1}Ks.Alias=Xn});var j=w(Qn=>{"use strict";var lh=C(),uh=Jr(),dh=De(),fh=t=>!t||typeof t!="function"&&typeof t!="object",Be=class extends uh.NodeBase{constructor(e){super(lh.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:dh.toJS(this.value,e,r)}toString(){return String(this.value)}};Be.BLOCK_FOLDED="BLOCK_FOLDED";Be.BLOCK_LITERAL="BLOCK_LITERAL";Be.PLAIN="PLAIN";Be.QUOTE_DOUBLE="QUOTE_DOUBLE";Be.QUOTE_SINGLE="QUOTE_SINGLE";Qn.Scalar=Be;Qn.isScalarValue=fh});var Ut=w(Xs=>{"use strict";var hh=Gt(),et=C(),Ys=j(),ph="tag:yaml.org,2002:";function mh(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 vh(t,e,r){if(et.isDocument(t)&&(t=t.contents),et.isNode(t))return t;if(et.isPair(t)){let d=r.schema[et.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 hh.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=ph+e.slice(2));let l=mh(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Ys.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?o[et.MAP]:Symbol.iterator in Object(t)?o[et.SEQ]:o[et.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 Ys.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}Xs.createNode=vh});var Kr=w(Ur=>{"use strict";var gh=Ut(),ye=C(),wh=Jr();function Zn(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 gh.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Qs=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,ea=class extends wh.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=>ye.isNode(i)||ye.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(Qs(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(ye.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,Zn(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(ye.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&&ye.isScalar(a)?a.value:a:ye.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!ye.isPair(r))return!1;let i=r.value;return i==null||e&&ye.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 ye.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(ye.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,Zn(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Ur.Collection=ea;Ur.collectionFromPath=Zn;Ur.isEmptyPath=Qs});var Kt=w(Yr=>{"use strict";var yh=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function ta(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Nh=(t,e,r)=>t.endsWith(`
6
- `)?ta(r,e):r.includes(`
4
+ var Df=Object.create;var Ts=Object.defineProperty;var Lf=Object.getOwnPropertyDescriptor;var Bf=Object.getOwnPropertyNames;var Mf=Object.getPrototypeOf,Ff=Object.prototype.hasOwnProperty;var Fr=(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 w=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Vf=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Bf(e))!Ff.call(t,n)&&n!==r&&Ts(t,n,{get:()=>e[n],enumerable:!(i=Lf(e,n))||i.enumerable});return t};var Wt=(t,e,r)=>(r=t!=null?Df(Mf(t)):{},Vf(e||!t||!t.__esModule?Ts(r,"default",{value:t,enumerable:!0}):r,t));var x=w(M=>{"use strict";var Yn=Symbol.for("yaml.alias"),Ds=Symbol.for("yaml.document"),qr=Symbol.for("yaml.map"),Ls=Symbol.for("yaml.pair"),Xn=Symbol.for("yaml.scalar"),Wr=Symbol.for("yaml.seq"),_e=Symbol.for("yaml.node.type"),ih=t=>!!t&&typeof t=="object"&&t[_e]===Yn,nh=t=>!!t&&typeof t=="object"&&t[_e]===Ds,ah=t=>!!t&&typeof t=="object"&&t[_e]===qr,oh=t=>!!t&&typeof t=="object"&&t[_e]===Ls,Bs=t=>!!t&&typeof t=="object"&&t[_e]===Xn,sh=t=>!!t&&typeof t=="object"&&t[_e]===Wr;function Ms(t){if(t&&typeof t=="object")switch(t[_e]){case qr:case Wr:return!0}return!1}function ch(t){if(t&&typeof t=="object")switch(t[_e]){case Yn:case qr:case Xn:case Wr:return!0}return!1}var lh=t=>(Bs(t)||Ms(t))&&!!t.anchor;M.ALIAS=Yn;M.DOC=Ds;M.MAP=qr;M.NODE_TYPE=_e;M.PAIR=Ls;M.SCALAR=Xn;M.SEQ=Wr;M.hasAnchor=lh;M.isAlias=ih;M.isCollection=Ms;M.isDocument=nh;M.isMap=ah;M.isNode=ch;M.isPair=oh;M.isScalar=Bs;M.isSeq=sh});var Jt=w(Qn=>{"use strict";var D=x(),J=Symbol("break visit"),Fs=Symbol("skip children"),ye=Symbol("remove node");function zr(t,e){let r=Vs(e);D.isDocument(t)?bt(null,t.contents,r,Object.freeze([t]))===ye&&(t.contents=null):bt(null,t,r,Object.freeze([]))}zr.BREAK=J;zr.SKIP=Fs;zr.REMOVE=ye;function bt(t,e,r,i){let n=qs(t,e,r,i);if(D.isNode(n)||D.isPair(n))return Ws(t,i,n),bt(t,n,r,i);if(typeof n!="symbol"){if(D.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=bt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===J)return J;o===ye&&(e.items.splice(a,1),a-=1)}}}else if(D.isPair(e)){i=Object.freeze(i.concat(e));let a=bt("key",e.key,r,i);if(a===J)return J;a===ye&&(e.key=null);let o=bt("value",e.value,r,i);if(o===J)return J;o===ye&&(e.value=null)}}return n}async function Jr(t,e){let r=Vs(e);D.isDocument(t)?await kt(null,t.contents,r,Object.freeze([t]))===ye&&(t.contents=null):await kt(null,t,r,Object.freeze([]))}Jr.BREAK=J;Jr.SKIP=Fs;Jr.REMOVE=ye;async function kt(t,e,r,i){let n=await qs(t,e,r,i);if(D.isNode(n)||D.isPair(n))return Ws(t,i,n),kt(t,n,r,i);if(typeof n!="symbol"){if(D.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await kt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===J)return J;o===ye&&(e.items.splice(a,1),a-=1)}}}else if(D.isPair(e)){i=Object.freeze(i.concat(e));let a=await kt("key",e.key,r,i);if(a===J)return J;a===ye&&(e.key=null);let o=await kt("value",e.value,r,i);if(o===J)return J;o===ye&&(e.value=null)}}return n}function Vs(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 qs(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(D.isMap(e))return r.Map?.(t,e,i);if(D.isSeq(e))return r.Seq?.(t,e,i);if(D.isPair(e))return r.Pair?.(t,e,i);if(D.isScalar(e))return r.Scalar?.(t,e,i);if(D.isAlias(e))return r.Alias?.(t,e,i)}function Ws(t,e,r){let i=e[e.length-1];if(D.isCollection(i))i.items[t]=r;else if(D.isPair(i))t==="key"?i.key=r:i.value=r;else if(D.isDocument(i))i.contents=r;else{let n=D.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Qn.visit=zr;Qn.visitAsync=Jr});var Zn=w(Js=>{"use strict";var zs=x(),uh=Jt(),dh={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},fh=t=>t.replace(/[!,[\]{}]/g,e=>dh[e]),Gt=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+fh(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&&zs.isNode(e.contents)){let a={};uh.visit(e.contents,(o,s)=>{zs.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
+ `)}};Gt.defaultYaml={explicit:!1,version:"1.2"};Gt.defaultTags={"!!":"tag:yaml.org,2002:"};Js.Directives=Gt});var Gr=w(Ut=>{"use strict";var Gs=x(),hh=Jt();function ph(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 Us(t){let e=new Set;return hh.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function Ks(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function mh(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Us(t));let o=Ks(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Gs.isScalar(o.node)||Gs.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}}Ut.anchorIsValid=ph;Ut.anchorNames=Us;Ut.createNodeAnchors=mh;Ut.findNewAnchor=Ks});var ea=w(Ys=>{"use strict";function Kt(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=Kt(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=Kt(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=Kt(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=Kt(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}Ys.applyReviver=Kt});var Be=w(Qs=>{"use strict";var vh=x();function Xs(t,e,r){if(Array.isArray(t))return t.map((i,n)=>Xs(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!vh.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}Qs.toJS=Xs});var Ur=w(ec=>{"use strict";var gh=ea(),Zs=x(),wh=Be(),ta=class{constructor(e){Object.defineProperty(this,Zs.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(!Zs.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=wh.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?gh.applyReviver(a,{"":s},"",s):s}};ec.NodeBase=ta});var Yt=w(tc=>{"use strict";var yh=Gr(),Nh=Jt(),St=x(),bh=Ur(),kh=Be(),ra=class extends bh.NodeBase{constructor(e){super(St.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=[],Nh.visit(e,{Node:(a,o)=>{(St.isAlias(o)||St.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||(kh.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=Kr(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(yh.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 Kr(t,e,r){if(St.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(St.isCollection(e)){let i=0;for(let n of e.items){let a=Kr(t,n,r);a>i&&(i=a)}return i}else if(St.isPair(e)){let i=Kr(t,e.key,r),n=Kr(t,e.value,r);return Math.max(i,n)}return 1}tc.Alias=ra});var $=w(ia=>{"use strict";var Sh=x(),Eh=Ur(),Ch=Be(),xh=t=>!t||typeof t!="function"&&typeof t!="object",Me=class extends Eh.NodeBase{constructor(e){super(Sh.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:Ch.toJS(this.value,e,r)}toString(){return String(this.value)}};Me.BLOCK_FOLDED="BLOCK_FOLDED";Me.BLOCK_LITERAL="BLOCK_LITERAL";Me.PLAIN="PLAIN";Me.QUOTE_DOUBLE="QUOTE_DOUBLE";Me.QUOTE_SINGLE="QUOTE_SINGLE";ia.Scalar=Me;ia.isScalarValue=xh});var Xt=w(ic=>{"use strict";var Ph=Yt(),rt=x(),rc=$(),Rh="tag:yaml.org,2002:";function Ah(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 _h(t,e,r){if(rt.isDocument(t)&&(t=t.contents),rt.isNode(t))return t;if(rt.isPair(t)){let d=r.schema[rt.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 Ph.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=Rh+e.slice(2));let l=Ah(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new rc.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?o[rt.MAP]:Symbol.iterator in Object(t)?o[rt.SEQ]:o[rt.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 rc.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}ic.createNode=_h});var Xr=w(Yr=>{"use strict";var Th=Xt(),Ne=x(),Ih=Ur();function na(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 Th.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 nc=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,aa=class extends Ih.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=>Ne.isNode(i)||Ne.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(nc(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(Ne.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,na(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(Ne.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&&Ne.isScalar(a)?a.value:a:Ne.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!Ne.isPair(r))return!1;let i=r.value;return i==null||e&&Ne.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 Ne.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(Ne.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,na(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Yr.Collection=aa;Yr.collectionFromPath=na;Yr.isEmptyPath=nc});var Qt=w(Qr=>{"use strict";var jh=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function oa(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var $h=(t,e,r)=>t.endsWith(`
6
+ `)?oa(r,e):r.includes(`
7
7
  `)?`
8
- `+ta(r,e):(t.endsWith(" ")?"":" ")+r;Yr.indentComment=ta;Yr.lineComment=Nh;Yr.stringifyComment=yh});var ec=w(Yt=>{"use strict";var bh="flow",ra="block",Xr="quoted";function kh(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,p,g=!1,h=-1,m=-1,y=-1;r===ra&&(h=Zs(t,h,e.length),h!==-1&&(d=h+c));for(let k;k=t[h+=1];){if(r===Xr&&k==="\\"){switch(m=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}y=h}if(k===`
9
- `)r===ra&&(h=Zs(t,h,e.length)),d=h+e.length+c,f=void 0;else{if(k===" "&&p&&p!==" "&&p!==`
8
+ `+oa(r,e):(t.endsWith(" ")?"":" ")+r;Qr.indentComment=oa;Qr.lineComment=$h;Qr.stringifyComment=jh});var oc=w(Zt=>{"use strict";var Oh="flow",sa="block",Zr="quoted";function Hh(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,p,g=!1,h=-1,m=-1,y=-1;r===sa&&(h=ac(t,h,e.length),h!==-1&&(d=h+c));for(let k;k=t[h+=1];){if(r===Zr&&k==="\\"){switch(m=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}y=h}if(k===`
9
+ `)r===sa&&(h=ac(t,h,e.length)),d=h+e.length+c,f=void 0;else{if(k===" "&&p&&p!==" "&&p!==`
10
10
  `&&p!==" "){let S=t[h+1];S&&S!==" "&&S!==`
11
- `&&S!==" "&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(r===Xr){for(;p===" "||p===" ";)p=k,k=t[h+=1],g=!0;let S=h>y+1?h-2:m-1;if(u[S])return t;l.push(S),u[S]=!0,d=S+c,f=void 0}else g=!0}p=k}if(g&&s&&s(),l.length===0)return t;o&&o();let N=t.slice(0,l[0]);for(let k=0;k<l.length;++k){let S=l[k],E=l[k+1]||t.length;S===0?N=`
12
- ${e}${t.slice(0,E)}`:(r===Xr&&u[S]&&(N+=`${t[S]}\\`),N+=`
13
- ${e}${t.slice(S+1,E)}`)}return N}function Zs(t,e,r){let i=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+r)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
- `);i=e,n=e+1,a=t[n]}return i}Yt.FOLD_BLOCK=ra;Yt.FOLD_FLOW=bh;Yt.FOLD_QUOTED=Xr;Yt.foldFlowLines=kh});var Qt=w(tc=>{"use strict";var ae=j(),Le=ec(),Zr=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),ei=t=>/^(%|---|\.\.\.)/m.test(t);function Sh(t,e,r){if(!e||e<0)return!1;let i=e-r,n=t.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
- `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function Xt(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(ei(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)+`
11
+ `&&S!==" "&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(r===Zr){for(;p===" "||p===" ";)p=k,k=t[h+=1],g=!0;let S=h>y+1?h-2:m-1;if(u[S])return t;l.push(S),u[S]=!0,d=S+c,f=void 0}else g=!0}p=k}if(g&&s&&s(),l.length===0)return t;o&&o();let N=t.slice(0,l[0]);for(let k=0;k<l.length;++k){let S=l[k],E=l[k+1]||t.length;S===0?N=`
12
+ ${e}${t.slice(0,E)}`:(r===Zr&&u[S]&&(N+=`${t[S]}\\`),N+=`
13
+ ${e}${t.slice(S+1,E)}`)}return N}function ac(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=sa;Zt.FOLD_FLOW=Oh;Zt.FOLD_QUOTED=Zr;Zt.foldFlowLines=Hh});var tr=w(sc=>{"use strict";var oe=$(),Fe=oc(),ti=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),ri=t=>/^(%|---|\.\.\.)/m.test(t);function Dh(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 er(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(ri(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)+`
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:Le.foldFlowLines(o,a,Le.FOLD_QUOTED,Zr(e,!1))}function ia(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(t))return Xt(t,e);let r=e.indent||(ei(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${r}`)+"'";return e.implicitKey?i:Le.foldFlowLines(i,r,Le.FOLD_FLOW,Zr(e,!1))}function kt(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=Xt;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=ia:a&&!n?i=Xt:i=r?ia:Xt}return i(t,e)}var na;try{na=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:Fe.foldFlowLines(o,a,Fe.FOLD_QUOTED,ti(e,!1))}function ca(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(t))return er(t,e);let r=e.indent||(ri(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${r}`)+"'";return e.implicitKey?i:Fe.foldFlowLines(i,r,Fe.FOLD_FLOW,ti(e,!1))}function Et(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=er;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=ca:a&&!n?i=er:i=r?ca:er}return i(t,e)}var la;try{la=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{na=/\n+(?!\n|$)/g}function Qr({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 kt(r,i);let l=i.indent||(i.forceBlockIndent||ei(r)?" ":""),u=o==="literal"?!0:o==="folded"||e===ae.Scalar.BLOCK_FOLDED?!1:e===ae.Scalar.BLOCK_LITERAL?!0:!Sh(r,c,l.length);if(!r)return u?`|
23
+ |$)`,"g")}catch{la=/\n+(?!\n|$)/g}function ei({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 Et(r,i);let l=i.indent||(i.forceBlockIndent||ri(r)?" ":""),u=o==="literal"?!0:o==="folded"||e===oe.Scalar.BLOCK_FOLDED?!1:e===oe.Scalar.BLOCK_LITERAL?!0:!Dh(r,c,l.length);if(!r)return u?`|
24
24
  `:`>
25
25
  `;let d,f;for(f=r.length;f>0;--f){let E=r[f-1];if(E!==`
26
26
  `&&E!==" "&&E!==" ")break}let p=r.substring(f),g=p.indexOf(`
27
27
  `);g===-1?d="-":r===p||g!==p.length-1?(d="+",a&&a()):d="",p&&(r=r.slice(0,-p.length),p[p.length-1]===`
28
- `&&(p=p.slice(0,-1)),p=p.replace(na,`$&${l}`));let h=!1,m,y=-1;for(m=0;m<r.length;++m){let E=r[m];if(E===" ")h=!0;else if(E===`
28
+ `&&(p=p.slice(0,-1)),p=p.replace(la,`$&${l}`));let h=!1,m,y=-1;for(m=0;m<r.length;++m){let E=r[m];if(E===" ")h=!0;else if(E===`
29
29
  `)y=m;else break}let N=r.substring(0,y<m?y+1:m);N&&(r=r.substring(N.length),N=N.replace(/\n+/g,`$&${l}`));let S=(h?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}`),v=!1,x=Zr(i,!0);o!=="folded"&&e!==ae.Scalar.BLOCK_FOLDED&&(x.onOverflow=()=>{v=!0});let b=Le.foldFlowLines(`${N}${E}${p}`,l,Le.FOLD_BLOCK,x);if(!v)return`>${S}
30
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),v=!1,P=ti(i,!0);o!=="folded"&&e!==oe.Scalar.BLOCK_FOLDED&&(P.onOverflow=()=>{v=!0});let b=Fe.foldFlowLines(`${N}${E}${p}`,l,Fe.FOLD_BLOCK,P);if(!v)return`>${S}
31
31
  ${l}${b}`}return r=r.replace(/\n+/g,`$&${l}`),`|${S}
32
- ${l}${N}${r}${p}`}function Eh(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 kt(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
34
- `)?kt(a,e):Qr(t,e,r,i);if(!s&&!u&&n!==ae.Scalar.PLAIN&&a.includes(`
35
- `))return Qr(t,e,r,i);if(ei(a)){if(c==="")return e.forceBlockIndent=!0,Qr(t,e,r,i);if(s&&c===l)return kt(a,e)}let d=a.replace(/\n+/g,`$&
36
- ${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:g}=e.doc.schema;if(g.some(f)||p?.some(f))return kt(a,e)}return s?d:Le.foldFlowLines(d,c,Le.FOLD_FLOW,Zr(e,!1))}function Ch(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?kt(o.value,e):Qr(o,e,r,i);case ae.Scalar.QUOTE_DOUBLE:return Xt(o.value,e);case ae.Scalar.QUOTE_SINGLE:return ia(o.value,e);case ae.Scalar.PLAIN:return Eh(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}tc.stringifyString=Ch});var Zt=w(aa=>{"use strict";var xh=zr(),Me=C(),Ph=Kt(),Rh=Qt();function Ah(t,e){let r=Object.assign({blockQuote:!0,commentString:Ph.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 _h(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(Me.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 Th(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(Me.isScalar(t)||Me.isCollection(t))&&t.anchor;a&&xh.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 Ih(t,e,r,i){if(Me.isPair(t))return t.toString(e,r,i);if(Me.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=Me.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=_h(e.doc.schema.tags,a));let o=Th(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):Me.isScalar(a)?Rh.stringifyString(a,e,r,i):a.toString(e,r,i);return o?Me.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${e.indent}${s}`:s}aa.createStringifyContext=Ah;aa.stringify=Ih});var ac=w(nc=>{"use strict";var Ae=C(),rc=j(),ic=Zt(),er=Kt();function jh({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=Ae.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(Ae.isCollection(t)||!Ae.isNode(t)&&typeof t=="object"){let x="With simple keys, collection cannot be used as a key value";throw new Error(x)}}let p=!d&&(!t||f&&e==null&&!r.inFlow||Ae.isCollection(t)||(Ae.isScalar(t)?t.type===rc.Scalar.BLOCK_FOLDED||t.type===rc.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let g=!1,h=!1,m=ic.stringify(t,r,()=>g=!0,()=>h=!0);if(!p&&!r.inFlow&&m.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(r.inFlow){if(a||e==null)return g&&i&&i(),m===""?"?":p?`? ${m}`:m}else if(a&&!d||e==null&&p)return m=`? ${m}`,f&&!g?m+=er.lineComment(m,r.indent,l(f)):h&&n&&n(),m;g&&(f=null),p?(f&&(m+=er.lineComment(m,r.indent,l(f))),m=`? ${m}
38
- ${s}:`):(m=`${m}:`,f&&(m+=er.lineComment(m,r.indent,l(f))));let y,N,k;Ae.isNode(e)?(y=!!e.spaceBefore,N=e.commentBefore,k=e.comment):(y=!1,N=null,k=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!p&&!f&&Ae.isScalar(e)&&(r.indentAtStart=m.length+1),h=!1,!u&&c.length>=2&&!r.inFlow&&!p&&Ae.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let S=!1,E=ic.stringify(e,r,()=>S=!0,()=>h=!0),v=" ";if(f||y||N){if(v=y?`
39
- `:"",N){let x=l(N);v+=`
40
- ${er.indentComment(x,r.indent)}`}E===""&&!r.inFlow?v===`
32
+ ${l}${N}${r}${p}`}function Lh(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 Et(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
34
+ `)?Et(a,e):ei(t,e,r,i);if(!s&&!u&&n!==oe.Scalar.PLAIN&&a.includes(`
35
+ `))return ei(t,e,r,i);if(ri(a)){if(c==="")return e.forceBlockIndent=!0,ei(t,e,r,i);if(s&&c===l)return Et(a,e)}let d=a.replace(/\n+/g,`$&
36
+ ${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:g}=e.doc.schema;if(g.some(f)||p?.some(f))return Et(a,e)}return s?d:Fe.foldFlowLines(d,c,Fe.FOLD_FLOW,ti(e,!1))}function Bh(t,e,r,i){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==oe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=oe.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case oe.Scalar.BLOCK_FOLDED:case oe.Scalar.BLOCK_LITERAL:return n||a?Et(o.value,e):ei(o,e,r,i);case oe.Scalar.QUOTE_DOUBLE:return er(o.value,e);case oe.Scalar.QUOTE_SINGLE:return ca(o.value,e);case oe.Scalar.PLAIN:return Lh(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}sc.stringifyString=Bh});var rr=w(ua=>{"use strict";var Mh=Gr(),Ve=x(),Fh=Qt(),Vh=tr();function qh(t,e){let r=Object.assign({blockQuote:!0,commentString:Fh.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 Wh(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(Ve.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 zh(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(Ve.isScalar(t)||Ve.isCollection(t))&&t.anchor;a&&Mh.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 Jh(t,e,r,i){if(Ve.isPair(t))return t.toString(e,r,i);if(Ve.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=Ve.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Wh(e.doc.schema.tags,a));let o=zh(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):Ve.isScalar(a)?Vh.stringifyString(a,e,r,i):a.toString(e,r,i);return o?Ve.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${e.indent}${s}`:s}ua.createStringifyContext=qh;ua.stringify=Jh});var dc=w(uc=>{"use strict";var Te=x(),cc=$(),lc=rr(),ir=Qt();function Gh({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=Te.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(Te.isCollection(t)||!Te.isNode(t)&&typeof t=="object"){let P="With simple keys, collection cannot be used as a key value";throw new Error(P)}}let p=!d&&(!t||f&&e==null&&!r.inFlow||Te.isCollection(t)||(Te.isScalar(t)?t.type===cc.Scalar.BLOCK_FOLDED||t.type===cc.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let g=!1,h=!1,m=lc.stringify(t,r,()=>g=!0,()=>h=!0);if(!p&&!r.inFlow&&m.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(r.inFlow){if(a||e==null)return g&&i&&i(),m===""?"?":p?`? ${m}`:m}else if(a&&!d||e==null&&p)return m=`? ${m}`,f&&!g?m+=ir.lineComment(m,r.indent,l(f)):h&&n&&n(),m;g&&(f=null),p?(f&&(m+=ir.lineComment(m,r.indent,l(f))),m=`? ${m}
38
+ ${s}:`):(m=`${m}:`,f&&(m+=ir.lineComment(m,r.indent,l(f))));let y,N,k;Te.isNode(e)?(y=!!e.spaceBefore,N=e.commentBefore,k=e.comment):(y=!1,N=null,k=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!p&&!f&&Te.isScalar(e)&&(r.indentAtStart=m.length+1),h=!1,!u&&c.length>=2&&!r.inFlow&&!p&&Te.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let S=!1,E=lc.stringify(e,r,()=>S=!0,()=>h=!0),v=" ";if(f||y||N){if(v=y?`
39
+ `:"",N){let P=l(N);v+=`
40
+ ${ir.indentComment(P,r.indent)}`}E===""&&!r.inFlow?v===`
41
41
  `&&k&&(v=`
42
42
 
43
43
  `):v+=`
44
- ${r.indent}`}else if(!p&&Ae.isCollection(e)){let x=E[0],b=E.indexOf(`
45
- `),A=b!==-1,G=r.inFlow??e.flow??e.items.length===0;if(A||!G){let wt=!1;if(A&&(x==="&"||x==="!")){let $=E.indexOf(" ");x==="&"&&$!==-1&&$<b&&E[$+1]==="!"&&($=E.indexOf(" ",$+1)),($===-1||b<$)&&(wt=!0)}wt||(v=`
44
+ ${r.indent}`}else if(!p&&Te.isCollection(e)){let P=E[0],b=E.indexOf(`
45
+ `),_=b!==-1,U=r.inFlow??e.flow??e.items.length===0;if(_||!U){let Nt=!1;if(_&&(P==="&"||P==="!")){let H=E.indexOf(" ");P==="&"&&H!==-1&&H<b&&E[H+1]==="!"&&(H=E.indexOf(" ",H+1)),(H===-1||b<H)&&(Nt=!0)}Nt||(v=`
46
46
  ${r.indent}`)}}else(E===""||E[0]===`
47
- `)&&(v="");return m+=v+E,r.inFlow?S&&i&&i():k&&!S?m+=er.lineComment(m,r.indent,l(k)):h&&n&&n(),m}nc.stringifyPair=jh});var sa=w(oa=>{"use strict";var oc=Lr("process");function $h(t,...e){t==="debug"&&console.log(...e)}function Oh(t,e){(t==="debug"||t==="warn")&&(typeof oc.emitWarning=="function"?oc.emitWarning(e):console.warn(e))}oa.debug=$h;oa.warn=Oh});var ai=w(ni=>{"use strict";var ii=C(),sc=j(),ti="<<",ri={identify:t=>t===ti||typeof t=="symbol"&&t.description===ti,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new sc.Scalar(Symbol(ti)),{addToJSMap:cc}),stringify:()=>ti},Hh=(t,e)=>(ri.identify(e)||ii.isScalar(e)&&(!e.type||e.type===sc.Scalar.PLAIN)&&ri.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===ri.tag&&r.default);function cc(t,e,r){let i=lc(t,r);if(ii.isSeq(i))for(let n of i.items)ca(t,e,n);else if(Array.isArray(i))for(let n of i)ca(t,e,n);else ca(t,e,i)}function ca(t,e,r){let i=lc(t,r);if(!ii.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,t,Map);for(let[a,o]of n)e instanceof Map?e.has(a)||e.set(a,o):e instanceof Set?e.add(a):Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function lc(t,e){return t&&ii.isAlias(e)?e.resolve(t.doc,t):e}ni.addMergeToJSMap=cc;ni.isMergeKey=Hh;ni.merge=ri});var ua=w(fc=>{"use strict";var Dh=sa(),uc=ai(),Bh=Zt(),dc=C(),la=De();function Lh(t,e,{key:r,value:i}){if(dc.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(uc.isMergeKey(t,r))uc.addMergeToJSMap(t,e,i);else{let n=la.toJS(r,"",t);if(e instanceof Map)e.set(n,la.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=Mh(r,n,t),o=la.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 Mh(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(dc.isNode(t)&&r?.doc){let i=Bh.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)+'..."'),Dh.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(e)}fc.addPairToJSMap=Lh});var Fe=w(da=>{"use strict";var hc=Ut(),Fh=ac(),Vh=ua(),oi=C();function qh(t,e,r){let i=hc.createNode(t,void 0,r),n=hc.createNode(e,void 0,r);return new si(i,n)}var si=class t{constructor(e,r=null){Object.defineProperty(this,oi.NODE_TYPE,{value:oi.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return oi.isNode(r)&&(r=r.clone(e)),oi.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return Vh.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?Fh.stringifyPair(this,e,r,i):JSON.stringify(this)}};da.Pair=si;da.createPair=qh});var fa=w(mc=>{"use strict";var tt=C(),pc=Zt(),ci=Kt();function Wh(t,e,r){return(e.inFlow??t.flow?Jh:zh)(t,e,r)}function zh({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 g=0;g<e.length;++g){let h=e[g],m=null;if(tt.isNode(h))!d&&h.spaceBefore&&f.push(""),li(r,f,h.commentBefore,d),h.comment&&(m=h.comment);else if(tt.isPair(h)){let N=tt.isNode(h.key)?h.key:null;N&&(!d&&N.spaceBefore&&f.push(""),li(r,f,N.commentBefore,d))}d=!1;let y=pc.stringify(h,u,()=>m=null,()=>d=!0);m&&(y+=ci.lineComment(y,a,l(m))),d&&m&&(d=!1),f.push(i+y)}let p;if(f.length===0)p=n.start+n.end;else{p=f[0];for(let g=1;g<f.length;++g){let h=f[g];p+=h?`
47
+ `)&&(v="");return m+=v+E,r.inFlow?S&&i&&i():k&&!S?m+=ir.lineComment(m,r.indent,l(k)):h&&n&&n(),m}uc.stringifyPair=Gh});var fa=w(da=>{"use strict";var fc=Fr("process");function Uh(t,...e){t==="debug"&&console.log(...e)}function Kh(t,e){(t==="debug"||t==="warn")&&(typeof fc.emitWarning=="function"?fc.emitWarning(e):console.warn(e))}da.debug=Uh;da.warn=Kh});var si=w(oi=>{"use strict";var ai=x(),hc=$(),ii="<<",ni={identify:t=>t===ii||typeof t=="symbol"&&t.description===ii,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new hc.Scalar(Symbol(ii)),{addToJSMap:pc}),stringify:()=>ii},Yh=(t,e)=>(ni.identify(e)||ai.isScalar(e)&&(!e.type||e.type===hc.Scalar.PLAIN)&&ni.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===ni.tag&&r.default);function pc(t,e,r){let i=mc(t,r);if(ai.isSeq(i))for(let n of i.items)ha(t,e,n);else if(Array.isArray(i))for(let n of i)ha(t,e,n);else ha(t,e,i)}function ha(t,e,r){let i=mc(t,r);if(!ai.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 mc(t,e){return t&&ai.isAlias(e)?e.resolve(t.doc,t):e}oi.addMergeToJSMap=pc;oi.isMergeKey=Yh;oi.merge=ni});var ma=w(wc=>{"use strict";var Xh=fa(),vc=si(),Qh=rr(),gc=x(),pa=Be();function Zh(t,e,{key:r,value:i}){if(gc.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(vc.isMergeKey(t,r))vc.addMergeToJSMap(t,e,i);else{let n=pa.toJS(r,"",t);if(e instanceof Map)e.set(n,pa.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=ep(r,n,t),o=pa.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 ep(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(gc.isNode(t)&&r?.doc){let i=Qh.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)+'..."'),Xh.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)}wc.addPairToJSMap=Zh});var qe=w(va=>{"use strict";var yc=Xt(),tp=dc(),rp=ma(),ci=x();function ip(t,e,r){let i=yc.createNode(t,void 0,r),n=yc.createNode(e,void 0,r);return new li(i,n)}var li=class t{constructor(e,r=null){Object.defineProperty(this,ci.NODE_TYPE,{value:ci.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return ci.isNode(r)&&(r=r.clone(e)),ci.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return rp.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?tp.stringifyPair(this,e,r,i):JSON.stringify(this)}};va.Pair=li;va.createPair=ip});var ga=w(bc=>{"use strict";var it=x(),Nc=rr(),ui=Qt();function np(t,e,r){return(e.inFlow??t.flow?op:ap)(t,e,r)}function ap({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 g=0;g<e.length;++g){let h=e[g],m=null;if(it.isNode(h))!d&&h.spaceBefore&&f.push(""),di(r,f,h.commentBefore,d),h.comment&&(m=h.comment);else if(it.isPair(h)){let N=it.isNode(h.key)?h.key:null;N&&(!d&&N.spaceBefore&&f.push(""),di(r,f,N.commentBefore,d))}d=!1;let y=Nc.stringify(h,u,()=>m=null,()=>d=!0);m&&(y+=ui.lineComment(y,a,l(m))),d&&m&&(d=!1),f.push(i+y)}let p;if(f.length===0)p=n.start+n.end;else{p=f[0];for(let g=1;g<f.length;++g){let h=f[g];p+=h?`
48
48
  ${c}${h}`:`
49
49
  `}}return t?(p+=`
50
- `+ci.indentComment(l(t),c),s&&s()):d&&o&&o(),p}function Jh({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 g=0;g<t.length;++g){let h=t[g],m=null;if(tt.isNode(h))h.spaceBefore&&d.push(""),li(e,d,h.commentBefore,!1),h.comment&&(m=h.comment);else if(tt.isPair(h)){let N=tt.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&d.push(""),li(e,d,N.commentBefore,!1),N.comment&&(l=!0));let k=tt.isNode(h.value)?h.value:null;k?(k.comment&&(m=k.comment),k.commentBefore&&(l=!0)):h.value==null&&N?.comment&&(m=N.comment)}m&&(l=!0);let y=pc.stringify(h,c,()=>m=null);l||(l=d.length>u||y.includes(`
51
- `)),g<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=d.reduce((N,k)=>N+k.length+2,2)+(y.length+2)>e.options.lineWidth)),l&&(y+=",")),m&&(y+=ci.lineComment(y,i,s(m))),d.push(y),u=d.length}let{start:f,end:p}=r;if(d.length===0)return f+p;if(!l){let g=d.reduce((h,m)=>h+m.length+2,2);l=e.options.lineWidth>0&&g>e.options.lineWidth}if(l){let g=f;for(let h of d)g+=h?`
50
+ `+ui.indentComment(l(t),c),s&&s()):d&&o&&o(),p}function op({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 g=0;g<t.length;++g){let h=t[g],m=null;if(it.isNode(h))h.spaceBefore&&d.push(""),di(e,d,h.commentBefore,!1),h.comment&&(m=h.comment);else if(it.isPair(h)){let N=it.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&d.push(""),di(e,d,N.commentBefore,!1),N.comment&&(l=!0));let k=it.isNode(h.value)?h.value:null;k?(k.comment&&(m=k.comment),k.commentBefore&&(l=!0)):h.value==null&&N?.comment&&(m=N.comment)}m&&(l=!0);let y=Nc.stringify(h,c,()=>m=null);l||(l=d.length>u||y.includes(`
51
+ `)),g<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=d.reduce((N,k)=>N+k.length+2,2)+(y.length+2)>e.options.lineWidth)),l&&(y+=",")),m&&(y+=ui.lineComment(y,i,s(m))),d.push(y),u=d.length}let{start:f,end:p}=r;if(d.length===0)return f+p;if(!l){let g=d.reduce((h,m)=>h+m.length+2,2);l=e.options.lineWidth>0&&g>e.options.lineWidth}if(l){let g=f;for(let h of d)g+=h?`
52
52
  ${a}${n}${h}`:`
53
53
  `;return`${g}
54
- ${n}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function li({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=ci.indentComment(e(i),t);r.push(a.trimStart())}}mc.stringifyCollection=Wh});var qe=w(pa=>{"use strict";var Gh=fa(),Uh=ua(),Kh=Kr(),Ve=C(),ui=Fe(),Yh=j();function tr(t,e){let r=Ve.isScalar(e)?e.value:e;for(let i of t)if(Ve.isPair(i)&&(i.key===e||i.key===r||Ve.isScalar(i.key)&&i.key.value===r))return i}var ha=class extends Kh.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Ve.MAP,e),this.items=[]}static from(e,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(e),s=(c,l)=>{if(typeof a=="function")l=a.call(r,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(ui.createPair(c,l,i))};if(r instanceof Map)for(let[c,l]of r)s(c,l);else if(r&&typeof r=="object")for(let c of Object.keys(r))s(c,r[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,r){let i;Ve.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new ui.Pair(e,e?.value):i=new ui.Pair(e.key,e.value);let n=tr(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);Ve.isScalar(n.value)&&Yh.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(a){let o=this.items.findIndex(s=>a(i,s)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){let r=tr(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=tr(this.items,e)?.value;return(!r&&Ve.isScalar(n)?n.value:n)??void 0}has(e){return!!tr(this.items,e)}set(e,r){this.add(new ui.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)Uh.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!Ve.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Gh.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};pa.YAMLMap=ha;pa.findPair=tr});var St=w(gc=>{"use strict";var Xh=C(),vc=qe(),Qh={collection:"map",default:!0,nodeClass:vc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Xh.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>vc.YAMLMap.from(t,e,r)};gc.map=Qh});var We=w(wc=>{"use strict";var Zh=Ut(),ep=fa(),tp=Kr(),fi=C(),rp=j(),ip=De(),ma=class extends tp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(fi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=di(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=di(e);if(typeof i!="number")return;let n=this.items[i];return!r&&fi.isScalar(n)?n.value:n}has(e){let r=di(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=di(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];fi.isScalar(n)&&rp.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(ip.toJS(a,String(n++),r));return i}toString(e,r,i){return e?ep.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(Zh.createNode(s,void 0,i))}}return a}};function di(t){let e=fi.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}wc.YAMLSeq=ma});var Et=w(Nc=>{"use strict";var np=C(),yc=We(),ap={collection:"seq",default:!0,nodeClass:yc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return np.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>yc.YAMLSeq.from(t,e,r)};Nc.seq=ap});var rr=w(bc=>{"use strict";var op=Qt(),sp={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),op.stringifyString(t,e,r,i)}};bc.string=sp});var hi=w(Ec=>{"use strict";var kc=j(),Sc={identify:t=>t==null,createNode:()=>new kc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new kc.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Sc.test.test(t)?t:e.options.nullStr};Ec.nullTag=Sc});var va=w(xc=>{"use strict";var cp=j(),Cc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new cp.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&Cc.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};xc.boolTag=Cc});var Ct=w(Pc=>{"use strict";function lp({format:t,minFractionDigits:e,tag:r,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(i,-0)?"-0":JSON.stringify(i);if(!t&&e&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=e-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Pc.stringifyNumber=lp});var wa=w(pi=>{"use strict";var up=j(),ga=Ct(),dp={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:ga.stringifyNumber},fp={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():ga.stringifyNumber(t)}},hp={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 up.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:ga.stringifyNumber};pi.float=hp;pi.floatExp=fp;pi.floatNaN=dp});var Na=w(vi=>{"use strict";var Rc=Ct(),mi=t=>typeof t=="bigint"||Number.isInteger(t),ya=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function Ac(t,e,r){let{value:i}=t;return mi(i)&&i>=0?r+i.toString(e):Rc.stringifyNumber(t)}var pp={identify:t=>mi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>ya(t,2,8,r),stringify:t=>Ac(t,8,"0o")},mp={identify:mi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>ya(t,0,10,r),stringify:Rc.stringifyNumber},vp={identify:t=>mi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>ya(t,2,16,r),stringify:t=>Ac(t,16,"0x")};vi.int=mp;vi.intHex=vp;vi.intOct=pp});var Tc=w(_c=>{"use strict";var gp=St(),wp=hi(),yp=Et(),Np=rr(),bp=va(),ba=wa(),ka=Na(),kp=[gp.map,yp.seq,Np.string,wp.nullTag,bp.boolTag,ka.intOct,ka.int,ka.intHex,ba.floatNaN,ba.floatExp,ba.float];_c.schema=kp});var $c=w(jc=>{"use strict";var Sp=j(),Ep=St(),Cp=Et();function Ic(t){return typeof t=="bigint"||Number.isInteger(t)}var gi=({value:t})=>JSON.stringify(t),xp=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:gi},{identify:t=>t==null,createNode:()=>new Sp.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:gi},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:gi},{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:gi}],Pp={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Rp=[Ep.map,Cp.seq].concat(xp,Pp);jc.schema=Rp});var Ea=w(Oc=>{"use strict";var ir=Lr("buffer"),Sa=j(),Ap=Qt(),_p={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof ir.Buffer=="function")return ir.Buffer.from(t,"base64");if(typeof atob=="function"){let r=atob(t.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof ir.Buffer=="function")s=o instanceof ir.Buffer?o.toString("base64"):ir.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Sa.Scalar.BLOCK_LITERAL),e!==Sa.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===Sa.Scalar.BLOCK_LITERAL?`
55
- `:" ")}return Ap.stringifyString({comment:t,type:e,value:s},i,n,a)}};Oc.binary=_p});var Ni=w(yi=>{"use strict";var wi=C(),Ca=Fe(),Tp=j(),Ip=We();function Hc(t,e){if(wi.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!wi.isPair(i)){if(wi.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new Ca.Pair(new Tp.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
54
+ ${n}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function di({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=ui.indentComment(e(i),t);r.push(a.trimStart())}}bc.stringifyCollection=np});var ze=w(ya=>{"use strict";var sp=ga(),cp=ma(),lp=Xr(),We=x(),fi=qe(),up=$();function nr(t,e){let r=We.isScalar(e)?e.value:e;for(let i of t)if(We.isPair(i)&&(i.key===e||i.key===r||We.isScalar(i.key)&&i.key.value===r))return i}var wa=class extends lp.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(We.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(fi.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;We.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new fi.Pair(e,e?.value):i=new fi.Pair(e.key,e.value);let n=nr(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);We.isScalar(n.value)&&up.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=nr(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=nr(this.items,e)?.value;return(!r&&We.isScalar(n)?n.value:n)??void 0}has(e){return!!nr(this.items,e)}set(e,r){this.add(new fi.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)cp.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!We.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})),sp.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};ya.YAMLMap=wa;ya.findPair=nr});var Ct=w(Sc=>{"use strict";var dp=x(),kc=ze(),fp={collection:"map",default:!0,nodeClass:kc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return dp.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>kc.YAMLMap.from(t,e,r)};Sc.map=fp});var Je=w(Ec=>{"use strict";var hp=Xt(),pp=ga(),mp=Xr(),pi=x(),vp=$(),gp=Be(),Na=class extends mp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(pi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=hi(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=hi(e);if(typeof i!="number")return;let n=this.items[i];return!r&&pi.isScalar(n)?n.value:n}has(e){let r=hi(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=hi(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];pi.isScalar(n)&&vp.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(gp.toJS(a,String(n++),r));return i}toString(e,r,i){return e?pp.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(hp.createNode(s,void 0,i))}}return a}};function hi(t){let e=pi.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Ec.YAMLSeq=Na});var xt=w(xc=>{"use strict";var wp=x(),Cc=Je(),yp={collection:"seq",default:!0,nodeClass:Cc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return wp.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>Cc.YAMLSeq.from(t,e,r)};xc.seq=yp});var ar=w(Pc=>{"use strict";var Np=tr(),bp={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),Np.stringifyString(t,e,r,i)}};Pc.string=bp});var mi=w(_c=>{"use strict";var Rc=$(),Ac={identify:t=>t==null,createNode:()=>new Rc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Rc.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Ac.test.test(t)?t:e.options.nullStr};_c.nullTag=Ac});var ba=w(Ic=>{"use strict";var kp=$(),Tc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new kp.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&Tc.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};Ic.boolTag=Tc});var Pt=w(jc=>{"use strict";function Sp({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}jc.stringifyNumber=Sp});var Sa=w(vi=>{"use strict";var Ep=$(),ka=Pt(),Cp={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:ka.stringifyNumber},xp={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():ka.stringifyNumber(t)}},Pp={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 Ep.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:ka.stringifyNumber};vi.float=Pp;vi.floatExp=xp;vi.floatNaN=Cp});var Ca=w(wi=>{"use strict";var $c=Pt(),gi=t=>typeof t=="bigint"||Number.isInteger(t),Ea=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function Oc(t,e,r){let{value:i}=t;return gi(i)&&i>=0?r+i.toString(e):$c.stringifyNumber(t)}var Rp={identify:t=>gi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>Ea(t,2,8,r),stringify:t=>Oc(t,8,"0o")},Ap={identify:gi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>Ea(t,0,10,r),stringify:$c.stringifyNumber},_p={identify:t=>gi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>Ea(t,2,16,r),stringify:t=>Oc(t,16,"0x")};wi.int=Ap;wi.intHex=_p;wi.intOct=Rp});var Dc=w(Hc=>{"use strict";var Tp=Ct(),Ip=mi(),jp=xt(),$p=ar(),Op=ba(),xa=Sa(),Pa=Ca(),Hp=[Tp.map,jp.seq,$p.string,Ip.nullTag,Op.boolTag,Pa.intOct,Pa.int,Pa.intHex,xa.floatNaN,xa.floatExp,xa.float];Hc.schema=Hp});var Mc=w(Bc=>{"use strict";var Dp=$(),Lp=Ct(),Bp=xt();function Lc(t){return typeof t=="bigint"||Number.isInteger(t)}var yi=({value:t})=>JSON.stringify(t),Mp=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:yi},{identify:t=>t==null,createNode:()=>new Dp.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:yi},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:yi},{identify:Lc,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})=>Lc(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:yi}],Fp={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Vp=[Lp.map,Bp.seq].concat(Mp,Fp);Bc.schema=Vp});var Aa=w(Fc=>{"use strict";var or=Fr("buffer"),Ra=$(),qp=tr(),Wp={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof or.Buffer=="function")return or.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 or.Buffer=="function")s=o instanceof or.Buffer?o.toString("base64"):or.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=Ra.Scalar.BLOCK_LITERAL),e!==Ra.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===Ra.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return qp.stringifyString({comment:t,type:e,value:s},i,n,a)}};Fc.binary=Wp});var ki=w(bi=>{"use strict";var Ni=x(),_a=qe(),zp=$(),Jp=Je();function Vc(t,e){if(Ni.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!Ni.isPair(i)){if(Ni.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new _a.Pair(new zp.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]=wi.isPair(i)?i:new Ca.Pair(i)}}else e("Expected a sequence for this tag");return t}function Dc(t,e,r){let{replacer:i}=r,n=new Ip.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(Ca.createPair(s,c,r))}return n}var jp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Hc,createNode:Dc};yi.createPairs=Dc;yi.pairs=jp;yi.resolvePairs=Hc});var Ra=w(Pa=>{"use strict";var Bc=C(),xa=De(),nr=qe(),$p=We(),Lc=Ni(),rt=class t extends $p.YAMLSeq{constructor(){super(),this.add=nr.YAMLMap.prototype.add.bind(this),this.delete=nr.YAMLMap.prototype.delete.bind(this),this.get=nr.YAMLMap.prototype.get.bind(this),this.has=nr.YAMLMap.prototype.has.bind(this),this.set=nr.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if(Bc.isPair(n)?(a=xa.toJS(n.key,"",r),o=xa.toJS(n.value,a,r)):a=xa.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}};rt.tag="tag:yaml.org,2002:omap";var Op={collection:"seq",identify:t=>t instanceof Map,nodeClass:rt,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)Bc.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new rt,r)},createNode:(t,e,r)=>rt.from(t,e,r)};Pa.YAMLOMap=rt;Pa.omap=Op});var Wc=w(Aa=>{"use strict";var Mc=j();function Fc({value:t,source:e},r){return e&&(t?Vc:qc).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Vc={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 Mc.Scalar(!0),stringify:Fc},qc={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Mc.Scalar(!1),stringify:Fc};Aa.falseTag=qc;Aa.trueTag=Vc});var zc=w(bi=>{"use strict";var Hp=j(),_a=Ct(),Dp={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:_a.stringifyNumber},Bp={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():_a.stringifyNumber(t)}},Lp={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 Hp.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:_a.stringifyNumber};bi.float=Lp;bi.floatExp=Bp;bi.floatNaN=Dp});var Gc=w(or=>{"use strict";var Jc=Ct(),ar=t=>typeof t=="bigint"||Number.isInteger(t);function ki(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 Ta(t,e,r){let{value:i}=t;if(ar(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return Jc.stringifyNumber(t)}var Mp={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>ki(t,2,2,r),stringify:t=>Ta(t,2,"0b")},Fp={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>ki(t,1,8,r),stringify:t=>Ta(t,8,"0")},Vp={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>ki(t,0,10,r),stringify:Jc.stringifyNumber},qp={identify:ar,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>ki(t,2,16,r),stringify:t=>Ta(t,16,"0x")};or.int=Vp;or.intBin=Mp;or.intHex=qp;or.intOct=Fp});var ja=w(Ia=>{"use strict";var Ci=C(),Si=Fe(),Ei=qe(),it=class t extends Ei.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;Ci.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new Si.Pair(e.key,null):r=new Si.Pair(e,null),Ei.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=Ei.findPair(this.items,e);return!r&&Ci.isPair(i)?Ci.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=Ei.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Si.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(Si.createPair(o,null,i));return a}};it.tag="tag:yaml.org,2002:set";var Wp={collection:"map",identify:t=>t instanceof Set,nodeClass:it,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>it.from(t,e,r),resolve(t,e){if(Ci.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new it,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Ia.YAMLSet=it;Ia.set=Wp});var Oa=w(xi=>{"use strict";var zp=Ct();function $a(t,e){let r=t[0],i=r==="-"||r==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=i.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return r==="-"?n(-1)*a:a}function Uc(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return 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 Jp={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})=>$a(t,r),stringify:Uc},Gp={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=>$a(t,!1),stringify:Uc},Kc={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Kc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,a||0,o||0,s||0,c),u=e[8];if(u&&u!=="Z"){let d=$a(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$/,"")??""};xi.floatTime=Gp;xi.intTime=Jp;xi.timestamp=Kc});var Qc=w(Xc=>{"use strict";var Up=St(),Kp=hi(),Yp=Et(),Xp=rr(),Qp=Ea(),Yc=Wc(),Ha=zc(),Pi=Gc(),Zp=ai(),em=Ra(),tm=Ni(),rm=ja(),Da=Oa(),im=[Up.map,Yp.seq,Xp.string,Kp.nullTag,Yc.trueTag,Yc.falseTag,Pi.intBin,Pi.intOct,Pi.int,Pi.intHex,Ha.floatNaN,Ha.floatExp,Ha.float,Qp.binary,Zp.merge,em.omap,tm.pairs,rm.set,Da.intTime,Da.floatTime,Da.timestamp];Xc.schema=im});var cl=w(Ma=>{"use strict";var rl=St(),nm=hi(),il=Et(),am=rr(),om=va(),Ba=wa(),La=Na(),sm=Tc(),cm=$c(),nl=Ea(),sr=ai(),al=Ra(),ol=Ni(),Zc=Qc(),sl=ja(),Ri=Oa(),el=new Map([["core",sm.schema],["failsafe",[rl.map,il.seq,am.string]],["json",cm.schema],["yaml11",Zc.schema],["yaml-1.1",Zc.schema]]),tl={binary:nl.binary,bool:om.boolTag,float:Ba.float,floatExp:Ba.floatExp,floatNaN:Ba.floatNaN,floatTime:Ri.floatTime,int:La.int,intHex:La.intHex,intOct:La.intOct,intTime:Ri.intTime,map:rl.map,merge:sr.merge,null:nm.nullTag,omap:al.omap,pairs:ol.pairs,seq:il.seq,set:sl.set,timestamp:Ri.timestamp},lm={"tag:yaml.org,2002:binary":nl.binary,"tag:yaml.org,2002:merge":sr.merge,"tag:yaml.org,2002:omap":al.omap,"tag:yaml.org,2002:pairs":ol.pairs,"tag:yaml.org,2002:set":sl.set,"tag:yaml.org,2002:timestamp":Ri.timestamp};function um(t,e,r){let i=el.get(e);if(i&&!t)return r&&!i.includes(sr.merge)?i.concat(sr.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(el.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${a} or define customTags array`)}if(Array.isArray(t))for(let a of t)n=n.concat(a);else typeof t=="function"&&(n=t(n.slice()));return r&&(n=n.concat(sr.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?tl[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(tl).map(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=lm;Ma.getTags=um});var qa=w(ll=>{"use strict";var Fa=C(),dm=St(),fm=Et(),hm=rr(),Ai=cl(),pm=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Va=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Ai.getTags(e,"compat"):e?Ai.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Ai.coreKnownTags:{},this.tags=Ai.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Fa.MAP,{value:dm.map}),Object.defineProperty(this,Fa.SCALAR,{value:hm.string}),Object.defineProperty(this,Fa.SEQ,{value:fm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?pm:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};ll.Schema=Va});var dl=w(ul=>{"use strict";var mm=C(),Wa=Zt(),cr=Kt();function vm(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=Wa.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(cr.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(mm.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let u=a(t.contents.commentBefore);r.push(cr.indentComment(u,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=Wa.stringify(t.contents,n,()=>s=null,c);s&&(l+=cr.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(Wa.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
- `)?(r.push("..."),r.push(cr.indentComment(c,""))):r.push(`... ${c}`)}else r.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&r[r.length-1]!==""&&r.push(""),r.push(cr.indentComment(a(c),"")))}return r.join(`
57
+ ${a.comment}`:i.comment}i=n}t.items[r]=Ni.isPair(i)?i:new _a.Pair(i)}}else e("Expected a sequence for this tag");return t}function qc(t,e,r){let{replacer:i}=r,n=new Jp.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(_a.createPair(s,c,r))}return n}var Gp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Vc,createNode:qc};bi.createPairs=qc;bi.pairs=Gp;bi.resolvePairs=Vc});var ja=w(Ia=>{"use strict";var Wc=x(),Ta=Be(),sr=ze(),Up=Je(),zc=ki(),nt=class t extends Up.YAMLSeq{constructor(){super(),this.add=sr.YAMLMap.prototype.add.bind(this),this.delete=sr.YAMLMap.prototype.delete.bind(this),this.get=sr.YAMLMap.prototype.get.bind(this),this.has=sr.YAMLMap.prototype.has.bind(this),this.set=sr.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(Wc.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=zc.createPairs(e,r,i),a=new this;return a.items=n.items,a}};nt.tag="tag:yaml.org,2002:omap";var Kp={collection:"seq",identify:t=>t instanceof Map,nodeClass:nt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=zc.resolvePairs(t,e),i=[];for(let{key:n}of r.items)Wc.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new nt,r)},createNode:(t,e,r)=>nt.from(t,e,r)};Ia.YAMLOMap=nt;Ia.omap=Kp});var Yc=w($a=>{"use strict";var Jc=$();function Gc({value:t,source:e},r){return e&&(t?Uc:Kc).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Uc={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 Jc.Scalar(!0),stringify:Gc},Kc={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 Jc.Scalar(!1),stringify:Gc};$a.falseTag=Kc;$a.trueTag=Uc});var Xc=w(Si=>{"use strict";var Yp=$(),Oa=Pt(),Xp={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:Oa.stringifyNumber},Qp={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():Oa.stringifyNumber(t)}},Zp={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 Yp.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:Oa.stringifyNumber};Si.float=Zp;Si.floatExp=Qp;Si.floatNaN=Xp});var Zc=w(lr=>{"use strict";var Qc=Pt(),cr=t=>typeof t=="bigint"||Number.isInteger(t);function Ei(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 Ha(t,e,r){let{value:i}=t;if(cr(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return Qc.stringifyNumber(t)}var em={identify:cr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>Ei(t,2,2,r),stringify:t=>Ha(t,2,"0b")},tm={identify:cr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>Ei(t,1,8,r),stringify:t=>Ha(t,8,"0")},rm={identify:cr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>Ei(t,0,10,r),stringify:Qc.stringifyNumber},im={identify:cr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>Ei(t,2,16,r),stringify:t=>Ha(t,16,"0x")};lr.int=rm;lr.intBin=em;lr.intHex=im;lr.intOct=tm});var La=w(Da=>{"use strict";var Pi=x(),Ci=qe(),xi=ze(),at=class t extends xi.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;Pi.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new Ci.Pair(e.key,null):r=new Ci.Pair(e,null),xi.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=xi.findPair(this.items,e);return!r&&Pi.isPair(i)?Pi.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=xi.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Ci.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(Ci.createPair(o,null,i));return a}};at.tag="tag:yaml.org,2002:set";var nm={collection:"map",identify:t=>t instanceof Set,nodeClass:at,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>at.from(t,e,r),resolve(t,e){if(Pi.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new at,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Da.YAMLSet=at;Da.set=nm});var Ma=w(Ri=>{"use strict";var am=Pt();function Ba(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 el(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return am.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 om={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})=>Ba(t,r),stringify:el},sm={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=>Ba(t,!1),stringify:el},tl={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(tl.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=Ba(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$/,"")??""};Ri.floatTime=sm;Ri.intTime=om;Ri.timestamp=tl});var nl=w(il=>{"use strict";var cm=Ct(),lm=mi(),um=xt(),dm=ar(),fm=Aa(),rl=Yc(),Fa=Xc(),Ai=Zc(),hm=si(),pm=ja(),mm=ki(),vm=La(),Va=Ma(),gm=[cm.map,um.seq,dm.string,lm.nullTag,rl.trueTag,rl.falseTag,Ai.intBin,Ai.intOct,Ai.int,Ai.intHex,Fa.floatNaN,Fa.floatExp,Fa.float,fm.binary,hm.merge,pm.omap,mm.pairs,vm.set,Va.intTime,Va.floatTime,Va.timestamp];il.schema=gm});var pl=w(za=>{"use strict";var cl=Ct(),wm=mi(),ll=xt(),ym=ar(),Nm=ba(),qa=Sa(),Wa=Ca(),bm=Dc(),km=Mc(),ul=Aa(),ur=si(),dl=ja(),fl=ki(),al=nl(),hl=La(),_i=Ma(),ol=new Map([["core",bm.schema],["failsafe",[cl.map,ll.seq,ym.string]],["json",km.schema],["yaml11",al.schema],["yaml-1.1",al.schema]]),sl={binary:ul.binary,bool:Nm.boolTag,float:qa.float,floatExp:qa.floatExp,floatNaN:qa.floatNaN,floatTime:_i.floatTime,int:Wa.int,intHex:Wa.intHex,intOct:Wa.intOct,intTime:_i.intTime,map:cl.map,merge:ur.merge,null:wm.nullTag,omap:dl.omap,pairs:fl.pairs,seq:ll.seq,set:hl.set,timestamp:_i.timestamp},Sm={"tag:yaml.org,2002:binary":ul.binary,"tag:yaml.org,2002:merge":ur.merge,"tag:yaml.org,2002:omap":dl.omap,"tag:yaml.org,2002:pairs":fl.pairs,"tag:yaml.org,2002:set":hl.set,"tag:yaml.org,2002:timestamp":_i.timestamp};function Em(t,e,r){let i=ol.get(e);if(i&&!t)return r&&!i.includes(ur.merge)?i.concat(ur.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(ol.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(ur.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?sl[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(sl).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},[])}za.coreKnownTags=Sm;za.getTags=Em});var Ua=w(ml=>{"use strict";var Ja=x(),Cm=Ct(),xm=xt(),Pm=ar(),Ti=pl(),Rm=(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)?Ti.getTags(e,"compat"):e?Ti.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Ti.coreKnownTags:{},this.tags=Ti.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Ja.MAP,{value:Cm.map}),Object.defineProperty(this,Ja.SCALAR,{value:Pm.string}),Object.defineProperty(this,Ja.SEQ,{value:xm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Rm:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};ml.Schema=Ga});var gl=w(vl=>{"use strict";var Am=x(),Ka=rr(),dr=Qt();function _m(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=Ka.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(dr.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(Am.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let u=a(t.contents.commentBefore);r.push(dr.indentComment(u,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=Ka.stringify(t.contents,n,()=>s=null,c);s&&(l+=dr.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(Ka.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
+ `)?(r.push("..."),r.push(dr.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(dr.indentComment(a(c),"")))}return r.join(`
59
59
  `)+`
60
- `}ul.stringifyDocument=vm});var lr=w(fl=>{"use strict";var gm=Gt(),xt=Kr(),K=C(),wm=Fe(),ym=De(),Nm=qa(),bm=dl(),za=zr(),km=Kn(),Sm=Ut(),Ja=Un(),Ga=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,K.NODE_TYPE,{value:K.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 Ja.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,{[K.NODE_TYPE]:{value:K.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=K.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Pt(this.contents)&&this.contents.add(e)}addIn(e,r){Pt(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=za.anchorNames(this);e.anchor=!r||i.has(r)?za.findNewAnchor(r||"a",i):r}return new gm.Alias(e.anchor)}createNode(e,r,i){let n;if(typeof r=="function")e=r.call({"":e},"",e),n=r;else if(Array.isArray(r)){let m=N=>typeof N=="number"||N instanceof String||N instanceof Number,y=r.filter(m).map(String);y.length>0&&(r=r.concat(y)),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:p}=za.createNodeAnchors(this,o||"a"),g={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=Sm.createNode(e,u,g);return s&&K.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 wm.Pair(n,a)}delete(e){return Pt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return xt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Pt(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return K.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return xt.isEmptyPath(e)?!r&&K.isScalar(this.contents)?this.contents.value:this.contents:K.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return K.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return xt.isEmptyPath(e)?this.contents!==void 0:K.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=xt.collectionFromPath(this.schema,[e],r):Pt(this.contents)&&this.contents.set(e,r)}setIn(e,r){xt.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=xt.collectionFromPath(this.schema,Array.from(e),r):Pt(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 Ja.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 Ja.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 Nm.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=ym.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"?km.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 bm.stringifyDocument(this,e)}};function Pt(t){if(K.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}fl.Document=Ga});var fr=w(dr=>{"use strict";var ur=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},Ua=class extends ur{constructor(e,r,i){super("YAMLParseError",e,r,i)}},Ka=class extends ur{constructor(e,r,i){super("YAMLWarning",e,r,i)}},Em=(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
+ `}vl.stringifyDocument=_m});var fr=w(wl=>{"use strict";var Tm=Yt(),Rt=Xr(),Y=x(),Im=qe(),jm=Be(),$m=Ua(),Om=gl(),Ya=Gr(),Hm=ea(),Dm=Xt(),Xa=Zn(),Qa=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Y.NODE_TYPE,{value:Y.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 Xa.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,{[Y.NODE_TYPE]:{value:Y.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=Y.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){At(this.contents)&&this.contents.add(e)}addIn(e,r){At(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=Ya.anchorNames(this);e.anchor=!r||i.has(r)?Ya.findNewAnchor(r||"a",i):r}return new Tm.Alias(e.anchor)}createNode(e,r,i){let n;if(typeof r=="function")e=r.call({"":e},"",e),n=r;else if(Array.isArray(r)){let m=N=>typeof N=="number"||N instanceof String||N instanceof Number,y=r.filter(m).map(String);y.length>0&&(r=r.concat(y)),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:p}=Ya.createNodeAnchors(this,o||"a"),g={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=Dm.createNode(e,u,g);return s&&Y.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 Im.Pair(n,a)}delete(e){return At(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Rt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):At(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return Y.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return Rt.isEmptyPath(e)?!r&&Y.isScalar(this.contents)?this.contents.value:this.contents:Y.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return Y.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Rt.isEmptyPath(e)?this.contents!==void 0:Y.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=Rt.collectionFromPath(this.schema,[e],r):At(this.contents)&&this.contents.set(e,r)}setIn(e,r){Rt.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=Rt.collectionFromPath(this.schema,Array.from(e),r):At(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 Xa.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 Xa.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 $m.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=jm.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"?Hm.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 Om.stringifyDocument(this,e)}};function At(t){if(Y.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}wl.Document=Qa});var mr=w(pr=>{"use strict";var hr=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},Za=class extends hr{constructor(e,r,i){super("YAMLParseError",e,r,i)}},eo=class extends hr{constructor(e,r,i){super("YAMLWarning",e,r,i)}},Lm=(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
- `}};dr.YAMLError=ur;dr.YAMLParseError=Ua;dr.YAMLWarning=Ka;dr.prettifyError=Em});var hr=w(hl=>{"use strict";function Cm(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d="",f="",p=!1,g=!1,h=null,m=null,y=null,N=null,k=null,S=null,E=null;for(let b of t)switch(g&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&a(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),h&&(l&&b.type!=="comment"&&b.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),b.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&b.source.includes(" ")&&(h=b),u=!0;break;case"comment":{u||a(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let A=b.source.substring(1)||" ";d?d+=f+A:d=A,f="",l=!1;break}case"newline":l?d?d+=b.source:(!S||r!=="seq-item-ind")&&(c=!0):f+=b.source,l=!0,p=!0,(m||y)&&(N=b),u=!0;break;case"anchor":m&&a(b,"MULTIPLE_ANCHORS","A node can have at most one anchor"),b.source.endsWith(":")&&a(b.offset+b.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=b,E??(E=b.offset),l=!1,u=!1,g=!0;break;case"tag":{y&&a(b,"MULTIPLE_TAGS","A node can have at most one tag"),y=b,E??(E=b.offset),l=!1,u=!1,g=!0;break}case r:(m||y)&&a(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),S&&a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${e??"collection"}`),S=b,l=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(e){k&&a(b,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=b,l=!1,u=!1;break}default:a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,u=!1}let v=t[t.length-1],x=v?v.offset+v.source.length:n;return g&&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:k,found:S,spaceBefore:c,comment:d,hasNewline:p,anchor:m,tag:y,newlineAfterProp:N,end:x,start:E??x}}hl.resolveProps=Cm});var _i=w(pl=>{"use strict";function Ya(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(Ya(e.key)||Ya(e.value))return!0}return!1;default:return!0}}pl.containsNewline=Ya});var Xa=w(ml=>{"use strict";var xm=_i();function Pm(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&xm.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}ml.flowIndentCheck=Pm});var Qa=w(gl=>{"use strict";var vl=C();function Rm(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||vl.isScalar(a)&&vl.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}gl.mapIncludes=Rm});var Sl=w(kl=>{"use strict";var wl=Fe(),Am=qe(),yl=hr(),_m=_i(),Nl=Xa(),Tm=Qa(),bl="All mapping items must start at the same column";function Im({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Am.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:p,value:g}=u,h=yl.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),m=!h.found;if(m){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",bl)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
67
- `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||_m.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&n(c,"BAD_INDENT",bl);r.atKey=!0;let y=h.end,N=f?t(r,f,h,n):e(r,y,d,null,h,n);r.schema.compat&&Nl.flowIndentCheck(i.indent,f,n),r.atKey=!1,Tm.mapIncludes(r,s.items,N)&&n(y,"DUPLICATE_KEY","Map keys must be unique");let k=yl.resolveProps(p??[],{indicator:"map-value-ind",next:g,offset:N.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=k.end,k.found){m&&(g?.type==="block-map"&&!k.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<k.found.offset-1024&&n(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=g?t(r,g,k,n):e(r,c,p,null,k,n);r.schema.compat&&Nl.flowIndentCheck(i.indent,g,n),c=S.range[2];let E=new wl.Pair(N,S);r.options.keepSourceTokens&&(E.srcToken=u),s.items.push(E)}else{m&&n(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(N.comment?N.comment+=`
68
- `+k.comment:N.comment=k.comment);let S=new wl.Pair(N);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}kl.resolveBlockMap=Im});var Cl=w(El=>{"use strict";var jm=We(),$m=hr(),Om=Xa();function Hm({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??jm.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=$m.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 p=d?t(r,d,f,n):e(r,f.end,u,null,f,n);r.schema.compat&&Om.flowIndentCheck(i.indent,d,n),c=p.range[2],s.items.push(p)}return s.range=[i.offset,c,l??c],s}El.resolveBlockSeq=Hm});var Rt=w(xl=>{"use strict";function Dm(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}}xl.resolveEnd=Dm});var _l=w(Al=>{"use strict";var Bm=C(),Lm=Fe(),Pl=qe(),Mm=We(),Fm=Rt(),Rl=hr(),Vm=_i(),qm=Qa(),Za="Block collections are not allowed within flow collections",eo=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Wm({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Pl.YAMLMap:Mm.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 m=0;m<i.items.length;++m){let y=i.items[m],{start:N,key:k,sep:S,value:E}=y,v=Rl.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:k??S?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!v.found){if(!v.anchor&&!v.tag&&!S&&!E){m===0&&v.comma?n(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<i.items.length-1&&n(v.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),v.comment&&(l.comment?l.comment+=`
69
- `+v.comment:l.comment=v.comment),d=v.end;continue}!o&&r.options.strict&&Vm.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)v.comma&&n(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(v.comma||n(v.start,"MISSING_CHAR",`Missing , between ${s} items`),v.comment){let x="";e:for(let b of N)switch(b.type){case"comma":case"space":break;case"comment":x=b.source.substring(1);break e;default:break e}if(x){let b=l.items[l.items.length-1];Bm.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
70
- `+x:b.comment=x,v.comment=v.comment.substring(x.length+1)}}if(!o&&!S&&!v.found){let x=E?t(r,E,v,n):e(r,v.end,S,null,v,n);l.items.push(x),d=x.range[2],eo(E)&&n(x.range,"BLOCK_IN_FLOW",Za)}else{r.atKey=!0;let x=v.end,b=k?t(r,k,v,n):e(r,x,N,null,v,n);eo(k)&&n(b.range,"BLOCK_IN_FLOW",Za),r.atKey=!1;let A=Rl.resolveProps(S??[],{flow:s,indicator:"map-value-ind",next:E,offset:b.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(A.found){if(!o&&!v.found&&r.options.strict){if(S)for(let $ of S){if($===A.found)break;if($.type==="newline"){n($,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}v.start<A.found.offset-1024&&n(A.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(A.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let G=E?t(r,E,A,n):A.found?e(r,A.end,S,null,A,n):null;G?eo(E)&&n(G.range,"BLOCK_IN_FLOW",Za):A.comment&&(b.comment?b.comment+=`
71
- `+A.comment:b.comment=A.comment);let wt=new Lm.Pair(b,G);if(r.options.keepSourceTokens&&(wt.srcToken=y),o){let $=l;qm.mapIncludes(r,$.items,b)&&n(x,"DUPLICATE_KEY","Map keys must be unique"),$.items.push(wt)}else{let $=new Pl.YAMLMap(r.schema);$.flow=!0,$.items.push(wt);let Es=(G??b).range;$.range=[b.range[0],Es[1],Es[2]],l.items.push($)}d=G?G.range[2]:A.end}}let f=o?"}":"]",[p,...g]=i.end,h=d;if(p?.source===f)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),y=u?`${m} must end with a ${f}`:`${m} in block collection must be sufficiently indented and end with a ${f}`;n(d,u?"MISSING_CHAR":"BAD_INDENT",y),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let m=Fm.resolveEnd(g,h,r.options.strict,n);m.comment&&(l.comment?l.comment+=`
72
- `+m.comment:l.comment=m.comment),l.range=[i.offset,h,m.offset]}else l.range=[i.offset,h,h];return l}Al.resolveFlowCollection=Wm});var Il=w(Tl=>{"use strict";var zm=C(),Jm=j(),Gm=qe(),Um=We(),Km=Sl(),Ym=Cl(),Xm=_l();function to(t,e,r,i,n,a){let o=r.type==="block-map"?Km.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?Ym.resolveBlockSeq(t,e,r,i,a):Xm.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 Qm(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:p}=i,g=f&&a?f.offset>a.offset?f:a:f??a;g&&(!p||p.offset<g.offset)&&n(g,"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===Gm.YAMLMap.tagName&&s==="map"||o===Um.YAMLSeq.tagName&&s==="seq")return to(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),to(t,e,r,n,o)}let l=to(t,e,r,n,o,c),u=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),e.options)??l,d=zm.isNode(u)?u:new Jm.Scalar(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}Tl.composeCollection=Qm});var io=w(jl=>{"use strict";var ro=j();function Zm(t,e,r){let i=e.offset,n=ev(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?ro.Scalar.BLOCK_FOLDED:ro.Scalar.BLOCK_LITERAL,o=e.source?tv(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
65
+ `}};pr.YAMLError=hr;pr.YAMLParseError=Za;pr.YAMLWarning=eo;pr.prettifyError=Lm});var vr=w(yl=>{"use strict";function Bm(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d="",f="",p=!1,g=!1,h=null,m=null,y=null,N=null,k=null,S=null,E=null;for(let b of t)switch(g&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&a(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),h&&(l&&b.type!=="comment"&&b.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),b.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&b.source.includes(" ")&&(h=b),u=!0;break;case"comment":{u||a(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=b.source.substring(1)||" ";d?d+=f+_:d=_,f="",l=!1;break}case"newline":l?d?d+=b.source:(!S||r!=="seq-item-ind")&&(c=!0):f+=b.source,l=!0,p=!0,(m||y)&&(N=b),u=!0;break;case"anchor":m&&a(b,"MULTIPLE_ANCHORS","A node can have at most one anchor"),b.source.endsWith(":")&&a(b.offset+b.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=b,E??(E=b.offset),l=!1,u=!1,g=!0;break;case"tag":{y&&a(b,"MULTIPLE_TAGS","A node can have at most one tag"),y=b,E??(E=b.offset),l=!1,u=!1,g=!0;break}case r:(m||y)&&a(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),S&&a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${e??"collection"}`),S=b,l=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(e){k&&a(b,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=b,l=!1,u=!1;break}default:a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,u=!1}let v=t[t.length-1],P=v?v.offset+v.source.length:n;return g&&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:k,found:S,spaceBefore:c,comment:d,hasNewline:p,anchor:m,tag:y,newlineAfterProp:N,end:P,start:E??P}}yl.resolveProps=Bm});var Ii=w(Nl=>{"use strict";function to(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(to(e.key)||to(e.value))return!0}return!1;default:return!0}}Nl.containsNewline=to});var ro=w(bl=>{"use strict";var Mm=Ii();function Fm(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&Mm.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}bl.flowIndentCheck=Fm});var io=w(Sl=>{"use strict";var kl=x();function Vm(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||kl.isScalar(a)&&kl.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}Sl.mapIncludes=Vm});var Al=w(Rl=>{"use strict";var El=qe(),qm=ze(),Cl=vr(),Wm=Ii(),xl=ro(),zm=io(),Pl="All mapping items must start at the same column";function Jm({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??qm.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:p,value:g}=u,h=Cl.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),m=!h.found;if(m){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",Pl)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Wm.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&n(c,"BAD_INDENT",Pl);r.atKey=!0;let y=h.end,N=f?t(r,f,h,n):e(r,y,d,null,h,n);r.schema.compat&&xl.flowIndentCheck(i.indent,f,n),r.atKey=!1,zm.mapIncludes(r,s.items,N)&&n(y,"DUPLICATE_KEY","Map keys must be unique");let k=Cl.resolveProps(p??[],{indicator:"map-value-ind",next:g,offset:N.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=k.end,k.found){m&&(g?.type==="block-map"&&!k.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<k.found.offset-1024&&n(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=g?t(r,g,k,n):e(r,c,p,null,k,n);r.schema.compat&&xl.flowIndentCheck(i.indent,g,n),c=S.range[2];let E=new El.Pair(N,S);r.options.keepSourceTokens&&(E.srcToken=u),s.items.push(E)}else{m&&n(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(N.comment?N.comment+=`
68
+ `+k.comment:N.comment=k.comment);let S=new El.Pair(N);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}Rl.resolveBlockMap=Jm});var Tl=w(_l=>{"use strict";var Gm=Je(),Um=vr(),Km=ro();function Ym({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Gm.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=Um.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 p=d?t(r,d,f,n):e(r,f.end,u,null,f,n);r.schema.compat&&Km.flowIndentCheck(i.indent,d,n),c=p.range[2],s.items.push(p)}return s.range=[i.offset,c,l??c],s}_l.resolveBlockSeq=Ym});var _t=w(Il=>{"use strict";function Xm(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}}Il.resolveEnd=Xm});var Hl=w(Ol=>{"use strict";var Qm=x(),Zm=qe(),jl=ze(),ev=Je(),tv=_t(),$l=vr(),rv=Ii(),iv=io(),no="Block collections are not allowed within flow collections",ao=t=>t&&(t.type==="block-map"||t.type==="block-seq");function nv({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?jl.YAMLMap:ev.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 m=0;m<i.items.length;++m){let y=i.items[m],{start:N,key:k,sep:S,value:E}=y,v=$l.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:k??S?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!v.found){if(!v.anchor&&!v.tag&&!S&&!E){m===0&&v.comma?n(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<i.items.length-1&&n(v.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),v.comment&&(l.comment?l.comment+=`
69
+ `+v.comment:l.comment=v.comment),d=v.end;continue}!o&&r.options.strict&&rv.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)v.comma&&n(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(v.comma||n(v.start,"MISSING_CHAR",`Missing , between ${s} items`),v.comment){let P="";e:for(let b of N)switch(b.type){case"comma":case"space":break;case"comment":P=b.source.substring(1);break e;default:break e}if(P){let b=l.items[l.items.length-1];Qm.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
70
+ `+P:b.comment=P,v.comment=v.comment.substring(P.length+1)}}if(!o&&!S&&!v.found){let P=E?t(r,E,v,n):e(r,v.end,S,null,v,n);l.items.push(P),d=P.range[2],ao(E)&&n(P.range,"BLOCK_IN_FLOW",no)}else{r.atKey=!0;let P=v.end,b=k?t(r,k,v,n):e(r,P,N,null,v,n);ao(k)&&n(b.range,"BLOCK_IN_FLOW",no),r.atKey=!1;let _=$l.resolveProps(S??[],{flow:s,indicator:"map-value-ind",next:E,offset:b.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(_.found){if(!o&&!v.found&&r.options.strict){if(S)for(let H of S){if(H===_.found)break;if(H.type==="newline"){n(H,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}v.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 U=E?t(r,E,_,n):_.found?e(r,_.end,S,null,_,n):null;U?ao(E)&&n(U.range,"BLOCK_IN_FLOW",no):_.comment&&(b.comment?b.comment+=`
71
+ `+_.comment:b.comment=_.comment);let Nt=new Zm.Pair(b,U);if(r.options.keepSourceTokens&&(Nt.srcToken=y),o){let H=l;iv.mapIncludes(r,H.items,b)&&n(P,"DUPLICATE_KEY","Map keys must be unique"),H.items.push(Nt)}else{let H=new jl.YAMLMap(r.schema);H.flow=!0,H.items.push(Nt);let _s=(U??b).range;H.range=[b.range[0],_s[1],_s[2]],l.items.push(H)}d=U?U.range[2]:_.end}}let f=o?"}":"]",[p,...g]=i.end,h=d;if(p?.source===f)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),y=u?`${m} must end with a ${f}`:`${m} in block collection must be sufficiently indented and end with a ${f}`;n(d,u?"MISSING_CHAR":"BAD_INDENT",y),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let m=tv.resolveEnd(g,h,r.options.strict,n);m.comment&&(l.comment?l.comment+=`
72
+ `+m.comment:l.comment=m.comment),l.range=[i.offset,h,m.offset]}else l.range=[i.offset,h,h];return l}Ol.resolveFlowCollection=nv});var Ll=w(Dl=>{"use strict";var av=x(),ov=$(),sv=ze(),cv=Je(),lv=Al(),uv=Tl(),dv=Hl();function oo(t,e,r,i,n,a){let o=r.type==="block-map"?lv.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?uv.resolveBlockSeq(t,e,r,i,a):dv.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 fv(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:p}=i,g=f&&a?f.offset>a.offset?f:a:f??a;g&&(!p||p.offset<g.offset)&&n(g,"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===sv.YAMLMap.tagName&&s==="map"||o===cv.YAMLSeq.tagName&&s==="seq")return oo(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),oo(t,e,r,n,o)}let l=oo(t,e,r,n,o,c),u=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),e.options)??l,d=av.isNode(u)?u:new ov.Scalar(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}Dl.composeCollection=fv});var co=w(Bl=>{"use strict";var so=$();function hv(t,e,r){let i=e.offset,n=pv(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?so.Scalar.BLOCK_FOLDED:so.Scalar.BLOCK_LITERAL,o=e.source?mv(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
73
  `.repeat(Math.max(1,o.length-1)):"",m=i+n.length;return e.source&&(m+=e.source.length),{value:h,type:a,comment:n.comment,range:[i,m,m]}}let c=e.indent+n.indent,l=e.offset+n.length,u=0;for(let h=0;h<s;++h){let[m,y]=o[h];if(y===""||y==="\r")n.indent===0&&m.length>c&&(c=m.length);else{m.length<c&&r(l+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=m.length),u=h,c===0&&!t.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+y.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let d="",f="",p=!1;for(let h=0;h<u;++h)d+=o[h][0].slice(c)+`
74
- `;for(let h=u;h<s;++h){let[m,y]=o[h];l+=m.length+y.length+1;let N=y[y.length-1]==="\r";if(N&&(y=y.slice(0,-1)),y&&m.length<c){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-y.length-(N?2:1),"BAD_INDENT",S),m=""}a===ro.Scalar.BLOCK_LITERAL?(d+=f+m.slice(c)+y,f=`
74
+ `;for(let h=u;h<s;++h){let[m,y]=o[h];l+=m.length+y.length+1;let N=y[y.length-1]==="\r";if(N&&(y=y.slice(0,-1)),y&&m.length<c){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-y.length-(N?2:1),"BAD_INDENT",S),m=""}a===so.Scalar.BLOCK_LITERAL?(d+=f+m.slice(c)+y,f=`
75
75
  `):m.length>c||y[0]===" "?(f===" "?f=`
76
76
  `:!p&&f===`
77
77
  `&&(f=`
@@ -84,85 +84,92 @@ ${l}
84
84
  `+o[h][0].slice(c);d[d.length-1]!==`
85
85
  `&&(d+=`
86
86
  `);break;default:d+=`
87
- `}let g=i+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[i,g,g]}}function ev({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 p=n[f];if(!s&&(p==="-"||p==="+"))s=p;else{let g=Number(p);!o&&g?o=g: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 p=e[f];switch(p.type){case"space":l=!0;case"newline":d+=p.source.length;break;case"comment":r&&!l&&i(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,u=p.source.substring(1);break;case"error":i(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let g=`Unexpected token in block scalar header: ${p.type}`;i(p,"UNEXPECTED_TOKEN",g);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function tv(t){let e=t.split(/\n( *)/),r=e[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}jl.resolveBlockScalar=Zm});var ao=w(Ol=>{"use strict";var no=j(),rv=Rt();function iv(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(f,p,g)=>r(i+f,p,g);switch(n){case"scalar":s=no.Scalar.PLAIN,c=nv(a,l);break;case"single-quoted-scalar":s=no.Scalar.QUOTE_SINGLE,c=av(a,l);break;case"double-quoted-scalar":s=no.Scalar.QUOTE_DOUBLE,c=ov(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=rv.resolveEnd(o,u,e,r);return{value:c,type:s,comment:d.comment,range:[i,u,d.offset]}}function nv(t,e){let r="";switch(t[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${t[0]}`;break}case"@":case"`":{r=`reserved character ${t[0]}`;break}}return r&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),$l(t)}function av(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),$l(t.slice(1,-1)).replace(/''/g,"'")}function $l(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
+ `}let g=i+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[i,g,g]}}function pv({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 p=n[f];if(!s&&(p==="-"||p==="+"))s=p;else{let g=Number(p);!o&&g?o=g: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 p=e[f];switch(p.type){case"space":l=!0;case"newline":d+=p.source.length;break;case"comment":r&&!l&&i(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,u=p.source.substring(1);break;case"error":i(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let g=`Unexpected token in block scalar header: ${p.type}`;i(p,"UNEXPECTED_TOKEN",g);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function mv(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}Bl.resolveBlockScalar=hv});var uo=w(Fl=>{"use strict";var lo=$(),vv=_t();function gv(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(f,p,g)=>r(i+f,p,g);switch(n){case"scalar":s=lo.Scalar.PLAIN,c=wv(a,l);break;case"single-quoted-scalar":s=lo.Scalar.QUOTE_SINGLE,c=yv(a,l);break;case"double-quoted-scalar":s=lo.Scalar.QUOTE_DOUBLE,c=Nv(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=vv.resolveEnd(o,u,e,r);return{value:c,type:s,comment:d.comment,range:[i,u,d.offset]}}function wv(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}`),Ml(t)}function yv(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Ml(t.slice(1,-1)).replace(/''/g,"'")}function Ml(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 ov(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 Nv(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}=sv(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=cv[a];if(o)r+=o;else if(a===`
93
+ `){let{fold:a,offset:o}=bv(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=kv[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+=lv(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+=Sv(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 sv(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 bv(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 cv={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function lv(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=iv});var Bl=w(Dl=>{"use strict";var nt=C(),Hl=j(),uv=io(),dv=ao();function fv(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?uv.resolveBlockScalar(t,e,i):dv.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[nt.SCALAR]:c?l=hv(t.schema,n,c,r,i):e.type==="scalar"?l=pv(t,n,e,i):l=t.schema[nt.SCALAR];let u;try{let d=l.resolve(n,f=>i(r??e,"TAG_RESOLVE_FAILED",f),t.options);u=nt.isScalar(d)?d:new Hl.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);i(r??e,"TAG_RESOLVE_FAILED",f),u=new Hl.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 hv(t,e,r,i,n){if(r==="!")return t[nt.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[nt.SCALAR])}function pv({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[nt.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[nt.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}Dl.composeScalar=fv});var Ml=w(Ll=>{"use strict";function mv(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=mv});var ql=w(so=>{"use strict";var vv=Gt(),gv=C(),wv=Il(),Fl=Bl(),yv=Rt(),Nv=Ml(),bv={composeNode:Vl,composeEmptyNode:oo};function Vl(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=kv(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=wv.composeCollection(bv,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=oo(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&&(!gv.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 oo(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let u={type:"scalar",offset:Nv.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 kv({options:t},{offset:e,source:r,end:i},n){let a=new vv.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=yv.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}so.composeEmptyNode=oo;so.composeNode=Vl});var Jl=w(zl=>{"use strict";var Sv=lr(),Wl=ql(),Ev=Rt(),Cv=hr();function xv(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new Sv.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=Cv.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?Wl.composeNode(l,n,u,o):Wl.composeEmptyNode(l,u.end,i,null,u,o);let d=c.contents.range[2],f=Ev.resolveEnd(a,d,!1,o);return f.comment&&(c.comment=f.comment),c.range=[r,d,f.offset],c}zl.composeDoc=xv});var lo=w(Kl=>{"use strict";var Pv=Lr("process"),Rv=Un(),Av=lr(),pr=fr(),Gl=C(),_v=Jl(),Tv=Rt();function mr(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:r}=t;return[e,e+(typeof r=="string"?r.length:1)]}function Ul(t){let e="",r=!1,i=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":i?`
101
+ `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var kv={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Sv(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}}Fl.resolveFlowScalar=gv});var Wl=w(ql=>{"use strict";var ot=x(),Vl=$(),Ev=co(),Cv=uo();function xv(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?Ev.resolveBlockScalar(t,e,i):Cv.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[ot.SCALAR]:c?l=Pv(t.schema,n,c,r,i):e.type==="scalar"?l=Rv(t,n,e,i):l=t.schema[ot.SCALAR];let u;try{let d=l.resolve(n,f=>i(r??e,"TAG_RESOLVE_FAILED",f),t.options);u=ot.isScalar(d)?d:new Vl.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);i(r??e,"TAG_RESOLVE_FAILED",f),u=new Vl.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 Pv(t,e,r,i,n){if(r==="!")return t[ot.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[ot.SCALAR])}function Rv({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[ot.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[ot.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}ql.composeScalar=xv});var Jl=w(zl=>{"use strict";function Av(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}zl.emptyScalarPosition=Av});var Kl=w(ho=>{"use strict";var _v=Yt(),Tv=x(),Iv=Ll(),Gl=Wl(),jv=_t(),$v=Jl(),Ov={composeNode:Ul,composeEmptyNode:fo};function Ul(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=Hv(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=Gl.composeScalar(t,e,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Iv.composeCollection(Ov,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=fo(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&&(!Tv.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 fo(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let u={type:"scalar",offset:$v.emptyScalarPosition(e,r,i),indent:-1,source:""},d=Gl.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 Hv({options:t},{offset:e,source:r,end:i},n){let a=new _v.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=jv.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}ho.composeEmptyNode=fo;ho.composeNode=Ul});var Ql=w(Xl=>{"use strict";var Dv=fr(),Yl=Kl(),Lv=_t(),Bv=vr();function Mv(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new Dv.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=Bv.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?Yl.composeNode(l,n,u,o):Yl.composeEmptyNode(l,u.end,i,null,u,o);let d=c.contents.range[2],f=Lv.resolveEnd(a,d,!1,o);return f.comment&&(c.comment=f.comment),c.range=[r,d,f.offset],c}Xl.composeDoc=Mv});var mo=w(tu=>{"use strict";var Fv=Fr("process"),Vv=Zn(),qv=fr(),gr=mr(),Zl=x(),Wv=Ql(),zv=_t();function wr(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 eu(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 co=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=mr(r);a?this.warnings.push(new pr.YAMLWarning(o,i,n)):this.errors.push(new pr.YAMLParseError(o,i,n))},this.directives=new Rv.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=Ul(this.prelude);if(i){let a=e.contents;if(r)e.comment=e.comment?`${e.comment}
106
- ${i}`:i;else if(n||e.directives.docStart||!a)e.commentBefore=i;else if(Gl.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Gl.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
105
+ `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:e,afterEmptyLine:i}}var po=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=wr(r);a?this.warnings.push(new gr.YAMLWarning(o,i,n)):this.errors.push(new gr.YAMLParseError(o,i,n))},this.directives=new Vv.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=eu(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(Zl.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Zl.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
107
107
  ${s}`:i}else{let o=a.commentBefore;a.commentBefore=o?`${i}
108
- ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)e.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)e.warnings.push(this.warnings[a])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Ul(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,r=!1,i=-1){for(let n of e)yield*this.next(n);yield*this.end(r,i)}*next(e){switch(Pv.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=mr(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=_v.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 pr.YAMLParseError(mr(e),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new pr.YAMLParseError(mr(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=Tv.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 pr.YAMLParseError(mr(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let i=Object.assign({_directives:this.directives},this.options),n=new Av.Document(void 0,i);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,r,r],this.decorate(n,!1),yield n}}};Kl.Composer=co});var Ql=w(Ti=>{"use strict";var Iv=io(),jv=ao(),$v=fr(),Yl=Qt();function Ov(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 $v.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return jv.resolveFlowScalar(t,e,i);case"block-scalar":return Iv.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function Hv(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=Yl.stringifyString({type:o,value:t},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:i,source:`
108
+ ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)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:eu(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(Fv.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=wr(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=Wv.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 gr.YAMLParseError(wr(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 gr.YAMLParseError(wr(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=zv.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 gr.YAMLParseError(wr(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 qv.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}}};tu.Composer=po});var nu=w(ji=>{"use strict";var Jv=co(),Gv=uo(),Uv=mr(),ru=tr();function Kv(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 Uv.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Gv.resolveFlowScalar(t,e,i);case"block-scalar":return Jv.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function Yv(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=ru.stringifyString({type:o,value:t},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:i,source:`
110
110
  `}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
111
111
  `),u=s.substring(0,l),d=s.substring(l+1)+`
112
- `,f=[{type:"block-scalar-header",offset:a,indent:i,source:u}];return Xl(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 Dv(t,e,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in t?t.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Yl.stringifyString({type:o,value:e},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":Bv(t,c);break;case'"':uo(t,c,"double-quoted-scalar");break;case"'":uo(t,c,"single-quoted-scalar");break;default:uo(t,c,"scalar")}}function Bv(t,e){let r=e.indexOf(`
112
+ `,f=[{type:"block-scalar-header",offset:a,indent:i,source:u}];return iu(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 Xv(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=ru.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">":Qv(t,c);break;case'"':vo(t,c,"double-quoted-scalar");break;case"'":vo(t,c,"single-quoted-scalar");break;default:vo(t,c,"scalar")}}function Qv(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}];Xl(s,"end"in t?t.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
- `});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:s,source:n})}}function Xl(t,e){if(e)for(let r of e)switch(r.type){case"space":case"comment":t.push(r);break;case"newline":return t.push(r),!0}return!1}function uo(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})}}}Ti.createScalarToken=Hv;Ti.resolveAsScalar=Ov;Ti.setScalarValue=Dv});var eu=w(Zl=>{"use strict";var Lv=t=>"type"in t?ji(t):Ii(t);function ji(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=ji(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=Ii(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=Ii(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=Ii(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 Ii({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=ji(e)),r)for(let a of r)n+=a.source;return i&&(n+=ji(i)),n}Zl.stringify=Lv});var nu=w(iu=>{"use strict";var fo=Symbol("break visit"),Mv=Symbol("skip children"),tu=Symbol("remove item");function at(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),ru(Object.freeze([]),t,e)}at.BREAK=fo;at.SKIP=Mv;at.REMOVE=tu;at.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};at.parentCollection=(t,e)=>{let r=at.itemAtPath(t,e.slice(0,-1)),i=e[e.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function ru(t,e,r){let i=r(e,t);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=e[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=ru(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===fo)return fo;s===tu&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}iu.visit=at});var $i=w(J=>{"use strict";var ho=Ql(),Fv=eu(),Vv=nu(),po="\uFEFF",mo="",vo="",go="",qv=t=>!!t&&"items"in t,Wv=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function zv(t){switch(t){case po:return"<BOM>";case mo:return"<DOC>";case vo:return"<FLOW_END>";case go:return"<SCALAR>";default:return JSON.stringify(t)}}function Jv(t){switch(t){case po:return"byte-order-mark";case mo:return"doc-mode";case vo:return"flow-error-end";case go: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}];iu(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 iu(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 vo(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})}}}ji.createScalarToken=Yv;ji.resolveAsScalar=Kv;ji.setScalarValue=Xv});var ou=w(au=>{"use strict";var Zv=t=>"type"in t?Oi(t):$i(t);function Oi(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=Oi(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=$i(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=$i(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=$i(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 $i({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Oi(e)),r)for(let a of r)n+=a.source;return i&&(n+=Oi(i)),n}au.stringify=Zv});var uu=w(lu=>{"use strict";var go=Symbol("break visit"),eg=Symbol("skip children"),su=Symbol("remove item");function st(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),cu(Object.freeze([]),t,e)}st.BREAK=go;st.SKIP=eg;st.REMOVE=su;st.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};st.parentCollection=(t,e)=>{let r=st.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 cu(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=cu(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===go)return go;s===su&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}lu.visit=st});var Hi=w(G=>{"use strict";var wo=nu(),tg=ou(),rg=uu(),yo="\uFEFF",No="",bo="",ko="",ig=t=>!!t&&"items"in t,ng=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function ag(t){switch(t){case yo:return"<BOM>";case No:return"<DOC>";case bo:return"<FLOW_END>";case ko:return"<SCALAR>";default:return JSON.stringify(t)}}function og(t){switch(t){case yo:return"byte-order-mark";case No:return"doc-mode";case bo:return"flow-error-end";case ko: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}J.createScalarToken=ho.createScalarToken;J.resolveAsScalar=ho.resolveAsScalar;J.setScalarValue=ho.setScalarValue;J.stringify=Fv.stringify;J.visit=Vv.visit;J.BOM=po;J.DOCUMENT=mo;J.FLOW_END=vo;J.SCALAR=go;J.isCollection=qv;J.isScalar=Wv;J.prettyToken=zv;J.tokenType=Jv});var No=w(ou=>{"use strict";var vr=$i();function oe(t){switch(t){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var au=new Set("0123456789ABCDEFabcdef"),Gv=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Oi=new Set(",[]{}"),Uv=new Set(` ,[]{}
121
- \r `),wo=t=>!t||Uv.has(t),yo=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=wo.createScalarToken;G.resolveAsScalar=wo.resolveAsScalar;G.setScalarValue=wo.setScalarValue;G.stringify=tg.stringify;G.visit=rg.visit;G.BOM=yo;G.DOCUMENT=No;G.FLOW_END=bo;G.SCALAR=ko;G.isCollection=ig;G.isScalar=ng;G.prettyToken=ag;G.tokenType=og});var Co=w(fu=>{"use strict";var yr=Hi();function se(t){switch(t){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var du=new Set("0123456789ABCDEFabcdef"),sg=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Di=new Set(",[]{}"),cg=new Set(` ,[]{}
121
+ \r `),So=t=>!t||cg.has(t),Eo=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
- `||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]===vr.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let r=e.length,i=e.indexOf("#");for(;i!==-1;){let a=e[i-1];if(a===" "||a===" "){r=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let a=e[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-r),yield*this.pushNewline(),"stream"}return yield vr.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&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(wo),"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 vr.FLOW_END,yield*this.parseLineStart();let a=0;for(;n[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(wo),"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(`
125
+ `||i>=this.indentNext||!r&&!this.atEnd?e+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&se(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
126
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===yr.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 yr.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&se(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!se(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&se(r)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(e[r]){case"#":yield*this.pushCount(e.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(So),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,i=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&se(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield yr.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(So),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||se(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
127
127
  `,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=i.indexOf(`
128
- `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>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`
128
+ `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>se(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
129
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 vr.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(oe(a)||e&&Oi.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 yr.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(se(a)||e&&Di.has(a))break;r=i}else if(se(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
134
134
  `?(i+=1,n=`
135
- `,a=this.buffer[i+1]):r=i),a==="#"||e&&Oi.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&&Oi.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield vr.SCALAR,yield*this.pushToIndex(r+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,r){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(wo),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(oe(i)||r&&Oi.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(Gv.has(r))r=this.buffer[++e];else if(r==="%"&&au.has(this.buffer[e+1])&&au.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
135
+ `,a=this.buffer[i+1]):r=i),a==="#"||e&&Di.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&&Di.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield yr.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(So),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(se(i)||r&&Di.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,r=this.buffer[e];for(;!se(r)&&r!==">";)r=this.buffer[++e];return yield*this.pushToIndex(r===">"?e+1:e,!1)}else{let e=this.pos+1,r=this.buffer[e];for(;r;)if(sg.has(r))r=this.buffer[++e];else if(r==="%"&&du.has(this.buffer[e+1])&&du.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)}};ou.Lexer=yo});var ko=w(su=>{"use strict";var bo=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<e?r=a+1:i=a}if(this.lineStarts[r]===e)return{line:r+1,col:1};if(r===0)return{line:0,col:e};let n=this.lineStarts[r-1];return{line:r,col:e-n+1}}}};su.LineCounter=bo});var Eo=w(fu=>{"use strict";var Kv=Lr("process"),cu=$i(),Yv=No();function ze(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function lu(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function du(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Hi(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 At(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 Di(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let r=0;r<e.length;++r)t.push(e[r])}function uu(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!ze(e.start,"explicit-key-ind")&&!ze(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,du(e.value)?e.value.end?Di(e.value.end,e.sep):e.value.end=e.sep:Di(e.start,e.sep),delete e.sep)}var So=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 Yv.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,Kv.env.LOG_TOKENS&&console.log("|",cu.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=cu.tokenType(e);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let r=e??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let i=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in i?i.indent:0:r.type==="flow-collection"&&i.type==="document"&&(r.indent=0),r.type==="flow-collection"&&uu(r),i.type){case"document":i.value=r;break;case"block-scalar":i.props.push(r);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=r;else{Object.assign(n,{key:r,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:r}):n.value=r;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:r,sep:[]}):n.sep?n.value=r:Object.assign(n,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let n=r.items[r.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&lu(n.start)===-1&&(r.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<r.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{lu(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let r=Hi(this.peek(2)),i=At(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)}};fu.Lexer=Eo});var Po=w(hu=>{"use strict";var xo=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}}}};hu.LineCounter=xo});var Ao=w(wu=>{"use strict";var lg=Fr("process"),pu=Hi(),ug=Co();function Ge(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function mu(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 gu(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 Li(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 Tt(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 Bi(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 vu(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Ge(e.start,"explicit-key-ind")&&!Ge(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,gu(e.value)?e.value.end?Bi(e.value.end,e.sep):e.value.end=e.sep:Bi(e.start,e.sep),delete e.sep)}var Ro=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 ug.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,lg.env.LOG_TOKENS&&console.log("|",pu.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=pu.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"&&vu(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&&mu(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":{mu(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=Li(this.peek(2)),i=Tt(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)){Di(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(ze(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(du(r.key)&&!ze(r.sep,"newline")){let o=At(r.start),s=r.key,c=r.sep;c.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?r.sep=r.sep.concat(a,this.sourceToken):r.sep.push(this.sourceToken);else if(ze(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=At(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]}):ze(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||r.value?(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&&!ze(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&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)){Di(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||ze(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=Hi(i),a=At(n);uu(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
140
+ `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(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)){Bi(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(Ge(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(gu(r.key)&&!Ge(r.sep,"newline")){let o=Tt(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(Ge(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Tt(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]}):Ge(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&&!Ge(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)){Bi(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||Ge(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=Li(i),a=Tt(n);vu(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=Hi(e),i=At(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=Hi(e),i=At(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};fu.Parser=So});var gu=w(wr=>{"use strict";var hu=lo(),Xv=lr(),gr=fr(),Qv=sa(),Zv=C(),eg=ko(),pu=Eo();function mu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new eg.LineCounter||null,prettyErrors:e}}function tg(t,e={}){let{lineCounter:r,prettyErrors:i}=mu(e),n=new pu.Parser(r?.addNewLine),a=new hu.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(gr.prettifyError(t,r)),s.warnings.forEach(gr.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function vu(t,e={}){let{lineCounter:r,prettyErrors:i}=mu(e),n=new pu.Parser(r?.addNewLine),a=new hu.Composer(e),o=null;for(let s of a.compose(n.parse(t),!0,t.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new gr.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(gr.prettifyError(t,r)),o.warnings.forEach(gr.prettifyError(t,r))),o}function rg(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=vu(t,r);if(!n)return null;if(n.warnings.forEach(a=>Qv.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 ig(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 Zv.isDocument(t)&&!i?t.toString(r):new Xv.Document(t,i,r).toString(r)}wr.parse=rg;wr.parseAllDocuments=tg;wr.parseDocument=vu;wr.stringify=ig});var _t=w(P=>{"use strict";var ng=lo(),ag=lr(),og=qa(),Co=fr(),sg=Gt(),Je=C(),cg=Fe(),lg=j(),ug=qe(),dg=We(),fg=$i(),hg=No(),pg=ko(),mg=Eo(),Bi=gu(),wu=qt();P.Composer=ng.Composer;P.Document=ag.Document;P.Schema=og.Schema;P.YAMLError=Co.YAMLError;P.YAMLParseError=Co.YAMLParseError;P.YAMLWarning=Co.YAMLWarning;P.Alias=sg.Alias;P.isAlias=Je.isAlias;P.isCollection=Je.isCollection;P.isDocument=Je.isDocument;P.isMap=Je.isMap;P.isNode=Je.isNode;P.isPair=Je.isPair;P.isScalar=Je.isScalar;P.isSeq=Je.isSeq;P.Pair=cg.Pair;P.Scalar=lg.Scalar;P.YAMLMap=ug.YAMLMap;P.YAMLSeq=dg.YAMLSeq;P.CST=fg;P.Lexer=hg.Lexer;P.LineCounter=pg.LineCounter;P.Parser=mg.Parser;P.parse=Bi.parse;P.parseAllDocuments=Bi.parseAllDocuments;P.parseDocument=Bi.parseDocument;P.stringify=Bi.stringify;P.visit=wu.visit;P.visitAsync=wu.visitAsync});import{promises as _b}from"fs";import ge from"path";var Af=null;function _f(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function Mr(t,e){return(...r)=>{let i=Af;if(i===null)return e(...r);let n=_f(`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}}import{readFileSync as Tf}from"fs";import xs from"path";function Fn(t){return t.charCodeAt(0)===65279?t.slice(1):t}var If=new Set(["applypatch","create","createfile","deletefile","edit","editfile","patch","searchreplace","strreplaceeditor","write","writefile","writefiletool"]),jf=new Set(["glob","grep","listfiles","read","readfile","search","view"]),Ps=["file_path","filePath","path","target_file","targetFile"],Rs=["file_paths","filePaths","paths","files","targets"],As=["operations","edits"],$f=["patch","diff","patchText","patch_text","changes"];function Wn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Vn(t){return t.toLowerCase().replace(/[^a-z0-9]+/gu,"")}function Of(t){for(let e of["tool_name","toolName","tool","name"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}return null}function Hf(t){for(let e of["cwd","working_directory","workspaceRoot"]){let r=t[e];if(!(typeof r!="string"||!r.trim()||!xs.isAbsolute(r.trim())))return xs.resolve(r.trim())}}function Df(t){for(let e of["session_id","sessionId","conversation_id","conversationId"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim().slice(0,256)}}function Bf(t){for(let e of["hook_event_name","hookEventName","event_name","eventName"]){let r=t[e];if(typeof r=="string"&&r.trim())return Vn(r)}}function Lf(t){for(let e of["task","prompt","user_prompt","userPrompt"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}}function Mf(t){if(typeof t!="string")return t;let e=t.trim();if(!e.startsWith("{")&&!e.startsWith("["))return t;try{return JSON.parse(e)}catch{return t}}function Ff(t){for(let e of["tool_input","toolInput","toolArgs","tool_args","arguments"])if(t[e]!==void 0)return Mf(t[e]);return t}function qn(t){let e=[],r=[/^\*\*\* (?:Add|Update|Delete) File:\s+(.+?)\s*$/gmu,/^\+\+\+\s+(?:b\/)?(.+?)\s*$/gmu];for(let i of r)for(let n of t.matchAll(i)){let a=n[1]?.trim();a&&a!=="/dev/null"&&e.push(a)}return e}function Ze(t,e){if(typeof e=="string"){let r=e.trim();r&&t.push(r);return}if(Array.isArray(e)){for(let r of e)Ze(t,r);return}if(Wn(e)){for(let r of Ps)Ze(t,e[r]);for(let r of Rs)Ze(t,e[r]);for(let r of As)Ze(t,e[r])}}function Vf(t,e){let r=[],i=[e,t].filter(Wn);for(let n of i){for(let a of Ps)Ze(r,n[a]);for(let a of Rs)Ze(r,n[a]);for(let a of As)Ze(r,n[a]);for(let a of $f){let o=n[a];typeof o=="string"&&r.push(...qn(o))}}return typeof e=="string"&&r.push(...qn(e)),[...new Set(r)]}function Vt(t,e){if(e?.trim())return{intent:"write",targets:[e.trim()],toolName:null};if(!t.trim())return{intent:"unknown",targets:[],toolName:null};let r;try{r=JSON.parse(Fn(t))}catch{let s=qn(t);return s.length>0?{intent:"write",targets:[...new Set(s)],toolName:"apply_patch"}:{intent:"unknown",targets:[],toolName:null}}if(!Wn(r))return{intent:"unknown",targets:[],toolName:null};let i=Of(r),n=Vf(r,Ff(r)),a=Hf(r),o=Df(r);if(Bf(r)==="beforeagentstart"){let s=Lf(r);return{intent:"context",targets:[],toolName:null,...s?{task:s}:{},...a?{cwd:a}:{},...o?{sessionId:o}:{}}}return i&&If.has(Vn(i))?{intent:n.length>0?"write":"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i&&jf.has(Vn(i))?{intent:"non-write",targets:[],toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i?{intent:"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:{intent:n.length>0?"write":"unknown",targets:n,toolName:null,...a?{cwd:a}:{},...o?{sessionId:o}:{}}}function _s(){let t=process.env.FILE_PATH;if(t?.trim()||process.stdin.isTTY)return Vt("",t);try{return Vt(Tf(0,"utf8"),t)}catch{return Vt("",t)}}var fs=Ft(_t(),1);import{promises as MN}from"fs";import ht from"path";import{execFileSync as vg}from"child_process";import Mi from"path";function Li(t,e){return vg("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function gg(t,e){let r=Mi.normalize(t),i=Mi.normalize(e);return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function se(t){try{let e=Mi.resolve(Li(t,["rev-parse","--show-toplevel"])),i=Li(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?Mi.resolve(i.slice(9)):e,a=null;try{a=Li(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!gg(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function yr(t,e){try{let r=Li(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 bg}from"node:crypto";import{promises as ce}from"node:fs";import Y from"node:path";import{TextDecoder as kg}from"node:util";var wg=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),yg=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Ng(t){return t.toLowerCase().startsWith(".env")}function Nr(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>Ng(i))?"environment-file":r.some(i=>yg.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>wg.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}function Ge(t){return t!==0&&t!==0n&&t!=="0"}function Ne(t,e){return Ge(t.dev)&&Ge(e.dev)&&Ge(t.ino)&&Ge(e.ino)}function _(t,e){let r=Ge(t.dev)&&Ge(e.dev);if(r&&t.dev!==e.dev)return!1;let i=Ge(t.ino)&&Ge(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var Vi=1024*1024;function xo(t,e){let r=Y.relative(t,e);return r===""||!Y.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Y.sep}`)}function Sg(t){let e=Y.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||Y.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let r=t.toLowerCase(),i=Nr(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 Eg(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Cg(t,e){return _({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Fi(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return Ne(r,i)?_(r,i):_(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function yu(t){let e=await ce.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await ce.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function xg(t,e){let r=Y.resolve(t),i=Y.resolve(e);if(!xo(r,i))throw new Error("Native artifact path is outside its root");let n=[await yu(r)],a=r;for(let o of Y.relative(r,i).split(Y.sep).filter(Boolean)){a=Y.join(a,o);let s=await yu(a);if(!xo(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Nu(t){for(let e of t){let r=await ce.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Cg(e,r)||await ce.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function X(t){let e=Sg(t.ref),r=t.maxBytes===null?null:Eg(t.maxBytes??Vi),i=Y.resolve(t.root,...e.split("/")),n=await xg(t.root,Y.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await ce.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 ce.realpath(i);if(!xo(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await ce.open(i,"r");try{let[c,l,u]=await Promise.all([s.stat(),ce.lstat(i),ce.realpath(i)]);if(await Nu(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!Fi(a,c)||!Fi(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],f=0,p=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let k=r===null?p.length:r+1-f,S=await s.read(p,0,Math.min(p.length,k),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(p.subarray(0,S.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[g,h,m]=await Promise.all([s.stat(),ce.lstat(i),ce.realpath(i)]);if(await Nu(n),!h.isFile()||h.isSymbolicLink()||m!==o||!Fi(c,g)||!Fi(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let y=Buffer.concat(d,f),N;try{N=new kg("utf-8",{fatal:!0}).decode(y)}catch(k){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:k})}return{ref:e,size:f,hash:t.includeHash===!1?null:bg("sha256").update(y).digest("hex"),text:N}}finally{await s.close()}}import{randomUUID as Pg}from"crypto";import{promises as L}from"fs";import le from"path";function Po(t,e){let r=le.relative(t,e);return r===""||!le.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${le.sep}`)}function Rg(t,e){return _({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Ro(t,e){return _({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function Ag(t,e){return Ro(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function bu(t){let e=await L.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await L.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function br(t){for(let e of t){let r=await L.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Rg(e,r)||await L.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function _g(t,e){let r=le.resolve(t),i=le.resolve(e);if(!Po(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await bu(r)],a=le.relative(r,i).split(le.sep).filter(Boolean),o=r;for(let s of a){await br(n),o=le.join(o,s);try{await L.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await bu(o);if(!Po(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await br(n),n}async function Tg(t){let e;try{e=await L.open(t,"r"),await e.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await e?.close()}}async function Ig(t,e,r={}){let i=le.dirname(t),n=r.containedRoot?await _g(r.containedRoot,i):null;n||await L.mkdir(i,{recursive:!0});let a=le.join(i,`.${le.basename(t)}.${Pg()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await L.open(a,"wx"),s=await o.stat(),n){let[l,u]=await Promise.all([L.lstat(a),L.realpath(a)]);if(await br(n),!l.isFile()||l.isSymbolicLink()||!Ro(s,l)||!Po(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 br(n);let l=await L.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!Ag(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await L.link(a,t),await L.unlink(a)):await L.rename(a,t),await Tg(i)}catch(l){if(await o?.close(),!n)await L.rm(a,{force:!0});else try{await br(n),await L.rm(a,{force:!0})}catch{}throw l}}async function be(t,e,r={}){await Ig(t,e,r)}async function ue(t,e,r={}){await be(t,JSON.stringify(e,null,2)+`
143
- `,r)}var Ao={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:"验证预期"}},jg={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:"结论"}},$g={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:"结论"}},Og=new Map,ku=new Map;for(let t of Object.keys(Ao)){for(let[e,r]of Object.entries(Ao[t]))Og.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(jg[t]))ku.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries($g[t]))ku.set(r.toLocaleLowerCase("en-US"),e)}function Hg(t,e){return Ao[t][e]}function qi(t){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${Hg(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=Li(e),i=Tt(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=Li(e),i=Tt(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())}}};wu.Parser=Ro});var Su=w(br=>{"use strict";var yu=mo(),dg=fr(),Nr=mr(),fg=fa(),hg=x(),pg=Po(),Nu=Ao();function bu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new pg.LineCounter||null,prettyErrors:e}}function mg(t,e={}){let{lineCounter:r,prettyErrors:i}=bu(e),n=new Nu.Parser(r?.addNewLine),a=new yu.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(Nr.prettifyError(t,r)),s.warnings.forEach(Nr.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function ku(t,e={}){let{lineCounter:r,prettyErrors:i}=bu(e),n=new Nu.Parser(r?.addNewLine),a=new yu.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 Nr.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(Nr.prettifyError(t,r)),o.warnings.forEach(Nr.prettifyError(t,r))),o}function vg(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=ku(t,r);if(!n)return null;if(n.warnings.forEach(a=>fg.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 gg(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 hg.isDocument(t)&&!i?t.toString(r):new dg.Document(t,i,r).toString(r)}br.parse=vg;br.parseAllDocuments=mg;br.parseDocument=ku;br.stringify=gg});var It=w(R=>{"use strict";var wg=mo(),yg=fr(),Ng=Ua(),_o=mr(),bg=Yt(),Ue=x(),kg=qe(),Sg=$(),Eg=ze(),Cg=Je(),xg=Hi(),Pg=Co(),Rg=Po(),Ag=Ao(),Mi=Su(),Eu=Jt();R.Composer=wg.Composer;R.Document=yg.Document;R.Schema=Ng.Schema;R.YAMLError=_o.YAMLError;R.YAMLParseError=_o.YAMLParseError;R.YAMLWarning=_o.YAMLWarning;R.Alias=bg.Alias;R.isAlias=Ue.isAlias;R.isCollection=Ue.isCollection;R.isDocument=Ue.isDocument;R.isMap=Ue.isMap;R.isNode=Ue.isNode;R.isPair=Ue.isPair;R.isScalar=Ue.isScalar;R.isSeq=Ue.isSeq;R.Pair=kg.Pair;R.Scalar=Sg.Scalar;R.YAMLMap=Eg.YAMLMap;R.YAMLSeq=Cg.YAMLSeq;R.CST=xg;R.Lexer=Pg.Lexer;R.LineCounter=Rg.LineCounter;R.Parser=Ag.Parser;R.parse=Mi.parse;R.parseAllDocuments=Mi.parseAllDocuments;R.parseDocument=Mi.parseDocument;R.stringify=Mi.stringify;R.visit=Eu.visit;R.visitAsync=Eu.visitAsync});import{promises as zb}from"fs";import we from"path";var qf=null;function Wf(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function Vr(t,e){return(...r)=>{let i=qf;if(i===null)return e(...r);let n=Wf(`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}}import{readFileSync as zf}from"fs";import Is from"path";function Jn(t){return t.charCodeAt(0)===65279?t.slice(1):t}var Jf=new Set(["applypatch","create","createfile","deletefile","edit","editfile","patch","searchreplace","strreplaceeditor","write","writefile","writefiletool"]),Gf=new Set(["glob","grep","listfiles","read","readfile","search","view"]),js=["file_path","filePath","path","target_file","targetFile"],$s=["file_paths","filePaths","paths","files","targets"],Os=["operations","edits"],Uf=["patch","diff","patchText","patch_text","changes"];function Kn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Gn(t){return t.toLowerCase().replace(/[^a-z0-9]+/gu,"")}function Kf(t){for(let e of["tool_name","toolName","tool","name"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}return null}function Yf(t){for(let e of["cwd","working_directory","workspaceRoot"]){let r=t[e];if(!(typeof r!="string"||!r.trim()||!Is.isAbsolute(r.trim())))return Is.resolve(r.trim())}}function Xf(t){for(let e of["session_id","sessionId","conversation_id","conversationId"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim().slice(0,256)}}function Qf(t){for(let e of["hook_event_name","hookEventName","event_name","eventName"]){let r=t[e];if(typeof r=="string"&&r.trim())return Gn(r)}}function Zf(t){for(let e of["task","prompt","user_prompt","userPrompt"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}}function eh(t){if(typeof t!="string")return t;let e=t.trim();if(!e.startsWith("{")&&!e.startsWith("["))return t;try{return JSON.parse(e)}catch{return t}}function th(t){for(let e of["tool_input","toolInput","toolArgs","tool_args","arguments"])if(t[e]!==void 0)return eh(t[e]);return t}function Un(t){let e=[],r=[/^\*\*\* (?:Add|Update|Delete) File:\s+(.+?)\s*$/gmu,/^\+\+\+\s+(?:b\/)?(.+?)\s*$/gmu];for(let i of r)for(let n of t.matchAll(i)){let a=n[1]?.trim();a&&a!=="/dev/null"&&e.push(a)}return e}function tt(t,e){if(typeof e=="string"){let r=e.trim();r&&t.push(r);return}if(Array.isArray(e)){for(let r of e)tt(t,r);return}if(Kn(e)){for(let r of js)tt(t,e[r]);for(let r of $s)tt(t,e[r]);for(let r of Os)tt(t,e[r])}}function rh(t,e){let r=[],i=[e,t].filter(Kn);for(let n of i){for(let a of js)tt(r,n[a]);for(let a of $s)tt(r,n[a]);for(let a of Os)tt(r,n[a]);for(let a of Uf){let o=n[a];typeof o=="string"&&r.push(...Un(o))}}return typeof e=="string"&&r.push(...Un(e)),[...new Set(r)]}function zt(t,e){if(e?.trim())return{intent:"write",targets:[e.trim()],toolName:null};if(!t.trim())return{intent:"unknown",targets:[],toolName:null};let r;try{r=JSON.parse(Jn(t))}catch{let s=Un(t);return s.length>0?{intent:"write",targets:[...new Set(s)],toolName:"apply_patch"}:{intent:"unknown",targets:[],toolName:null}}if(!Kn(r))return{intent:"unknown",targets:[],toolName:null};let i=Kf(r),n=rh(r,th(r)),a=Yf(r),o=Xf(r);if(Qf(r)==="beforeagentstart"){let s=Zf(r);return{intent:"context",targets:[],toolName:null,...s?{task:s}:{},...a?{cwd:a}:{},...o?{sessionId:o}:{}}}return i&&Jf.has(Gn(i))?{intent:n.length>0?"write":"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i&&Gf.has(Gn(i))?{intent:"non-write",targets:[],toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i?{intent:"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:{intent:n.length>0?"write":"unknown",targets:n,toolName:null,...a?{cwd:a}:{},...o?{sessionId:o}:{}}}function Hs(){let t=process.env.FILE_PATH;if(t?.trim()||process.stdin.isTTY)return zt("",t);try{return zt(zf(0,"utf8"),t)}catch{return zt("",t)}}var ps=Wt(It(),1);import{promises as tb}from"fs";import mt from"path";import{execFileSync as _g}from"child_process";import Vi from"path";function Fi(t,e){return _g("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Tg(t,e){let r=Vi.normalize(t),i=Vi.normalize(e);return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function ce(t){try{let e=Vi.resolve(Fi(t,["rev-parse","--show-toplevel"])),i=Fi(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?Vi.resolve(i.slice(9)):e,a=null;try{a=Fi(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Tg(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function kr(t,e){try{let r=Fi(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 Og}from"node:crypto";import{promises as le}from"node:fs";import X from"node:path";import{TextDecoder as Hg}from"node:util";var Ig=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),jg=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function $g(t){return t.toLowerCase().startsWith(".env")}function Sr(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>$g(i))?"environment-file":r.some(i=>jg.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>Ig.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}function Ke(t){return t!==0&&t!==0n&&t!=="0"}function be(t,e){return Ke(t.dev)&&Ke(e.dev)&&Ke(t.ino)&&Ke(e.ino)}function T(t,e){let r=Ke(t.dev)&&Ke(e.dev);if(r&&t.dev!==e.dev)return!1;let i=Ke(t.ino)&&Ke(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var Wi=1024*1024;function To(t,e){let r=X.relative(t,e);return r===""||!X.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${X.sep}`)}function Dg(t){let e=X.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||X.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let r=t.toLowerCase(),i=Sr(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 Lg(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Bg(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function qi(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return be(r,i)?T(r,i):T(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Cu(t){let e=await le.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await le.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Mg(t,e){let r=X.resolve(t),i=X.resolve(e);if(!To(r,i))throw new Error("Native artifact path is outside its root");let n=[await Cu(r)],a=r;for(let o of X.relative(r,i).split(X.sep).filter(Boolean)){a=X.join(a,o);let s=await Cu(a);if(!To(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function xu(t){for(let e of t){let r=await le.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Bg(e,r)||await le.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function Q(t){let e=Dg(t.ref),r=t.maxBytes===null?null:Lg(t.maxBytes??Wi),i=X.resolve(t.root,...e.split("/")),n=await Mg(t.root,X.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await le.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 le.realpath(i);if(!To(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await le.open(i,"r");try{let[c,l,u]=await Promise.all([s.stat(),le.lstat(i),le.realpath(i)]);if(await xu(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!qi(a,c)||!qi(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],f=0,p=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let k=r===null?p.length:r+1-f,S=await s.read(p,0,Math.min(p.length,k),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(p.subarray(0,S.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[g,h,m]=await Promise.all([s.stat(),le.lstat(i),le.realpath(i)]);if(await xu(n),!h.isFile()||h.isSymbolicLink()||m!==o||!qi(c,g)||!qi(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let y=Buffer.concat(d,f),N;try{N=new Hg("utf-8",{fatal:!0}).decode(y)}catch(k){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:k})}return{ref:e,size:f,hash:t.includeHash===!1?null:Og("sha256").update(y).digest("hex"),text:N}}finally{await s.close()}}import{randomUUID as Fg}from"crypto";import{promises as L}from"fs";import ue from"path";function zi(t,e){let r=ue.relative(t,e);return r===""||!ue.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ue.sep}`)}function Vg(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Ji(t,e){return T({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function qg(t,e){return Ji(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Pu(t){let e=await L.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await L.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function jt(t){for(let e of t){let r=await L.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Vg(e,r)||await L.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Wg(t,e,r){let[i,n]=await Promise.all([L.lstat(t),L.realpath(t),r?jt(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Ji(i,e)||r&&!zi(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function zg(t,e){let r=ue.resolve(t),i=ue.resolve(e);if(!zi(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Pu(r)],a=ue.relative(r,i).split(ue.sep).filter(Boolean),o=r;for(let s of a){await jt(n),o=ue.join(o,s);try{await L.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Pu(o);if(!zi(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await jt(n),n}async function Jg(t){let e;try{e=await L.open(t,"r"),await e.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await e?.close()}}async function Gg(t,e,r={}){let i=ue.dirname(t),n=r.containedRoot?await zg(r.containedRoot,i):null;n||await L.mkdir(i,{recursive:!0});let a=ue.join(i,`.${ue.basename(t)}.${Fg()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await L.open(a,"wx"),s=await o.stat(),n){let[l,u]=await Promise.all([L.lstat(a),L.realpath(a)]);if(await jt(n),!l.isFile()||l.isSymbolicLink()||!Ji(s,l)||!zi(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(),!Ji(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 Wg(a,c,n),await r.beforeCommit?.(),n){await jt(n);let l=await L.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!qg(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await L.link(a,t),await L.unlink(a)):await L.rename(a,t),await Jg(i)}catch(l){if(await o?.close(),!n)await L.rm(a,{force:!0});else try{await jt(n),await L.rm(a,{force:!0})}catch{}throw l}}async function ke(t,e,r={}){await Gg(t,e,r)}async function de(t,e,r={}){await ke(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:"验证预期"}},Ug={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:"结论"}},Kg={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:"结论"}},Yg=new Map,Ru=new Map;for(let t of Object.keys(Io)){for(let[e,r]of Object.entries(Io[t]))Yg.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Ug[t]))Ru.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Kg[t]))Ru.set(r.toLocaleLowerCase("en-US"),e)}function Xg(t,e){return Io[t][e]}function Gi(t){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${Xg(t,r)}
144
144
  `).join(`
145
- `)}var Io=Ft(_t(),1);import Ue from"path";var kr=64*1024,Wi=1024,zi=64,Su=1024,Eu=64,Pu=5,_o={learning:!0,retrieval:!0},Dg={provider:"local"},Bg=12e4,Cu=6e5,Lg=[".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/**"],Mg=["**/.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"],Fg=[...Lg,...Mg].sort((t,e)=>t.localeCompare(e,"en"));var ke={include:["**/*"],exclude:[...Fg],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function Vg(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||Ue.posix.isAbsolute(r)||Ue.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 Tt(t){let e=Vg(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Ru(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 Ji(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||Ue.posix.isAbsolute(i)||Ue.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 _e(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Au(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 Gi(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>Wi)throw new Error(`${e} exceeds ${Wi} 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>zi)throw new Error(`${e} contains more than ${zi} wildcard tokens`);return t}function xu(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=>Gi(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function To(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 qg(t){if(t===void 0)return{...ke,include:[...ke.include],exclude:[...ke.exclude]};let e=_e(t,"native.snapshot");return{include:xu(e.include,"native.snapshot.include",ke.include),exclude:xu(e.exclude,"native.snapshot.exclude",ke.exclude),max_files:To(e.max_files,ke.max_files,"native.snapshot.max_files"),max_total_bytes:To(e.max_total_bytes,ke.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:To(e.max_duration_ms,ke.max_duration_ms,"native.snapshot.max_duration_ms")}}function Wg(t){if(t===void 0)return;let e=_e(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=_e(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:Tt(i),toArtifactRoot:Tt(n),stage:a,...o?{cleanup:o}:{}}}function zg(t){if(t===void 0)return;let e=_e(t,"native.finish");if(e.pull_request===void 0)return{};let r=_e(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(Ue.posix.isAbsolute(i[0])||Ue.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??Bg;if(!Number.isSafeInteger(n)||n<1||n>Cu)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Cu}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function Jg(t,e={}){let r=_e(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??Pu;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Wg(r.pending_root_move),c=zg(r.finish);return{artifact_root:Tt(i),language:Au(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:qg(r.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function Gg(t){let e=_e(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:Ru(e.artifact_layout),language:Au(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n}}function Ug(t){let r=_e(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)=>Ji(i,`hook.allow_paths[${n}]`)))]}}function Kg(t){if(t===void 0)return{..._o};let e=_e(t,"memory"),r=e.learning??_o.learning,i=e.retrieval??_o.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 jo(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Yg(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")||Ue.posix.isAbsolute(r)||Ue.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>Su)throw new Error(`${e} exceeds ${Su} 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>Eu)throw new Error(`${e} contains more than ${Eu} wildcard tokens`);return r}function Xg(t){let r=jo(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)=>Yg(i,`knowledge.local.include[${n}]`)))]}}function Qg(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 Zg(t){let e=jo(t,"knowledge.remote"),r=Qg(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 ew(t){if(t===void 0)return{...Dg};let e=jo(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:Xg(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:Zg(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 tw(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function rw(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 Sr(t,e={}){let r=(0,Io.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=tw(n.ambient_resume),o=n.hook===void 0?void 0:Ug(n.hook),s=Kg(n.memory),c=ew(n.knowledge),l=n.native===void 0?void 0:Jg(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=n.classic===void 0?void 0:Gg(n.classic),d=rw(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}:{}}}import{createHash as nw}from"crypto";import{promises as Yi}from"fs";import Ke from"path";import{constants as Ui,promises as ot}from"fs";var de=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}};function $o(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function _u(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function Er(t){return{dev:t.dev,ino:t.ino,birthtime:$o(t)}}function Ki(t,e){let r=Er(t),i=Er(e);return Ne(r,i)?_(r,i):_(r,i)&&$o(t)===$o(e)&&_u(t)===_u(e)&&t.size===e.size}async function st(t,e,r={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let i=r.label??"file",n=r.bigint===!0,a=await ot.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new de("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new de("too-large",`${i} exceeds ${e} bytes`);let o=await ot.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:Er(a)});let s=process.platform==="win32"?Ui.O_RDONLY:Ui.O_RDONLY|Ui.O_NOFOLLOW|Ui.O_NONBLOCK,c;try{c=await ot.open(t,s)}catch(l){throw l.code==="ELOOP"?new de("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,u,d]=await Promise.all([c.stat({bigint:n}),ot.lstat(t,{bigint:n}),ot.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!Ki(a,l)||!Ki(a,u))throw new de("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:d,identity:Er(l)}),await r.hooks?.afterOpen?.();let f=[],p=0,g=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let N=e+1-p,{bytesRead:k}=await c.read(g,0,Math.min(g.length,N),null);if(k===0)break;if(p+=k,p>e)throw new de("too-large",`${i} exceeds ${e} bytes`);f.push(Buffer.from(g.subarray(0,k)))}await r.hooks?.beforeFinalCheck?.();let[h,m,y]=await Promise.all([c.stat({bigint:n}),ot.lstat(t,{bigint:n}),ot.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||y!==o||!Ki(a,h)||!Ki(a,m))throw new de("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:y,identity:Er(h)}),{bytes:Buffer.concat(f,p),stat:h,realPath:y}}finally{await c.close()}}function iw(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Oo(t,e){let r=Ke.relative(t,e);return r===""||!Ke.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ke.sep}`)}async function Tu(t,e){let r=Ke.resolve(t),i=await Yi.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Yi.realpath(r)}async function Iu(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=Ke.join(n,r[a]);let o;try{o=await Yi.lstat(n)}catch(u){if(iw(u))return{exists:!1,kind:"missing"};throw u}let s=Ke.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 Yi.realpath(n);if(!Oo(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 It(t,e,r){let i=Ji(e,r.label),n=Ke.resolve(t),a=await Tu(n,r.label),o=i.split("/"),s=Ke.resolve(n,...o);if(!Oo(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 Ye(t,e,r,i){let n=await It(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 Tu(n.projectRoot,i.label);return st(n.target,r,{...i,verify:async(o,s)=>{if(!Oo(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 Cr=".comet/config.yaml";function aw(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Xi(t,e={}){return(await Qi(t,e)).document}async function ow(t){try{return(await Ye(t,Cr,kr,{label:Cr})).bytes}catch(e){if(aw(e))return null;throw e}}function sw(t){return t?{exists:!0,sha256:nw("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Qi(t,e={}){let r=await ow(t);return{document:r?Sr(r.toString("utf8"),e):null,identity:sw(r)}}async function Ho(t){return(await Xi(t))?.config??null}var TE=16*1024;import{existsSync as $u,promises as ct}from"fs";import R from"path";import fw from"os";var Fo=".comet/config.yaml",hw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function Lo(t){try{return await ct.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function pw(t){try{let e=await ct.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function $t(t,e){let r=R.relative(t,e);return r===""||!R.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${R.sep}`)}async function jt(t){let e=[],r=t;for(;!await Lo(r);){let n=R.dirname(r);if(n===r)break;e.push(R.basename(r)),r=n}let i=await ct.realpath(r);return R.resolve(i,...e.reverse())}async function Mo(t){try{return(await ct.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Vo(t){let e=R.resolve(t);try{(await ct.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=R.resolve(fw.homedir());for(;;){if(!(e===i&&r!==i)){let o=R.join(e,...Fo.split("/")),s=e===r||await pw(o);if(await Lo(o)&&s)return e}if(await Lo(R.join(e,".git")))return e;let a=R.dirname(e);if(a===e)return r;e=a}}function qo(t){return Tt(t)}async function mw(t,e){let r=qo(e),i=R.resolve(t,...r.split("/")),n=await ct.realpath(t),a=await jt(i);if(!$t(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function lt(t,e){let r=qo(e),i=await mw(t,r),n=R.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([jt(i),jt(n)]);if(!$t(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=R.resolve(t),c=R.join(s,".comet","runtime","native");if(await Mo(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,u]=await Promise.all([ct.realpath(s),jt(c)]);if(!$t(l,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(t,...Fo.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:R.join(n,"specs"),changesDir:R.join(n,"changes"),archiveDir:R.join(n,"archive"),runtimeDir:c,changesRuntimeDir:R.join(c,"changes"),locksDir:R.join(c,"locks"),transactionsDir:R.join(c,"transactions")}}function Ou(t){if(!hw.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Ot(t,e){Ou(e);let r=R.join(t.changesRuntimeDir,e);if(!M(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function vw(t,e){Ou(e);let r=R.join(t.changesDir,e,"runtime");if(!M(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Q(t,e){let r=Ot(t,e);if($u(r))return r;let i=vw(t,e);return $u(i)?i:r}function fe(t,e){let r=R.resolve(e);if(M(t.runtimeDir,r))return t.runtimeDir;if(M(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function M(t,e){return $t(R.resolve(t),R.resolve(e))}async function T(t,e){let r=R.resolve(t),i=R.resolve(e);if(!$t(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await Mo(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([jt(r),jt(i)]);if(!$t(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}var Zi=Gi;async function he(t){let e=(await Xi(t))?.config??null;return e?.native?e:null}async function en(t){let e=await he(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}import{promises as Fy}from"fs";import Vy from"path";import{AsyncLocalStorage as ww}from"async_hooks";import{randomUUID as Lu}from"crypto";import{promises as Z}from"fs";import Mu from"os";import F from"path";var Du=16*1024,Fu=".coordinator",yw=5e3,Bu=new ww,tn=new Map;function Nw(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function bw(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let r=t;if(typeof r.id!="string"||r.id.length===0||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<1||typeof r.hostname!="string"||r.hostname.length===0||typeof r.createdAt!="string"||r.createdAt.length===0||typeof r.operation!="string"||r.operation.length===0)throw new Error(`Invalid Native lock metadata: ${e}`);return r}function Vu(t){return{device:t.dev.toString(),inode:t.ino.toString(),size:t.size.toString(),birthtimeNs:t.birthtimeNs.toString(),ctimeNs:t.ctimeNs.toString(),mtimeNs:t.mtimeNs.toString()}}function Wo(t,e){let r={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},i={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return Ne(r,i)?_(r,i):_(r,i)&&t.size===e.size}function zo(t,e){return Wo(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}async function Te(t){let e,r;try{let i=await st(t,Du,{bigint:!0,label:"Native lock"});e=i.bytes,r=i.stat}catch(i){if(i.code==="ENOENT")return null;throw i instanceof de?i.reason==="too-large"?new Error(`Native lock metadata exceeds ${Du} bytes: ${t}`,{cause:i}):i.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:i}):new Error(`Native lock changed while reading: ${t}`,{cause:i}):i}return{file:t,owner:bw(JSON.parse(e.toString("utf8")),t),identity:Vu(r)}}async function kw(t){return(await Te(t))?.owner??null}function qu(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==Mu.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=Rw(t.owner.pid);return{status:e===!0?"active":e===!1?"stale":"unknown",owner:t.owner,identity:t.identity}}async function Sw(t,e){try{await Z.lstat(e);return}catch(r){if(r.code!=="ENOENT")throw r}try{await Z.rename(t,e)}catch(r){if(r.code!=="ENOENT")throw r}}async function Jo(t,e){let r=await Te(t.file);if(!r)return"missing";if(r.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!zo(r.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await Z.mkdir(e,{recursive:!0});let i=F.join(e,`${F.basename(t.file)}.${t.owner.id}.${Lu()}.removed`);try{await Z.rename(t.file,i)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await Te(i);if(!n||n.owner.id!==t.owner.id||!Wo(n.identity,t.identity))throw await Sw(i,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await Z.rm(i,{force:!0}),"removed"}function Wu(t){return{id:Lu(),pid:process.pid,hostname:Mu.hostname(),createdAt:new Date().toISOString(),operation:t}}async function zu(t,e){let r;try{r=await Z.open(t,"wx")}catch(i){if(i.code==="EEXIST"){let n=await kw(t);throw new Error(`Native lock is already held: ${t}${n?` by pid ${n.pid} for ${n.operation}`:""}`,{cause:i})}throw i}try{return await r.writeFile(JSON.stringify(e,null,2)+`
146
- `,"utf8"),await r.sync(),Vu(await r.stat({bigint:!0}))}finally{await r.close()}}async function Ew(t,e){let r=await T(t.runtimeDir,t.locksDir);await Z.mkdir(r,{recursive:!0});let i=await T(t.runtimeDir,F.join(r,Fu));await Z.mkdir(i,{recursive:!0});let n=Wu(e),a=F.join(i,`.${n.id}.tmp`),o=F.join(i,`${n.id}.claim`);try{let s=await zu(a,n);await Z.rename(a,o);let c=await Te(o);if(!c||!Wo(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:r,owner:n,identity:c.identity}}finally{await Z.rm(a,{force:!0})}}async function Cw(t){let e=F.dirname(t.file),r=!1,i=F.basename(t.file);for(let n of await Z.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=F.join(e,n.name);if(F.resolve(a)!==F.resolve(t.file))try{let o=await Te(a),s=qu(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await Jo(o,e);continue}n.name<i&&(r=!0)}catch{n.name<i&&(r=!0)}}return r}async function Ju(t){let e=await Te(t.file);if(e){if(e.owner.id!==t.owner.id||!zo(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await Jo(e,F.dirname(t.file))}}async function xw(t,e){let r=Date.now()+yw;for(;;){let i=await Ew(t,e);if(!await Cw(i))return i;if(await Ju(i),Date.now()>=r)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function Pw(t){let e=tn.get(t)??Promise.resolve(),r,i=new Promise(a=>{r=a}),n=e.then(()=>i);return tn.set(t,n),await e,()=>{r(),tn.get(t)===n&&tn.delete(t)}}async function Gu(t,e,r){let i=F.resolve(t.locksDir),n=Bu.getStore();if(n?.has(i))return r();let a=await Pw(i);try{let o=await xw(t,e),s=new Map(n??[]);return s.set(i,o),await Bu.run(s,async()=>{try{return await r()}finally{await Ju(o)}})}finally{a()}}async function rn(t,e,r){return Gu(t,`acquire ${e}`,async()=>{let i=await T(t.runtimeDir,t.locksDir);await Z.mkdir(i,{recursive:!0});let n=await T(t.runtimeDir,F.join(i,Nw(e))),a=Wu(r),o=await zu(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:i,owner:a,identity:o}})}async function nn(t){await Te(t.file)&&await Gu({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${F.basename(t.file)}`,async()=>{let e=await Te(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!zo(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let r=F.join(t.locksDir,Fu);await Jo(e,r)})}function Rw(t){try{return process.kill(t,0),!0}catch(e){let r=e.code;return r==="ESRCH"?!1:r==="EPERM"?!0:null}}async function Uu(t){return qu(await Te(t))}import hy from"node:path";import{createHash as Aw}from"crypto";function pe(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function _w(t,e){e.has(t)&&pe("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)||pe("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&pe("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&pe("symbol properties are not supported"),`[${t.map(i=>Go(i,e)).join(",")}]`}finally{e.delete(t)}}function Tw(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&pe("only plain objects are supported"),e.has(t)&&pe("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&pe("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))&&pe("accessor properties are not supported"),`${JSON.stringify(o)}:${Go(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function Go(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)||pe("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?_w(t,e):Tw(t,e);case"bigint":case"function":case"symbol":case"undefined":return pe(`${typeof t} values are not supported`)}return pe("unsupported value type")}function Uo(t){return Go(t,new Set)}function ee(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 Aw("sha256").update(`${t}
147
- ${Uo(e)}`).digest("hex")}var dC=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Ku=Object.freeze({maxCriteria:1024});var sn=Ft(_t(),1);import{promises as Hw}from"node:fs";var Pr="comet.native.v4",Rr="comet.native.local-execution.v4";var Dw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Bw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Lw=/^A[1-9][0-9]*$/u,Mw=/^[a-f0-9]{64}$/u,Fw=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"]),on=class extends Error{constructor(r,i){super(`Native state version conflict: expected ${r}, got ${i}`);this.expectedStateVersion=r;this.actualStateVersion=i;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};function V(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function q(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 D(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 Yo(t,e){return t===null?null:D(t,e)}function Vw(t,e){let r=D(t,e);if(!Mw.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function Ht(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function I(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function qw(t,e){return t===null?null:I(t,e,Number.MIN_SAFE_INTEGER)}function H(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Se(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function cn(t,e){return Se(t,e,(r,i)=>D(r,`${e}[${i}]`))}function ut(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Dt(t,e){let r=D(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function Xo(t,e,r=!1){let i=D(t,e);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return i}function te(t,e){let r=V(t,e);return q(r,new Set(["text","truncated"]),e),{text:D(r.text,`${e}.text`,{empty:!0}),truncated:Ht(r.truncated,`${e}.truncated`)}}function Ww(t,e){let r=`Native spec_changes[${e}]`,i=V(t,r);q(i,new Set(["capability","operation","source"]),r);let n=D(i.capability,`${r}.capability`);if(!Bw.test(n))throw new Error(`${r}.capability is invalid`);let a=H(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:Xo(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 zw(t){let e="Native workspace",r=V(t,e);q(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=H(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=Yo(r.change_branch,`${e}.change_branch`),a=Yo(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:H(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 Jw(t){let e="Native loop",r=V(t,e);q(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","execution_failure_count","previous_unresolved_ids","next_action"]),e);let i=cn(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);return ut(i,`${e}.previous_unresolved_ids`),{stage:H(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:I(r.goal_cycle,`${e}.goal_cycle`,1),iteration:I(r.iteration,`${e}.iteration`),attempt:I(r.attempt,`${e}.attempt`),retry_epoch:I(r.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:I(r.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:I(r.no_progress_count,`${e}.no_progress_count`),execution_failure_count:I(r.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:i,next_action:Yo(r.next_action,`${e}.next_action`)}}function Gw(t,e){let r=`Native acceptance[${e}]`,i=V(t,r);q(i,new Set(["id","source","text","result","reason"]),r);let n=D(i.id,`${r}.id`);if(!Lw.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:Xo(i.source,`${r}.source`),text:D(i.text,`${r}.text`),result:H(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:te(i.reason,`${r}.reason`)}}function Uw(t,e){let r=`Native builder_handoff.checks[${e}]`,i=V(t,r);return q(i,new Set(["name","result","note"]),r),{name:te(i.name,`${r}.name`),result:H(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:te(i.note,`${r}.note`)}}function Kw(t){let e="Native builder_handoff",r=V(t,e);q(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=cn(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);ut(i,`${e}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:V(r.review,`${e}.review`);return n&&q(n,new Set(["status","summary","reviewer_execution_ref"]),`${e}.review`),{candidate_id:D(r.candidate_id,`${e}.candidate_id`),identity_provider:D(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:D(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:I(r.iteration,`${e}.iteration`,1),summary:te(r.summary,`${e}.summary`),addressed_acceptance_ids:i,checks:Se(r.checks,`${e}.checks`,Uw),checks_truncated:Ht(r.checks_truncated,`${e}.checks_truncated`),known_limits:Se(r.known_limits,`${e}.known_limits`,(a,o)=>te(a,`${e}.known_limits[${o}]`)),known_limits_truncated:Ht(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:H(n.status,["passed"],`${e}.review.status`),summary:te(n.summary,`${e}.review.summary`),reviewer_execution_ref:D(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:Dt(r.submitted_at,`${e}.submitted_at`)}}function Yw(t,e){let r=`Native blockers[${e}]`,i=V(t,r);q(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=cn(i.acceptance_ids,`${r}.acceptance_ids`);return ut(n,`${r}.acceptance_ids`),{owner:H(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:te(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:H(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function Xw(t,e){let r=`Native verification.checks[${e}]`,i=V(t,r);return q(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:D(i.id,`${r}.id`),name:te(i.name,`${r}.name`),argv_display:Se(i.argv_display,`${r}.argv_display`,(n,a)=>te(n,`${r}.argv_display[${a}]`)),argv_truncated:Ht(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:Xo(i.cwd_ref,`${r}.cwd_ref`,!0),status:H(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:qw(i.exit_code,`${r}.exit_code`),duration_ms:I(i.duration_ms,`${r}.duration_ms`)}}function Qw(t){let e="Native verification",r=V(t,e);q(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let i=Se(r.checks,`${e}.checks`,Xw);ut(i.map(a=>a.id),`${e}.checks IDs`);let n=D(r.identity_provider,`${e}.identity_provider`);return{candidate_id:D(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:D(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:I(r.iteration,`${e}.iteration`,1),attempt:I(r.attempt,`${e}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":H(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:H(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:te(r.summary,`${e}.summary`),risks:Se(r.risks,`${e}.risks`,(a,o)=>te(a,`${e}.risks[${o}]`)),risks_truncated:Ht(r.risks_truncated,`${e}.risks_truncated`),completed_at:Dt(r.completed_at,`${e}.completed_at`)}}function Yu(t,e){let r=`Native history[${e}]`,i=V(t,r);q(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=cn(i.unresolved_ids,`${r}.unresolved_ids`);return ut(n,`${r}.unresolved_ids`),{goal_cycle:I(i.goal_cycle,`${r}.goal_cycle`,1),iteration:I(i.iteration,`${r}.iteration`),attempt:I(i.attempt,`${r}.attempt`),outcome:H(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:te(i.summary,`${r}.summary`),completed_at:Dt(i.completed_at,`${r}.completed_at`)}}function Zw(t){let e="Native history_overflow.outcome_counts",r=V(t,e),i=["pass","fail","blocked","execution-error","recovery"];return q(r,new Set(i),e),{pass:I(r.pass,`${e}.pass`),fail:I(r.fail,`${e}.fail`),blocked:I(r.blocked,`${e}.blocked`),"execution-error":I(r["execution-error"],`${e}.execution-error`),recovery:I(r.recovery,`${e}.recovery`)}}function ey(t){let e="Native history_overflow",r=V(t,e);q(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let i=I(r.dropped_entries,`${e}.dropped_entries`),n=r.first_dropped_at===null?null:Dt(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:Dt(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=Zw(r.outcome_counts);if(Object.values(o).reduce((c,l)=>c+l,0)!==i)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:i,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function ty(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 ry(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 Ee(t){let e=V(t,"Native portable state");if(q(e,Fw,"Native portable state"),e.schema!==Pr)throw new Error(`Native portable state schema must be ${Pr}`);let r=D(e.name,"Native state name");if(!Dw.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=Se(e.spec_changes,"Native spec_changes",Ww);ut(i.map(s=>s.capability),"Native spec change capabilities");let n=Se(e.acceptance,"Native acceptance",Gw);ut(n.map(s=>s.id),"Native acceptance IDs");let a=Se(e.history,"Native history",Yu);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Pr,name:r,language:H(e.language,["en","zh-CN"],"Native state language"),phase:H(e.phase,["shape","build","verify","archive"],"Native state phase"),status:H(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:I(e.state_version,"Native state_version",1),brief:"brief.md",...e.children_contract_hash===void 0?{}:{children_contract_hash:Vw(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:H(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:zw(e.workspace),loop:Jw(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Kw(e.builder_handoff),blockers:Se(e.blockers,"Native blockers",Yw),verification:e.verification===null?null:Qw(e.verification),history:a,history_overflow:ey(e.history_overflow),verification_result:H(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:H(e.verification_report,["verification.md"],"Native verification_report"),archived:Ht(e.archived,"Native archived"),created_at:Dt(e.created_at,"Native created_at")};return ty(o),ry(o),o}function ln(t,e){let r=Ee(t),i=Yu(e,r.history.length),n=[...r.history,i],a={...r.history_overflow,outcome_counts:{...r.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return Ee({...r,history:n,history_overflow:a})}function iy(t,e){let r=(0,sn.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 Ar(t){let e=await Hw.readFile(t,"utf8");return Ee(iy(e,"Native portable state"))}async function Xu(t,e,r={}){let i=Ee(e);await be(t,(0,sn.stringify)(i),r)}var an=new Map;async function ny(t,e){let r=an.get(t)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);an.set(t,a),await r;try{return await e()}finally{i(),an.get(t)===a&&an.delete(t)}}async function Qu(t){return ny(t.file,async()=>{let e=I(t.expectedStateVersion,"Native expected state version",1),r=Ee(t.next);if(r.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await Ar(t.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==e)throw new on(e,i.state_version);return await Xu(t.file,r,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await Ar(t.file);if(n.state_version!==e)throw new on(e,n.state_version)}}),r})}function ay(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function _r(t,e=16384){if(typeof t!="string")throw new Error("Native portable text must be a string");if(ay(e),Buffer.byteLength(t,"utf8")<=e)return{text:t,truncated:!1};let r="",i=0;for(let n of t){let a=Buffer.byteLength(n,"utf8");if(i+a>e)break;r+=n,i+=a}return{text:r,truncated:!0}}var Ie="comet.native.v3",je="comet.native.v2",$e="comet.native.v1";var Zu="comet.native.portable-migration.v1",oy=new Set(["schema","id","change","fromSchema","status","createdAt"]),sy=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,cy=/^[a-z0-9][a-z0-9-]{7,127}$/u,ly=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),uy=new Set([$e,je,Ie]);function dy(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function fy(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let r=new Date(t);if(Number.isNaN(r.valueOf())||r.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function ed(t){let e=dy(t,"Native portable migration transaction"),r=Object.keys(e).filter(i=>!oy.has(i));if(r.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${r.join(", ")}`);if(e.schema!==Zu)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!cy.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!sy.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!uy.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!ly.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:Zu,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:fy(e.createdAt,"Native portable migration transaction createdAt")}}var td="comet.native.archive-transaction.v4",rd="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",py=new RegExp(`^portable-archive-(${rd})\\.json$`,"u"),my=new RegExp(`^portable-migration-(${rd})\\.json$`,"u"),vy=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,gy=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,wy=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),yy=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),Ny=new Set(["capability","operation","source","content"]),id=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function nd(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ad(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`);if(Object.keys(t).length!==e.size)throw new Error(`${r} fields are invalid`)}function by(t,e){let r=`Native portable Archive spec_changes[${e}]`,i=nd(t,r);if(ad(i,Ny,r),typeof i.capability!="string"||!id.test(i.capability))throw new Error(`${r}.capability is invalid`);if(!["create","modify","remove"].includes(String(i.operation)))throw new Error(`${r}.operation is invalid`);let n=i.operation;if(n==="remove"){if(i.source!==null||i.content!==null)throw new Error(`${r} remove requires source and content null`);return{capability:i.capability,operation:n,source:null,content:null}}if(typeof i.source!="string"||i.source.length===0||i.source.includes("\\")||i.source.startsWith("/")||/^[A-Za-z]:/u.test(i.source)||i.source.split("/").some(a=>a==="."||a===".."))throw new Error(`${r}.${n} source is invalid`);if(typeof i.content!="string")throw new Error(`${r}.${n} content is invalid`);return{capability:i.capability,operation:n,source:i.source,content:i.content}}function ky(t){let e=nd(t,"Native portable Archive transaction");if(ad(e,yy,"Native portable Archive transaction"),e.schema!==td)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!vy.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!id.test(e.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(e.start_state_version)||Number(e.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof e.archive_ref!="string"||!gy.test(e.archive_ref)||!e.archive_ref.endsWith(`-${e.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof e.status!="string"||!wy.has(e.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let r=e.spec_changes.map(by);if(new Set(r.map(({capability:n})=>n)).size!==r.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>r.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof e.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let i=new Date(e.created_at);if(Number.isNaN(i.valueOf())||i.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:td,id:e.id,change:e.change,start_state_version:Number(e.start_state_version),archive_ref:e.archive_ref,status:e.status,next_spec_index:Number(e.next_spec_index),spec_changes:r,created_at:e.created_at}}function Qo(t){let e=py.exec(t);if(e)return{kind:"archive",change:e[1]};let r=my.exec(t);return r?{kind:"migration",change:r[1]}:null}async function od(t,e){let r=Qo(e);if(!r)return null;let i=await X({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(i.text),a=hy.join(t.transactionsDir,e);if(r.kind==="archive"){let s=ky(n);if(s.change!==r.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:r.change,file:a,journal:s}}let o=ed(n);if(o.change!==r.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:r.change,file:a,journal:o}}function sd(t){return t.kind==="archive"||t.journal.status!=="committed"}import Oe from"path";import{TextDecoder as Ty}from"util";import{createHash as Sy}from"node:crypto";import{constants as hn,promises as me}from"node:fs";import ve from"node:path";import{TextDecoder as Ey}from"node:util";function mn(t,e){let r=ve.relative(t,e);return r===""||!ve.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ve.sep}`)}function Cy(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function xy(t,e){return _({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Py(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function pn(t,e){return _({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Zo(t,e){let r=await me.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await me.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function Ry(t,e,r){let i=ve.resolve(t),n=ve.resolve(e);if(!mn(i,n))throw new Error(`${r} is outside its managed root`);let a=[await Zo(i,r)],o=i;for(let s of ve.relative(i,n).split(ve.sep).filter(Boolean)){await dt(a,r),o=ve.join(o,s);let c=await Zo(o,r);if(!mn(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await dt(a,r),a}async function dt(t,e){for(let r of t){let i=await me.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!xy(r,i)||await me.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function Ay(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 ft(t){let e=Cy(t.maxBytes),r=ve.resolve(t.file),i=await Ry(t.root,ve.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(u=>Zo(ve.resolve(u),t.label)));await t.hooks?.afterParentChainCaptured?.(),await dt(i,t.label);let a=await me.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=Py(a),s=await me.realpath(r);if(!mn(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(u=>mn(u.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?hn.O_RDONLY:hn.O_RDONLY|hn.O_NOFOLLOW|hn.O_NONBLOCK,l=await me.open(r,c);try{let u=await l.stat();await t.hooks?.afterOpen?.();let[d,f]=await Promise.all([me.lstat(r),me.realpath(r)]);if(await dt(i,t.label),await dt(n,t.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!pn(o,u)||!pn(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let p=await Ay(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[g,h,m]=await Promise.all([l.stat(),me.lstat(r),me.realpath(r)]);if(await dt(i,t.label),await dt(n,t.label),!h.isFile()||h.isSymbolicLink()||m!==s||!pn(o,g)||!pn(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:p,hash:Sy("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}async function cd(t){let e=await ft(t),r;try{r=new Ey("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}}var Iy=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),jy=new Set(["id","type","source","target","staged","backup"]),$y=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Oy=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var dd=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var Hy=256*1024,YC=1024*1024,XC=16*1024;var QC=64*1024*1024;var Dy=new Ty("utf-8",{fatal:!0});function gn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function wn(t,e,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 fd(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function es(t,e){if(typeof t!="string"||t.length===0||Oe.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function vn(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function ld(t,e){if(es(t,e),t.includes("\\")||t!==Oe.posix.normalize(t)||t.split("/").includes(".")||t.endsWith("/")||Buffer.byteLength(t,"utf8")>1024)throw new Error(`${e} must be a normalized Native-relative ref`)}function By(t,e){let r=gn(t,`transaction operations[${e}]`);if(wn(r,jy,`transaction operations[${e}]`),typeof r.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(r.id))throw new Error(`transaction operations[${e}].id is invalid`);if(r.type!=="write"&&r.type!=="remove"&&r.type!=="move")throw new Error(`transaction operation ${r.id} has an invalid type`);es(r.target,`transaction operation ${r.id} target`);for(let i of["source","staged","backup"])r[i]!==void 0&&es(r[i],`transaction operation ${r.id} ${i}`);if(r.type==="write"){if(r.staged===void 0||r.source!==void 0)throw new Error(`write operation ${r.id} requires staged and forbids source`)}else if(r.type==="remove"){if(r.source!==void 0||r.staged!==void 0)throw new Error(`remove operation ${r.id} forbids source and staged`)}else if(r.source===void 0||r.staged!==void 0||r.backup!==void 0)throw new Error(`move operation ${r.id} requires source and forbids staged and backup`);return r}function hd(t){let e=gn(t,"Native Archive transaction journal");if(wn(e,$y,"Native Archive transaction journal"),e.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native Archive transaction id is invalid");if(e.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof e.status!="string"||!dd.has(e.status))throw new Error("Native Archive transaction status is invalid");if(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change))throw new Error("Native Archive transaction change name is invalid");if(!fd(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(vn(e.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(e.operations)||e.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let r=e.operations.map((s,c)=>{let l=gn(s,`Archive transaction operations[${c}]`);if(wn(l,Oy,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);ld(l.target,`Archive transaction operation ${l.id} target`);for(let u of["source","staged","backup"])l[u]!==void 0&&ld(l[u],`Archive transaction operation ${l.id} ${u}`);if(l.expectedTargetHash!==null&&vn(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(vn(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);vn(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),i=r.map(s=>s.id);if(new Set(i).size!==i.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=r.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${e.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${e.change}$`,"u").test(a[0].target)||r.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of r.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:r}}function Ly(t){let e=gn(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return hd(e);if(wn(e,Iy,"Native transaction journal"),e.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native transaction id is invalid");if(e.kind!=="archive"&&e.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof e.status!="string"||!dd.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!Oe.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!Oe.isAbsolute(e.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(e.change!==void 0&&(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change)))throw new Error("Native transaction change name is invalid");if(!fd(e.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(e.operations))throw new Error("Native transaction operations must be an array");let r=e.operations.map(By),i=r.map(n=>n.id);if(new Set(i).size!==i.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:e.id,kind:e.kind,status:e.status,projectRoot:e.projectRoot,nativeRoot:e.nativeRoot,...typeof e.change=="string"?{change:e.change}:{},createdAt:e.createdAt,operations:r}}function My(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return Oe.join(t.transactionsDir,e)}function pd(t,e){let r=My(t,e);return{directory:r,journal:Oe.join(r,"transaction.json"),events:Oe.join(r,"events.jsonl"),staged:Oe.join(r,"staged"),backups:Oe.join(r,"backups")}}async function rs(t,e){let r=pd(t,e);return await Promise.all(Object.values(r).map(i=>T(t.runtimeDir,i))),r}async function is(t,e,r={}){let i=await rs(t,e),n=await ft({root:t.runtimeDir,file:i.journal,maxBytes:Hy,label:`Native transaction journal ${e}`,hooks:r.hooks}),a=JSON.parse(Dy.decode(n.bytes)),o=Ly(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}async function qy(t,e,r){let i;try{i=await Fy.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await is(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of i)if(Qo(n.name))try{let a=await od(t,n.name);if(!a||r?.kind===a.kind&&r.change===a.change)continue;if(sd(a))return!0}catch{return!0}return!1}async function Wy(t,e){let r=Date.now()+5e3,i=Vy.join(t.locksDir,"root-move.lock");for(;;)try{return await rn(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Uu(i);if(o.status==="missing")continue;if(o.status!=="active"||Date.now()>=r)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function re(t,e,r,i){let n=await Wy(t,e);try{if(await en(t.projectRoot),await qy(t,i?.allowedTransactionId,i?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await r()}finally{await nn(n)}}import as from"path";import{createHash as zy}from"crypto";function U(t){return zy("sha256").update(t).digest("hex")}var wx={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},Gy=1e3,Uy=8*1024*1024,Ky=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Yy=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),Xy=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),Qy=new Set(["schema","include","exclude","hash"]),Zy=new Set(["provider","gitSelection","physicalSelection","projection"]),eN=new Set(["provider","selection"]),tN=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),rN=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),iN=new Set(["schema","status","before","after"]),nN=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),aN=new Set(["path","hash","size","type","gitObjectId"]),oN=new Set(["path","size","type","reason"]),sN=new Set(["ref","hash","count"]),cN=new Set(["change-created","legacy-migration","explicit"]),lN=new Set(["file","directory","other"]),uN=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"]),Nn=/^[a-f0-9]{64}$/u,dN=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var yx=64*1024,Nx=64*1024;var bx={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},kx={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function yn(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var Sx=(1n<<256n)-1n;function fN(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 hN(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
148
- `)}function pN(t,e){return U(`comet.native.snapshot-policy.v1
149
- ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function ns(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 mN(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function md(t){let e=Zi(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?mN(n):void 0;if(a&&!a())return!1;let o=ns(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=ns(r,c,a),o===null||o.size===0)return!1}return ns(r,o,a)?.has(r.length)??!1}}function vN(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>Zi(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>Zi(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=pN(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(md),excludeMatchers:r.map(md),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 ie(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ne(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function Lt(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Ce(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function wd(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=as.posix.normalize(t);if(r!==t||as.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function gN(t,e){let r=ie(t,`Native snapshot entry ${e}`);ne(r,aN,`Native snapshot entry ${e}`);let i=wd(r.path,`Native snapshot entry ${e} path`);if(typeof r.hash!="string"||!Nn.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:Ce(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!dN.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function wN(t,e){let r=ie(t,`Native snapshot omission ${e}`);if(ne(r,oN,`Native snapshot omission ${e}`),!lN.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!uN.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:wd(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:Ce(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function yN(t){let e=ie(t,"Native snapshot omission overflow");if(ne(e,sN,"Native snapshot omission overflow"),typeof e.hash!="string"||!Nn.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:Lt(e.count,"Native snapshot omission overflow count")}}function Bt(t,e){let r=ie(t,e);if(ne(r,rN,e),typeof r.hash!="string"||!Nn.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=Ce(r.recordCount,`${e} recordCount`),n=Ce(r.storedRecordCount,`${e} storedRecordCount`),a=Ce(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 vd(t){let e=ie(t,"Native Git selection evidence");if(ne(e,tN,"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=Bt(e.stageBefore,"Native Git selection stageBefore"),i=Bt(e.combined,"Native Git selection combined"),n=Bt(e.stageAfter,"Native Git selection stageAfter"),a=Bt(e.finalStageBefore,"Native Git selection finalStageBefore"),o=Bt(e.finalCombined,"Native Git selection finalCombined"),s=Bt(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(d=>d.overflow),l=!yn(r,n)||!yn(n,a)||!yn(i,o)||!yn(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 gd(t,e){let r=ie(t,e);if(ne(r,nN,e),typeof r.hash!="string"||!Nn.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=Ce(r.visitedNodeCount,`${e} visitedNodeCount`),n=Ce(r.recordCount,`${e} recordCount`),a=Ce(r.storedRecordCount,`${e} storedRecordCount`),o=Ce(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 NN(t){let e=ie(t,"Native physical selection evidence");if(ne(e,iN,"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=gd(e.before,"Native physical selection before"),i=gd(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!fN(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 yd(t){let e=ie(t,"Native content snapshot manifest");if(ne(e,Yy,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!cN.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let v=ie(e.capture,"Native content snapshot capture");if(ne(v,Zy,"Native content snapshot capture"),v.provider!=="git"&&v.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let x=v.gitSelection===void 0?void 0:vd(v.gitSelection),b=v.physicalSelection===void 0?void 0:NN(v.physicalSelection),A=null;if(v.projection!==void 0){let G=ie(v.projection,"Native content snapshot projection");if(ne(G,eN,"Native content snapshot projection"),G.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");A={provider:"git",...G.selection===void 0?{}:{selection:vd(G.selection)}}}if(v.provider==="git"){if(b||A)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",...x?{gitSelection:x}:{}}}else{if(x)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(b&&A)throw new Error("Native physical-tree capture cannot combine selection and projection");r=A?{provider:"physical-tree",projection:A}:{provider:"physical-tree",...b?{physicalSelection:b}:{}}}}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=ie(e.limits,"Native content snapshot limits");ne(i,Xy,"Native content snapshot limits");let n={maxFiles:Lt(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Lt(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Lt(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Lt(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:Lt(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let v=ie(e.policy,"Native snapshot policy");if(ne(v,Qy,"Native snapshot policy"),v.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(v.include)||!Array.isArray(v.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=vN({include:v.include,exclude:v.exclude,hash:v.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(gN),s=e.omitted.map(wN),c=Ce(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:yN(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(v=>v.size>n.maxFileBytes)||o.reduce((v,x)=>v+x.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(v=>v.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>Gy||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(v=>v.reason==="git-enumeration-limit"),f=s.filter(v=>v.reason==="git-selection-changed");for(let v of[...d,...f])if(v.path!=="."||v.size!==null||v.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 p=r?.provider==="git"?r.gitSelection:r?.projection?.selection,g=p?.status==="overflow"||p?.status==="overflow-and-changed",h=p?.status==="changed"||p?.status==="overflow-and-changed";if(g!==(d.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 m=s.filter(v=>v.reason==="physical-enumeration-limit"),y=s.filter(v=>v.reason==="physical-selection-changed");for(let v of[...m,...y])if(v.path!=="."||v.size!==null||v.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(m.length>1||y.length>1)throw new Error("Native physical selection omissions must not be duplicated");let N=r?.physicalSelection,k=N?.status==="overflow"||N?.status==="overflow-and-changed",S=N?.status==="changed"||N?.status==="overflow-and-changed";if(k!==(m.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(S!==(y.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(hN(E)>n.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function bN(t,e){if(!Ky.test(e))throw new Error(`Invalid Native change name: ${e}`);return as.join(Q(t,e),"baseline-manifest.json")}async function Nd(t,e){let r=bN(t,e),i=fe(t,r);await T(i,r);try{let n=await cd({root:i,file:r,maxBytes:Uy,label:"Native baseline snapshot manifest"});return yd(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var PN=Ft(_t(),1);var Lx=4*1024*1024;import W from"path";var RN=Mr("hookWritePolicy",async t=>(await Ho(t))?.hook??{allow_paths:[]});function bd(t,e){let r=W.relative(t,e);return r===""||!W.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${W.sep}`)}function AN(t,e){let r=W.isAbsolute(e)?W.resolve(e):W.resolve(t,e),i=W.relative(W.resolve(t),r);return i===""||W.isAbsolute(i)||i===".."||i.startsWith(`..${W.sep}`)?null:i.replaceAll("\\","/")}function kd(t){return process.platform==="win32"?t.toLowerCase():t}async function bn(t,e,r=[]){let i=W.isAbsolute(e)?W.resolve(e):W.resolve(t,e),n=W.resolve(t);if(!bd(n,i)||r.some(c=>bd(W.resolve(c),i)))return null;let a=AN(t,e);if(!a)return null;let s=(await RN(t)).allow_paths.find(c=>{let l=kd(a),u=kd(c);return l===u||l.startsWith(`${u}/`)});return s?`${a} (configured Hook allow path: ${s})`:null}var DP=256*1024;var YP={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};import{createHash as TN}from"node:crypto";import{promises as kn}from"node:fs";import Xe from"node:path";var Tr=/^[a-f0-9]{64}$/u,Ed=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,IN=16*1024,ss=process.platform;function Rd(t,e){let r=Xe.relative(t,e);return Xe.isAbsolute(r)||r===".."||r.startsWith(`..${Xe.sep}`)?null:r.replaceAll("\\","/")||"."}function Ad(t){return Array.from(t).some(e=>{let r=e.codePointAt(0)??0;return r<=31||r===127})}function _d(t,e){if(t.length===0||Ad(t)||t.includes("\\")||Xe.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let r=Xe.posix.normalize(t);if(r!==t||r===".."||r.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return r}function cs(t,e){return TN("sha256").update(`${t}
150
- ${e}`).digest("hex")}async function Cd(t,e){let r=await kn.realpath(e),i=await kn.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=ss==="win32"?Xe.normalize(r).toLowerCase():r;return cs(t,`${n}
145
+ `)}var Oo=Wt(It(),1);import Ye from"path";var Er=64*1024,Ui=1024,Ki=64,Au=1024,_u=64,ju=5,jo={learning:!0,retrieval:!0},Qg={provider:"local"},Zg=12e4,Tu=6e5,ew=[".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/**"],tw=["**/.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"],rw=[...ew,...tw].sort((t,e)=>t.localeCompare(e,"en"));var Se={include:["**/*"],exclude:[...rw],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4};function iw(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||Ye.posix.isAbsolute(r)||Ye.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 $t(t){let e=iw(t,"native.artifact_root");return e.length===0?".":e.join("/")}function $u(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 Yi(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||Ye.posix.isAbsolute(i)||Ye.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 Ie(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ou(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 Xi(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>Ui)throw new Error(`${e} exceeds ${Ui} 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>Ki)throw new Error(`${e} contains more than ${Ki} wildcard tokens`);return t}function Iu(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=>Xi(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function $o(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 nw(t){if(t===void 0)return{...Se,include:[...Se.include],exclude:[...Se.exclude]};let e=Ie(t,"native.snapshot");return{include:Iu(e.include,"native.snapshot.include",Se.include),exclude:Iu(e.exclude,"native.snapshot.exclude",Se.exclude),max_files:$o(e.max_files,Se.max_files,"native.snapshot.max_files"),max_total_bytes:$o(e.max_total_bytes,Se.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:$o(e.max_duration_ms,Se.max_duration_ms,"native.snapshot.max_duration_ms")}}function aw(t){if(t===void 0)return;let e=Ie(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=Ie(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:$t(i),toArtifactRoot:$t(n),stage:a,...o?{cleanup:o}:{}}}function ow(t){if(t===void 0)return;let e=Ie(t,"native.finish");if(e.pull_request===void 0)return{};let r=Ie(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(Ye.posix.isAbsolute(i[0])||Ye.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??Zg;if(!Number.isSafeInteger(n)||n<1||n>Tu)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Tu}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function sw(t,e={}){let r=Ie(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??ju;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=aw(r.pending_root_move),c=ow(r.finish);return{artifact_root:$t(i),language:Ou(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:nw(r.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function cw(t){let e=Ie(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:$u(e.artifact_layout),language:Ou(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n}}function lw(t){let r=Ie(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)=>Yi(i,`hook.allow_paths[${n}]`)))]}}function uw(t){if(t===void 0)return{...jo};let e=Ie(t,"memory"),r=e.learning??jo.learning,i=e.retrieval??jo.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 Ho(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function dw(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")||Ye.posix.isAbsolute(r)||Ye.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>Au)throw new Error(`${e} exceeds ${Au} 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>_u)throw new Error(`${e} contains more than ${_u} wildcard tokens`);return r}function fw(t){let r=Ho(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)=>dw(i,`knowledge.local.include[${n}]`)))]}}function hw(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 pw(t){let e=Ho(t,"knowledge.remote"),r=hw(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 mw(t){if(t===void 0)return{...Qg};let e=Ho(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:fw(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:pw(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 vw(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function gw(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 Cr(t,e={}){let r=(0,Oo.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=vw(n.ambient_resume),o=n.hook===void 0?void 0:lw(n.hook),s=uw(n.memory),c=mw(n.knowledge),l=n.native===void 0?void 0:sw(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=n.classic===void 0?void 0:cw(n.classic),d=gw(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}:{}}}import{createHash as yw}from"crypto";import{promises as en}from"fs";import Xe from"path";import{constants as Qi,promises as ct}from"fs";var fe=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}};function Do(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Hu(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function xr(t){return{dev:t.dev,ino:t.ino,birthtime:Do(t)}}function Zi(t,e){let r=xr(t),i=xr(e);return be(r,i)?T(r,i):T(r,i)&&Do(t)===Do(e)&&Hu(t)===Hu(e)&&t.size===e.size}async function lt(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 ct.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new fe("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new fe("too-large",`${i} exceeds ${e} bytes`);let o=await ct.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:xr(a)});let s=process.platform==="win32"?Qi.O_RDONLY:Qi.O_RDONLY|Qi.O_NOFOLLOW|Qi.O_NONBLOCK,c;try{c=await ct.open(t,s)}catch(l){throw l.code==="ELOOP"?new fe("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,u,d]=await Promise.all([c.stat({bigint:n}),ct.lstat(t,{bigint:n}),ct.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!Zi(a,l)||!Zi(a,u))throw new fe("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:d,identity:xr(l)}),await r.hooks?.afterOpen?.();let f=[],p=0,g=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let N=e+1-p,{bytesRead:k}=await c.read(g,0,Math.min(g.length,N),null);if(k===0)break;if(p+=k,p>e)throw new fe("too-large",`${i} exceeds ${e} bytes`);f.push(Buffer.from(g.subarray(0,k)))}await r.hooks?.beforeFinalCheck?.();let[h,m,y]=await Promise.all([c.stat({bigint:n}),ct.lstat(t,{bigint:n}),ct.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||y!==o||!Zi(a,h)||!Zi(a,m))throw new fe("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:y,identity:xr(h)}),{bytes:Buffer.concat(f,p),stat:h,realPath:y}}finally{await c.close()}}function ww(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Lo(t,e){let r=Xe.relative(t,e);return r===""||!Xe.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Xe.sep}`)}async function Du(t,e){let r=Xe.resolve(t),i=await en.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return en.realpath(r)}async function Lu(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=Xe.join(n,r[a]);let o;try{o=await en.lstat(n)}catch(u){if(ww(u))return{exists:!1,kind:"missing"};throw u}let s=Xe.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 en.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 Ot(t,e,r){let i=Yi(e,r.label),n=Xe.resolve(t),a=await Du(n,r.label),o=i.split("/"),s=Xe.resolve(n,...o);if(!Lo(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await Lu(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 Ot(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 Du(n.projectRoot,i.label);return lt(n.target,r,{...i,verify:async(o,s)=>{if(!Lo(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await Lu(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var Pr=".comet/config.yaml";function Nw(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function tn(t,e={}){return(await rn(t,e)).document}async function bw(t){try{return(await Qe(t,Pr,Er,{label:Pr})).bytes}catch(e){if(Nw(e))return null;throw e}}function kw(t){return t?{exists:!0,sha256:yw("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function rn(t,e={}){let r=await bw(t);return{document:r?Cr(r.toString("utf8"),e):null,identity:kw(r)}}async function Bo(t){return(await tn(t))?.config??null}var nC=16*1024;import{existsSync as Mu,promises as ut}from"fs";import A from"path";import Pw from"os";var Wo=".comet/config.yaml",Rw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function Vo(t){try{return await ut.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Aw(t){try{let e=await ut.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Dt(t,e){let r=A.relative(t,e);return r===""||!A.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${A.sep}`)}async function Ht(t){let e=[],r=t;for(;!await Vo(r);){let n=A.dirname(r);if(n===r)break;e.push(A.basename(r)),r=n}let i=await ut.realpath(r);return A.resolve(i,...e.reverse())}async function qo(t){try{return(await ut.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function zo(t){let e=A.resolve(t);try{(await ut.stat(e)).isDirectory()||(e=A.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=A.resolve(Pw.homedir());for(;;){if(!(e===i&&r!==i)){let o=A.join(e,...Wo.split("/")),s=e===r||await Aw(o);if(await Vo(o)&&s)return e}if(await Vo(A.join(e,".git")))return e;let a=A.dirname(e);if(a===e)return r;e=a}}function Jo(t){return $t(t)}async function _w(t,e){let r=Jo(e),i=A.resolve(t,...r.split("/")),n=await ut.realpath(t),a=await Ht(i);if(!Dt(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function dt(t,e){let r=Jo(e),i=await _w(t,r),n=A.join(i,"comet");if(await qo(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([Ht(i),Ht(n)]);if(!Dt(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 qo(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,u]=await Promise.all([ut.realpath(s),Ht(c)]);if(!Dt(l,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:A.join(t,...Wo.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 Fu(t){if(!Rw.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Lt(t,e){Fu(e);let r=A.join(t.changesRuntimeDir,e);if(!F(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function Tw(t,e){Fu(e);let r=A.join(t.changesDir,e,"runtime");if(!F(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Z(t,e){let r=Lt(t,e);if(Mu(r))return r;let i=Tw(t,e);return Mu(i)?i:r}function he(t,e){let r=A.resolve(e);if(F(t.runtimeDir,r))return t.runtimeDir;if(F(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function F(t,e){return Dt(A.resolve(t),A.resolve(e))}async function I(t,e){let r=A.resolve(t),i=A.resolve(e);if(!Dt(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await qo(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([Ht(r),Ht(i)]);if(!Dt(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}var nn=Xi;async function pe(t){let e=(await tn(t))?.config??null;return e?.native?e:null}async function an(t){let e=await pe(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}import{promises as rN}from"fs";import iN from"path";import{AsyncLocalStorage as jw}from"async_hooks";import{randomUUID as zu}from"crypto";import{promises as ee}from"fs";import Ju from"os";import V from"path";var qu=16*1024,Gu=".coordinator",$w=5e3,Wu=new jw,on=new Map;function Ow(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function Hw(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let r=t;if(typeof r.id!="string"||r.id.length===0||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<1||typeof r.hostname!="string"||r.hostname.length===0||typeof r.createdAt!="string"||r.createdAt.length===0||typeof r.operation!="string"||r.operation.length===0)throw new Error(`Invalid Native lock metadata: ${e}`);return r}function Uu(t){return{device:t.dev.toString(),inode:t.ino.toString(),size:t.size.toString(),birthtimeNs:t.birthtimeNs.toString(),ctimeNs:t.ctimeNs.toString(),mtimeNs:t.mtimeNs.toString()}}function sn(t,e){let r={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},i={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return be(r,i)?T(r,i):T(r,i)&&t.size===e.size}function Go(t,e){return sn(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}async function Ee(t){let e,r;try{let i=await lt(t,qu,{bigint:!0,label:"Native lock"});e=i.bytes,r=i.stat}catch(i){if(i.code==="ENOENT")return null;throw i instanceof fe?i.reason==="too-large"?new Error(`Native lock metadata exceeds ${qu} bytes: ${t}`,{cause:i}):i.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:i}):new Error(`Native lock changed while reading: ${t}`,{cause:i}):i}return{file:t,owner:Hw(JSON.parse(e.toString("utf8")),t),identity:Uu(r)}}async function Dw(t){return(await Ee(t))?.owner??null}function Ku(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==Ju.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=qw(t.owner.pid);return{status:e===!0?"active":e===!1?"stale":"unknown",owner:t.owner,identity:t.identity}}async function Lw(t,e){try{await ee.lstat(e);return}catch(r){if(r.code!=="ENOENT")throw r}try{await ee.rename(t,e)}catch(r){if(r.code!=="ENOENT")throw r}}async function Uo(t,e){let r=await Ee(t.file);if(!r)return"missing";if(r.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!Go(r.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await ee.mkdir(e,{recursive:!0});let i=V.join(e,`${V.basename(t.file)}.${t.owner.id}.${zu()}.removed`);try{await ee.rename(t.file,i)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await Ee(i);if(!n||n.owner.id!==t.owner.id||!sn(n.identity,t.identity))throw await Lw(i,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await ee.rm(i,{force:!0}),"removed"}function Yu(t){return{id:zu(),pid:process.pid,hostname:Ju.hostname(),createdAt:new Date().toISOString(),operation:t}}async function Xu(t,e){let r;try{r=await ee.open(t,"wx")}catch(a){if(a.code==="EEXIST"){let o=await Dw(t);throw new Error(`Native lock is already held: ${t}${o?` by pid ${o.pid} for ${o.operation}`:""}`,{cause:a})}throw a}let i;try{await r.writeFile(JSON.stringify(e,null,2)+`
146
+ `,"utf8"),await r.sync(),i=Uu(await r.stat({bigint:!0}))}finally{await r.close()}let n=await Ee(t);if(!i||!n||n.owner.id!==e.id||!sn(n.identity,i))throw new Error(`Native lock changed after write: ${t}`);return n.identity}async function Bw(t,e){let r=await I(t.runtimeDir,t.locksDir);await ee.mkdir(r,{recursive:!0});let i=await I(t.runtimeDir,V.join(r,Gu));await ee.mkdir(i,{recursive:!0});let n=Yu(e),a=V.join(i,`.${n.id}.tmp`),o=V.join(i,`${n.id}.claim`);try{let s=await Xu(a,n);await ee.rename(a,o);let c=await Ee(o);if(!c||!sn(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:r,owner:n,identity:c.identity}}finally{await ee.rm(a,{force:!0})}}async function Mw(t){let e=V.dirname(t.file),r=!1,i=V.basename(t.file);for(let n of await ee.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=V.join(e,n.name);if(V.resolve(a)!==V.resolve(t.file))try{let o=await Ee(a),s=Ku(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await Uo(o,e);continue}n.name<i&&(r=!0)}catch{n.name<i&&(r=!0)}}return r}async function Qu(t){let e=await Ee(t.file);if(e){if(e.owner.id!==t.owner.id||!Go(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await Uo(e,V.dirname(t.file))}}async function Fw(t,e){let r=Date.now()+$w;for(;;){let i=await Bw(t,e);if(!await Mw(i))return i;if(await Qu(i),Date.now()>=r)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function Vw(t){let e=on.get(t)??Promise.resolve(),r,i=new Promise(a=>{r=a}),n=e.then(()=>i);return on.set(t,n),await e,()=>{r(),on.get(t)===n&&on.delete(t)}}async function Zu(t,e,r){let i=V.resolve(t.locksDir),n=Wu.getStore();if(n?.has(i))return r();let a=await Vw(i);try{let o=await Fw(t,e),s=new Map(n??[]);return s.set(i,o),await Wu.run(s,async()=>{try{return await r()}finally{await Qu(o)}})}finally{a()}}async function cn(t,e,r){return Zu(t,`acquire ${e}`,async()=>{let i=await I(t.runtimeDir,t.locksDir);await ee.mkdir(i,{recursive:!0});let n=await I(t.runtimeDir,V.join(i,Ow(e))),a=Yu(r),o=await Xu(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:i,owner:a,identity:o}})}async function ln(t){await Ee(t.file)&&await Zu({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${V.basename(t.file)}`,async()=>{let e=await Ee(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!Go(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let r=V.join(t.locksDir,Gu);await Uo(e,r)})}function qw(t){try{return process.kill(t,0),!0}catch(e){let r=e.code;return r==="ESRCH"?!1:r==="EPERM"?!0:null}}async function ed(t){return Ku(await Ee(t))}import Ry from"node:path";import{createHash as Ww}from"crypto";function me(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function zw(t,e){e.has(t)&&me("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)||me("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&me("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&me("symbol properties are not supported"),`[${t.map(i=>Ko(i,e)).join(",")}]`}finally{e.delete(t)}}function Jw(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&me("only plain objects are supported"),e.has(t)&&me("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&me("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))&&me("accessor properties are not supported"),`${JSON.stringify(o)}:${Ko(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function Ko(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)||me("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?zw(t,e):Jw(t,e);case"bigint":case"function":case"symbol":case"undefined":return me(`${typeof t} values are not supported`)}return me("unsupported value type")}function Yo(t){return Ko(t,new Set)}function te(t,e){if(t.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(t))throw new TypeError("Canonical hash tag must not contain a line break");return Ww("sha256").update(`${t}
147
+ ${Yo(e)}`).digest("hex")}var LC=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),td=Object.freeze({maxCriteria:1024});var fn=Wt(It(),1);import{promises as Xw}from"node:fs";var Ar="comet.native.v4",_r="comet.native.local-execution.v4";var Qw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Zw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,ey=/^A[1-9][0-9]*$/u,ty=/^[a-f0-9]{64}$/u,ry=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"]),dn=class extends Error{constructor(r,i){super(`Native state version conflict: expected ${r}, got ${i}`);this.expectedStateVersion=r;this.actualStateVersion=i;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};function q(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function W(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function B(t,e,r){if(typeof t!="string"||!r?.empty&&t.length===0)throw new Error(`${e} must be ${r?.empty?"a string":"a non-empty string"}`);return t}function Qo(t,e){return t===null?null:B(t,e)}function iy(t,e){let r=B(t,e);if(!ty.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function Bt(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 ny(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 Ce(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function hn(t,e){return Ce(t,e,(r,i)=>B(r,`${e}[${i}]`))}function ft(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Mt(t,e){let r=B(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function Zo(t,e,r=!1){let i=B(t,e);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return i}function re(t,e){let r=q(t,e);return W(r,new Set(["text","truncated"]),e),{text:B(r.text,`${e}.text`,{empty:!0}),truncated:Bt(r.truncated,`${e}.truncated`)}}function ay(t,e){let r=`Native spec_changes[${e}]`,i=q(t,r);W(i,new Set(["capability","operation","source"]),r);let n=B(i.capability,`${r}.capability`);if(!Zw.test(n))throw new Error(`${r}.capability is invalid`);let a=O(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:Zo(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 oy(t){let e="Native workspace",r=q(t,e);W(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=O(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=Qo(r.change_branch,`${e}.change_branch`),a=Qo(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 sy(t){let e="Native loop",r=q(t,e);W(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","stop_reason","execution_failure_count","previous_unresolved_ids","next_action"]),e);let i=hn(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);ft(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:Qo(r.next_action,`${e}.next_action`)}}function cy(t,e){let r=`Native acceptance[${e}]`,i=q(t,r);W(i,new Set(["id","source","text","result","reason"]),r);let n=B(i.id,`${r}.id`);if(!ey.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:Zo(i.source,`${r}.source`),text:B(i.text,`${r}.text`),result:O(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:re(i.reason,`${r}.reason`)}}function ly(t,e){let r=`Native builder_handoff.checks[${e}]`,i=q(t,r);return W(i,new Set(["name","result","note"]),r),{name:re(i.name,`${r}.name`),result:O(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:re(i.note,`${r}.note`)}}function uy(t){let e="Native builder_handoff",r=q(t,e);W(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),e);let i=hn(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);ft(i,`${e}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:q(r.review,`${e}.review`);return n&&W(n,new Set(["status","summary","reviewer_execution_ref"]),`${e}.review`),{candidate_id:B(r.candidate_id,`${e}.candidate_id`),identity_provider:B(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:B(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:j(r.iteration,`${e}.iteration`,1),summary:re(r.summary,`${e}.summary`),addressed_acceptance_ids:i,checks:Ce(r.checks,`${e}.checks`,ly),checks_truncated:Bt(r.checks_truncated,`${e}.checks_truncated`),known_limits:Ce(r.known_limits,`${e}.known_limits`,(a,o)=>re(a,`${e}.known_limits[${o}]`)),known_limits_truncated:Bt(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:O(n.status,["passed"],`${e}.review.status`),summary:re(n.summary,`${e}.review.summary`),reviewer_execution_ref:B(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:Mt(r.submitted_at,`${e}.submitted_at`)}}function dy(t,e){let r=`Native blockers[${e}]`,i=q(t,r);W(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=hn(i.acceptance_ids,`${r}.acceptance_ids`);return ft(n,`${r}.acceptance_ids`),{owner:O(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:re(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 fy(t,e){let r=`Native verification.checks[${e}]`,i=q(t,r);return W(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:B(i.id,`${r}.id`),name:re(i.name,`${r}.name`),argv_display:Ce(i.argv_display,`${r}.argv_display`,(n,a)=>re(n,`${r}.argv_display[${a}]`)),argv_truncated:Bt(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:Zo(i.cwd_ref,`${r}.cwd_ref`,!0),status:O(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:ny(i.exit_code,`${r}.exit_code`),duration_ms:j(i.duration_ms,`${r}.duration_ms`)}}function hy(t){let e="Native verification",r=q(t,e);W(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let i=Ce(r.checks,`${e}.checks`,fy);ft(i.map(a=>a.id),`${e}.checks IDs`);let n=B(r.identity_provider,`${e}.identity_provider`);return{candidate_id:B(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:B(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration: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:re(r.summary,`${e}.summary`),risks:Ce(r.risks,`${e}.risks`,(a,o)=>re(a,`${e}.risks[${o}]`)),risks_truncated:Bt(r.risks_truncated,`${e}.risks_truncated`),completed_at:Mt(r.completed_at,`${e}.completed_at`)}}function rd(t,e){let r=`Native history[${e}]`,i=q(t,r);W(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=hn(i.unresolved_ids,`${r}.unresolved_ids`);return ft(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:re(i.summary,`${r}.summary`),completed_at:Mt(i.completed_at,`${r}.completed_at`)}}function py(t){let e="Native history_overflow.outcome_counts",r=q(t,e),i=["pass","fail","blocked","execution-error","recovery"];return W(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 my(t){let e="Native history_overflow",r=q(t,e);W(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:Mt(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:Mt(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=py(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 vy(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 gy(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 xe(t){let e=q(t,"Native portable state");if(W(e,ry,"Native portable state"),e.schema!==Ar)throw new Error(`Native portable state schema must be ${Ar}`);let r=B(e.name,"Native state name");if(!Qw.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=Ce(e.spec_changes,"Native spec_changes",ay);ft(i.map(s=>s.capability),"Native spec change capabilities");let n=Ce(e.acceptance,"Native acceptance",cy);ft(n.map(s=>s.id),"Native acceptance IDs");let a=Ce(e.history,"Native history",rd);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Ar,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:iy(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:oy(e.workspace),loop:sy(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:uy(e.builder_handoff),blockers:Ce(e.blockers,"Native blockers",dy),verification:e.verification===null?null:hy(e.verification),history:a,history_overflow:my(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:Bt(e.archived,"Native archived"),created_at:Mt(e.created_at,"Native created_at")};return vy(o),gy(o),o}function pn(t,e){let r=xe(t),i=rd(e,r.history.length),n=[...r.history,i],a={...r.history_overflow,outcome_counts:{...r.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return xe({...r,history:n,history_overflow:a})}function wy(t,e){let r=(0,fn.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 Tr(t){let e=await Xw.readFile(t,"utf8");return xe(wy(e,"Native portable state"))}async function id(t,e,r={}){let i=xe(e);await ke(t,(0,fn.stringify)(i),r)}var un=new Map;async function yy(t,e){let r=un.get(t)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);un.set(t,a),await r;try{return await e()}finally{i(),un.get(t)===a&&un.delete(t)}}async function nd(t){return yy(t.file,async()=>{let e=j(t.expectedStateVersion,"Native expected state version",1),r=xe(t.next);if(r.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await Tr(t.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==e)throw new dn(e,i.state_version);return await id(t.file,r,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await Tr(t.file);if(n.state_version!==e)throw new dn(e,n.state_version)}}),r})}function Ny(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function Ir(t,e=16384){if(typeof t!="string")throw new Error("Native portable text must be a string");if(Ny(e),Buffer.byteLength(t,"utf8")<=e)return{text:t,truncated:!1};let r="",i=0;for(let n of t){let a=Buffer.byteLength(n,"utf8");if(i+a>e)break;r+=n,i+=a}return{text:r,truncated:!0}}var je="comet.native.v3",$e="comet.native.v2",Oe="comet.native.v1";var ad="comet.native.portable-migration.v1",by=new Set(["schema","id","change","fromSchema","status","createdAt"]),ky=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Sy=/^[a-z0-9][a-z0-9-]{7,127}$/u,Ey=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),Cy=new Set([Oe,$e,je]);function xy(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Py(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let r=new Date(t);if(Number.isNaN(r.valueOf())||r.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function od(t){let e=xy(t,"Native portable migration transaction"),r=Object.keys(e).filter(i=>!by.has(i));if(r.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${r.join(", ")}`);if(e.schema!==ad)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!Sy.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!ky.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!Cy.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!Ey.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:ad,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:Py(e.createdAt,"Native portable migration transaction createdAt")}}var sd="comet.native.archive-transaction.v4",cd="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",Ay=new RegExp(`^portable-archive-(${cd})\\.json$`,"u"),_y=new RegExp(`^portable-migration-(${cd})\\.json$`,"u"),Ty=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,Iy=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,jy=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),$y=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),Oy=new Set(["capability","operation","source","content"]),ld=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function ud(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function dd(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`);if(Object.keys(t).length!==e.size)throw new Error(`${r} fields are invalid`)}function Hy(t,e){let r=`Native portable Archive spec_changes[${e}]`,i=ud(t,r);if(dd(i,Oy,r),typeof i.capability!="string"||!ld.test(i.capability))throw new Error(`${r}.capability is invalid`);if(!["create","modify","remove"].includes(String(i.operation)))throw new Error(`${r}.operation is invalid`);let n=i.operation;if(n==="remove"){if(i.source!==null||i.content!==null)throw new Error(`${r} remove requires source and content null`);return{capability:i.capability,operation:n,source:null,content:null}}if(typeof i.source!="string"||i.source.length===0||i.source.includes("\\")||i.source.startsWith("/")||/^[A-Za-z]:/u.test(i.source)||i.source.split("/").some(a=>a==="."||a===".."))throw new Error(`${r}.${n} source is invalid`);if(typeof i.content!="string")throw new Error(`${r}.${n} content is invalid`);return{capability:i.capability,operation:n,source:i.source,content:i.content}}function Dy(t){let e=ud(t,"Native portable Archive transaction");if(dd(e,$y,"Native portable Archive transaction"),e.schema!==sd)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!Ty.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!ld.test(e.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(e.start_state_version)||Number(e.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof e.archive_ref!="string"||!Iy.test(e.archive_ref)||!e.archive_ref.endsWith(`-${e.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof e.status!="string"||!jy.has(e.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let r=e.spec_changes.map(Hy);if(new Set(r.map(({capability:n})=>n)).size!==r.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>r.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof e.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let i=new Date(e.created_at);if(Number.isNaN(i.valueOf())||i.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:sd,id:e.id,change:e.change,start_state_version:Number(e.start_state_version),archive_ref:e.archive_ref,status:e.status,next_spec_index:Number(e.next_spec_index),spec_changes:r,created_at:e.created_at}}function es(t){let e=Ay.exec(t);if(e)return{kind:"archive",change:e[1]};let r=_y.exec(t);return r?{kind:"migration",change:r[1]}:null}async function fd(t,e){let r=es(e);if(!r)return null;let i=await Q({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(i.text),a=Ry.join(t.transactionsDir,e);if(r.kind==="archive"){let s=Dy(n);if(s.change!==r.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:r.change,file:a,journal:s}}let o=od(n);if(o.change!==r.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:r.change,file:a,journal:o}}function hd(t){return t.kind==="archive"||t.journal.status!=="committed"}import He from"path";import{TextDecoder as Jy}from"util";import{createHash as Ly}from"node:crypto";import{constants as wn,promises as ve}from"node:fs";import ge from"node:path";import{TextDecoder as By}from"node:util";function Nn(t,e){let r=ge.relative(t,e);return r===""||!ge.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ge.sep}`)}function My(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function Fy(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Vy(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function yn(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 ts(t,e){let r=await ve.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await ve.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function qy(t,e,r){let i=ge.resolve(t),n=ge.resolve(e);if(!Nn(i,n))throw new Error(`${r} is outside its managed root`);let a=[await ts(i,r)],o=i;for(let s of ge.relative(i,n).split(ge.sep).filter(Boolean)){await ht(a,r),o=ge.join(o,s);let c=await ts(o,r);if(!Nn(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await ht(a,r),a}async function ht(t,e){for(let r of t){let i=await ve.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!Fy(r,i)||await ve.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function Wy(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 pt(t){let e=My(t.maxBytes),r=ge.resolve(t.file),i=await qy(t.root,ge.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(u=>ts(ge.resolve(u),t.label)));await t.hooks?.afterParentChainCaptured?.(),await ht(i,t.label);let a=await ve.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=Vy(a),s=await ve.realpath(r);if(!Nn(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(u=>Nn(u.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?wn.O_RDONLY:wn.O_RDONLY|wn.O_NOFOLLOW|wn.O_NONBLOCK,l=await ve.open(r,c);try{let u=await l.stat();await t.hooks?.afterOpen?.();let[d,f]=await Promise.all([ve.lstat(r),ve.realpath(r)]);if(await ht(i,t.label),await ht(n,t.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!yn(o,u)||!yn(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let p=await Wy(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[g,h,m]=await Promise.all([l.stat(),ve.lstat(r),ve.realpath(r)]);if(await ht(i,t.label),await ht(n,t.label),!h.isFile()||h.isSymbolicLink()||m!==s||!yn(o,g)||!yn(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:p,hash:Ly("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}async function pd(t){let e=await pt(t),r;try{r=new By("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}}var Gy=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),Uy=new Set(["id","type","source","target","staged","backup"]),Ky=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Yy=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var gd=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var Xy=256*1024,Sx=1024*1024,Ex=16*1024;var Cx=64*1024*1024;var Qy=new Jy("utf-8",{fatal:!0});function kn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Sn(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 wd(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function rs(t,e){if(typeof t!="string"||t.length===0||He.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function bn(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function md(t,e){if(rs(t,e),t.includes("\\")||t!==He.posix.normalize(t)||t.split("/").includes(".")||t.endsWith("/")||Buffer.byteLength(t,"utf8")>1024)throw new Error(`${e} must be a normalized Native-relative ref`)}function Zy(t,e){let r=kn(t,`transaction operations[${e}]`);if(Sn(r,Uy,`transaction operations[${e}]`),typeof r.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(r.id))throw new Error(`transaction operations[${e}].id is invalid`);if(r.type!=="write"&&r.type!=="remove"&&r.type!=="move")throw new Error(`transaction operation ${r.id} has an invalid type`);rs(r.target,`transaction operation ${r.id} target`);for(let i of["source","staged","backup"])r[i]!==void 0&&rs(r[i],`transaction operation ${r.id} ${i}`);if(r.type==="write"){if(r.staged===void 0||r.source!==void 0)throw new Error(`write operation ${r.id} requires staged and forbids source`)}else if(r.type==="remove"){if(r.source!==void 0||r.staged!==void 0)throw new Error(`remove operation ${r.id} forbids source and staged`)}else if(r.source===void 0||r.staged!==void 0||r.backup!==void 0)throw new Error(`move operation ${r.id} requires source and forbids staged and backup`);return r}function yd(t){let e=kn(t,"Native Archive transaction journal");if(Sn(e,Ky,"Native Archive transaction journal"),e.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native Archive transaction id is invalid");if(e.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof e.status!="string"||!gd.has(e.status))throw new Error("Native Archive transaction status is invalid");if(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change))throw new Error("Native Archive transaction change name is invalid");if(!wd(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(bn(e.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(e.operations)||e.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let r=e.operations.map((s,c)=>{let l=kn(s,`Archive transaction operations[${c}]`);if(Sn(l,Yy,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);md(l.target,`Archive transaction operation ${l.id} target`);for(let u of["source","staged","backup"])l[u]!==void 0&&md(l[u],`Archive transaction operation ${l.id} ${u}`);if(l.expectedTargetHash!==null&&bn(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(bn(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);bn(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),i=r.map(s=>s.id);if(new Set(i).size!==i.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=r.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${e.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${e.change}$`,"u").test(a[0].target)||r.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of r.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:r}}function eN(t){let e=kn(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return yd(e);if(Sn(e,Gy,"Native transaction journal"),e.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native transaction id is invalid");if(e.kind!=="archive"&&e.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof e.status!="string"||!gd.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!He.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!He.isAbsolute(e.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(e.change!==void 0&&(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change)))throw new Error("Native transaction change name is invalid");if(!wd(e.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(e.operations))throw new Error("Native transaction operations must be an array");let r=e.operations.map(Zy),i=r.map(n=>n.id);if(new Set(i).size!==i.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:e.id,kind:e.kind,status:e.status,projectRoot:e.projectRoot,nativeRoot:e.nativeRoot,...typeof e.change=="string"?{change:e.change}:{},createdAt:e.createdAt,operations:r}}function tN(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return He.join(t.transactionsDir,e)}function Nd(t,e){let r=tN(t,e);return{directory:r,journal:He.join(r,"transaction.json"),events:He.join(r,"events.jsonl"),staged:He.join(r,"staged"),backups:He.join(r,"backups")}}async function ns(t,e){let r=Nd(t,e);return await Promise.all(Object.values(r).map(i=>I(t.runtimeDir,i))),r}async function as(t,e,r={}){let i=await ns(t,e),n=await pt({root:t.runtimeDir,file:i.journal,maxBytes:Xy,label:`Native transaction journal ${e}`,hooks:r.hooks}),a=JSON.parse(Qy.decode(n.bytes)),o=eN(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}async function nN(t,e,r){let i;try{i=await rN.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await as(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of i)if(es(n.name))try{let a=await fd(t,n.name);if(!a||r?.kind===a.kind&&r.change===a.change)continue;if(hd(a))return!0}catch{return!0}return!1}async function aN(t,e){let r=Date.now()+5e3,i=iN.join(t.locksDir,"root-move.lock");for(;;)try{return await cn(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await ed(i);if(o.status==="missing")continue;if(o.status!=="active"||Date.now()>=r)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function ie(t,e,r,i){let n=await aN(t,e);try{if(await an(t.projectRoot),await nN(t,i?.allowedTransactionId,i?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await r()}finally{await ln(n)}}import ss from"path";import{createHash as oN}from"crypto";function K(t){return oN("sha256").update(t).digest("hex")}var zx={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},cN=1e3,lN=8*1024*1024,uN=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,dN=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),fN=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),hN=new Set(["schema","include","exclude","hash"]),pN=new Set(["provider","gitSelection","physicalSelection","projection"]),mN=new Set(["provider","selection"]),vN=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),gN=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),wN=new Set(["schema","status","before","after"]),yN=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),NN=new Set(["path","hash","size","type","gitObjectId"]),bN=new Set(["path","size","type","reason"]),kN=new Set(["ref","hash","count"]),SN=new Set(["change-created","legacy-migration","explicit"]),EN=new Set(["file","directory","other"]),CN=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,xN=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var Jx=64*1024,Gx=64*1024;var Ux={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},Kx={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function En(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var Yx=(1n<<256n)-1n;function PN(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 RN(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
148
+ `)}function AN(t,e){return K(`comet.native.snapshot-policy.v1
149
+ ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function os(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 _N(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function bd(t){let e=nn(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?_N(n):void 0;if(a&&!a())return!1;let o=os(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=os(r,c,a),o===null||o.size===0)return!1}return os(r,o,a)?.has(r.length)??!1}}function TN(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>nn(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>nn(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=AN(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(bd),excludeMatchers:r.map(bd),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 ne(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ae(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function Vt(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Pe(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function Ed(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=ss.posix.normalize(t);if(r!==t||ss.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function IN(t,e){let r=ne(t,`Native snapshot entry ${e}`);ae(r,NN,`Native snapshot entry ${e}`);let i=Ed(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:Pe(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!xN.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function jN(t,e){let r=ne(t,`Native snapshot omission ${e}`);if(ae(r,bN,`Native snapshot omission ${e}`),!EN.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!CN.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:Ed(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:Pe(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function $N(t){let e=ne(t,"Native snapshot omission overflow");if(ae(e,kN,"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:Vt(e.count,"Native snapshot omission overflow count")}}function Ft(t,e){let r=ne(t,e);if(ae(r,gN,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=Pe(r.recordCount,`${e} recordCount`),n=Pe(r.storedRecordCount,`${e} storedRecordCount`),a=Pe(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 kd(t){let e=ne(t,"Native Git selection evidence");if(ae(e,vN,"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=Ft(e.stageBefore,"Native Git selection stageBefore"),i=Ft(e.combined,"Native Git selection combined"),n=Ft(e.stageAfter,"Native Git selection stageAfter"),a=Ft(e.finalStageBefore,"Native Git selection finalStageBefore"),o=Ft(e.finalCombined,"Native Git selection finalCombined"),s=Ft(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(d=>d.overflow),l=!En(r,n)||!En(n,a)||!En(i,o)||!En(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 Sd(t,e){let r=ne(t,e);if(ae(r,yN,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=Pe(r.visitedNodeCount,`${e} visitedNodeCount`),n=Pe(r.recordCount,`${e} recordCount`),a=Pe(r.storedRecordCount,`${e} storedRecordCount`),o=Pe(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 ON(t){let e=ne(t,"Native physical selection evidence");if(ae(e,wN,"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=Sd(e.before,"Native physical selection before"),i=Sd(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!PN(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 Cd(t){let e=ne(t,"Native content snapshot manifest");if(ae(e,dN,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!SN.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let v=ne(e.capture,"Native content snapshot capture");if(ae(v,pN,"Native content snapshot capture"),v.provider!=="git"&&v.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let P=v.gitSelection===void 0?void 0:kd(v.gitSelection),b=v.physicalSelection===void 0?void 0:ON(v.physicalSelection),_=null;if(v.projection!==void 0){let U=ne(v.projection,"Native content snapshot projection");if(ae(U,mN,"Native content snapshot projection"),U.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");_={provider:"git",...U.selection===void 0?{}:{selection:kd(U.selection)}}}if(v.provider==="git"){if(b||_)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",...P?{gitSelection:P}:{}}}else{if(P)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(b&&_)throw new Error("Native physical-tree capture cannot combine selection and projection");r=_?{provider:"physical-tree",projection:_}:{provider:"physical-tree",...b?{physicalSelection:b}:{}}}}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=ne(e.limits,"Native content snapshot limits");ae(i,fN,"Native content snapshot limits");let n={maxFiles:Vt(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Vt(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Vt(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Vt(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:Vt(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let v=ne(e.policy,"Native snapshot policy");if(ae(v,hN,"Native snapshot policy"),v.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(v.include)||!Array.isArray(v.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=TN({include:v.include,exclude:v.exclude,hash:v.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(IN),s=e.omitted.map(jN),c=Pe(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:$N(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(v=>v.size>n.maxFileBytes)||o.reduce((v,P)=>v+P.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(v=>v.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>cN||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(v=>v.reason==="git-enumeration-limit"),f=s.filter(v=>v.reason==="git-selection-changed");for(let v of[...d,...f])if(v.path!=="."||v.size!==null||v.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 p=r?.provider==="git"?r.gitSelection:r?.projection?.selection,g=p?.status==="overflow"||p?.status==="overflow-and-changed",h=p?.status==="changed"||p?.status==="overflow-and-changed";if(g!==(d.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 m=s.filter(v=>v.reason==="physical-enumeration-limit"),y=s.filter(v=>v.reason==="physical-selection-changed");for(let v of[...m,...y])if(v.path!=="."||v.size!==null||v.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(m.length>1||y.length>1)throw new Error("Native physical selection omissions must not be duplicated");let N=r?.physicalSelection,k=N?.status==="overflow"||N?.status==="overflow-and-changed",S=N?.status==="changed"||N?.status==="overflow-and-changed";if(k!==(m.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(S!==(y.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(RN(E)>n.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function HN(t,e){if(!uN.test(e))throw new Error(`Invalid Native change name: ${e}`);return ss.join(Z(t,e),"baseline-manifest.json")}async function xd(t,e){let r=HN(t,e),i=he(t,r);await I(i,r);try{let n=await pd({root:i,file:r,maxBytes:lN,label:"Native baseline snapshot manifest"});return Cd(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var VN=Wt(It(),1);var fP=4*1024*1024;import z from"path";var qN=Vr("hookWritePolicy",async t=>(await Bo(t))?.hook??{allow_paths:[]});function Pd(t,e){let r=z.relative(t,e);return r===""||!z.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${z.sep}`)}function WN(t,e){let r=z.isAbsolute(e)?z.resolve(e):z.resolve(t,e),i=z.relative(z.resolve(t),r);return i===""||z.isAbsolute(i)||i===".."||i.startsWith(`..${z.sep}`)?null:i.replaceAll("\\","/")}function Rd(t){return process.platform==="win32"?t.toLowerCase():t}async function xn(t,e,r=[]){let i=z.isAbsolute(e)?z.resolve(e):z.resolve(t,e),n=z.resolve(t);if(!Pd(n,i)||r.some(c=>Pd(z.resolve(c),i)))return null;let a=WN(t,e);if(!a)return null;let s=(await qN(t)).allow_paths.find(c=>{let l=Rd(a),u=Rd(c);return l===u||l.startsWith(`${u}/`)});return s?`${a} (configured Hook allow path: ${s})`:null}var fR=256*1024;var CR={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};import{createHash as JN}from"node:crypto";import{promises as Pn}from"node:fs";import Ze from"node:path";var jr=/^[a-f0-9]{64}$/u,_d=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,GN=16*1024,ls=process.platform;function $d(t,e){let r=Ze.relative(t,e);return Ze.isAbsolute(r)||r===".."||r.startsWith(`..${Ze.sep}`)?null:r.replaceAll("\\","/")||"."}function Od(t){return Array.from(t).some(e=>{let r=e.codePointAt(0)??0;return r<=31||r===127})}function Hd(t,e){if(t.length===0||Od(t)||t.includes("\\")||Ze.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let r=Ze.posix.normalize(t);if(r!==t||r===".."||r.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return r}function us(t,e){return JN("sha256").update(`${t}
150
+ ${e}`).digest("hex")}async function Td(t,e){let r=await Pn.realpath(e),i=await Pn.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=ls==="win32"?Ze.normalize(r).toLowerCase():r;return us(t,`${n}
151
151
  ${i.dev}
152
152
  ${i.ino}
153
- ${i.birthtimeMs}`)}async function xd(t,e){let r=await kn.realpath(e),i=await kn.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=ss==="win32"?Xe.normalize(r).toLowerCase():r;return cs(t,n)}function jN(t){if(typeof t!="string")throw new Error("Native workspace capturedAt is invalid");let e=new Date(t);if(!Number.isFinite(e.getTime())||e.toISOString()!==t)throw new Error("Native workspace capturedAt is invalid");return t}function os(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||Ad(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function Td(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(os(t.changeBranch,"Native workspace change branch"),os(t.targetBranch,"Native workspace target branch"),(t.isolation==="branch"||t.isolation==="worktree")&&(t.changeBranch===null||t.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function $N(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(e).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!Ed.test(e.baseCommit)||typeof e.targetCommit!="string"||!Ed.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");os(e.targetBranch,"Native workspace Git target branch")}function Sn(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(e).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(e.schema!=="comet.native.workspace.v2"&&e.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(e.capturedRevision)||e.capturedRevision<1||typeof e.nativeRootRef!="string"||!Tr.test(String(e.projectRootId))||!Tr.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");jN(e.capturedAt),_d(e.nativeRootRef,"Native workspace root ref");let n=e.projectRootPathId!==void 0,a=e.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!Tr.test(String(e.projectRootPathId))||a&&!Tr.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!Tr.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&$N(e.git),e.schema==="comet.native.workspace.v2"){if(e.isolation!==void 0||e.changeBranch!==void 0||e.targetBranch!==void 0||e.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof e.isolation!="string"||e.changeBranch===void 0||e.targetBranch===void 0||e.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(Td(e),e.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(e.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function ON(t,e){return Xe.join(Q(t,e),"workspace.json")}function HN(t,e){let r=ON(t,e),i=fe(t,r),n=Rd(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:_d(n,"Native workspace file ref")}}async function DN(t,e){try{let r=HN(t,e),i=await X({root:r.root,ref:r.ref,maxBytes:IN});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function BN(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=Rd(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let r=se(t.paths.projectRoot),i=r.isGitWorktree?yr(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??r.currentBranch,a=n==null?null:yr(t.paths.projectRoot,n),o=i!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:i,targetBranch:n,targetCommit:a}:void 0,[s,c,l,u]=await Promise.all([Cd("comet.native.workspace-project-root.v2",t.paths.projectRoot),Cd("comet.native.workspace-native-root.v2",t.paths.nativeRoot),xd("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),xd("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),d=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&Td(t.binding);let f={capturedAt:d,capturedRevision:t.revision,nativeRootRef:e,projectRootId:s,nativeRootId:c,projectRootPathId:l,nativeRootPathId:u,...o?{git:o}:{},...t.sessionId?{sessionHash:cs("comet.native.workspace-session.v2",`${s}
153
+ ${i.birthtimeMs}`)}async function Id(t,e){let r=await Pn.realpath(e),i=await Pn.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=ls==="win32"?Ze.normalize(r).toLowerCase():r;return us(t,n)}function UN(t){if(typeof t!="string")throw new Error("Native workspace capturedAt is invalid");let e=new Date(t);if(!Number.isFinite(e.getTime())||e.toISOString()!==t)throw new Error("Native workspace capturedAt is invalid");return t}function cs(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||Od(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function Dd(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(cs(t.changeBranch,"Native workspace change branch"),cs(t.targetBranch,"Native workspace target branch"),(t.isolation==="branch"||t.isolation==="worktree")&&(t.changeBranch===null||t.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function KN(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(e).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!_d.test(e.baseCommit)||typeof e.targetCommit!="string"||!_d.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");cs(e.targetBranch,"Native workspace Git target branch")}function Rn(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(e).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(e.schema!=="comet.native.workspace.v2"&&e.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(e.capturedRevision)||e.capturedRevision<1||typeof e.nativeRootRef!="string"||!jr.test(String(e.projectRootId))||!jr.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");UN(e.capturedAt),Hd(e.nativeRootRef,"Native workspace root ref");let n=e.projectRootPathId!==void 0,a=e.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!jr.test(String(e.projectRootPathId))||a&&!jr.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!jr.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&KN(e.git),e.schema==="comet.native.workspace.v2"){if(e.isolation!==void 0||e.changeBranch!==void 0||e.targetBranch!==void 0||e.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof e.isolation!="string"||e.changeBranch===void 0||e.targetBranch===void 0||e.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(Dd(e),e.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(e.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function YN(t,e){return Ze.join(Z(t,e),"workspace.json")}function XN(t,e){let r=YN(t,e),i=he(t,r),n=$d(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:Hd(n,"Native workspace file ref")}}async function QN(t,e){try{let r=XN(t,e),i=await Q({root:r.root,ref:r.ref,maxBytes:GN});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function ZN(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=$d(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let r=ce(t.paths.projectRoot),i=r.isGitWorktree?kr(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??r.currentBranch,a=n==null?null:kr(t.paths.projectRoot,n),o=i!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:i,targetBranch:n,targetCommit:a}:void 0,[s,c,l,u]=await Promise.all([Td("comet.native.workspace-project-root.v2",t.paths.projectRoot),Td("comet.native.workspace-native-root.v2",t.paths.nativeRoot),Id("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),Id("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),d=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&Dd(t.binding);let f={capturedAt:d,capturedRevision:t.revision,nativeRootRef:e,projectRootId:s,nativeRootId:c,projectRootPathId:l,nativeRootPathId:u,...o?{git:o}:{},...t.sessionId?{sessionHash:us("comet.native.workspace-session.v2",`${s}
154
154
  ${c}
155
- ${t.sessionId}`)}:{}},p=t.binding?{schema:"comet.native.workspace.v3",...f,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...f};return Sn(p),p}async function En(t,e){let r=await DN(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(Sn(r),r)}async function Id(t){Sn(t.identity);let e=await BN({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),r=[],i=[];return e.nativeRootRef!==t.identity.nativeRootRef&&r.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&r.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&r.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&r.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&r.push("native-root-legacy-identity")),ss==="win32"&&r.length>0&&r.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?i.push("workspace-inspection-unavailable"):r.length>0&&i.push("workspace-root-changed"),{state:i.length===0?"aligned":i.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:i,driftComponents:r}}async function jd(t){if(Sn(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await Id(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=se(t.paths.projectRoot);return t.identity.changeBranch===null?r.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:r.isGitWorktree?r.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${r.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!r.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}async function $d(t,e){let r=await En(t,e);if(r===null)return null;let i=await jd({paths:t,identity:r});if(i.state==="drifted")throw new Error(`${i.code}: ${i.message}`);return r}var Hd=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],FN=new Set(Hd),Dd=new Set([...Hd,"minimum_runtime_version","revision"]),VN=new Set([...Dd,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),qN=new Set(["capability","operation","source","base_hash"]),WN=new Set(["shape","build","verify","archive"]),zN=new Set(["implicit","confirmed"]),JN=new Set(["pending","pass","fail"]),mt="comet-state.yaml",us=/^[a-f0-9]{64}$/u,Bd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,GN=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Cn=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"},pt=class extends Error{constructor(r,i){super(r!==Ie||i===null?`Unsupported Native change schema ${r} for runtime protocol ${3}`:`Native change ${r} requires runtime protocol ${i}; current protocol is ${3}`);this.schema=r;this.minimumRuntimeVersion=i;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"},xn=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},Ir=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},Pn=class extends Error{constructor(r,i,n,a,o,s=null,c=null){super(`Native change ${r} baseline is incomplete (${i} omitted entr${i===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=r;this.omittedCount=i;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},OR=qi("en");function $r(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ld(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Rn(t){if(!Bd.test(t))throw new Error(`Invalid Native change name: ${t}`)}function UN(t){if(!Bd.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Md(t,e){if(t.length===0||ht.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function KN(t,e){let r=$r(t,`spec_changes[${e}]`);if(Ld(r,qN,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(UN(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"&&Md(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"||!us.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"||!us.test(n))throw new Error(`Remove spec ${r.capability} requires a SHA-256 base_hash`)}return{capability:r.capability,operation:r.operation,...typeof i=="string"?{source:i}:{},base_hash:n}}function YN(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 hs(t,e){if(Ld(t,e,mt),typeof t.name!="string")throw new Error("Native change name is required");if(Rn(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"||!WN.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&&!zN.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(KN),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"||!JN.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"&&Md(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!YN(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 un(t){let e=$r(t,mt);if(e.schema!==$e)throw new Error(`Expected ${$e}`);return{schema:$e,...hs(e,FN)}}function jr(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function ls(t,e,r){if(t===null)return null;let i=typeof t=="string"?GN.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 XN(t){if(t==null)return null;if(typeof t!="string"||!us.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function QN(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 dn(t){let e=$r(t,mt);if(e.schema!==je)throw new Error(`Expected ${je}`);if(jr(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${je} minimum_runtime_version must be 2`);return{schema:je,minimum_runtime_version:2,revision:jr(e.revision,"Native v2 revision"),...hs(e,Dd)}}function fn(t){let e=$r(t,mt);if(e.schema!==Ie){if(e.schema===$e||e.schema===je){let o=e.schema===$e?un(e):dn(e);throw new Cn(o.name,o.schema)}throw new pt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=jr(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new pt(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=jr(e.revision,"Native revision"),n=hs(e,VN),a=XN(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Ie,minimum_runtime_version:3,revision:i,verification_protocol:QN(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:ls(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:ls(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:ls(e.partial_allowance,"Native partial_allowance","allowances")}}function ZN(t){let e=$r(t,mt);if(e.schema===$e){let n=un(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Ie}`}}if(e.schema===je){let n=dn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Ie}`}}if(e.schema!==Ie){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 pt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=jr(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new pt(e.schema,r).message};let i=fn(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}function vt(t,e){Rn(e);let r=ht.join(t.changesDir,e);if(!M(t.changesDir,r))throw new Error("Native change path escaped");return r}async function ps(t,e){let r=Q(t,e),i=ht.join(r,"schema-migration.json");await T(M(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await MN.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function eb(t,e=ht.dirname(t)){let r=ht.relative(e,t).split(ht.sep).join("/"),i=await X({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,fs.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 tb(t,e){let r=ht.join(vt(t,e),mt);await T(t.nativeRoot,r);let i=ZN(await eb(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await ps(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 rb(t,i.state),i)}async function rb(t,e){if(await Nd(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function xe(t,e){let r=await tb(t,e);if(r.status==="migration-required")throw new Cn(e,r.schema);if(r.status==="runtime-incompatible"||!r.state)throw new pt(r.schema,r.minimumRuntimeVersion);return await $d(t,e),r.state}import ib from"path";var ms="comet.selection.v2",nb=16*1024;function Vd(t){return ib.join(t,".comet","current-change.json")}function ab(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Fd(t){return t===null||typeof t=="string"}function ob(t){let e;try{e=JSON.parse(t)}catch(r){throw new Error(`current change selection contains invalid JSON: ${r instanceof Error?r.message:String(r)}`,{cause:r})}if(!ab(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!Fd(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:ms,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==ms)throw new Error(`current change selection schema must be ${ms}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!Fd(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function qd(t){let e;try{let i=Vd(t),{bytes:n}=await st(i,nb,{label:"current change selection"});e=n.toString("utf8")}catch(i){if(i.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${i instanceof Error?i.message:String(i)}`,{cause:i})}return{status:"selected",...ob(e)}}import{promises as Ud}from"node:fs";import $n from"node:path";var db=Ft(_t(),1);var MR=8*1024*1024;var An=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};var yA=["$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("; ");function vb(t){return t.state_version+1}function gb(t){return t.map(e=>({...e,result:"pending",reason:null}))}function wb(t){return{goal_cycle:t.state.loop.goal_cycle,iteration:t.state.loop.iteration,attempt:t.state.loop.attempt,outcome:t.outcome,unresolved_ids:t.unresolvedIds??[],summary:_r(t.summary),completed_at:t.completedAt}}function zd(t){let e=Ee(t.state);if(e.phase!=="verify"&&e.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let r=(t.now??new Date).toISOString(),i=ln(e,wb({state:e,outcome:"recovery",summary:t.reason,completedAt:r})),n=new Set(e.loop.previous_unresolved_ids),a=n.size===0?gb(e.acceptance):e.acceptance.map(o=>n.has(o.id)?{...o,result:"pending",reason:null}:o);return Ee({...i,phase:"build",status:"active",state_version:vb(e),verification_result:"pending",verification_report:null,verification:null,builder_handoff:e.builder_handoff,blockers:[],acceptance:a,loop:{...e.loop,stage:"repairing",iteration:e.loop.iteration+1,attempt:0,execution_failure_count:0,next_action:"submit-builder-candidate"}})}import{promises as yb}from"node:fs";import Hr from"node:path";function _n(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Tn(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 Pe(t,e,r=!1){if(typeof t!="string"||!r&&t.length===0)throw new Error(`${e} must be ${r?"a string":"a non-empty string"}`);return t}function Jd(t,e){return t===null?null:Pe(t,e)}function jn(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 Nb(t,e){if(t===null)return null;if(!Number.isSafeInteger(t))throw new Error(`${e} must be null or a safe integer`);return t}function bb(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function In(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function vs(t,e){if(t===null)return null;let r=Pe(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function gs(t,e){let r=Pe(t,e);if(!Hr.isAbsolute(r))throw new Error(`${e} must be absolute`);return Hr.resolve(r)}function kb(t,e){let r=`Native local checks[${e}]`,i=_n(t,r);if(Tn(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((l,u)=>Pe(l,`${r}.argv[${u}]`,!0)),a=In(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=vs(i.startedAt,`${r}.startedAt`),s=vs(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let c=jn(i.timeoutMs,`${r}.timeoutMs`);if(c<1)throw new Error(`${r}.timeoutMs must be positive`);return{id:Pe(i.id,`${r}.id`),name:Pe(i.name,`${r}.name`),operationId:Pe(i.operationId,`${r}.operationId`),status:a,repeatable:bb(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:jn(i.executionCount,`${r}.executionCount`),argv:n,cwd:gs(i.cwd,`${r}.cwd`),exitCode:Nb(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:Pe(i.log,`${r}.log`)}}function Gd(t){let e="Native local execution state",r=_n(t,e);if(Tn(r,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),e),r.schema!==Rr)throw new Error(`Native local execution schema must be ${Rr}`);let i=_n(r.workspace,"Native local workspace");Tn(i,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(r.execution!==null){let o=_n(r.execution,"Native local execution");Tn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=vs(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Pe(o.operationId,"Native local execution.operationId"),stage:In(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:In(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Jd(o.executionId,"Native local execution.executionId"),status:In(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:jn(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(kb);if(new Set(a.map(o=>o.id)).size!==a.length)throw new Error("Native local check IDs must be unique");if(n&&a.some(o=>o.operationId!==n.operationId))throw new Error("Native local checks must belong to the current operation");return{schema:Rr,change:Pe(r.change,"Native local change"),basedOnStateVersion:jn(r.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:gs(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:gs(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Jd(i.branch,"Native local workspace.branch")},execution:n,checks:a}}function ws(t){return Gd({schema:Rr,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,workspace:{projectRoot:Hr.resolve(t.projectRoot),worktreeRoot:Hr.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null},execution:null,checks:[]})}async function ys(t,e,r={}){let i=Gd(e);await yb.mkdir(Hr.dirname(t),{recursive:!0}),await ue(t,i,r)}var Cb=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,xb="comet-state.yaml",Pb="state.json",U_=qi("en");function Kd(t){let e=t.expected;if(e){if(t.state.state_version!==e.stateVersion)throw new Error(`Native continuation is stale for state version ${e.stateVersion}; current state version is ${t.state.state_version}`);if(e.action!==t.action)throw new Error(`Native continuation expected ${e.action} cannot be used for ${t.action}`)}}function On(t,e){if(!Cb.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=$n.join(t.changesDir,e);if(!M(t.changesDir,r))throw new Error("Native change path escaped");return r}function Ns(t,e){return $n.join(On(t,e),xb)}function Yd(t,e){return $n.join(Ot(t,e),Pb)}async function Hn(t,e){try{let r=await Ud.readFile(Ns(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function Xd(t){return se(t).currentBranch}async function Mt(t,e){return Ar(Ns(t,e))}async function Qd(t){let e=await Qu({file:Ns(t.paths,t.previous.name),expectedStateVersion:t.previous.state_version,next:t.next,containedRoot:t.paths.nativeRoot});if(e.verification===null&&e.verification_report===null){let r=$n.join(On(t.paths,e.name),"verification.md");await T(t.paths.nativeRoot,r),await Ud.rm(r,{force:!0})}return e}async function Zd(t){return re(t.paths,`return portable change ${t.name} to Build`,async()=>{let e=await Mt(t.paths,t.name);if(Kd({state:e,expected:t.expectedContinuation,action:"revise-implementation"}),e.phase==="build")return e;let r=zd({state:e,reason:t.reason}),i=await Qd({paths:t.paths,previous:e,next:r});return await ys(Yd(t.paths,e.name),ws({portableState:i,projectRoot:t.paths.projectRoot,branch:Xd(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),i})}async function ef(t){return re(t.paths,`return portable change ${t.name} to Shape`,async()=>{let e=await Mt(t.paths,t.name);if(Kd({state:e,expected:t.expectedContinuation,action:"revise-requirements"}),t.allowedPhases&&!t.allowedPhases.includes(e.phase))throw new Error("--revise-requirements is only valid from Verify or Archive");return e.phase==="shape"?e:Rb({paths:t.paths,state:e,reason:t.reason})})}async function Rb(t){let{state:e}=t;if(e.archived)throw new Error(`Native change ${e.name} is already archived`);let i={...ln(e,{goal_cycle:e.loop.goal_cycle,iteration:e.loop.iteration,attempt:e.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:_r(t.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:e.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:e.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"confirm-shape"}};delete i.children_contract_hash;let n=await Qd({paths:t.paths,previous:e,next:i});return await ys(Yd(t.paths,e.name),ws({portableState:n,projectRoot:t.paths.projectRoot,branch:Xd(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n}var nT=16*1024;async function Ab(t){let e=await qd(t.projectRoot);return e.status==="missing"||e.selection.workflow!=="native"?null:(Rn(e.selection.change),e.selection)}async function tf(t){let e=await Ab(t);return e?(await Hn(t,e.change)?await Mt(t,e.change):await xe(t,e.change),e.change):null}function rf(t){let e=`Native change ${t.name} is in ${t.phase}; implementation writes are only allowed in Build.`;return t.phase==="shape"?`${e} Reread the latest continuation, complete requirement clarification, and execute the Shape confirmation command after user confirmation.`:t.phase==="verify"?`${e} Select and execute the matching commandAlternative from the latest continuation, preserving --expected-state-version and --expected-action.`:t.phase==="archive"?`${e} Continue finalizing the accepted result; do not run Verify-only revision commands from Archive.`:`${e} Create or select a separate Native change if this write belongs to different work.`}async function Tb(t){let{projectRoot:e,paths:r,state:i,request:n}=t,a=On(r,i.name),o=[],s=[],c=!1,l=!1,u=!1;for(let d of n.targets){let f=ge.resolve(e,d);if(!gt(e,f)){u=!0;continue}let p=ge.relative(e,f).replaceAll("\\","/");if(p===".comet/config.yaml"){l=!0;continue}if(!gt(r.nativeRoot,f)){if(await bn(e,f,[ge.join(e,".comet"),r.nativeRoot])){c=!0;continue}s.push(p);continue}if(!gt(a,f))return{allowed:!1,reason:"Portable Native control state is Runtime-owned",workflow:"native",phase:i.phase,change:i.name};let g=ge.relative(a,f).replaceAll("\\","/");if(g==="brief.md"||g==="children.yaml"||g.startsWith("specs/")){o.push(g);continue}return{allowed:!1,reason:`${g||"change directory"} is Runtime-owned and cannot be edited by the Agent`,workflow:"native",phase:i.phase,change:i.name}}return o.length>0&&s.length>0?{allowed:!1,reason:"Formal Native requirements and implementation files must be edited in separate actions",workflow:"native",phase:i.phase,change:i.name}:o.length>0?i.phase!=="shape"?{allowed:!0,reason:`Native requirements changed; returned to Shape goal cycle ${(await ef({paths:r,name:i.name,reason:`Formal requirement write requested for ${o.join(", ")}`})).loop.goal_cycle}`,workflow:"native",phase:"shape",change:i.name}:{allowed:!0,reason:"Native control artifact write",workflow:"native",phase:i.phase,change:i.name}:s.length>0?i.children_contract_hash?{allowed:!1,reason:"Native parent Build advances child changes instead of editing implementation",workflow:"native",phase:i.phase,change:i.name}:i.phase==="build"?{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:i.phase,change:i.name}:i.phase==="verify"||i.phase==="archive"?{allowed:!0,reason:`Native candidate was invalidated and returned to Build iteration ${(await Zd({paths:r,name:i.name,reason:`Observed implementation write before ${s.join(", ")}`})).loop.iteration}`,workflow:"native",phase:"build",change:i.name}:{allowed:!1,reason:rf(i),workflow:"native",phase:i.phase,change:i.name}:c?{allowed:!0,reason:"Native configured Hook allow path",workflow:"native",phase:i.phase,change:i.name}:{allowed:!0,reason:l?"Native control artifact write":u?"Write target is outside the guarded project":"No guarded write target was provided",workflow:"native",phase:i.phase,change:i.name}}function gt(t,e){let r=ge.relative(t,e);return r===""||!r.startsWith("..")&&!ge.isAbsolute(r)}function Ib(t,e,r){return r.targets.length>0&&r.targets.every(i=>{let n=ge.resolve(t,i);return gt(t,n)?ge.relative(t,n).replaceAll("\\","/")===".comet/config.yaml"||gt(e,n):!0})}async function jb(t){let e=await he(t);if(!e||!(e.workflows??[e.default_workflow]).includes("native"))return null;let r=await lt(t,e.native.artifact_root),i;try{i=await _b.readdir(r.changesDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return{paths:r,changes:[]};throw a}let n=[];for(let a of i.sort((o,s)=>o.name.localeCompare(s.name)))if(!(!a.isDirectory()||a.isSymbolicLink()))if(await Hn(r,a.name)){let o=await Mt(r,a.name);o.archived||n.push({kind:"portable",state:o})}else{let o=await xe(r,a.name);o.archived||n.push({kind:"legacy",state:o})}return{paths:r,changes:n}}var $b=Mr("nativeActiveContext",t=>jb(t));async function nf(){let{intent:t,targets:e}=await _s();return{intent:t,targets:e}}async function af(t,e,r){let i=await $b(t);if(!i)return{allowed:!0,reason:"Native workflow is not enabled"};if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(i.changes.length===0)return{allowed:!0,reason:Ib(t,i.paths.nativeRoot,e)?"Native control artifact write":"No Native changes exist"};let n;if(r){if(n=i.changes.find(l=>l.state.name===r),!n)return{allowed:!1,reason:`Selected Native change ${r} is missing or archived; resume /comet-native before retrying`,workflow:"native",change:r}}else if(i.changes.length===1)n=i.changes[0];else{let l=await tf(i.paths);if(n=i.changes.find(u=>u.state.name===l),!n)return{allowed:!1,reason:"Multiple Native changes are active; select the change to resume before writing code",workflow:"native"}}let a=n.state;if(n.kind==="legacy"&&a.phase==="build")return{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:a.phase,change:a.name};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"native",phase:a.phase,change:a.name};if(n.kind==="portable")return Tb({projectRoot:t,paths:i.paths,state:n.state,request:e});let o=!1,s=!1,c=!1;for(let l of e.targets){let u=ge.resolve(t,l);if(!gt(t,u)){s=!0;continue}if(ge.relative(t,u).replaceAll("\\","/")===".comet/config.yaml"){o=!0;continue}if(gt(i.paths.nativeRoot,u)){o=!0;continue}if(await bn(t,u,[ge.join(t,".comet"),i.paths.nativeRoot])){c=!0;continue}return{allowed:!1,reason:rf(a),workflow:"native",phase:a.phase,change:a.name}}return{allowed:!0,reason:o?"Native control artifact write":s?"Write target is outside the guarded project":c?"Native configured Hook allow path":"No guarded write target was provided",workflow:"native",phase:a.phase,change:a.name}}import Br from"path";import{realpathSync as wk}from"fs";var Hb=["outcome","scope","nonGoals","acceptanceExamples"],IT=[...Hb,"constraints","decisions","openQuestions","verificationExpectations"];var Db=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 of=1024*1024;var cf="scoped-text-safety",Bb=1,Lb=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var Mb="comet.native.checker-policy.v1";var GT=ee(Mb,{policy:cf,version:Bb,limits:Lb,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var Fb=["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"],UT=new Set(Fb);var Wb=of,dI=3*Wb;var lf={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:[]},Jb=U("comet-native-runtime:v3:scope-reopen"),BI=[{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 df=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],wj=new Set(df),Qb=new Set([...df,"minimum_runtime_version","revision"]),yj=new Set([...Qb,"operation"]),Nj=512*1024,Zb=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),bj=new Set([...Zb,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var xj={maxAcceptanceCriteria:Ku.maxCriteria};var Tj={maxSpecs:64,maxFileBytes:Vi,maxTotalBytes:4*1024*1024};import{execFile as ck}from"node:child_process";import{promisify as lk}from"node:util";var Fj={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var c$=512*1024;var Dr=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};var T$=64*1024;var I$=3600*1e3;var j$=lk(ck);var Dn=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 wO={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var RO=16*1024*1024,AO=256*1024,_O=16*1024;var HO=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var x0=16*1024*1024,Bn=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},Ln=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};var pf=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--help Show help without requiring an initialized project."],ks=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:pf,output:"Human-readable text by default; use --json for a structured command envelope.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:"comet native spec remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page, or a named details/history page.","--details Include one fixed-size page of acceptance, Spec, handoff, verification, history, workspace, and report details."],output:"A compact v2 status page or one compact Loop projection with local execution availability. Use --details and --cursor to read fixed-size detail pages; parent changes expose childSummary and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--confirmed] [--coordination-mode multi-session|single-session] [--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker] [--max-parallel <n>] [--expected-state-version <n>] [--expected-action <action>]
156
- comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm Shape or an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Required when confirming a multi-child Supervisor Shape.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a 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]
157
- comet native archive <change-name> [--confirmed] [--serial-first <current-change>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Inspect readiness without rerunning verification.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness plus continuation, or the completed Archive transaction and workspace finish result; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function bs(t,e){return`${t}:
155
+ ${t.sessionId}`)}:{}},p=t.binding?{schema:"comet.native.workspace.v3",...f,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...f};return Rn(p),p}async function An(t,e){let r=await QN(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(Rn(r),r)}async function Ld(t){Rn(t.identity);let e=await ZN({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),r=[],i=[];return e.nativeRootRef!==t.identity.nativeRootRef&&r.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&r.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&r.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&r.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&r.push("native-root-legacy-identity")),ls==="win32"&&r.length>0&&r.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?i.push("workspace-inspection-unavailable"):r.length>0&&i.push("workspace-root-changed"),{state:i.length===0?"aligned":i.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:i,driftComponents:r}}async function Bd(t){if(Rn(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await Ld(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=ce(t.paths.projectRoot);return t.identity.changeBranch===null?r.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:r.isGitWorktree?r.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${r.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!r.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}async function Md(t,e){let r=await An(t,e);if(r===null)return null;let i=await Bd({paths:t,identity:r});if(i.state==="drifted")throw new Error(`${i.code}: ${i.message}`);return r}var Vd=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],rb=new Set(Vd),qd=new Set([...Vd,"minimum_runtime_version","revision"]),ib=new Set([...qd,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),nb=new Set(["capability","operation","source","base_hash"]),ab=new Set(["shape","build","verify","archive"]),ob=new Set(["implicit","confirmed"]),sb=new Set(["pending","pass","fail"]),gt="comet-state.yaml",fs=/^[a-f0-9]{64}$/u,Wd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,cb=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,_n=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"},vt=class extends Error{constructor(r,i){super(r!==je||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"},Tn=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},$r=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},In=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"},uA=Gi("en");function Hr(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function zd(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 jn(t){if(!Wd.test(t))throw new Error(`Invalid Native change name: ${t}`)}function lb(t){if(!Wd.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Jd(t,e){if(t.length===0||mt.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function ub(t,e){let r=Hr(t,`spec_changes[${e}]`);if(zd(r,nb,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(lb(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"&&Jd(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"||!fs.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"||!fs.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 db(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 ms(t,e){if(zd(t,e,gt),typeof t.name!="string")throw new Error("Native change name is required");if(jn(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"||!ab.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&&!ob.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(ub),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"||!sb.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"&&Jd(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!db(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 mn(t){let e=Hr(t,gt);if(e.schema!==Oe)throw new Error(`Expected ${Oe}`);return{schema:Oe,...ms(e,rb)}}function Or(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function ds(t,e,r){if(t===null)return null;let i=typeof t=="string"?cb.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 fb(t){if(t==null)return null;if(typeof t!="string"||!fs.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function hb(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 vn(t){let e=Hr(t,gt);if(e.schema!==$e)throw new Error(`Expected ${$e}`);if(Or(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${$e} minimum_runtime_version must be 2`);return{schema:$e,minimum_runtime_version:2,revision:Or(e.revision,"Native v2 revision"),...ms(e,qd)}}function gn(t){let e=Hr(t,gt);if(e.schema!==je){if(e.schema===Oe||e.schema===$e){let o=e.schema===Oe?mn(e):vn(e);throw new _n(o.name,o.schema)}throw new vt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=Or(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new vt(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=Or(e.revision,"Native revision"),n=ms(e,ib),a=fb(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:je,minimum_runtime_version:3,revision:i,verification_protocol:hb(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:ds(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:ds(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:ds(e.partial_allowance,"Native partial_allowance","allowances")}}function pb(t){let e=Hr(t,gt);if(e.schema===Oe){let n=mn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${je}`}}if(e.schema===$e){let n=vn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${je}`}}if(e.schema!==je){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 vt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=Or(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new vt(e.schema,r).message};let i=gn(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}function wt(t,e){jn(e);let r=mt.join(t.changesDir,e);if(!F(t.changesDir,r))throw new Error("Native change path escaped");return r}async function vs(t,e){let r=Z(t,e),i=mt.join(r,"schema-migration.json");await I(F(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await tb.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function mb(t,e=mt.dirname(t)){let r=mt.relative(e,t).split(mt.sep).join("/"),i=await Q({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,ps.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 vb(t,e){let r=mt.join(wt(t,e),gt);await I(t.nativeRoot,r);let i=pb(await mb(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await vs(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 gb(t,i.state),i)}async function gb(t,e){if(await xd(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function Re(t,e){let r=await vb(t,e);if(r.status==="migration-required")throw new _n(e,r.schema);if(r.status==="runtime-incompatible"||!r.state)throw new vt(r.schema,r.minimumRuntimeVersion);return await Md(t,e),r.state}import wb from"path";var gs="comet.selection.v2",yb=16*1024;function Ud(t){return wb.join(t,".comet","current-change.json")}function Nb(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Gd(t){return t===null||typeof t=="string"}function bb(t){let e;try{e=JSON.parse(t)}catch(r){throw new Error(`current change selection contains invalid JSON: ${r instanceof Error?r.message:String(r)}`,{cause:r})}if(!Nb(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!Gd(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:gs,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==gs)throw new Error(`current change selection schema must be ${gs}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!Gd(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function Kd(t){let e;try{let i=Ud(t),{bytes:n}=await lt(i,yb,{label:"current change selection"});e=n.toString("utf8")}catch(i){if(i.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${i instanceof Error?i.message:String(i)}`,{cause:i})}return{status:"selected",...bb(e)}}import{promises as ef}from"node:fs";import Bn from"node:path";var xb=Wt(It(),1);var mA=8*1024*1024;var $n=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};var UA=["$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("; ");function Tb(t){return t.state_version+1}function Ib(t){return t.map(e=>({...e,result:"pending",reason:null}))}function jb(t){return{goal_cycle:t.state.loop.goal_cycle,iteration:t.state.loop.iteration,attempt:t.state.loop.attempt,outcome:t.outcome,unresolved_ids:t.unresolvedIds??[],summary:Ir(t.summary),completed_at:t.completedAt}}function Xd(t){let e=xe(t.state);if(e.phase!=="verify"&&e.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let r=(t.now??new Date).toISOString(),i=pn(e,jb({state:e,outcome:"recovery",summary:t.reason,completedAt:r})),n=new Set(e.loop.previous_unresolved_ids),a=n.size===0?Ib(e.acceptance):e.acceptance.map(o=>n.has(o.id)?{...o,result:"pending",reason:null}:o);return xe({...i,phase:"build",status:"active",state_version:Tb(e),verification_result:"pending",verification_report:null,verification:null,builder_handoff:e.builder_handoff,blockers:[],acceptance:a,loop:{...e.loop,stage:"repairing",iteration:e.loop.iteration+1,attempt:0,execution_failure_count:0,stop_reason:void 0,next_action:"submit-builder-candidate"}})}import{promises as $b}from"node:fs";import Lr from"node:path";function On(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Hn(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 Ae(t,e,r=!1){if(typeof t!="string"||!r&&t.length===0)throw new Error(`${e} must be ${r?"a string":"a non-empty string"}`);return t}function Qd(t,e){return t===null?null:Ae(t,e)}function Ln(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 Ob(t,e){if(t===null)return null;if(!Number.isSafeInteger(t))throw new Error(`${e} must be null or a safe integer`);return t}function Hb(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function Dn(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function ws(t,e){if(t===null)return null;let r=Ae(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function ys(t,e){let r=Ae(t,e);if(!Lr.isAbsolute(r))throw new Error(`${e} must be absolute`);return Lr.resolve(r)}function Db(t,e){let r=`Native local checks[${e}]`,i=On(t,r);if(Hn(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((l,u)=>Ae(l,`${r}.argv[${u}]`,!0)),a=Dn(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=ws(i.startedAt,`${r}.startedAt`),s=ws(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let c=Ln(i.timeoutMs,`${r}.timeoutMs`);if(c<1)throw new Error(`${r}.timeoutMs must be positive`);return{id:Ae(i.id,`${r}.id`),name:Ae(i.name,`${r}.name`),operationId:Ae(i.operationId,`${r}.operationId`),status:a,repeatable:Hb(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:Ln(i.executionCount,`${r}.executionCount`),argv:n,cwd:ys(i.cwd,`${r}.cwd`),exitCode:Ob(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:Ae(i.log,`${r}.log`)}}function Zd(t){let e="Native local execution state",r=On(t,e);if(Hn(r,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),e),r.schema!==_r)throw new Error(`Native local execution schema must be ${_r}`);let i=On(r.workspace,"Native local workspace");Hn(i,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(r.execution!==null){let o=On(r.execution,"Native local execution");Hn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=ws(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Ae(o.operationId,"Native local execution.operationId"),stage:Dn(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Dn(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Qd(o.executionId,"Native local execution.executionId"),status:Dn(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Ln(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(Db);if(new Set(a.map(o=>o.id)).size!==a.length)throw new Error("Native local check IDs must be unique");if(n&&a.some(o=>o.operationId!==n.operationId))throw new Error("Native local checks must belong to the current operation");return{schema:_r,change:Ae(r.change,"Native local change"),basedOnStateVersion:Ln(r.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:ys(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:ys(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Qd(i.branch,"Native local workspace.branch")},execution:n,checks:a}}function Ns(t){return Zd({schema:_r,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,workspace:{projectRoot:Lr.resolve(t.projectRoot),worktreeRoot:Lr.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null},execution:null,checks:[]})}async function bs(t,e,r={}){let i=Zd(e);await $b.mkdir(Lr.dirname(t),{recursive:!0}),await de(t,i,r)}var Mb=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Fb="comet-state.yaml",Vb="state.json",PT=Gi("en");function tf(t){let e=t.expected;if(e){if(t.state.state_version!==e.stateVersion)throw new Error(`Native continuation is stale for state version ${e.stateVersion}; current state version is ${t.state.state_version}`);if(e.action!==t.action)throw new Error(`Native continuation expected ${e.action} cannot be used for ${t.action}`)}}function Mn(t,e){if(!Mb.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=Bn.join(t.changesDir,e);if(!F(t.changesDir,r))throw new Error("Native change path escaped");return r}function ks(t,e){return Bn.join(Mn(t,e),Fb)}function rf(t,e){return Bn.join(Lt(t,e),Vb)}async function Fn(t,e){try{let r=await ef.readFile(ks(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function nf(t){return ce(t).currentBranch}async function qt(t,e){return Tr(ks(t,e))}async function af(t){let e=await nd({file:ks(t.paths,t.previous.name),expectedStateVersion:t.previous.state_version,next:t.next,containedRoot:t.paths.nativeRoot});if(e.verification===null&&e.verification_report===null){let r=Bn.join(Mn(t.paths,e.name),"verification.md");await I(t.paths.nativeRoot,r),await ef.rm(r,{force:!0})}return e}async function of(t){return ie(t.paths,`return portable change ${t.name} to Build`,async()=>{let e=await qt(t.paths,t.name);if(tf({state:e,expected:t.expectedContinuation,action:"revise-implementation"}),e.phase==="build")return e;let r=Xd({state:e,reason:t.reason}),i=await af({paths:t.paths,previous:e,next:r});return await bs(rf(t.paths,e.name),Ns({portableState:i,projectRoot:t.paths.projectRoot,branch:nf(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),i})}async function sf(t){return ie(t.paths,`return portable change ${t.name} to Shape`,async()=>{let e=await qt(t.paths,t.name);if(tf({state:e,expected:t.expectedContinuation,action:"revise-requirements"}),t.allowedPhases&&!t.allowedPhases.includes(e.phase))throw new Error("--revise-requirements is only valid from Verify or Archive");return e.phase==="shape"?e:qb({paths:t.paths,state:e,reason:t.reason})})}async function qb(t){let{state:e}=t;if(e.archived)throw new Error(`Native change ${e.name} is already archived`);let i={...pn(e,{goal_cycle:e.loop.goal_cycle,iteration:e.loop.iteration,attempt:e.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:Ir(t.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:e.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:e.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"confirm-shape"}};delete i.children_contract_hash;let n=await af({paths:t.paths,previous:e,next:i});return await bs(rf(t.paths,e.name),Ns({portableState:n,projectRoot:t.paths.projectRoot,branch:nf(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n}var DT=16*1024;async function Wb(t){let e=await Kd(t.projectRoot);return e.status==="missing"||e.selection.workflow!=="native"?null:(jn(e.selection.change),e.selection)}async function cf(t){let e=await Wb(t);return e?(await Fn(t,e.change)?await qt(t,e.change):await Re(t,e.change),e.change):null}function lf(t){let e=`Native change ${t.name} is in ${t.phase}; implementation writes are only allowed in Build.`;return t.phase==="shape"?`${e} Reread the latest continuation, complete requirement clarification, and execute the Shape confirmation command after user confirmation.`:t.phase==="verify"?`${e} Select and execute the matching commandAlternative from the latest continuation, preserving --expected-state-version and --expected-action.`:t.phase==="archive"?`${e} Continue finalizing the accepted result; do not run Verify-only revision commands from Archive.`:`${e} Create or select a separate Native change if this write belongs to different work.`}async function Jb(t){let{projectRoot:e,paths:r,state:i,request:n}=t,a=Mn(r,i.name),o=[],s=[],c=!1,l=!1,u=!1;for(let d of n.targets){let f=we.resolve(e,d);if(!yt(e,f)){u=!0;continue}let p=we.relative(e,f).replaceAll("\\","/");if(p===".comet/config.yaml"){l=!0;continue}if(!yt(r.nativeRoot,f)){if(await xn(e,f,[we.join(e,".comet"),r.nativeRoot])){c=!0;continue}s.push(p);continue}if(!yt(a,f))return{allowed:!1,reason:"Portable Native control state is Runtime-owned",workflow:"native",phase:i.phase,change:i.name};let g=we.relative(a,f).replaceAll("\\","/");if(g==="brief.md"||g==="children.yaml"||g.startsWith("specs/")){o.push(g);continue}return{allowed:!1,reason:`${g||"change directory"} is Runtime-owned and cannot be edited by the Agent`,workflow:"native",phase:i.phase,change:i.name}}return o.length>0&&s.length>0?{allowed:!1,reason:"Formal Native requirements and implementation files must be edited in separate actions",workflow:"native",phase:i.phase,change:i.name}:o.length>0?i.phase!=="shape"?{allowed:!0,reason:`Native requirements changed; returned to Shape goal cycle ${(await sf({paths:r,name:i.name,reason:`Formal requirement write requested for ${o.join(", ")}`})).loop.goal_cycle}`,workflow:"native",phase:"shape",change:i.name}:{allowed:!0,reason:"Native control artifact write",workflow:"native",phase:i.phase,change:i.name}:s.length>0?i.children_contract_hash?{allowed:!1,reason:"Native parent Build advances child changes instead of editing implementation",workflow:"native",phase:i.phase,change:i.name}:i.phase==="build"?{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:i.phase,change:i.name}:i.phase==="verify"||i.phase==="archive"?{allowed:!0,reason:`Native candidate was invalidated and returned to Build iteration ${(await of({paths:r,name:i.name,reason:`Observed implementation write before ${s.join(", ")}`})).loop.iteration}`,workflow:"native",phase:"build",change:i.name}:{allowed:!1,reason:lf(i),workflow:"native",phase:i.phase,change:i.name}:c?{allowed:!0,reason:"Native configured Hook allow path",workflow:"native",phase:i.phase,change:i.name}:{allowed:!0,reason:l?"Native control artifact write":u?"Write target is outside the guarded project":"No guarded write target was provided",workflow:"native",phase:i.phase,change:i.name}}function yt(t,e){let r=we.relative(t,e);return r===""||!r.startsWith("..")&&!we.isAbsolute(r)}function Gb(t,e,r){return r.targets.length>0&&r.targets.every(i=>{let n=we.resolve(t,i);return yt(t,n)?we.relative(t,n).replaceAll("\\","/")===".comet/config.yaml"||yt(e,n):!0})}async function Ub(t){let e=await pe(t);if(!e||!(e.workflows??[e.default_workflow]).includes("native"))return null;let r=await dt(t,e.native.artifact_root),i;try{i=await zb.readdir(r.changesDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return{paths:r,changes:[]};throw a}let n=[];for(let a of i.sort((o,s)=>o.name.localeCompare(s.name)))if(!(!a.isDirectory()||a.isSymbolicLink()))if(await Fn(r,a.name)){let o=await qt(r,a.name);o.archived||n.push({kind:"portable",state:o})}else{let o=await Re(r,a.name);o.archived||n.push({kind:"legacy",state:o})}return{paths:r,changes:n}}var Kb=Vr("nativeActiveContext",t=>Ub(t));async function uf(){let{intent:t,targets:e}=await Hs();return{intent:t,targets:e}}async function df(t,e,r){let i=await Kb(t);if(!i)return{allowed:!0,reason:"Native workflow is not enabled"};if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(i.changes.length===0)return{allowed:!0,reason:Gb(t,i.paths.nativeRoot,e)?"Native control artifact write":"No Native changes exist"};let n;if(r){if(n=i.changes.find(l=>l.state.name===r),!n)return{allowed:!1,reason:`Selected Native change ${r} is missing or archived; resume /comet-native before retrying`,workflow:"native",change:r}}else if(i.changes.length===1)n=i.changes[0];else{let l=await cf(i.paths);if(n=i.changes.find(u=>u.state.name===l),!n)return{allowed:!1,reason:"Multiple Native changes are active; select the change to resume before writing code",workflow:"native"}}let a=n.state;if(n.kind==="legacy"&&a.phase==="build")return{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:a.phase,change:a.name};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"native",phase:a.phase,change:a.name};if(n.kind==="portable")return Jb({projectRoot:t,paths:i.paths,state:n.state,request:e});let o=!1,s=!1,c=!1;for(let l of e.targets){let u=we.resolve(t,l);if(!yt(t,u)){s=!0;continue}if(we.relative(t,u).replaceAll("\\","/")===".comet/config.yaml"){o=!0;continue}if(yt(i.paths.nativeRoot,u)){o=!0;continue}if(await xn(t,u,[we.join(t,".comet"),i.paths.nativeRoot])){c=!0;continue}return{allowed:!1,reason:lf(a),workflow:"native",phase:a.phase,change:a.name}}return{allowed:!0,reason:o?"Native control artifact write":s?"Write target is outside the guarded project":c?"Native configured Hook allow path":"No guarded write target was provided",workflow:"native",phase:a.phase,change:a.name}}import Mr from"path";import{realpathSync as Wk}from"fs";var De={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function ff(t){return t?t.command?`${De.next} ${t.command}`:t.ask_user?`${De.next} ${t.ask_user}`:null:null}function hf(t,e){let r=[t.summary],i=ff(t.next);return i&&r.push(i),t.user_message&&r.push("",De.relay,t.user_message),e!==void 0&&r.push("",De.details,JSON.stringify(e,null,2)),`${r.join(`
156
+ `)}
157
+ `}function pf(t,e,r){let i=[t.summary],n=ff(t.next);return n&&i.push(n),t.user_message&&i.push("",De.relay,t.user_message),i.push("",`${De.detail} ${e}`),r!==void 0&&i.push("",De.details,JSON.stringify(r,null,2)),i.join(`
158
+ `)}var Xb=["outcome","scope","nonGoals","acceptanceExamples"],fI=[...Xb,"constraints","decisions","openQuestions","verificationExpectations"];var Qb=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 mf=1024*1024;var gf="scoped-text-safety",Zb=1,ek=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var tk="comet.native.checker-policy.v1";var PI=te(tk,{policy:gf,version:Zb,limits:ek,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var rk=["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"],RI=new Set(rk);var ak=mf,zI=3*ak;var wf={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:[]},sk=K("comet-native-runtime:v3:scope-reopen"),wj=[{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 Nf=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],Qj=new Set(Nf),hk=new Set([...Nf,"minimum_runtime_version","revision"]),Zj=new Set([...hk,"operation"]),e$=512*1024,pk=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),t$=new Set([...pk,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var o$={maxAcceptanceCriteria:td.maxCriteria};var d$={maxSpecs:64,maxFileBytes:Wi,maxTotalBytes:4*1024*1024};import{execFile as Sk}from"node:child_process";import{promisify as Ek}from"node:util";var b$={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var V$=512*1024;var Br=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};var dO=64*1024;var fO=3600*1e3;var hO=Ek(Sk);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 QO={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var c0=16*1024*1024,l0=256*1024,u0=16*1024;var v0=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var oH=16*1024*1024,qn=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 C(t,e,r){return t==="zh-CN"?r:e}var Ss={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Sf(t,e){return typeof t=="string"&&Ss[t]?C(e,Ss[t].en,Ss[t].zh):typeof t=="string"?t:""}function Es(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 _k(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 Ef(t,e){let r=[];t.failed>0&&r.push(C(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(C(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(C(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=C(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Cf(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 Cs(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function Tk(t,e,r){return t==="done"?C(r,"complete","已完成"):t==="await-user"?C(r,"waiting for a user decision","等待用户决定"):t==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):e?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function Ik(t,e,r){let i=Cs(t),n=[];r&&n.push(r);let a=C(i,`Change ${t.change}`,`需求 ${t.change}`),o=Sf(t.phase,i),s=Tk(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(Ef(e,i));let c=t.userCommunication,l=xf(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function xf(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:C(e,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(t.commandArgs&&t.commandArgs.length>0)return{command:t.commandArgs.join(" ")};if(t.disposition==="done")return{ask_user:C(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:C(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function jk(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function $k(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=Sf(t.phase,e),n=t.status==="await-user"?C(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?C(e,"paused","已暂停"):t.status==="done"?C(e,"complete","已完成"):C(e,"in progress","进行中"),a=Es(t.acceptance)?`${C(e,", ",",")}${Ef(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function Ok(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 Hk(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 Dk(t){if(t.healthy){let i=t.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=Lk(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:C("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:C("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function Lk(t){return Cf(t)?xf(t,Cs(t)):void 0}function Pf(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(Hk(e))return Dk(e);if(jk(e)){let i=Ok(e.items);return{summary:[e.total===e.items.length?C(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):C(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>$k(a,i))].join(`
159
+ `)}}let r=e.continuation;if(Cf(r))return Ik(r,Bk(e),Mk(e,Cs(r)));if(typeof e.artifactRoot=="string"&&typeof e.nativeRoot=="string"){let i=e.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in e;return{summary:C(i,n?`Comet Native artifacts live under ${e.artifactRoot} (state root: ${e.nativeRoot}).`:`Initialized Comet Native at ${e.nativeRoot} (artifacts: ${e.artifactRoot}).`,n?`Comet Native 产物位于 ${e.artifactRoot}(状态根目录:${e.nativeRoot})。`:`Comet Native 已初始化于 ${e.nativeRoot}(产物目录:${e.artifactRoot})。`)}}}function Bk(t){if(Es(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(Es(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return _k(r.acceptance)}return null}function Mk(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return C(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?C(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function Rf(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}var Af=["--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."],Ps=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:Af,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>]
160
+ comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm Shape or an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Required when confirming a multi-child Supervisor Shape.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits, review. review fields: status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," Supervisor task fields: supervisor-builder-result (child, runId, candidateCommit), supervisor-builder-failure (child, runId, reason), supervisor-verifier-result (child, runId, verdict, verification data), supervisor-reconnect (child, runId), supervisor-cancel (child, runId, reason), or supervisor-integrate (child, checks)."],output:'A compact portable state summary, explicit skill-coordinated label, Runtime-owned check results, scoped verifierDispatch, bounded request-check response, continuation.runnerAction, machine-readable continuation.inputOptions, and continuation.userCommunication with a user-ready message and Agent relay guidance. Read acceptance text and other long fields from paged status --details output. Human-readable verification statuses include "Host independently verified", "Checks completed, but your confirmation is required", "Full verification was unavailable; only automatic checks completed", and "You accepted the incomplete verification result". This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.',examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep]
161
+ 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 xs(t,e){return`${t}:
158
162
  ${e.map(r=>` ${r}`).join(`
159
- `)}`}function mk(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return ks[r]||e.length>1&&ks[e[0]]?.subcommands?r:e[0]}function vk(t=[]){let e=mk(t),r=ks[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.subcommands&&i.push("",bs("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...pf];return n&&n.length>0&&i.push("",bs("Options",n)),i.push("",`Output:
160
- ${r.output}`),r.examples&&i.push("",bs("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
163
+ `)}`}function Fk(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return Ps[r]||e.length>1&&Ps[e[0]]?.subcommands?r:e[0]}function Vk(t=[]){let e=Fk(t),r=Ps[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.subcommands&&i.push("",xs("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...Af];return n&&n.length>0&&i.push("",xs("Options",n)),i.push("",`Output:
164
+ ${r.output}`),r.examples&&i.push("",xs("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
161
165
  `)}
162
- `}}var gk=vk().usage;var V0=10*1024*1024,He=class extends Error{};function vf(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new He(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function Mn(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new He(`${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 He(`${e} requires a value`);return t.splice(i,2),n}function gf(t){if(t.length>0)throw new He(`Unexpected argument: ${t[0]}`)}function Ss(t,e){let r=Br.normalize(mf(t)),i=Br.normalize(mf(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function mf(t){let e=Br.resolve(t);try{return wk.native(e)}catch{return e}}function yk(t){let e=Br.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||!Ss(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||Ss(r.currentWorktreeRoot,i.currentWorktreeRoot)?e:Ss(process.cwd(),r.currentWorktreeRoot)?Br.resolve(process.cwd()):r.currentWorktreeRoot}async function wf(t){return t?yk(t):Vo(process.cwd())}function yf(t,e){if(e instanceof He)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof Bn)return{command:t,exitCode:73,data:{capability:e.capability,expectedHash:e.expectedHash,actualHash:e.actualHash,canonicalPath:e.canonicalPath},error:{code:"conflict",message:e.message}};if(e instanceof Ln)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof xn)return{command:t,exitCode:73,data:{change:e.change,expectedRevision:e.expectedRevision,actualRevision:e.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:e.message}};if(e instanceof Ir)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 An)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof Pn)return{command:t,exitCode:65,data:{change:e.change,complete:!1,omittedCount:e.omittedCount,omittedByReason:e.omittedByReason,samplePaths:e.samplePaths,sampleTruncated:e.sampleTruncated,effectiveLimits:e.effectiveLimits,policyHash:e.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:e.message}};if(e instanceof Dn)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof Dr)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let r=e.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function Nf(t,e){return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
163
- `}:t.error?{exitCode:t.exitCode,stderr:t.error.message}:{exitCode:t.exitCode,stdout:t.text}}async function bf(t,e){let r=Mn(t,"--hook-output");if(r!==void 0&&r!=="copilot")throw new He("--hook-output must be copilot");gf(t);let i=await af(e,await nf());return r==="copilot"?{command:"hook-guard",exitCode:0,data:i,text:i.allowed?`{}
166
+ `}}var qk=Vk().usage;var CH=10*1024*1024,Le=class extends Error{};function As(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new Le(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function zn(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new Le(`${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 Le(`${e} requires a value`);return t.splice(i,2),n}function Tf(t){if(t.length>0)throw new Le(`Unexpected argument: ${t[0]}`)}function Rs(t,e){let r=Mr.normalize(_f(t)),i=Mr.normalize(_f(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function _f(t){let e=Mr.resolve(t);try{return Wk.native(e)}catch{return e}}function zk(t){let e=Mr.resolve(t),r=ce(process.cwd());if(!r.isSecondaryWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null)return e;let i=ce(e);return!i.isGitWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null||!Rs(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||Rs(r.currentWorktreeRoot,i.currentWorktreeRoot)?e:Rs(process.cwd(),r.currentWorktreeRoot)?Mr.resolve(process.cwd()):r.currentWorktreeRoot}async function If(t){return t?zk(t):zo(process.cwd())}function Jk(t){return JSON.stringify(t,null,2)+`
167
+ `}function Gk(t,e){if(e instanceof Le)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof qn)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 Tn)return{command:t,exitCode:73,data:{change:e.change,expectedRevision:e.expectedRevision,actualRevision:e.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:e.message}};if(e instanceof $r)return{command:t,exitCode:73,data:{requestedIsolation:e.requestedIsolation,activeChanges:e.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:e.message}};if(e instanceof $n)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof In)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 Br)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 jf(t,e){let r=Gk(t,e),i=r.error;if(!i)return r;let n=Rf({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function $f(t,e,r=!1){let i=t.envelope??Pf(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}})+`
168
+ `}:t.error?{exitCode:t.exitCode,stderr:i?pf(i,t.error.message,r?t.data:void 0):t.error.message}:i?{exitCode:t.exitCode,stdout:hf(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==Jk(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
169
+ ${De.details}
170
+ ${JSON.stringify(t.data,null,2)}
171
+ `}:{exitCode:t.exitCode,stdout:t.text}}async function Of(t,e){let r=zn(t,"--hook-output");if(r!==void 0&&r!=="copilot")throw new Le("--hook-output must be copilot");Tf(t);let i=await df(e,await uf());return r==="copilot"?{command:"hook-guard",exitCode:0,data:i,text:i.allowed?`{}
164
172
  `:`${JSON.stringify({permissionDecision:"deny",permissionDecisionReason:i.reason})}
165
- `}:i.allowed?{command:"hook-guard",exitCode:0,data:i}:{command:"hook-guard",exitCode:2,data:i,error:{code:"blocked",message:i.reason}}}function Nk(t){return{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
166
- `}}async function kf(t,e,r=process.argv.slice(2)){let i=r.indexOf("--"),n=i<0?[...r]:r.slice(0,i),a=i<0?[]:r.slice(i),o=n.includes("--json"),s,c;try{vf(n,"--json"),s=Mn(n,"--project-root");let u=[...n,...a],d=await wf(s);c=await e(u,d)}catch(u){c=yf(t,u)}let l=o?Nk(c):Nf(c,!1);return l.stdout&&process.stdout.write(l.stdout),l.stderr&&process.stderr.write(l.stderr+(l.stderr.endsWith(`
173
+ `}:i.allowed?{command:"hook-guard",exitCode:0,data:i}:{command:"hook-guard",exitCode:2,data:i,error:{code:"blocked",message:i.reason}}}async function Hf(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{As(n,"--json"),As(n,"--verbose"),c=zn(n,"--project-root");let d=[...n,...a],f=await If(c);l=await e(d,f)}catch(d){l=jf(t,d)}let u=$f(l,o,s);return u.stdout&&process.stdout.write(u.stdout),u.stderr&&process.stderr.write(u.stderr+(u.stderr.endsWith(`
167
174
  `)?"":`
168
- `)),l.exitCode}process.exitCode=await kf("hook-guard",bf);
175
+ `)),u.exitCode}process.exitCode=await Hf("hook-guard",Of);