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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +18 -3
  2. package/assets/manifest.json +3 -1
  3. package/assets/skills/comet/scripts/comet-archive.mjs +121 -121
  4. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +84 -84
  5. package/assets/skills/comet/scripts/comet-guard.mjs +152 -152
  6. package/assets/skills/comet/scripts/comet-handoff.mjs +123 -123
  7. package/assets/skills/comet/scripts/comet-hook-guard.mjs +75 -75
  8. package/assets/skills/comet/scripts/comet-hook-router.mjs +91 -91
  9. package/assets/skills/comet/scripts/comet-intent.mjs +6 -6
  10. package/assets/skills/comet/scripts/comet-resume-probe.mjs +79 -79
  11. package/assets/skills/comet/scripts/comet-runtime.mjs +169 -169
  12. package/assets/skills/comet/scripts/comet-state.mjs +88 -88
  13. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +97 -97
  14. package/assets/skills/comet-build/SKILL.md +21 -6
  15. package/assets/skills/comet-design/SKILL.md +2 -2
  16. package/assets/skills/comet-native/SKILL.md +7 -7
  17. package/assets/skills/comet-native/reference/artifacts.md +3 -3
  18. package/assets/skills/comet-native/reference/clarification.md +1 -1
  19. package/assets/skills/comet-native/reference/commands.md +3 -3
  20. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +114 -113
  21. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +123 -123
  22. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +88 -88
  23. package/assets/skills/comet-native/scripts/comet-native-init.mjs +116 -116
  24. package/assets/skills/comet-native/scripts/comet-native-new.mjs +100 -100
  25. package/assets/skills/comet-native/scripts/comet-native-next.mjs +118 -118
  26. package/assets/skills/comet-native/scripts/comet-native-root.mjs +95 -95
  27. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +145 -144
  28. package/assets/skills/comet-native/scripts/comet-native-select.mjs +101 -101
  29. package/assets/skills/comet-native/scripts/comet-native-show.mjs +83 -83
  30. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +87 -87
  31. package/assets/skills/comet-native/scripts/comet-native-status.mjs +98 -98
  32. package/assets/skills/comet-review/SKILL.md +121 -0
  33. package/assets/skills/comet-review/agents/openai.yaml +5 -0
  34. package/assets/skills-zh/comet-build/SKILL.md +21 -6
  35. package/assets/skills-zh/comet-design/SKILL.md +2 -2
  36. package/assets/skills-zh/comet-native/SKILL.md +7 -7
  37. package/assets/skills-zh/comet-native/reference/artifacts.md +3 -3
  38. package/assets/skills-zh/comet-native/reference/clarification.md +1 -1
  39. package/assets/skills-zh/comet-native/reference/commands.md +3 -3
  40. package/assets/skills-zh/comet-review/SKILL.md +121 -0
  41. package/assets/skills-zh/comet-review/agents/openai.yaml +5 -0
  42. package/dist/app/commands/init.d.ts.map +1 -1
  43. package/dist/app/commands/init.js +5 -9
  44. package/dist/app/commands/init.js.map +1 -1
  45. package/dist/app/commands/update.d.ts.map +1 -1
  46. package/dist/app/commands/update.js +5 -9
  47. package/dist/app/commands/update.js.map +1 -1
  48. package/dist/domains/comet-classic/classic-command-context.d.ts +9 -0
  49. package/dist/domains/comet-classic/classic-command-context.d.ts.map +1 -1
  50. package/dist/domains/comet-classic/classic-command-context.js +10 -0
  51. package/dist/domains/comet-classic/classic-command-context.js.map +1 -1
  52. package/dist/domains/comet-classic/classic-guard.d.ts.map +1 -1
  53. package/dist/domains/comet-classic/classic-guard.js +2 -2
  54. package/dist/domains/comet-classic/classic-guard.js.map +1 -1
  55. package/dist/domains/comet-classic/classic-handoff.d.ts.map +1 -1
  56. package/dist/domains/comet-classic/classic-handoff.js +44 -6
  57. package/dist/domains/comet-classic/classic-handoff.js.map +1 -1
  58. package/dist/domains/comet-classic/classic-hook-guard.d.ts.map +1 -1
  59. package/dist/domains/comet-classic/classic-hook-guard.js +2 -1
  60. package/dist/domains/comet-classic/classic-hook-guard.js.map +1 -1
  61. package/dist/domains/comet-classic/classic-intent-command.d.ts.map +1 -1
  62. package/dist/domains/comet-classic/classic-intent-command.js +2 -1
  63. package/dist/domains/comet-classic/classic-intent-command.js.map +1 -1
  64. package/dist/domains/comet-classic/classic-resume-probe-command.d.ts.map +1 -1
  65. package/dist/domains/comet-classic/classic-resume-probe-command.js +4 -3
  66. package/dist/domains/comet-classic/classic-resume-probe-command.js.map +1 -1
  67. package/dist/domains/comet-classic/classic-runtime-run.d.ts +6 -0
  68. package/dist/domains/comet-classic/classic-runtime-run.d.ts.map +1 -1
  69. package/dist/domains/comet-classic/classic-runtime-run.js +58 -9
  70. package/dist/domains/comet-classic/classic-runtime-run.js.map +1 -1
  71. package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
  72. package/dist/domains/comet-classic/classic-state-command.js +8 -5
  73. package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
  74. package/dist/domains/comet-classic/classic-validate-command.d.ts.map +1 -1
  75. package/dist/domains/comet-classic/classic-validate-command.js +2 -2
  76. package/dist/domains/comet-classic/classic-validate-command.js.map +1 -1
  77. package/dist/domains/comet-classic/classic-workspace-command.d.ts.map +1 -1
  78. package/dist/domains/comet-classic/classic-workspace-command.js +3 -3
  79. package/dist/domains/comet-classic/classic-workspace-command.js.map +1 -1
  80. package/dist/domains/comet-entry/hook-adapter.d.ts.map +1 -1
  81. package/dist/domains/comet-entry/hook-adapter.js +4 -1
  82. package/dist/domains/comet-entry/hook-adapter.js.map +1 -1
  83. package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
  84. package/dist/domains/comet-native/native-archive-command.js +2 -0
  85. package/dist/domains/comet-native/native-archive-command.js.map +1 -1
  86. package/dist/domains/comet-native/native-atomic-file.d.ts.map +1 -1
  87. package/dist/domains/comet-native/native-atomic-file.js +17 -10
  88. package/dist/domains/comet-native/native-atomic-file.js.map +1 -1
  89. package/dist/domains/comet-native/native-children.d.ts +18 -2
  90. package/dist/domains/comet-native/native-children.d.ts.map +1 -1
  91. package/dist/domains/comet-native/native-children.js +73 -8
  92. package/dist/domains/comet-native/native-children.js.map +1 -1
  93. package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
  94. package/dist/domains/comet-native/native-cli-help.js +10 -4
  95. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  96. package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
  97. package/dist/domains/comet-native/native-cli-shared.js +18 -5
  98. package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
  99. package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
  100. package/dist/domains/comet-native/native-hook-guard.js +15 -2
  101. package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
  102. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  103. package/dist/domains/comet-native/native-next-command.js +94 -15
  104. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  105. package/dist/domains/comet-native/native-portable-continuation.d.ts +19 -7
  106. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  107. package/dist/domains/comet-native/native-portable-continuation.js +115 -72
  108. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  109. package/dist/domains/comet-native/native-portable-migration-runtime.d.ts.map +1 -1
  110. package/dist/domains/comet-native/native-portable-migration-runtime.js +9 -4
  111. package/dist/domains/comet-native/native-portable-migration-runtime.js.map +1 -1
  112. package/dist/domains/comet-native/native-portable-runtime.d.ts +14 -1
  113. package/dist/domains/comet-native/native-portable-runtime.d.ts.map +1 -1
  114. package/dist/domains/comet-native/native-portable-runtime.js +59 -1
  115. package/dist/domains/comet-native/native-portable-runtime.js.map +1 -1
  116. package/dist/domains/comet-native/native-pull-request-finish.d.ts +35 -0
  117. package/dist/domains/comet-native/native-pull-request-finish.d.ts.map +1 -0
  118. package/dist/domains/comet-native/native-pull-request-finish.js +282 -0
  119. package/dist/domains/comet-native/native-pull-request-finish.js.map +1 -0
  120. package/dist/domains/comet-native/native-status-discovery.d.ts.map +1 -1
  121. package/dist/domains/comet-native/native-status-discovery.js +24 -6
  122. package/dist/domains/comet-native/native-status-discovery.js.map +1 -1
  123. package/dist/domains/comet-native/native-workspace-finish.d.ts +6 -0
  124. package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -1
  125. package/dist/domains/comet-native/native-workspace-finish.js +86 -35
  126. package/dist/domains/comet-native/native-workspace-finish.js.map +1 -1
  127. package/dist/domains/dashboard/web/assets/{abnfDiagram-N423BO3Z-B5cFR6hS.js → abnfDiagram-N423BO3Z-BYya6ofk.js} +1 -1
  128. package/dist/domains/dashboard/web/assets/{arc-CVQDtMsu.js → arc-DJbo4TD3.js} +1 -1
  129. package/dist/domains/dashboard/web/assets/{architectureDiagram-T3A2C74G-C0v0kULK.js → architectureDiagram-T3A2C74G-D8uZ2IB-.js} +1 -1
  130. package/dist/domains/dashboard/web/assets/{blockDiagram-VBNYF7ZC-DpHLuxu4.js → blockDiagram-VBNYF7ZC-B16BVj-r.js} +1 -1
  131. package/dist/domains/dashboard/web/assets/{c4Diagram-5PPSVZJV-BHnFxUs1.js → c4Diagram-5PPSVZJV-ayV208_D.js} +1 -1
  132. package/dist/domains/dashboard/web/assets/channel-CEsrvmig.js +1 -0
  133. package/dist/domains/dashboard/web/assets/{chunk-2GRJ4B5K-CGC9gh5n.js → chunk-2GRJ4B5K-Bn5o8p3H.js} +1 -1
  134. package/dist/domains/dashboard/web/assets/{chunk-2Q5K7J3B-l4puLU_O.js → chunk-2Q5K7J3B-BnF1SI6B.js} +1 -1
  135. package/dist/domains/dashboard/web/assets/{chunk-5RXB4S5H-ls9jQHZc.js → chunk-5RXB4S5H-ETnma053.js} +1 -1
  136. package/dist/domains/dashboard/web/assets/{chunk-5VM5RSS4-BVavmTEq.js → chunk-5VM5RSS4-Cuvy639H.js} +1 -1
  137. package/dist/domains/dashboard/web/assets/{chunk-6Q2QTUOP-Dungt2g9.js → chunk-6Q2QTUOP-DOXBzl73.js} +1 -1
  138. package/dist/domains/dashboard/web/assets/{chunk-GF5L2VYU-BidXO_ZP.js → chunk-GF5L2VYU-CfREXlEl.js} +1 -1
  139. package/dist/domains/dashboard/web/assets/{chunk-JWPE2WC7-57L5Up5X.js → chunk-JWPE2WC7-DWIdpYTb.js} +1 -1
  140. package/dist/domains/dashboard/web/assets/{chunk-KBJHAD2P-C5u5vbwr.js → chunk-KBJHAD2P-BnqPcfZB.js} +1 -1
  141. package/dist/domains/dashboard/web/assets/{chunk-RYQCIY6F-CvLz21I2.js → chunk-RYQCIY6F-DdJ00fZz.js} +1 -1
  142. package/dist/domains/dashboard/web/assets/{chunk-XXDRQBXY-D5nJpckG.js → chunk-XXDRQBXY-BVDhdJyW.js} +1 -1
  143. package/dist/domains/dashboard/web/assets/classDiagram-JCYQIIEL-CKFe0hg4.js +1 -0
  144. package/dist/domains/dashboard/web/assets/classDiagram-v2-OCEON4UE-CKFe0hg4.js +1 -0
  145. package/dist/domains/dashboard/web/assets/{cose-bilkent-JH36ORCC-Dp0JAGyE.js → cose-bilkent-JH36ORCC-C-nglwHC.js} +1 -1
  146. package/dist/domains/dashboard/web/assets/{cynefin-VYW2F7L2-EjC54l1g.js → cynefin-VYW2F7L2-C8TMmrbP.js} +1 -1
  147. package/dist/domains/dashboard/web/assets/{cynefinDiagram-MW4NZA55-CpYrW3w3.js → cynefinDiagram-MW4NZA55-C3pnQnjg.js} +1 -1
  148. package/dist/domains/dashboard/web/assets/{dagre-VZM6K2ZE-h5K39rCk.js → dagre-VZM6K2ZE-DY7UWiPI.js} +1 -1
  149. package/dist/domains/dashboard/web/assets/{diagram-7IWD3JNH-CKQj9O4H.js → diagram-7IWD3JNH-voTyDkQ5.js} +1 -1
  150. package/dist/domains/dashboard/web/assets/{diagram-B4RE2ZJO-DXRIYcnW.js → diagram-B4RE2ZJO-B3VkUMck.js} +1 -1
  151. package/dist/domains/dashboard/web/assets/{diagram-LBJQPF4R-wWutQYmv.js → diagram-LBJQPF4R-BdJzPkv8.js} +1 -1
  152. package/dist/domains/dashboard/web/assets/{diagram-Q27KOJAE-EgXLJQYi.js → diagram-Q27KOJAE-Bsq0anZx.js} +1 -1
  153. package/dist/domains/dashboard/web/assets/{diagram-UB23O5K3-CsQRXDQZ.js → diagram-UB23O5K3-CBaKRbcu.js} +1 -1
  154. package/dist/domains/dashboard/web/assets/{ebnfDiagram-BXEA7PRR-gm328Eho.js → ebnfDiagram-BXEA7PRR-Bl9Bm5wa.js} +1 -1
  155. package/dist/domains/dashboard/web/assets/{erDiagram-JOGREHBK-BbbMVUx_.js → erDiagram-JOGREHBK-DjOZzfKI.js} +1 -1
  156. package/dist/domains/dashboard/web/assets/{flowDiagram-UKHOOZJN-1Y7scCns.js → flowDiagram-UKHOOZJN-C21e4siK.js} +1 -1
  157. package/dist/domains/dashboard/web/assets/{ganttDiagram-PKOTCBZU-BAoBqczv.js → ganttDiagram-PKOTCBZU-Bs62uy6-.js} +1 -1
  158. package/dist/domains/dashboard/web/assets/{gitGraphDiagram-DS77QQ5N-CMUAyEzl.js → gitGraphDiagram-DS77QQ5N-DQY_Ba00.js} +1 -1
  159. package/dist/domains/dashboard/web/assets/{index-CCApJ0Yr.js → index-BLv71GRj.js} +1 -1
  160. package/dist/domains/dashboard/web/assets/{index-DWdm_XBi.js → index-Be4r99N4.js} +3 -3
  161. package/dist/domains/dashboard/web/assets/index-ByVYiA6g.css +1 -0
  162. package/dist/domains/dashboard/web/assets/{infoDiagram-6WML65LV-BaCdtYYC.js → infoDiagram-6WML65LV-CNgNNG9l.js} +1 -1
  163. package/dist/domains/dashboard/web/assets/{ishikawaDiagram-WSZJBQD7-DQQlNnjU.js → ishikawaDiagram-WSZJBQD7-D9k1fTO1.js} +1 -1
  164. package/dist/domains/dashboard/web/assets/{journeyDiagram-NVQOT4AX-DW9wUMqn.js → journeyDiagram-NVQOT4AX-CHijUnPl.js} +1 -1
  165. package/dist/domains/dashboard/web/assets/{kanban-definition-27J2QSJJ-C_ITaZ0q.js → kanban-definition-27J2QSJJ-DfWlntDq.js} +1 -1
  166. package/dist/domains/dashboard/web/assets/{linear-DXOo6ZRT.js → linear-o6hemX-z.js} +1 -1
  167. package/dist/domains/dashboard/web/assets/{mermaid.core-ol-0NI97.js → mermaid.core-B1DoOsPD.js} +4 -4
  168. package/dist/domains/dashboard/web/assets/{mindmap-definition-FAOFIHXS-CHF_HOLV.js → mindmap-definition-FAOFIHXS-COMQF9Yy.js} +1 -1
  169. package/dist/domains/dashboard/web/assets/{pegDiagram-VL7TDLO6-wQEvkNF8.js → pegDiagram-VL7TDLO6-C_21n7Ps.js} +1 -1
  170. package/dist/domains/dashboard/web/assets/{pieDiagram-7S7Q4E2Y-C3H3kiIP.js → pieDiagram-7S7Q4E2Y-D3EmoYDY.js} +1 -1
  171. package/dist/domains/dashboard/web/assets/{quadrantDiagram-CIZ2JOQS-S0FdVzJb.js → quadrantDiagram-CIZ2JOQS-C3fGdiMa.js} +1 -1
  172. package/dist/domains/dashboard/web/assets/{railroadDiagram-AXF67PYL-DCDXDaVg.js → railroadDiagram-AXF67PYL-mIsjemD-.js} +1 -1
  173. package/dist/domains/dashboard/web/assets/{requirementDiagram-LRYGKXZP-BW8J4gO_.js → requirementDiagram-LRYGKXZP-D_UMpS5e.js} +1 -1
  174. package/dist/domains/dashboard/web/assets/{sankeyDiagram-W5VNT64P-DQQBmLoy.js → sankeyDiagram-W5VNT64P-D1MwyMF6.js} +1 -1
  175. package/dist/domains/dashboard/web/assets/{sequenceDiagram-SI44F4Z6-2tDcli0Y.js → sequenceDiagram-SI44F4Z6-B8jp1RxX.js} +1 -1
  176. package/dist/domains/dashboard/web/assets/{sizeCapture-X5ZJPWSS-4sEZLBKb.js → sizeCapture-X5ZJPWSS-BKioI1Ql.js} +1 -1
  177. package/dist/domains/dashboard/web/assets/{stateDiagram-OKZ733FA-OgPb8pyR.js → stateDiagram-OKZ733FA-B7l8_CDo.js} +1 -1
  178. package/dist/domains/dashboard/web/assets/stateDiagram-v2-UEYNNEHI-BIxuwbeV.js +1 -0
  179. package/dist/domains/dashboard/web/assets/{swimlanes-SLNWSIFB-DR7lwtxd.js → swimlanes-SLNWSIFB-951PRLYp.js} +2 -2
  180. package/dist/domains/dashboard/web/assets/swimlanesDiagram-ULZ7WXOC-CEo6cGsy.js +8 -0
  181. package/dist/domains/dashboard/web/assets/{timeline-definition-Z64GVDOM-DNIJVlQV.js → timeline-definition-Z64GVDOM-CeyA2KbI.js} +1 -1
  182. package/dist/domains/dashboard/web/assets/{vennDiagram-T6HMQDX7-CClhw4QZ.js → vennDiagram-T6HMQDX7-BHe0TZJV.js} +1 -1
  183. package/dist/domains/dashboard/web/assets/{wardleyDiagram-T6FBY63Y-DzR3aFPS.js → wardleyDiagram-T6FBY63Y-CWqdSzJ-.js} +1 -1
  184. package/dist/domains/dashboard/web/assets/{xychartDiagram-ELKLHX3M-DZhq0ZRj.js → xychartDiagram-ELKLHX3M-DCKiZVPV.js} +1 -1
  185. package/dist/domains/dashboard/web/index.html +2 -2
  186. package/dist/domains/dashboard/workspace.d.ts +3 -0
  187. package/dist/domains/dashboard/workspace.d.ts.map +1 -1
  188. package/dist/domains/dashboard/workspace.js +23 -2
  189. package/dist/domains/dashboard/workspace.js.map +1 -1
  190. package/dist/domains/integrations/openspec.d.ts +1 -1
  191. package/dist/domains/integrations/openspec.d.ts.map +1 -1
  192. package/dist/domains/integrations/openspec.js +43 -84
  193. package/dist/domains/integrations/openspec.js.map +1 -1
  194. package/dist/domains/integrations/superpowers.d.ts +10 -1
  195. package/dist/domains/integrations/superpowers.d.ts.map +1 -1
  196. package/dist/domains/integrations/superpowers.js +73 -4
  197. package/dist/domains/integrations/superpowers.js.map +1 -1
  198. package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
  199. package/dist/domains/skill/platform-inspect.js +3 -3
  200. package/dist/domains/skill/platform-inspect.js.map +1 -1
  201. package/dist/domains/skill/platform-install.d.ts +3 -1
  202. package/dist/domains/skill/platform-install.d.ts.map +1 -1
  203. package/dist/domains/skill/platform-install.js +15 -9
  204. package/dist/domains/skill/platform-install.js.map +1 -1
  205. package/dist/domains/skill/project-instructions.d.ts.map +1 -1
  206. package/dist/domains/skill/project-instructions.js +6 -0
  207. package/dist/domains/skill/project-instructions.js.map +1 -1
  208. package/dist/domains/skill/uninstall.d.ts.map +1 -1
  209. package/dist/domains/skill/uninstall.js +39 -29
  210. package/dist/domains/skill/uninstall.js.map +1 -1
  211. package/dist/domains/workflow-contract/contained-atomic-write.d.ts.map +1 -1
  212. package/dist/domains/workflow-contract/contained-atomic-write.js +18 -10
  213. package/dist/domains/workflow-contract/contained-atomic-write.js.map +1 -1
  214. package/dist/domains/workflow-contract/project-config.d.ts +4 -2
  215. package/dist/domains/workflow-contract/project-config.d.ts.map +1 -1
  216. package/dist/domains/workflow-contract/project-config.js +132 -0
  217. package/dist/domains/workflow-contract/project-config.js.map +1 -1
  218. package/dist/domains/workflow-contract/types.d.ts +9 -0
  219. package/dist/domains/workflow-contract/types.d.ts.map +1 -1
  220. package/dist/platform/fs/strip-bom.d.ts +10 -0
  221. package/dist/platform/fs/strip-bom.d.ts.map +1 -0
  222. package/dist/platform/fs/strip-bom.js +12 -0
  223. package/dist/platform/fs/strip-bom.js.map +1 -0
  224. package/dist/platform/install/platforms.d.ts +11 -0
  225. package/dist/platform/install/platforms.d.ts.map +1 -1
  226. package/dist/platform/install/platforms.js +36 -0
  227. package/dist/platform/install/platforms.js.map +1 -1
  228. package/dist/platform/process/external-command.d.ts +1 -0
  229. package/dist/platform/process/external-command.d.ts.map +1 -1
  230. package/dist/platform/process/external-command.js +2 -1
  231. package/dist/platform/process/external-command.js.map +1 -1
  232. package/eval/local/tests/conftest.py +18 -3
  233. package/eval/local/tests/scaffold/test_conftest_helpers.py +57 -0
  234. package/package.json +11 -26
  235. package/dist/domains/dashboard/web/assets/channel-eM0x3m1G.js +0 -1
  236. package/dist/domains/dashboard/web/assets/classDiagram-JCYQIIEL-CEFhao2K.js +0 -1
  237. package/dist/domains/dashboard/web/assets/classDiagram-v2-OCEON4UE-CEFhao2K.js +0 -1
  238. package/dist/domains/dashboard/web/assets/index-DhhbseFJ.css +0 -1
  239. package/dist/domains/dashboard/web/assets/stateDiagram-v2-UEYNNEHI-CiDNPr4P.js +0 -1
  240. package/dist/domains/dashboard/web/assets/swimlanesDiagram-ULZ7WXOC-DggHFP9q.js +0 -8
  241. package/eval/local/tasks/comet-native-interrupted-transition/environment/.comet/config.yaml +0 -6
@@ -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 Ef=Object.create;var Ss=Object.defineProperty;var Pf=Object.getOwnPropertyDescriptor;var xf=Object.getOwnPropertyNames;var Cf=Object.getPrototypeOf,Rf=Object.prototype.hasOwnProperty;var Gi=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):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(i){throw e=0,i}};var Af=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of xf(e))!Rf.call(t,n)&&n!==i&&Ss(t,n,{get:()=>e[n],enumerable:!(r=Pf(e,n))||r.enumerable});return t};var Jt=(t,e,i)=>(i=t!=null?Ef(Cf(t)):{},Af(e||!t||!t.__esModule?Ss(i,"default",{value:t,enumerable:!0}):i,t));var P=w(D=>{"use strict";var zn=Symbol.for("yaml.alias"),Es=Symbol.for("yaml.document"),Ui=Symbol.for("yaml.map"),Ps=Symbol.for("yaml.pair"),Jn=Symbol.for("yaml.scalar"),Ki=Symbol.for("yaml.seq"),Ce=Symbol.for("yaml.node.type"),_f=t=>!!t&&typeof t=="object"&&t[Ce]===zn,Tf=t=>!!t&&typeof t=="object"&&t[Ce]===Es,If=t=>!!t&&typeof t=="object"&&t[Ce]===Ui,jf=t=>!!t&&typeof t=="object"&&t[Ce]===Ps,xs=t=>!!t&&typeof t=="object"&&t[Ce]===Jn,$f=t=>!!t&&typeof t=="object"&&t[Ce]===Ki;function Cs(t){if(t&&typeof t=="object")switch(t[Ce]){case Ui:case Ki:return!0}return!1}function Of(t){if(t&&typeof t=="object")switch(t[Ce]){case zn:case Ui:case Jn:case Ki:return!0}return!1}var Hf=t=>(xs(t)||Cs(t))&&!!t.anchor;D.ALIAS=zn;D.DOC=Es;D.MAP=Ui;D.NODE_TYPE=Ce;D.PAIR=Ps;D.SCALAR=Jn;D.SEQ=Ki;D.hasAnchor=Hf;D.isAlias=_f;D.isCollection=Cs;D.isDocument=Tf;D.isMap=If;D.isNode=Of;D.isPair=jf;D.isScalar=xs;D.isSeq=$f});var Gt=w(Gn=>{"use strict";var O=P(),q=Symbol("break visit"),Rs=Symbol("skip children"),be=Symbol("remove node");function Yi(t,e){let i=As(e);O.isDocument(t)?yt(null,t.contents,i,Object.freeze([t]))===be&&(t.contents=null):yt(null,t,i,Object.freeze([]))}Yi.BREAK=q;Yi.SKIP=Rs;Yi.REMOVE=be;function yt(t,e,i,r){let n=_s(t,e,i,r);if(O.isNode(n)||O.isPair(n))return Ts(t,r,n),yt(t,n,i,r);if(typeof n!="symbol"){if(O.isCollection(e)){r=Object.freeze(r.concat(e));for(let a=0;a<e.items.length;++a){let o=yt(a,e.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===q)return q;o===be&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){r=Object.freeze(r.concat(e));let a=yt("key",e.key,i,r);if(a===q)return q;a===be&&(e.key=null);let o=yt("value",e.value,i,r);if(o===q)return q;o===be&&(e.value=null)}}return n}async function Xi(t,e){let i=As(e);O.isDocument(t)?await Nt(null,t.contents,i,Object.freeze([t]))===be&&(t.contents=null):await Nt(null,t,i,Object.freeze([]))}Xi.BREAK=q;Xi.SKIP=Rs;Xi.REMOVE=be;async function Nt(t,e,i,r){let n=await _s(t,e,i,r);if(O.isNode(n)||O.isPair(n))return Ts(t,r,n),Nt(t,n,i,r);if(typeof n!="symbol"){if(O.isCollection(e)){r=Object.freeze(r.concat(e));for(let a=0;a<e.items.length;++a){let o=await Nt(a,e.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===q)return q;o===be&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){r=Object.freeze(r.concat(e));let a=await Nt("key",e.key,i,r);if(a===q)return q;a===be&&(e.key=null);let o=await Nt("value",e.value,i,r);if(o===q)return q;o===be&&(e.value=null)}}return n}function As(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 _s(t,e,i,r){if(typeof i=="function")return i(t,e,r);if(O.isMap(e))return i.Map?.(t,e,r);if(O.isSeq(e))return i.Seq?.(t,e,r);if(O.isPair(e))return i.Pair?.(t,e,r);if(O.isScalar(e))return i.Scalar?.(t,e,r);if(O.isAlias(e))return i.Alias?.(t,e,r)}function Ts(t,e,i){let r=e[e.length-1];if(O.isCollection(r))r.items[t]=i;else if(O.isPair(r))t==="key"?r.key=i:r.value=i;else if(O.isDocument(r))r.contents=i;else{let n=O.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Gn.visit=Yi;Gn.visitAsync=Xi});var Un=w(js=>{"use strict";var Is=P(),Df=Gt(),Bf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Lf=t=>t.replace(/[!,[\]{}]/g,e=>Bf[e]),Ut=class t{constructor(e,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,i)}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,i){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2&&(i(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[a,o]=r;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return i(0,"%YAML directive should contain exactly one part"),!1;let[a]=r;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return i(6,`Unsupported YAML version ${a}`,o),!1}}default:return i(0,`Unknown directive ${n}`,!0),!1}}tagName(e,i){if(e==="!")return"!";if(e[0]!=="!")return i(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(i(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&i("Verbatim tags must end with a >"),o)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||i(`The ${e} tag has no suffix`);let a=this.tags[r];if(a)try{return a+decodeURIComponent(n)}catch(o){return i(String(o)),null}return r==="!"?e:(i(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[i,r]of Object.entries(this.tags))if(e.startsWith(r))return i+Lf(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&Is.isNode(e.contents)){let a={};Df.visit(e.contents,(o,s)=>{Is.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of r)a==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(o)))&&i.push(`%TAG ${a} ${o}`);return i.join(`
5
- `)}};Ut.defaultYaml={explicit:!1,version:"1.2"};Ut.defaultTags={"!!":"tag:yaml.org,2002:"};js.Directives=Ut});var Qi=w(Kt=>{"use strict";var $s=P(),Mf=Gt();function Ff(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(i)}return!0}function Os(t){let e=new Set;return Mf.visit(t,{Value(i,r){r.anchor&&e.add(r.anchor)}}),e}function Hs(t,e){for(let i=1;;++i){let r=`${t}${i}`;if(!e.has(r))return r}}function Vf(t,e){let i=[],r=new Map,n=null;return{onAnchor:a=>{i.push(a),n??(n=Os(t));let o=Hs(e,n);return n.add(o),o},setAnchors:()=>{for(let a of i){let o=r.get(a);if(typeof o=="object"&&o.anchor&&($s.isScalar(o.node)||$s.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:r}}Kt.anchorIsValid=Ff;Kt.anchorNames=Os;Kt.createNodeAnchors=Vf;Kt.findNewAnchor=Hs});var Kn=w(Ds=>{"use strict";function Yt(t,e,i,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let n=0,a=r.length;n<a;++n){let o=r[n],s=Yt(t,r,String(n),o);s===void 0?delete r[n]:s!==o&&(r[n]=s)}else if(r instanceof Map)for(let n of Array.from(r.keys())){let a=r.get(n),o=Yt(t,r,n,a);o===void 0?r.delete(n):o!==a&&r.set(n,o)}else if(r instanceof Set)for(let n of Array.from(r)){let a=Yt(t,r,n,n);a===void 0?r.delete(n):a!==n&&(r.delete(n),r.add(a))}else for(let[n,a]of Object.entries(r)){let o=Yt(t,r,n,a);o===void 0?delete r[n]:o!==a&&(r[n]=o)}return t.call(e,i,r)}Ds.applyReviver=Yt});var Le=w(Ls=>{"use strict";var qf=P();function Bs(t,e,i){if(Array.isArray(t))return t.map((r,n)=>Bs(r,String(n),i));if(t&&typeof t.toJSON=="function"){if(!i||!qf.hasAnchor(t))return t.toJSON(e,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(t,r),i.onCreate=a=>{r.res=a,delete i.onCreate};let n=t.toJSON(e,i);return i.onCreate&&i.onCreate(n),n}return typeof t=="bigint"&&!i?.keep?Number(t):t}Ls.toJS=Bs});var Zi=w(Fs=>{"use strict";var Wf=Kn(),Ms=P(),zf=Le(),Yn=class{constructor(e){Object.defineProperty(this,Ms.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:i,maxAliasCount:r,onAnchor:n,reviver:a}={}){if(!Ms.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=zf.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?Wf.applyReviver(a,{"":s},"",s):s}};Fs.NodeBase=Yn});var Xt=w(Vs=>{"use strict";var Jf=Qi(),Gf=Gt(),bt=P(),Uf=Zi(),Kf=Le(),Xn=class extends Uf.NodeBase{constructor(e){super(bt.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],Gf.visit(e,{Node:(a,o)=>{(bt.isAlias(o)||bt.hasAnchor(o))&&r.push(o)}}),i&&(i.aliasResolveCache=r));let n;for(let a of r){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,i){if(!i)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:a}=i,o=this.resolve(n,i);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=r.get(o);if(s||(Kf.toJS(o,null,i),s=r.get(o)),s?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=er(n,o,r)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,i,r){let n=`*${this.source}`;if(e){if(Jf.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 er(t,e,i){if(bt.isAlias(e)){let r=e.resolve(t),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(bt.isCollection(e)){let r=0;for(let n of e.items){let a=er(t,n,i);a>r&&(r=a)}return r}else if(bt.isPair(e)){let r=er(t,e.key,i),n=er(t,e.value,i);return Math.max(r,n)}return 1}Vs.Alias=Xn});var j=w(Qn=>{"use strict";var Yf=P(),Xf=Zi(),Qf=Le(),Zf=t=>!t||typeof t!="function"&&typeof t!="object",Me=class extends Xf.NodeBase{constructor(e){super(Yf.SCALAR),this.value=e}toJSON(e,i){return i?.keep?this.value:Qf.toJS(this.value,e,i)}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";Qn.Scalar=Me;Qn.isScalarValue=Zf});var Qt=w(Ws=>{"use strict";var eh=Xt(),ot=P(),qs=j(),th="tag:yaml.org,2002:";function ih(t,e,i){if(e){let r=i.filter(a=>a.tag===e),n=r.find(a=>!a.format)??r[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return i.find(r=>r.identify?.(t)&&!r.format)}function rh(t,e,i){if(ot.isDocument(t)&&(t=t.contents),ot.isNode(t))return t;if(ot.isPair(t)){let d=i.schema[ot.MAP].createNode?.(i.schema,null,i);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:r,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=i,c;if(r&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new eh.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=th+e.slice(2));let l=ih(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new qs.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?o[ot.MAP]:Symbol.iterator in Object(t)?o[ot.SEQ]:o[ot.MAP]}a&&(a(l),delete i.onTagObj);let u=l?.createNode?l.createNode(i.schema,t,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,t,i):new qs.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}Ws.createNode=rh});var ir=w(tr=>{"use strict";var nh=Qt(),ke=P(),ah=Zi();function Zn(t,e,i){let r=i;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]=r,r=o}else r=new Map([[a,r]])}return nh.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var zs=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,ea=class extends ah.NodeBase{constructor(e,i){super(e),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(e){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(i.schema=e),i.items=i.items.map(r=>ke.isNode(r)||ke.isPair(r)?r.clone(e):r),this.range&&(i.range=this.range.slice()),i}addIn(e,i){if(zs(e))this.add(i);else{let[r,...n]=e,a=this.get(r,!0);if(ke.isCollection(a))a.addIn(n,i);else if(a===void 0&&this.schema)this.set(r,Zn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[i,...r]=e;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(ke.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(e,i){let[r,...n]=e,a=this.get(r,!0);return n.length===0?!i&&ke.isScalar(a)?a.value:a:ke.isCollection(a)?a.getIn(n,i):void 0}hasAllNullValues(e){return this.items.every(i=>{if(!ke.isPair(i))return!1;let r=i.value;return r==null||e&&ke.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[i,...r]=e;if(r.length===0)return this.has(i);let n=this.get(i,!0);return ke.isCollection(n)?n.hasIn(r):!1}setIn(e,i){let[r,...n]=e;if(n.length===0)this.set(r,i);else{let a=this.get(r,!0);if(ke.isCollection(a))a.setIn(n,i);else if(a===void 0&&this.schema)this.set(r,Zn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};tr.Collection=ea;tr.collectionFromPath=Zn;tr.isEmptyPath=zs});var Zt=w(rr=>{"use strict";var oh=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function ta(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var sh=(t,e,i)=>t.endsWith(`
6
- `)?ta(i,e):i.includes(`
4
+ var _f=Object.create;var Rs=Object.defineProperty;var Tf=Object.getOwnPropertyDescriptor;var If=Object.getOwnPropertyNames;var jf=Object.getPrototypeOf,$f=Object.prototype.hasOwnProperty;var Ki=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):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(i){throw e=0,i}};var Of=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of If(e))!$f.call(t,n)&&n!==i&&Rs(t,n,{get:()=>e[n],enumerable:!(r=Tf(e,n))||r.enumerable});return t};var Gt=(t,e,i)=>(i=t!=null?_f(jf(t)):{},Of(e||!t||!t.__esModule?Rs(i,"default",{value:t,enumerable:!0}):i,t));var x=w(D=>{"use strict";var Kn=Symbol.for("yaml.alias"),As=Symbol.for("yaml.document"),Yi=Symbol.for("yaml.map"),_s=Symbol.for("yaml.pair"),Yn=Symbol.for("yaml.scalar"),Xi=Symbol.for("yaml.seq"),Ce=Symbol.for("yaml.node.type"),Hf=t=>!!t&&typeof t=="object"&&t[Ce]===Kn,Df=t=>!!t&&typeof t=="object"&&t[Ce]===As,Bf=t=>!!t&&typeof t=="object"&&t[Ce]===Yi,Lf=t=>!!t&&typeof t=="object"&&t[Ce]===_s,Ts=t=>!!t&&typeof t=="object"&&t[Ce]===Yn,Mf=t=>!!t&&typeof t=="object"&&t[Ce]===Xi;function Is(t){if(t&&typeof t=="object")switch(t[Ce]){case Yi:case Xi:return!0}return!1}function Ff(t){if(t&&typeof t=="object")switch(t[Ce]){case Kn:case Yi:case Yn:case Xi:return!0}return!1}var Vf=t=>(Ts(t)||Is(t))&&!!t.anchor;D.ALIAS=Kn;D.DOC=As;D.MAP=Yi;D.NODE_TYPE=Ce;D.PAIR=_s;D.SCALAR=Yn;D.SEQ=Xi;D.hasAnchor=Vf;D.isAlias=Hf;D.isCollection=Is;D.isDocument=Df;D.isMap=Bf;D.isNode=Ff;D.isPair=Lf;D.isScalar=Ts;D.isSeq=Mf});var Ut=w(Xn=>{"use strict";var O=x(),q=Symbol("break visit"),js=Symbol("skip children"),Ne=Symbol("remove node");function Qi(t,e){let i=$s(e);O.isDocument(t)?bt(null,t.contents,i,Object.freeze([t]))===Ne&&(t.contents=null):bt(null,t,i,Object.freeze([]))}Qi.BREAK=q;Qi.SKIP=js;Qi.REMOVE=Ne;function bt(t,e,i,r){let n=Os(t,e,i,r);if(O.isNode(n)||O.isPair(n))return Hs(t,r,n),bt(t,n,i,r);if(typeof n!="symbol"){if(O.isCollection(e)){r=Object.freeze(r.concat(e));for(let a=0;a<e.items.length;++a){let o=bt(a,e.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===q)return q;o===Ne&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){r=Object.freeze(r.concat(e));let a=bt("key",e.key,i,r);if(a===q)return q;a===Ne&&(e.key=null);let o=bt("value",e.value,i,r);if(o===q)return q;o===Ne&&(e.value=null)}}return n}async function Zi(t,e){let i=$s(e);O.isDocument(t)?await kt(null,t.contents,i,Object.freeze([t]))===Ne&&(t.contents=null):await kt(null,t,i,Object.freeze([]))}Zi.BREAK=q;Zi.SKIP=js;Zi.REMOVE=Ne;async function kt(t,e,i,r){let n=await Os(t,e,i,r);if(O.isNode(n)||O.isPair(n))return Hs(t,r,n),kt(t,n,i,r);if(typeof n!="symbol"){if(O.isCollection(e)){r=Object.freeze(r.concat(e));for(let a=0;a<e.items.length;++a){let o=await kt(a,e.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===q)return q;o===Ne&&(e.items.splice(a,1),a-=1)}}}else if(O.isPair(e)){r=Object.freeze(r.concat(e));let a=await kt("key",e.key,i,r);if(a===q)return q;a===Ne&&(e.key=null);let o=await kt("value",e.value,i,r);if(o===q)return q;o===Ne&&(e.value=null)}}return n}function $s(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 Os(t,e,i,r){if(typeof i=="function")return i(t,e,r);if(O.isMap(e))return i.Map?.(t,e,r);if(O.isSeq(e))return i.Seq?.(t,e,r);if(O.isPair(e))return i.Pair?.(t,e,r);if(O.isScalar(e))return i.Scalar?.(t,e,r);if(O.isAlias(e))return i.Alias?.(t,e,r)}function Hs(t,e,i){let r=e[e.length-1];if(O.isCollection(r))r.items[t]=i;else if(O.isPair(r))t==="key"?r.key=i:r.value=i;else if(O.isDocument(r))r.contents=i;else{let n=O.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Xn.visit=Qi;Xn.visitAsync=Zi});var Qn=w(Bs=>{"use strict";var Ds=x(),qf=Ut(),Wf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},zf=t=>t.replace(/[!,[\]{}]/g,e=>Wf[e]),Kt=class t{constructor(e,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,i)}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,i){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2&&(i(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[a,o]=r;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return i(0,"%YAML directive should contain exactly one part"),!1;let[a]=r;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return i(6,`Unsupported YAML version ${a}`,o),!1}}default:return i(0,`Unknown directive ${n}`,!0),!1}}tagName(e,i){if(e==="!")return"!";if(e[0]!=="!")return i(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(i(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&i("Verbatim tags must end with a >"),o)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||i(`The ${e} tag has no suffix`);let a=this.tags[r];if(a)try{return a+decodeURIComponent(n)}catch(o){return i(String(o)),null}return r==="!"?e:(i(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[i,r]of Object.entries(this.tags))if(e.startsWith(r))return i+zf(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&Ds.isNode(e.contents)){let a={};qf.visit(e.contents,(o,s)=>{Ds.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of r)a==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(o)))&&i.push(`%TAG ${a} ${o}`);return i.join(`
5
+ `)}};Kt.defaultYaml={explicit:!1,version:"1.2"};Kt.defaultTags={"!!":"tag:yaml.org,2002:"};Bs.Directives=Kt});var er=w(Yt=>{"use strict";var Ls=x(),Jf=Ut();function Gf(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(i)}return!0}function Ms(t){let e=new Set;return Jf.visit(t,{Value(i,r){r.anchor&&e.add(r.anchor)}}),e}function Fs(t,e){for(let i=1;;++i){let r=`${t}${i}`;if(!e.has(r))return r}}function Uf(t,e){let i=[],r=new Map,n=null;return{onAnchor:a=>{i.push(a),n??(n=Ms(t));let o=Fs(e,n);return n.add(o),o},setAnchors:()=>{for(let a of i){let o=r.get(a);if(typeof o=="object"&&o.anchor&&(Ls.isScalar(o.node)||Ls.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:r}}Yt.anchorIsValid=Gf;Yt.anchorNames=Ms;Yt.createNodeAnchors=Uf;Yt.findNewAnchor=Fs});var Zn=w(Vs=>{"use strict";function Xt(t,e,i,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let n=0,a=r.length;n<a;++n){let o=r[n],s=Xt(t,r,String(n),o);s===void 0?delete r[n]:s!==o&&(r[n]=s)}else if(r instanceof Map)for(let n of Array.from(r.keys())){let a=r.get(n),o=Xt(t,r,n,a);o===void 0?r.delete(n):o!==a&&r.set(n,o)}else if(r instanceof Set)for(let n of Array.from(r)){let a=Xt(t,r,n,n);a===void 0?r.delete(n):a!==n&&(r.delete(n),r.add(a))}else for(let[n,a]of Object.entries(r)){let o=Xt(t,r,n,a);o===void 0?delete r[n]:o!==a&&(r[n]=o)}return t.call(e,i,r)}Vs.applyReviver=Xt});var Me=w(Ws=>{"use strict";var Kf=x();function qs(t,e,i){if(Array.isArray(t))return t.map((r,n)=>qs(r,String(n),i));if(t&&typeof t.toJSON=="function"){if(!i||!Kf.hasAnchor(t))return t.toJSON(e,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(t,r),i.onCreate=a=>{r.res=a,delete i.onCreate};let n=t.toJSON(e,i);return i.onCreate&&i.onCreate(n),n}return typeof t=="bigint"&&!i?.keep?Number(t):t}Ws.toJS=qs});var tr=w(Js=>{"use strict";var Yf=Zn(),zs=x(),Xf=Me(),ea=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:i,maxAliasCount:r,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:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=Xf.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?Yf.applyReviver(a,{"":s},"",s):s}};Js.NodeBase=ea});var Qt=w(Gs=>{"use strict";var Qf=er(),Zf=Ut(),St=x(),eh=tr(),th=Me(),ta=class extends eh.NodeBase{constructor(e){super(St.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],Zf.visit(e,{Node:(a,o)=>{(St.isAlias(o)||St.hasAnchor(o))&&r.push(o)}}),i&&(i.aliasResolveCache=r));let n;for(let a of r){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,i){if(!i)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:a}=i,o=this.resolve(n,i);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=r.get(o);if(s||(th.toJS(o,null,i),s=r.get(o)),s?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=ir(n,o,r)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,i,r){let n=`*${this.source}`;if(e){if(Qf.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 ir(t,e,i){if(St.isAlias(e)){let r=e.resolve(t),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(St.isCollection(e)){let r=0;for(let n of e.items){let a=ir(t,n,i);a>r&&(r=a)}return r}else if(St.isPair(e)){let r=ir(t,e.key,i),n=ir(t,e.value,i);return Math.max(r,n)}return 1}Gs.Alias=ta});var j=w(ia=>{"use strict";var ih=x(),rh=tr(),nh=Me(),ah=t=>!t||typeof t!="function"&&typeof t!="object",Fe=class extends rh.NodeBase{constructor(e){super(ih.SCALAR),this.value=e}toJSON(e,i){return i?.keep?this.value:nh.toJS(this.value,e,i)}toString(){return String(this.value)}};Fe.BLOCK_FOLDED="BLOCK_FOLDED";Fe.BLOCK_LITERAL="BLOCK_LITERAL";Fe.PLAIN="PLAIN";Fe.QUOTE_DOUBLE="QUOTE_DOUBLE";Fe.QUOTE_SINGLE="QUOTE_SINGLE";ia.Scalar=Fe;ia.isScalarValue=ah});var Zt=w(Ks=>{"use strict";var oh=Qt(),ct=x(),Us=j(),sh="tag:yaml.org,2002:";function ch(t,e,i){if(e){let r=i.filter(a=>a.tag===e),n=r.find(a=>!a.format)??r[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return i.find(r=>r.identify?.(t)&&!r.format)}function lh(t,e,i){if(ct.isDocument(t)&&(t=t.contents),ct.isNode(t))return t;if(ct.isPair(t)){let d=i.schema[ct.MAP].createNode?.(i.schema,null,i);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:r,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=i,c;if(r&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new oh.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=sh+e.slice(2));let l=ch(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Us.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?o[ct.MAP]:Symbol.iterator in Object(t)?o[ct.SEQ]:o[ct.MAP]}a&&(a(l),delete i.onTagObj);let u=l?.createNode?l.createNode(i.schema,t,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,t,i):new Us.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}Ks.createNode=lh});var nr=w(rr=>{"use strict";var uh=Zt(),be=x(),dh=tr();function ra(t,e,i){let r=i;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]=r,r=o}else r=new Map([[a,r]])}return uh.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Ys=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,na=class extends dh.NodeBase{constructor(e,i){super(e),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(e){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(i.schema=e),i.items=i.items.map(r=>be.isNode(r)||be.isPair(r)?r.clone(e):r),this.range&&(i.range=this.range.slice()),i}addIn(e,i){if(Ys(e))this.add(i);else{let[r,...n]=e,a=this.get(r,!0);if(be.isCollection(a))a.addIn(n,i);else if(a===void 0&&this.schema)this.set(r,ra(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[i,...r]=e;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(be.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(e,i){let[r,...n]=e,a=this.get(r,!0);return n.length===0?!i&&be.isScalar(a)?a.value:a:be.isCollection(a)?a.getIn(n,i):void 0}hasAllNullValues(e){return this.items.every(i=>{if(!be.isPair(i))return!1;let r=i.value;return r==null||e&&be.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[i,...r]=e;if(r.length===0)return this.has(i);let n=this.get(i,!0);return be.isCollection(n)?n.hasIn(r):!1}setIn(e,i){let[r,...n]=e;if(n.length===0)this.set(r,i);else{let a=this.get(r,!0);if(be.isCollection(a))a.setIn(n,i);else if(a===void 0&&this.schema)this.set(r,ra(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};rr.Collection=na;rr.collectionFromPath=ra;rr.isEmptyPath=Ys});var ei=w(ar=>{"use strict";var fh=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function aa(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var hh=(t,e,i)=>t.endsWith(`
6
+ `)?aa(i,e):i.includes(`
7
7
  `)?`
8
- `+ta(i,e):(t.endsWith(" ")?"":" ")+i;rr.indentComment=ta;rr.lineComment=sh;rr.stringifyComment=oh});var Gs=w(ei=>{"use strict";var ch="flow",ia="block",nr="quoted";function lh(t,e,i="flow",{indentAtStart:r,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 r=="number"&&(r>n-Math.max(2,a)?l.push(0):d=n-r);let f,p,v=!1,h=-1,m=-1,y=-1;i===ia&&(h=Js(t,h,e.length),h!==-1&&(d=h+c));for(let k;k=t[h+=1];){if(i===nr&&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
- `)i===ia&&(h=Js(t,h,e.length)),d=h+e.length+c,f=void 0;else{if(k===" "&&p&&p!==" "&&p!==`
8
+ `+aa(i,e):(t.endsWith(" ")?"":" ")+i;ar.indentComment=aa;ar.lineComment=hh;ar.stringifyComment=fh});var Qs=w(ti=>{"use strict";var ph="flow",oa="block",or="quoted";function mh(t,e,i="flow",{indentAtStart:r,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 r=="number"&&(r>n-Math.max(2,a)?l.push(0):d=n-r);let f,p,v=!1,h=-1,m=-1,y=-1;i===oa&&(h=Xs(t,h,e.length),h!==-1&&(d=h+c));for(let k;k=t[h+=1];){if(i===or&&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
+ `)i===oa&&(h=Xs(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(i===nr){for(;p===" "||p===" ";)p=k,k=t[h+=1],v=!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 v=!0}p=k}if(v&&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)}`:(i===nr&&u[S]&&(N+=`${t[S]}\\`),N+=`
13
- ${e}${t.slice(S+1,E)}`)}return N}function Js(t,e,i){let r=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+i)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
- `);r=e,n=e+1,a=t[n]}return r}ei.FOLD_BLOCK=ia;ei.FOLD_FLOW=ch;ei.FOLD_QUOTED=nr;ei.foldFlowLines=lh});var ii=w(Us=>{"use strict";var ue=j(),Fe=Gs(),or=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),sr=t=>/^(%|---|\.\.\.)/m.test(t);function uh(t,e,i){if(!e||e<0)return!1;let r=e-i,n=t.length;if(n<=r)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
- `){if(a-o>r)return!0;if(o=a+1,n-o<=r)return!1}return!0}function ti(t,e){let i=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(sr(t)?" ":""),o="",s=0;for(let c=0,l=i[c];l;l=i[++c])if(l===" "&&i[c+1]==="\\"&&i[c+2]==="n"&&(o+=i.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(i[c+1]){case"u":{o+=i.slice(s,c);let u=i.substr(c+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=i.substr(c,6)}c+=5,s=c+1}break;case"n":if(r||i[c+2]==='"'||i.length<n)c+=1;else{for(o+=i.slice(s,c)+`
11
+ `&&S!==" "&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(i===or){for(;p===" "||p===" ";)p=k,k=t[h+=1],v=!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 v=!0}p=k}if(v&&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)}`:(i===or&&u[S]&&(N+=`${t[S]}\\`),N+=`
13
+ ${e}${t.slice(S+1,E)}`)}return N}function Xs(t,e,i){let r=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+i)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
+ `);r=e,n=e+1,a=t[n]}return r}ti.FOLD_BLOCK=oa;ti.FOLD_FLOW=ph;ti.FOLD_QUOTED=or;ti.foldFlowLines=mh});var ri=w(Zs=>{"use strict";var le=j(),Ve=Qs(),cr=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),lr=t=>/^(%|---|\.\.\.)/m.test(t);function vh(t,e,i){if(!e||e<0)return!1;let r=e-i,n=t.length;if(n<=r)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
+ `){if(a-o>r)return!0;if(o=a+1,n-o<=r)return!1}return!0}function ii(t,e){let i=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(lr(t)?" ":""),o="",s=0;for(let c=0,l=i[c];l;l=i[++c])if(l===" "&&i[c+1]==="\\"&&i[c+2]==="n"&&(o+=i.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(i[c+1]){case"u":{o+=i.slice(s,c);let u=i.substr(c+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=i.substr(c,6)}c+=5,s=c+1}break;case"n":if(r||i[c+2]==='"'||i.length<n)c+=1;else{for(o+=i.slice(s,c)+`
16
16
 
17
17
  `;i[c+2]==="\\"&&i[c+3]==="n"&&i[c+4]!=='"';)o+=`
18
- `,c+=2;o+=a,i[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+i.slice(s):i,r?o:Fe.foldFlowLines(o,a,Fe.FOLD_QUOTED,or(e,!1))}function ra(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(t))return ti(t,e);let i=e.indent||(sr(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${i}`)+"'";return e.implicitKey?r:Fe.foldFlowLines(r,i,Fe.FOLD_FLOW,or(e,!1))}function kt(t,e){let{singleQuote:i}=e.options,r;if(i===!1)r=ti;else{let n=t.includes('"'),a=t.includes("'");n&&!a?r=ra:a&&!n?r=ti:r=i?ra:ti}return r(t,e)}var na;try{na=new RegExp(`(^|(?<!
18
+ `,c+=2;o+=a,i[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+i.slice(s):i,r?o:Ve.foldFlowLines(o,a,Ve.FOLD_QUOTED,cr(e,!1))}function sa(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(t))return ii(t,e);let i=e.indent||(lr(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${i}`)+"'";return e.implicitKey?r:Ve.foldFlowLines(r,i,Ve.FOLD_FLOW,cr(e,!1))}function Et(t,e){let{singleQuote:i}=e.options,r;if(i===!1)r=ii;else{let n=t.includes('"'),a=t.includes("'");n&&!a?r=sa:a&&!n?r=ii:r=i?sa:ii}return r(t,e)}var ca;try{ca=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{na=/\n+(?!\n|$)/g}function ar({comment:t,type:e,value:i},r,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(i))return kt(i,r);let l=r.indent||(r.forceBlockIndent||sr(i)?" ":""),u=o==="literal"?!0:o==="folded"||e===ue.Scalar.BLOCK_FOLDED?!1:e===ue.Scalar.BLOCK_LITERAL?!0:!uh(i,c,l.length);if(!i)return u?`|
23
+ |$)`,"g")}catch{ca=/\n+(?!\n|$)/g}function sr({comment:t,type:e,value:i},r,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(i))return Et(i,r);let l=r.indent||(r.forceBlockIndent||lr(i)?" ":""),u=o==="literal"?!0:o==="folded"||e===le.Scalar.BLOCK_FOLDED?!1:e===le.Scalar.BLOCK_LITERAL?!0:!vh(i,c,l.length);if(!i)return u?`|
24
24
  `:`>
25
25
  `;let d,f;for(f=i.length;f>0;--f){let E=i[f-1];if(E!==`
26
26
  `&&E!==" "&&E!==" ")break}let p=i.substring(f),v=p.indexOf(`
27
27
  `);v===-1?d="-":i===p||v!==p.length-1?(d="+",a&&a()):d="",p&&(i=i.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<i.length;++m){let E=i[m];if(E===" ")h=!0;else if(E===`
28
+ `&&(p=p.slice(0,-1)),p=p.replace(ca,`$&${l}`));let h=!1,m,y=-1;for(m=0;m<i.length;++m){let E=i[m];if(E===" ")h=!0;else if(E===`
29
29
  `)y=m;else break}let N=i.substring(0,y<m?y+1:m);N&&(i=i.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=i.replace(/\n+/g,`
30
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),g=!1,x=or(r,!0);o!=="folded"&&e!==ue.Scalar.BLOCK_FOLDED&&(x.onOverflow=()=>{g=!0});let b=Fe.foldFlowLines(`${N}${E}${p}`,l,Fe.FOLD_BLOCK,x);if(!g)return`>${S}
30
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),g=!1,P=cr(r,!0);o!=="folded"&&e!==le.Scalar.BLOCK_FOLDED&&(P.onOverflow=()=>{g=!0});let b=Ve.foldFlowLines(`${N}${E}${p}`,l,Ve.FOLD_BLOCK,P);if(!g)return`>${S}
31
31
  ${l}${b}`}return i=i.replace(/\n+/g,`$&${l}`),`|${S}
32
- ${l}${N}${i}${p}`}function dh(t,e,i,r){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):ar(t,e,i,r);if(!s&&!u&&n!==ue.Scalar.PLAIN&&a.includes(`
35
- `))return ar(t,e,i,r);if(sr(a)){if(c==="")return e.forceBlockIndent=!0,ar(t,e,i,r);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:v}=e.doc.schema;if(v.some(f)||p?.some(f))return kt(a,e)}return s?d:Fe.foldFlowLines(d,c,Fe.FOLD_FLOW,or(e,!1))}function fh(t,e,i,r){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==ue.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=ue.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case ue.Scalar.BLOCK_FOLDED:case ue.Scalar.BLOCK_LITERAL:return n||a?kt(o.value,e):ar(o,e,i,r);case ue.Scalar.QUOTE_DOUBLE:return ti(o.value,e);case ue.Scalar.QUOTE_SINGLE:return ra(o.value,e);case ue.Scalar.PLAIN:return dh(o,e,i,r);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}Us.stringifyString=fh});var ri=w(aa=>{"use strict";var hh=Qi(),Ve=P(),ph=Zt(),mh=ii();function vh(t,e){let i=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),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function gh(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 i,r;if(Ve.isScalar(e)){r=e.value;let n=t.filter(a=>a.identify?.(r));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}i=n.find(a=>a.format===e.format)??n.find(a=>!a.format)}else r=e,i=t.find(n=>n.nodeClass&&r instanceof n.nodeClass);if(!i){let n=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${n} value`)}return i}function wh(t,e,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],a=(Ve.isScalar(t)||Ve.isCollection(t))&&t.anchor;a&&hh.anchorIsValid(a)&&(i.add(a),n.push(`&${a}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(r.directives.tagString(o)),n.join(" ")}function yh(t,e,i,r){if(Ve.isPair(t))return t.toString(e,i,r);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=gh(e.doc.schema.tags,a));let o=wh(a,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,e,i,r):Ve.isScalar(a)?mh.stringifyString(a,e,i,r):a.toString(e,i,r);return o?Ve.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${e.indent}${s}`:s}aa.createStringifyContext=vh;aa.stringify=yh});var Qs=w(Xs=>{"use strict";var Re=P(),Ks=j(),Ys=ri(),ni=Zt();function Nh({key:t,value:e},i,r,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=i,f=Re.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(Re.isCollection(t)||!Re.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&&!i.inFlow||Re.isCollection(t)||(Re.isScalar(t)?t.type===Ks.Scalar.BLOCK_FOLDED||t.type===Ks.Scalar.BLOCK_LITERAL:typeof t=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let v=!1,h=!1,m=Ys.stringify(t,i,()=>v=!0,()=>h=!0);if(!p&&!i.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(i.inFlow){if(a||e==null)return v&&r&&r(),m===""?"?":p?`? ${m}`:m}else if(a&&!d||e==null&&p)return m=`? ${m}`,f&&!v?m+=ni.lineComment(m,i.indent,l(f)):h&&n&&n(),m;v&&(f=null),p?(f&&(m+=ni.lineComment(m,i.indent,l(f))),m=`? ${m}
38
- ${s}:`):(m=`${m}:`,f&&(m+=ni.lineComment(m,i.indent,l(f))));let y,N,k;Re.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))),i.implicitKey=!1,!p&&!f&&Re.isScalar(e)&&(i.indentAtStart=m.length+1),h=!1,!u&&c.length>=2&&!i.inFlow&&!p&&Re.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(i.indent=i.indent.substring(2));let S=!1,E=Ys.stringify(e,i,()=>S=!0,()=>h=!0),g=" ";if(f||y||N){if(g=y?`
39
- `:"",N){let x=l(N);g+=`
40
- ${ni.indentComment(x,i.indent)}`}E===""&&!i.inFlow?g===`
32
+ ${l}${N}${i}${p}`}function gh(t,e,i,r){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):sr(t,e,i,r);if(!s&&!u&&n!==le.Scalar.PLAIN&&a.includes(`
35
+ `))return sr(t,e,i,r);if(lr(a)){if(c==="")return e.forceBlockIndent=!0,sr(t,e,i,r);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:v}=e.doc.schema;if(v.some(f)||p?.some(f))return Et(a,e)}return s?d:Ve.foldFlowLines(d,c,Ve.FOLD_FLOW,cr(e,!1))}function wh(t,e,i,r){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==le.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=le.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case le.Scalar.BLOCK_FOLDED:case le.Scalar.BLOCK_LITERAL:return n||a?Et(o.value,e):sr(o,e,i,r);case le.Scalar.QUOTE_DOUBLE:return ii(o.value,e);case le.Scalar.QUOTE_SINGLE:return sa(o.value,e);case le.Scalar.PLAIN:return gh(o,e,i,r);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}Zs.stringifyString=wh});var ni=w(la=>{"use strict";var yh=er(),qe=x(),Nh=ei(),bh=ri();function kh(t,e){let i=Object.assign({blockQuote:!0,commentString:Nh.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),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function Sh(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 i,r;if(qe.isScalar(e)){r=e.value;let n=t.filter(a=>a.identify?.(r));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}i=n.find(a=>a.format===e.format)??n.find(a=>!a.format)}else r=e,i=t.find(n=>n.nodeClass&&r instanceof n.nodeClass);if(!i){let n=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${n} value`)}return i}function Eh(t,e,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],a=(qe.isScalar(t)||qe.isCollection(t))&&t.anchor;a&&yh.anchorIsValid(a)&&(i.add(a),n.push(`&${a}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(r.directives.tagString(o)),n.join(" ")}function xh(t,e,i,r){if(qe.isPair(t))return t.toString(e,i,r);if(qe.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=qe.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Sh(e.doc.schema.tags,a));let o=Eh(a,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,e,i,r):qe.isScalar(a)?bh.stringifyString(a,e,i,r):a.toString(e,i,r);return o?qe.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${e.indent}${s}`:s}la.createStringifyContext=kh;la.stringify=xh});var rc=w(ic=>{"use strict";var Re=x(),ec=j(),tc=ni(),ai=ei();function Ph({key:t,value:e},i,r,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=i,f=Re.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(Re.isCollection(t)||!Re.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&&!i.inFlow||Re.isCollection(t)||(Re.isScalar(t)?t.type===ec.Scalar.BLOCK_FOLDED||t.type===ec.Scalar.BLOCK_LITERAL:typeof t=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let v=!1,h=!1,m=tc.stringify(t,i,()=>v=!0,()=>h=!0);if(!p&&!i.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(i.inFlow){if(a||e==null)return v&&r&&r(),m===""?"?":p?`? ${m}`:m}else if(a&&!d||e==null&&p)return m=`? ${m}`,f&&!v?m+=ai.lineComment(m,i.indent,l(f)):h&&n&&n(),m;v&&(f=null),p?(f&&(m+=ai.lineComment(m,i.indent,l(f))),m=`? ${m}
38
+ ${s}:`):(m=`${m}:`,f&&(m+=ai.lineComment(m,i.indent,l(f))));let y,N,k;Re.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))),i.implicitKey=!1,!p&&!f&&Re.isScalar(e)&&(i.indentAtStart=m.length+1),h=!1,!u&&c.length>=2&&!i.inFlow&&!p&&Re.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(i.indent=i.indent.substring(2));let S=!1,E=tc.stringify(e,i,()=>S=!0,()=>h=!0),g=" ";if(f||y||N){if(g=y?`
39
+ `:"",N){let P=l(N);g+=`
40
+ ${ai.indentComment(P,i.indent)}`}E===""&&!i.inFlow?g===`
41
41
  `&&k&&(g=`
42
42
 
43
43
  `):g+=`
44
- ${i.indent}`}else if(!p&&Re.isCollection(e)){let x=E[0],b=E.indexOf(`
45
- `),_=b!==-1,K=i.inFlow??e.flow??e.items.length===0;if(_||!K){let wt=!1;if(_&&(x==="&"||x==="!")){let $=E.indexOf(" ");x==="&"&&$!==-1&&$<b&&E[$+1]==="!"&&($=E.indexOf(" ",$+1)),($===-1||b<$)&&(wt=!0)}wt||(g=`
44
+ ${i.indent}`}else if(!p&&Re.isCollection(e)){let P=E[0],b=E.indexOf(`
45
+ `),_=b!==-1,K=i.inFlow??e.flow??e.items.length===0;if(_||!K){let Nt=!1;if(_&&(P==="&"||P==="!")){let $=E.indexOf(" ");P==="&"&&$!==-1&&$<b&&E[$+1]==="!"&&($=E.indexOf(" ",$+1)),($===-1||b<$)&&(Nt=!0)}Nt||(g=`
46
46
  ${i.indent}`)}}else(E===""||E[0]===`
47
- `)&&(g="");return m+=g+E,i.inFlow?S&&r&&r():k&&!S?m+=ni.lineComment(m,i.indent,l(k)):h&&n&&n(),m}Xs.stringifyPair=Nh});var sa=w(oa=>{"use strict";var Zs=Gi("process");function bh(t,...e){t==="debug"&&console.log(...e)}function kh(t,e){(t==="debug"||t==="warn")&&(typeof Zs.emitWarning=="function"?Zs.emitWarning(e):console.warn(e))}oa.debug=bh;oa.warn=kh});var fr=w(dr=>{"use strict";var ur=P(),ec=j(),cr="<<",lr={identify:t=>t===cr||typeof t=="symbol"&&t.description===cr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ec.Scalar(Symbol(cr)),{addToJSMap:tc}),stringify:()=>cr},Sh=(t,e)=>(lr.identify(e)||ur.isScalar(e)&&(!e.type||e.type===ec.Scalar.PLAIN)&&lr.identify(e.value))&&t?.doc.schema.tags.some(i=>i.tag===lr.tag&&i.default);function tc(t,e,i){let r=ic(t,i);if(ur.isSeq(r))for(let n of r.items)ca(t,e,n);else if(Array.isArray(r))for(let n of r)ca(t,e,n);else ca(t,e,r)}function ca(t,e,i){let r=ic(t,i);if(!ur.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.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 ic(t,e){return t&&ur.isAlias(e)?e.resolve(t.doc,t):e}dr.addMergeToJSMap=tc;dr.isMergeKey=Sh;dr.merge=lr});var ua=w(ac=>{"use strict";var Eh=sa(),rc=fr(),Ph=ri(),nc=P(),la=Le();function xh(t,e,{key:i,value:r}){if(nc.isNode(i)&&i.addToJSMap)i.addToJSMap(t,e,r);else if(rc.isMergeKey(t,i))rc.addMergeToJSMap(t,e,r);else{let n=la.toJS(i,"",t);if(e instanceof Map)e.set(n,la.toJS(r,n,t));else if(e instanceof Set)e.add(n);else{let a=Ch(i,n,t),o=la.toJS(r,a,t);a in e?Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[a]=o}}return e}function Ch(t,e,i){if(e===null)return"";if(typeof e!="object")return String(e);if(nc.isNode(t)&&i?.doc){let r=Ph.createStringifyContext(i.doc,{});r.anchors=new Set;for(let a of i.anchors.keys())r.anchors.add(a.anchor);r.inFlow=!0,r.inStringifyKey=!0;let n=t.toString(r);if(!i.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Eh.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return n}return JSON.stringify(e)}ac.addPairToJSMap=xh});var qe=w(da=>{"use strict";var oc=Qt(),Rh=Qs(),Ah=ua(),hr=P();function _h(t,e,i){let r=oc.createNode(t,void 0,i),n=oc.createNode(e,void 0,i);return new pr(r,n)}var pr=class t{constructor(e,i=null){Object.defineProperty(this,hr.NODE_TYPE,{value:hr.PAIR}),this.key=e,this.value=i}clone(e){let{key:i,value:r}=this;return hr.isNode(i)&&(i=i.clone(e)),hr.isNode(r)&&(r=r.clone(e)),new t(i,r)}toJSON(e,i){let r=i?.mapAsMap?new Map:{};return Ah.addPairToJSMap(i,r,this)}toString(e,i,r){return e?.doc?Rh.stringifyPair(this,e,i,r):JSON.stringify(this)}};da.Pair=pr;da.createPair=_h});var fa=w(cc=>{"use strict";var st=P(),sc=ri(),mr=Zt();function Th(t,e,i){return(e.inFlow??t.flow?jh:Ih)(t,e,i)}function Ih({comment:t,items:e},i,{blockItemPrefix:r,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=i,u=Object.assign({},i,{indent:a,type:null}),d=!1,f=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(st.isNode(h))!d&&h.spaceBefore&&f.push(""),vr(i,f,h.commentBefore,d),h.comment&&(m=h.comment);else if(st.isPair(h)){let N=st.isNode(h.key)?h.key:null;N&&(!d&&N.spaceBefore&&f.push(""),vr(i,f,N.commentBefore,d))}d=!1;let y=sc.stringify(h,u,()=>m=null,()=>d=!0);m&&(y+=mr.lineComment(y,a,l(m))),d&&m&&(d=!1),f.push(r+y)}let p;if(f.length===0)p=n.start+n.end;else{p=f[0];for(let v=1;v<f.length;++v){let h=f[v];p+=h?`
47
+ `)&&(g="");return m+=g+E,i.inFlow?S&&r&&r():k&&!S?m+=ai.lineComment(m,i.indent,l(k)):h&&n&&n(),m}ic.stringifyPair=Ph});var da=w(ua=>{"use strict";var nc=Ki("process");function Ch(t,...e){t==="debug"&&console.log(...e)}function Rh(t,e){(t==="debug"||t==="warn")&&(typeof nc.emitWarning=="function"?nc.emitWarning(e):console.warn(e))}ua.debug=Ch;ua.warn=Rh});var pr=w(hr=>{"use strict";var fr=x(),ac=j(),ur="<<",dr={identify:t=>t===ur||typeof t=="symbol"&&t.description===ur,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ac.Scalar(Symbol(ur)),{addToJSMap:oc}),stringify:()=>ur},Ah=(t,e)=>(dr.identify(e)||fr.isScalar(e)&&(!e.type||e.type===ac.Scalar.PLAIN)&&dr.identify(e.value))&&t?.doc.schema.tags.some(i=>i.tag===dr.tag&&i.default);function oc(t,e,i){let r=sc(t,i);if(fr.isSeq(r))for(let n of r.items)fa(t,e,n);else if(Array.isArray(r))for(let n of r)fa(t,e,n);else fa(t,e,r)}function fa(t,e,i){let r=sc(t,i);if(!fr.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.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 sc(t,e){return t&&fr.isAlias(e)?e.resolve(t.doc,t):e}hr.addMergeToJSMap=oc;hr.isMergeKey=Ah;hr.merge=dr});var pa=w(uc=>{"use strict";var _h=da(),cc=pr(),Th=ni(),lc=x(),ha=Me();function Ih(t,e,{key:i,value:r}){if(lc.isNode(i)&&i.addToJSMap)i.addToJSMap(t,e,r);else if(cc.isMergeKey(t,i))cc.addMergeToJSMap(t,e,r);else{let n=ha.toJS(i,"",t);if(e instanceof Map)e.set(n,ha.toJS(r,n,t));else if(e instanceof Set)e.add(n);else{let a=jh(i,n,t),o=ha.toJS(r,a,t);a in e?Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[a]=o}}return e}function jh(t,e,i){if(e===null)return"";if(typeof e!="object")return String(e);if(lc.isNode(t)&&i?.doc){let r=Th.createStringifyContext(i.doc,{});r.anchors=new Set;for(let a of i.anchors.keys())r.anchors.add(a.anchor);r.inFlow=!0,r.inStringifyKey=!0;let n=t.toString(r);if(!i.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),_h.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return n}return JSON.stringify(e)}uc.addPairToJSMap=Ih});var We=w(ma=>{"use strict";var dc=Zt(),$h=rc(),Oh=pa(),mr=x();function Hh(t,e,i){let r=dc.createNode(t,void 0,i),n=dc.createNode(e,void 0,i);return new vr(r,n)}var vr=class t{constructor(e,i=null){Object.defineProperty(this,mr.NODE_TYPE,{value:mr.PAIR}),this.key=e,this.value=i}clone(e){let{key:i,value:r}=this;return mr.isNode(i)&&(i=i.clone(e)),mr.isNode(r)&&(r=r.clone(e)),new t(i,r)}toJSON(e,i){let r=i?.mapAsMap?new Map:{};return Oh.addPairToJSMap(i,r,this)}toString(e,i,r){return e?.doc?$h.stringifyPair(this,e,i,r):JSON.stringify(this)}};ma.Pair=vr;ma.createPair=Hh});var va=w(hc=>{"use strict";var lt=x(),fc=ni(),gr=ei();function Dh(t,e,i){return(e.inFlow??t.flow?Lh:Bh)(t,e,i)}function Bh({comment:t,items:e},i,{blockItemPrefix:r,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=i,u=Object.assign({},i,{indent:a,type:null}),d=!1,f=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(lt.isNode(h))!d&&h.spaceBefore&&f.push(""),wr(i,f,h.commentBefore,d),h.comment&&(m=h.comment);else if(lt.isPair(h)){let N=lt.isNode(h.key)?h.key:null;N&&(!d&&N.spaceBefore&&f.push(""),wr(i,f,N.commentBefore,d))}d=!1;let y=fc.stringify(h,u,()=>m=null,()=>d=!0);m&&(y+=gr.lineComment(y,a,l(m))),d&&m&&(d=!1),f.push(r+y)}let p;if(f.length===0)p=n.start+n.end;else{p=f[0];for(let v=1;v<f.length;++v){let h=f[v];p+=h?`
48
48
  ${c}${h}`:`
49
49
  `}}return t?(p+=`
50
- `+mr.indentComment(l(t),c),s&&s()):d&&o&&o(),p}function jh({items:t},e,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;r+=a;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(st.isNode(h))h.spaceBefore&&d.push(""),vr(e,d,h.commentBefore,!1),h.comment&&(m=h.comment);else if(st.isPair(h)){let N=st.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&d.push(""),vr(e,d,N.commentBefore,!1),N.comment&&(l=!0));let k=st.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=sc.stringify(h,c,()=>m=null);l||(l=d.length>u||y.includes(`
51
- `)),v<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+=mr.lineComment(y,r,s(m))),d.push(y),u=d.length}let{start:f,end:p}=i;if(d.length===0)return f+p;if(!l){let v=d.reduce((h,m)=>h+m.length+2,2);l=e.options.lineWidth>0&&v>e.options.lineWidth}if(l){let v=f;for(let h of d)v+=h?`
50
+ `+gr.indentComment(l(t),c),s&&s()):d&&o&&o(),p}function Lh({items:t},e,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;r+=a;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(lt.isNode(h))h.spaceBefore&&d.push(""),wr(e,d,h.commentBefore,!1),h.comment&&(m=h.comment);else if(lt.isPair(h)){let N=lt.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&d.push(""),wr(e,d,N.commentBefore,!1),N.comment&&(l=!0));let k=lt.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=fc.stringify(h,c,()=>m=null);l||(l=d.length>u||y.includes(`
51
+ `)),v<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+=gr.lineComment(y,r,s(m))),d.push(y),u=d.length}let{start:f,end:p}=i;if(d.length===0)return f+p;if(!l){let v=d.reduce((h,m)=>h+m.length+2,2);l=e.options.lineWidth>0&&v>e.options.lineWidth}if(l){let v=f;for(let h of d)v+=h?`
52
52
  ${a}${n}${h}`:`
53
53
  `;return`${v}
54
- ${n}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function vr({indent:t,options:{commentString:e}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let a=mr.indentComment(e(r),t);i.push(a.trimStart())}}cc.stringifyCollection=Th});var ze=w(pa=>{"use strict";var $h=fa(),Oh=ua(),Hh=ir(),We=P(),gr=qe(),Dh=j();function ai(t,e){let i=We.isScalar(e)?e.value:e;for(let r of t)if(We.isPair(r)&&(r.key===e||r.key===i||We.isScalar(r.key)&&r.key.value===i))return r}var ha=class extends Hh.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(We.MAP,e),this.items=[]}static from(e,i,r){let{keepUndefined:n,replacer:a}=r,o=new this(e),s=(c,l)=>{if(typeof a=="function")l=a.call(i,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(gr.createPair(c,l,r))};if(i instanceof Map)for(let[c,l]of i)s(c,l);else if(i&&typeof i=="object")for(let c of Object.keys(i))s(c,i[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,i){let r;We.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new gr.Pair(e,e?.value):r=new gr.Pair(e.key,e.value);let n=ai(this.items,r.key),a=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);We.isScalar(n.value)&&Dh.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(a){let o=this.items.findIndex(s=>a(r,s)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let i=ai(this.items,e);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(e,i){let n=ai(this.items,e)?.value;return(!i&&We.isScalar(n)?n.value:n)??void 0}has(e){return!!ai(this.items,e)}set(e,i){this.add(new gr.Pair(e,i),!0)}toJSON(e,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let a of this.items)Oh.addPairToJSMap(i,n,a);return n}toString(e,i,r){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})),$h.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:i})}};pa.YAMLMap=ha;pa.findPair=ai});var St=w(uc=>{"use strict";var Bh=P(),lc=ze(),Lh={collection:"map",default:!0,nodeClass:lc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Bh.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,i)=>lc.YAMLMap.from(t,e,i)};uc.map=Lh});var Je=w(dc=>{"use strict";var Mh=Qt(),Fh=fa(),Vh=ir(),yr=P(),qh=j(),Wh=Le(),ma=class extends Vh.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(yr.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let i=wr(e);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(e,i){let r=wr(e);if(typeof r!="number")return;let n=this.items[r];return!i&&yr.isScalar(n)?n.value:n}has(e){let i=wr(e);return typeof i=="number"&&i<this.items.length}set(e,i){let r=wr(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[r];yr.isScalar(n)&&qh.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(e,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let a of this.items)r.push(Wh.toJS(a,String(n++),i));return r}toString(e,i,r){return e?Fh.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(e,i,r){let{replacer:n}=r,a=new this(e);if(i&&Symbol.iterator in Object(i)){let o=0;for(let s of i){if(typeof n=="function"){let c=i instanceof Set?s:String(o++);s=n.call(i,c,s)}a.items.push(Mh.createNode(s,void 0,r))}}return a}};function wr(t){let e=yr.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}dc.YAMLSeq=ma});var Et=w(hc=>{"use strict";var zh=P(),fc=Je(),Jh={collection:"seq",default:!0,nodeClass:fc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return zh.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,i)=>fc.YAMLSeq.from(t,e,i)};hc.seq=Jh});var oi=w(pc=>{"use strict";var Gh=ii(),Uh={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,i,r){return e=Object.assign({actualString:!0},e),Gh.stringifyString(t,e,i,r)}};pc.string=Uh});var Nr=w(gc=>{"use strict";var mc=j(),vc={identify:t=>t==null,createNode:()=>new mc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new mc.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&vc.test.test(t)?t:e.options.nullStr};gc.nullTag=vc});var va=w(yc=>{"use strict";var Kh=j(),wc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Kh.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},i){if(t&&wc.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?i.options.trueStr:i.options.falseStr}};yc.boolTag=wc});var Pt=w(Nc=>{"use strict";function Yh({format:t,minFractionDigits:e,tag:i,value:r}){if(typeof r=="bigint")return String(r);let n=typeof r=="number"?r:Number(r);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!i||i==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=e-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Nc.stringifyNumber=Yh});var wa=w(br=>{"use strict";var Xh=j(),ga=Pt(),Qh={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},Zh={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)}},ep={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 Xh.Scalar(parseFloat(t)),i=t.indexOf(".");return i!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-i-1),e},stringify:ga.stringifyNumber};br.float=ep;br.floatExp=Zh;br.floatNaN=Qh});var Na=w(Sr=>{"use strict";var bc=Pt(),kr=t=>typeof t=="bigint"||Number.isInteger(t),ya=(t,e,i,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),i);function kc(t,e,i){let{value:r}=t;return kr(r)&&r>=0?i+r.toString(e):bc.stringifyNumber(t)}var tp={identify:t=>kr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,i)=>ya(t,2,8,i),stringify:t=>kc(t,8,"0o")},ip={identify:kr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,i)=>ya(t,0,10,i),stringify:bc.stringifyNumber},rp={identify:t=>kr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,i)=>ya(t,2,16,i),stringify:t=>kc(t,16,"0x")};Sr.int=ip;Sr.intHex=rp;Sr.intOct=tp});var Ec=w(Sc=>{"use strict";var np=St(),ap=Nr(),op=Et(),sp=oi(),cp=va(),ba=wa(),ka=Na(),lp=[np.map,op.seq,sp.string,ap.nullTag,cp.boolTag,ka.intOct,ka.int,ka.intHex,ba.floatNaN,ba.floatExp,ba.float];Sc.schema=lp});var Cc=w(xc=>{"use strict";var up=j(),dp=St(),fp=Et();function Pc(t){return typeof t=="bigint"||Number.isInteger(t)}var Er=({value:t})=>JSON.stringify(t),hp=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Er},{identify:t=>t==null,createNode:()=>new up.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Er},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Er},{identify:Pc,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:i})=>i?BigInt(t):parseInt(t,10),stringify:({value:t})=>Pc(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:Er}],pp={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},mp=[dp.map,fp.seq].concat(hp,pp);xc.schema=mp});var Ea=w(Rc=>{"use strict";var si=Gi("buffer"),Sa=j(),vp=ii(),gp={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof si.Buffer=="function")return si.Buffer.from(t,"base64");if(typeof atob=="function"){let i=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(i.length);for(let n=0;n<i.length;++n)r[n]=i.charCodeAt(n);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:i},r,n,a){if(!i)return"";let o=i,s;if(typeof si.Buffer=="function")s=o instanceof si.Buffer?o.toString("base64"):si.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(r.options.lineWidth-r.indent.length,r.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 vp.stringifyString({comment:t,type:e,value:s},r,n,a)}};Rc.binary=gp});var Cr=w(xr=>{"use strict";var Pr=P(),Pa=qe(),wp=j(),yp=Je();function Ac(t,e){if(Pr.isSeq(t))for(let i=0;i<t.items.length;++i){let r=t.items[i];if(!Pr.isPair(r)){if(Pr.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let n=r.items[0]||new Pa.Pair(new wp.Scalar(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
54
+ ${n}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function wr({indent:t,options:{commentString:e}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let a=gr.indentComment(e(r),t);i.push(a.trimStart())}}hc.stringifyCollection=Dh});var Je=w(wa=>{"use strict";var Mh=va(),Fh=pa(),Vh=nr(),ze=x(),yr=We(),qh=j();function oi(t,e){let i=ze.isScalar(e)?e.value:e;for(let r of t)if(ze.isPair(r)&&(r.key===e||r.key===i||ze.isScalar(r.key)&&r.key.value===i))return r}var ga=class extends Vh.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(ze.MAP,e),this.items=[]}static from(e,i,r){let{keepUndefined:n,replacer:a}=r,o=new this(e),s=(c,l)=>{if(typeof a=="function")l=a.call(i,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(yr.createPair(c,l,r))};if(i instanceof Map)for(let[c,l]of i)s(c,l);else if(i&&typeof i=="object")for(let c of Object.keys(i))s(c,i[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,i){let r;ze.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new yr.Pair(e,e?.value):r=new yr.Pair(e.key,e.value);let n=oi(this.items,r.key),a=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);ze.isScalar(n.value)&&qh.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(a){let o=this.items.findIndex(s=>a(r,s)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let i=oi(this.items,e);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(e,i){let n=oi(this.items,e)?.value;return(!i&&ze.isScalar(n)?n.value:n)??void 0}has(e){return!!oi(this.items,e)}set(e,i){this.add(new yr.Pair(e,i),!0)}toJSON(e,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let a of this.items)Fh.addPairToJSMap(i,n,a);return n}toString(e,i,r){if(!e)return JSON.stringify(this);for(let n of this.items)if(!ze.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})),Mh.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:i})}};wa.YAMLMap=ga;wa.findPair=oi});var xt=w(mc=>{"use strict";var Wh=x(),pc=Je(),zh={collection:"map",default:!0,nodeClass:pc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Wh.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,i)=>pc.YAMLMap.from(t,e,i)};mc.map=zh});var Ge=w(vc=>{"use strict";var Jh=Zt(),Gh=va(),Uh=nr(),br=x(),Kh=j(),Yh=Me(),ya=class extends Uh.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(br.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let i=Nr(e);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(e,i){let r=Nr(e);if(typeof r!="number")return;let n=this.items[r];return!i&&br.isScalar(n)?n.value:n}has(e){let i=Nr(e);return typeof i=="number"&&i<this.items.length}set(e,i){let r=Nr(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[r];br.isScalar(n)&&Kh.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(e,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let a of this.items)r.push(Yh.toJS(a,String(n++),i));return r}toString(e,i,r){return e?Gh.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(e,i,r){let{replacer:n}=r,a=new this(e);if(i&&Symbol.iterator in Object(i)){let o=0;for(let s of i){if(typeof n=="function"){let c=i instanceof Set?s:String(o++);s=n.call(i,c,s)}a.items.push(Jh.createNode(s,void 0,r))}}return a}};function Nr(t){let e=br.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}vc.YAMLSeq=ya});var Pt=w(wc=>{"use strict";var Xh=x(),gc=Ge(),Qh={collection:"seq",default:!0,nodeClass:gc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Xh.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,i)=>gc.YAMLSeq.from(t,e,i)};wc.seq=Qh});var si=w(yc=>{"use strict";var Zh=ri(),ep={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,i,r){return e=Object.assign({actualString:!0},e),Zh.stringifyString(t,e,i,r)}};yc.string=ep});var kr=w(kc=>{"use strict";var Nc=j(),bc={identify:t=>t==null,createNode:()=>new Nc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Nc.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&bc.test.test(t)?t:e.options.nullStr};kc.nullTag=bc});var Na=w(Ec=>{"use strict";var tp=j(),Sc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new tp.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},i){if(t&&Sc.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?i.options.trueStr:i.options.falseStr}};Ec.boolTag=Sc});var Ct=w(xc=>{"use strict";function ip({format:t,minFractionDigits:e,tag:i,value:r}){if(typeof r=="bigint")return String(r);let n=typeof r=="number"?r:Number(r);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!i||i==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=e-(a.length-o-1);for(;s-- >0;)a+="0"}return a}xc.stringifyNumber=ip});var ka=w(Sr=>{"use strict";var rp=j(),ba=Ct(),np={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:ba.stringifyNumber},ap={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():ba.stringifyNumber(t)}},op={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 rp.Scalar(parseFloat(t)),i=t.indexOf(".");return i!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-i-1),e},stringify:ba.stringifyNumber};Sr.float=op;Sr.floatExp=ap;Sr.floatNaN=np});var Ea=w(xr=>{"use strict";var Pc=Ct(),Er=t=>typeof t=="bigint"||Number.isInteger(t),Sa=(t,e,i,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),i);function Cc(t,e,i){let{value:r}=t;return Er(r)&&r>=0?i+r.toString(e):Pc.stringifyNumber(t)}var sp={identify:t=>Er(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,i)=>Sa(t,2,8,i),stringify:t=>Cc(t,8,"0o")},cp={identify:Er,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,i)=>Sa(t,0,10,i),stringify:Pc.stringifyNumber},lp={identify:t=>Er(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,i)=>Sa(t,2,16,i),stringify:t=>Cc(t,16,"0x")};xr.int=cp;xr.intHex=lp;xr.intOct=sp});var Ac=w(Rc=>{"use strict";var up=xt(),dp=kr(),fp=Pt(),hp=si(),pp=Na(),xa=ka(),Pa=Ea(),mp=[up.map,fp.seq,hp.string,dp.nullTag,pp.boolTag,Pa.intOct,Pa.int,Pa.intHex,xa.floatNaN,xa.floatExp,xa.float];Rc.schema=mp});var Ic=w(Tc=>{"use strict";var vp=j(),gp=xt(),wp=Pt();function _c(t){return typeof t=="bigint"||Number.isInteger(t)}var Pr=({value:t})=>JSON.stringify(t),yp=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Pr},{identify:t=>t==null,createNode:()=>new vp.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Pr},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Pr},{identify:_c,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:i})=>i?BigInt(t):parseInt(t,10),stringify:({value:t})=>_c(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:Pr}],Np={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},bp=[gp.map,wp.seq].concat(yp,Np);Tc.schema=bp});var Ra=w(jc=>{"use strict";var ci=Ki("buffer"),Ca=j(),kp=ri(),Sp={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof ci.Buffer=="function")return ci.Buffer.from(t,"base64");if(typeof atob=="function"){let i=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(i.length);for(let n=0;n<i.length;++n)r[n]=i.charCodeAt(n);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:i},r,n,a){if(!i)return"";let o=i,s;if(typeof ci.Buffer=="function")s=o instanceof ci.Buffer?o.toString("base64"):ci.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=Ca.Scalar.BLOCK_LITERAL),e!==Ca.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(s.length/c),u=new Array(l);for(let d=0,f=0;d<l;++d,f+=c)u[d]=s.substr(f,c);s=u.join(e===Ca.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return kp.stringifyString({comment:t,type:e,value:s},r,n,a)}};jc.binary=Sp});var Ar=w(Rr=>{"use strict";var Cr=x(),Aa=We(),Ep=j(),xp=Ge();function $c(t,e){if(Cr.isSeq(t))for(let i=0;i<t.items.length;++i){let r=t.items[i];if(!Cr.isPair(r)){if(Cr.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let n=r.items[0]||new Aa.Pair(new Ep.Scalar(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
56
56
  ${n.key.commentBefore}`:r.commentBefore),r.comment){let a=n.value??n.key;a.comment=a.comment?`${r.comment}
57
- ${a.comment}`:r.comment}r=n}t.items[i]=Pr.isPair(r)?r:new Pa.Pair(r)}}else e("Expected a sequence for this tag");return t}function _c(t,e,i){let{replacer:r}=i,n=new yp.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 r=="function"&&(o=r.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(Pa.createPair(s,c,i))}return n}var Np={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ac,createNode:_c};xr.createPairs=_c;xr.pairs=Np;xr.resolvePairs=Ac});var Ra=w(Ca=>{"use strict";var Tc=P(),xa=Le(),ci=ze(),bp=Je(),Ic=Cr(),ct=class t extends bp.YAMLSeq{constructor(){super(),this.add=ci.YAMLMap.prototype.add.bind(this),this.delete=ci.YAMLMap.prototype.delete.bind(this),this.get=ci.YAMLMap.prototype.get.bind(this),this.has=ci.YAMLMap.prototype.has.bind(this),this.set=ci.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,i){if(!i)return super.toJSON(e);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let a,o;if(Tc.isPair(n)?(a=xa.toJS(n.key,"",i),o=xa.toJS(n.value,a,i)):a=xa.toJS(n,"",i),r.has(a))throw new Error("Ordered maps must not include duplicate keys");r.set(a,o)}return r}static from(e,i,r){let n=Ic.createPairs(e,i,r),a=new this;return a.items=n.items,a}};ct.tag="tag:yaml.org,2002:omap";var kp={collection:"seq",identify:t=>t instanceof Map,nodeClass:ct,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let i=Ic.resolvePairs(t,e),r=[];for(let{key:n}of i.items)Tc.isScalar(n)&&(r.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new ct,i)},createNode:(t,e,i)=>ct.from(t,e,i)};Ca.YAMLOMap=ct;Ca.omap=kp});var Dc=w(Aa=>{"use strict";var jc=j();function $c({value:t,source:e},i){return e&&(t?Oc:Hc).test.test(e)?e:t?i.options.trueStr:i.options.falseStr}var Oc={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:$c},Hc={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new jc.Scalar(!1),stringify:$c};Aa.falseTag=Hc;Aa.trueTag=Oc});var Bc=w(Rr=>{"use strict";var Sp=j(),_a=Pt(),Ep={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},Pp={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)}},xp={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 Sp.Scalar(parseFloat(t.replace(/_/g,""))),i=t.indexOf(".");if(i!==-1){let r=t.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:_a.stringifyNumber};Rr.float=xp;Rr.floatExp=Pp;Rr.floatNaN=Ep});var Mc=w(ui=>{"use strict";var Lc=Pt(),li=t=>typeof t=="bigint"||Number.isInteger(t);function Ar(t,e,i,{intAsBigInt:r}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(i){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,i);return n==="-"?-1*a:a}function Ta(t,e,i){let{value:r}=t;if(li(r)){let n=r.toString(e);return r<0?"-"+i+n.substr(1):i+n}return Lc.stringifyNumber(t)}var Cp={identify:li,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,i)=>Ar(t,2,2,i),stringify:t=>Ta(t,2,"0b")},Rp={identify:li,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,i)=>Ar(t,1,8,i),stringify:t=>Ta(t,8,"0")},Ap={identify:li,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,i)=>Ar(t,0,10,i),stringify:Lc.stringifyNumber},_p={identify:li,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,i)=>Ar(t,2,16,i),stringify:t=>Ta(t,16,"0x")};ui.int=Ap;ui.intBin=Cp;ui.intHex=_p;ui.intOct=Rp});var ja=w(Ia=>{"use strict";var Ir=P(),_r=qe(),Tr=ze(),lt=class t extends Tr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let i;Ir.isPair(e)?i=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?i=new _r.Pair(e.key,null):i=new _r.Pair(e,null),Tr.findPair(this.items,i.key)||this.items.push(i)}get(e,i){let r=Tr.findPair(this.items,e);return!i&&Ir.isPair(r)?Ir.isScalar(r.key)?r.key.value:r.key:r}set(e,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=Tr.findPair(this.items,e);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new _r.Pair(e))}toJSON(e,i){return super.toJSON(e,i,Set)}toString(e,i,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(e,i,r){let{replacer:n}=r,a=new this(e);if(i&&Symbol.iterator in Object(i))for(let o of i)typeof n=="function"&&(o=n.call(i,o,o)),a.items.push(_r.createPair(o,null,r));return a}};lt.tag="tag:yaml.org,2002:set";var Tp={collection:"map",identify:t=>t instanceof Set,nodeClass:lt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,i)=>lt.from(t,e,i),resolve(t,e){if(Ir.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new lt,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Ia.YAMLSet=lt;Ia.set=Tp});var Oa=w(jr=>{"use strict";var Ip=Pt();function $a(t,e){let i=t[0],r=i==="-"||i==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=r.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return i==="-"?n(-1)*a:a}function Fc(t){let{value:e}=t,i=o=>o;if(typeof e=="bigint")i=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Ip.stringifyNumber(t);let r="";e<0&&(r="-",e*=i(-1));let n=i(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))),r+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:i})=>$a(t,i),stringify:Fc},$p={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:Fc},Vc={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(Vc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-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$/,"")??""};jr.floatTime=$p;jr.intTime=jp;jr.timestamp=Vc});var zc=w(Wc=>{"use strict";var Op=St(),Hp=Nr(),Dp=Et(),Bp=oi(),Lp=Ea(),qc=Dc(),Ha=Bc(),$r=Mc(),Mp=fr(),Fp=Ra(),Vp=Cr(),qp=ja(),Da=Oa(),Wp=[Op.map,Dp.seq,Bp.string,Hp.nullTag,qc.trueTag,qc.falseTag,$r.intBin,$r.intOct,$r.int,$r.intHex,Ha.floatNaN,Ha.floatExp,Ha.float,Lp.binary,Mp.merge,Fp.omap,Vp.pairs,qp.set,Da.intTime,Da.floatTime,Da.timestamp];Wc.schema=Wp});var tl=w(Ma=>{"use strict";var Kc=St(),zp=Nr(),Yc=Et(),Jp=oi(),Gp=va(),Ba=wa(),La=Na(),Up=Ec(),Kp=Cc(),Xc=Ea(),di=fr(),Qc=Ra(),Zc=Cr(),Jc=zc(),el=ja(),Or=Oa(),Gc=new Map([["core",Up.schema],["failsafe",[Kc.map,Yc.seq,Jp.string]],["json",Kp.schema],["yaml11",Jc.schema],["yaml-1.1",Jc.schema]]),Uc={binary:Xc.binary,bool:Gp.boolTag,float:Ba.float,floatExp:Ba.floatExp,floatNaN:Ba.floatNaN,floatTime:Or.floatTime,int:La.int,intHex:La.intHex,intOct:La.intOct,intTime:Or.intTime,map:Kc.map,merge:di.merge,null:zp.nullTag,omap:Qc.omap,pairs:Zc.pairs,seq:Yc.seq,set:el.set,timestamp:Or.timestamp},Yp={"tag:yaml.org,2002:binary":Xc.binary,"tag:yaml.org,2002:merge":di.merge,"tag:yaml.org,2002:omap":Qc.omap,"tag:yaml.org,2002:pairs":Zc.pairs,"tag:yaml.org,2002:set":el.set,"tag:yaml.org,2002:timestamp":Or.timestamp};function Xp(t,e,i){let r=Gc.get(e);if(r&&!t)return i&&!r.includes(di.merge)?r.concat(di.merge):r.slice();let n=r;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Gc.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 i&&(n=n.concat(di.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Uc[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Uc).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=Yp;Ma.getTags=Xp});var qa=w(il=>{"use strict";var Fa=P(),Qp=St(),Zp=Et(),em=oi(),Hr=tl(),tm=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Va=class t{constructor({compat:e,customTags:i,merge:r,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Hr.getTags(e,"compat"):e?Hr.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Hr.coreKnownTags:{},this.tags=Hr.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,Fa.MAP,{value:Qp.map}),Object.defineProperty(this,Fa.SCALAR,{value:em.string}),Object.defineProperty(this,Fa.SEQ,{value:Zp.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?tm:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};il.Schema=Va});var nl=w(rl=>{"use strict";var im=P(),Wa=ri(),fi=Zt();function rm(t,e){let i=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(i.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&i.push("---");let n=Wa.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){i.length!==1&&i.unshift("");let c=a(t.commentBefore);i.unshift(fi.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(im.isNode(t.contents)){if(t.contents.spaceBefore&&r&&i.push(""),t.contents.commentBefore){let u=a(t.contents.commentBefore);i.push(fi.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+=fi.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(Wa.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
- `)?(i.push("..."),i.push(fi.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&i[i.length-1]!==""&&i.push(""),i.push(fi.indentComment(a(c),"")))}return i.join(`
57
+ ${a.comment}`:r.comment}r=n}t.items[i]=Cr.isPair(r)?r:new Aa.Pair(r)}}else e("Expected a sequence for this tag");return t}function Oc(t,e,i){let{replacer:r}=i,n=new xp.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 r=="function"&&(o=r.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(Aa.createPair(s,c,i))}return n}var Pp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:$c,createNode:Oc};Rr.createPairs=Oc;Rr.pairs=Pp;Rr.resolvePairs=$c});var Ia=w(Ta=>{"use strict";var Hc=x(),_a=Me(),li=Je(),Cp=Ge(),Dc=Ar(),ut=class t extends Cp.YAMLSeq{constructor(){super(),this.add=li.YAMLMap.prototype.add.bind(this),this.delete=li.YAMLMap.prototype.delete.bind(this),this.get=li.YAMLMap.prototype.get.bind(this),this.has=li.YAMLMap.prototype.has.bind(this),this.set=li.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,i){if(!i)return super.toJSON(e);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let a,o;if(Hc.isPair(n)?(a=_a.toJS(n.key,"",i),o=_a.toJS(n.value,a,i)):a=_a.toJS(n,"",i),r.has(a))throw new Error("Ordered maps must not include duplicate keys");r.set(a,o)}return r}static from(e,i,r){let n=Dc.createPairs(e,i,r),a=new this;return a.items=n.items,a}};ut.tag="tag:yaml.org,2002:omap";var Rp={collection:"seq",identify:t=>t instanceof Map,nodeClass:ut,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let i=Dc.resolvePairs(t,e),r=[];for(let{key:n}of i.items)Hc.isScalar(n)&&(r.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new ut,i)},createNode:(t,e,i)=>ut.from(t,e,i)};Ta.YAMLOMap=ut;Ta.omap=Rp});var Vc=w(ja=>{"use strict";var Bc=j();function Lc({value:t,source:e},i){return e&&(t?Mc:Fc).test.test(e)?e:t?i.options.trueStr:i.options.falseStr}var Mc={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 Bc.Scalar(!0),stringify:Lc},Fc={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 Bc.Scalar(!1),stringify:Lc};ja.falseTag=Fc;ja.trueTag=Mc});var qc=w(_r=>{"use strict";var Ap=j(),$a=Ct(),_p={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},Tp={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)}},Ip={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 Ap.Scalar(parseFloat(t.replace(/_/g,""))),i=t.indexOf(".");if(i!==-1){let r=t.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:$a.stringifyNumber};_r.float=Ip;_r.floatExp=Tp;_r.floatNaN=_p});var zc=w(di=>{"use strict";var Wc=Ct(),ui=t=>typeof t=="bigint"||Number.isInteger(t);function Tr(t,e,i,{intAsBigInt:r}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(i){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,i);return n==="-"?-1*a:a}function Oa(t,e,i){let{value:r}=t;if(ui(r)){let n=r.toString(e);return r<0?"-"+i+n.substr(1):i+n}return Wc.stringifyNumber(t)}var jp={identify:ui,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,i)=>Tr(t,2,2,i),stringify:t=>Oa(t,2,"0b")},$p={identify:ui,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,i)=>Tr(t,1,8,i),stringify:t=>Oa(t,8,"0")},Op={identify:ui,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,i)=>Tr(t,0,10,i),stringify:Wc.stringifyNumber},Hp={identify:ui,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,i)=>Tr(t,2,16,i),stringify:t=>Oa(t,16,"0x")};di.int=Op;di.intBin=jp;di.intHex=Hp;di.intOct=$p});var Da=w(Ha=>{"use strict";var $r=x(),Ir=We(),jr=Je(),dt=class t extends jr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let i;$r.isPair(e)?i=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?i=new Ir.Pair(e.key,null):i=new Ir.Pair(e,null),jr.findPair(this.items,i.key)||this.items.push(i)}get(e,i){let r=jr.findPair(this.items,e);return!i&&$r.isPair(r)?$r.isScalar(r.key)?r.key.value:r.key:r}set(e,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=jr.findPair(this.items,e);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new Ir.Pair(e))}toJSON(e,i){return super.toJSON(e,i,Set)}toString(e,i,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(e,i,r){let{replacer:n}=r,a=new this(e);if(i&&Symbol.iterator in Object(i))for(let o of i)typeof n=="function"&&(o=n.call(i,o,o)),a.items.push(Ir.createPair(o,null,r));return a}};dt.tag="tag:yaml.org,2002:set";var Dp={collection:"map",identify:t=>t instanceof Set,nodeClass:dt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,i)=>dt.from(t,e,i),resolve(t,e){if($r.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new dt,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Ha.YAMLSet=dt;Ha.set=Dp});var La=w(Or=>{"use strict";var Bp=Ct();function Ba(t,e){let i=t[0],r=i==="-"||i==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=r.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return i==="-"?n(-1)*a:a}function Jc(t){let{value:e}=t,i=o=>o;if(typeof e=="bigint")i=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Bp.stringifyNumber(t);let r="";e<0&&(r="-",e*=i(-1));let n=i(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))),r+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Lp={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:i})=>Ba(t,i),stringify:Jc},Mp={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:Jc},Gc={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(Gc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-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$/,"")??""};Or.floatTime=Mp;Or.intTime=Lp;Or.timestamp=Gc});var Yc=w(Kc=>{"use strict";var Fp=xt(),Vp=kr(),qp=Pt(),Wp=si(),zp=Ra(),Uc=Vc(),Ma=qc(),Hr=zc(),Jp=pr(),Gp=Ia(),Up=Ar(),Kp=Da(),Fa=La(),Yp=[Fp.map,qp.seq,Wp.string,Vp.nullTag,Uc.trueTag,Uc.falseTag,Hr.intBin,Hr.intOct,Hr.int,Hr.intHex,Ma.floatNaN,Ma.floatExp,Ma.float,zp.binary,Jp.merge,Gp.omap,Up.pairs,Kp.set,Fa.intTime,Fa.floatTime,Fa.timestamp];Kc.schema=Yp});var ol=w(Wa=>{"use strict";var el=xt(),Xp=kr(),tl=Pt(),Qp=si(),Zp=Na(),Va=ka(),qa=Ea(),em=Ac(),tm=Ic(),il=Ra(),fi=pr(),rl=Ia(),nl=Ar(),Xc=Yc(),al=Da(),Dr=La(),Qc=new Map([["core",em.schema],["failsafe",[el.map,tl.seq,Qp.string]],["json",tm.schema],["yaml11",Xc.schema],["yaml-1.1",Xc.schema]]),Zc={binary:il.binary,bool:Zp.boolTag,float:Va.float,floatExp:Va.floatExp,floatNaN:Va.floatNaN,floatTime:Dr.floatTime,int:qa.int,intHex:qa.intHex,intOct:qa.intOct,intTime:Dr.intTime,map:el.map,merge:fi.merge,null:Xp.nullTag,omap:rl.omap,pairs:nl.pairs,seq:tl.seq,set:al.set,timestamp:Dr.timestamp},im={"tag:yaml.org,2002:binary":il.binary,"tag:yaml.org,2002:merge":fi.merge,"tag:yaml.org,2002:omap":rl.omap,"tag:yaml.org,2002:pairs":nl.pairs,"tag:yaml.org,2002:set":al.set,"tag:yaml.org,2002:timestamp":Dr.timestamp};function rm(t,e,i){let r=Qc.get(e);if(r&&!t)return i&&!r.includes(fi.merge)?r.concat(fi.merge):r.slice();let n=r;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Qc.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 i&&(n=n.concat(fi.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Zc[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Zc).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},[])}Wa.coreKnownTags=im;Wa.getTags=rm});var Ga=w(sl=>{"use strict";var za=x(),nm=xt(),am=Pt(),om=si(),Br=ol(),sm=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Ja=class t{constructor({compat:e,customTags:i,merge:r,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Br.getTags(e,"compat"):e?Br.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Br.coreKnownTags:{},this.tags=Br.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,za.MAP,{value:nm.map}),Object.defineProperty(this,za.SCALAR,{value:om.string}),Object.defineProperty(this,za.SEQ,{value:am.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?sm:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};sl.Schema=Ja});var ll=w(cl=>{"use strict";var cm=x(),Ua=ni(),hi=ei();function lm(t,e){let i=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(i.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&i.push("---");let n=Ua.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){i.length!==1&&i.unshift("");let c=a(t.commentBefore);i.unshift(hi.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(cm.isNode(t.contents)){if(t.contents.spaceBefore&&r&&i.push(""),t.contents.commentBefore){let u=a(t.contents.commentBefore);i.push(hi.indentComment(u,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=Ua.stringify(t.contents,n,()=>s=null,c);s&&(l+=hi.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(Ua.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
+ `)?(i.push("..."),i.push(hi.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&i[i.length-1]!==""&&i.push(""),i.push(hi.indentComment(a(c),"")))}return i.join(`
59
59
  `)+`
60
- `}rl.stringifyDocument=rm});var hi=w(al=>{"use strict";var nm=Xt(),xt=ir(),ee=P(),am=qe(),om=Le(),sm=qa(),cm=nl(),za=Qi(),lm=Kn(),um=Qt(),Ja=Un(),Ga=class t{constructor(e,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ee.NODE_TYPE,{value:ee.DOC});let n=null;typeof i=="function"||Array.isArray(i)?n=i:r===void 0&&i&&(r=i,i=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=a;let{version:o}=a;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Ja.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(t.prototype,{[ee.NODE_TYPE]:{value:ee.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=ee.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ct(this.contents)&&this.contents.add(e)}addIn(e,i){Ct(this.contents)&&this.contents.addIn(e,i)}createAlias(e,i){if(!e.anchor){let r=za.anchorNames(this);e.anchor=!i||r.has(i)?za.findNewAnchor(i||"a",r):i}return new nm.Alias(e.anchor)}createNode(e,i,r){let n;if(typeof i=="function")e=i.call({"":e},"",e),n=i;else if(Array.isArray(i)){let m=N=>typeof N=="number"||N instanceof String||N instanceof Number,y=i.filter(m).map(String);y.length>0&&(i=i.concat(y)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:u}=r??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=za.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=um.createNode(e,u,v);return s&&ee.isCollection(h)&&(h.flow=!0),f(),h}createPair(e,i,r={}){let n=this.createNode(e,null,r),a=this.createNode(i,null,r);return new am.Pair(n,a)}delete(e){return Ct(this.contents)?this.contents.delete(e):!1}deleteIn(e){return xt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Ct(this.contents)?this.contents.deleteIn(e):!1}get(e,i){return ee.isCollection(this.contents)?this.contents.get(e,i):void 0}getIn(e,i){return xt.isEmptyPath(e)?!i&&ee.isScalar(this.contents)?this.contents.value:this.contents:ee.isCollection(this.contents)?this.contents.getIn(e,i):void 0}has(e){return ee.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return xt.isEmptyPath(e)?this.contents!==void 0:ee.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,i){this.contents==null?this.contents=xt.collectionFromPath(this.schema,[e],i):Ct(this.contents)&&this.contents.set(e,i)}setIn(e,i){xt.isEmptyPath(e)?this.contents=i:this.contents==null?this.contents=xt.collectionFromPath(this.schema,Array.from(e),i):Ct(this.contents)&&this.contents.setIn(e,i)}setSchema(e,i={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Ja.Directives({version:"1.1"}),r={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}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=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(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new sm.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=om.toJS(this.contents,i??"",s);if(typeof a=="function")for(let{count:l,res:u}of s.anchors.values())a(u,l);return typeof o=="function"?lm.applyReviver(o,{"":c},"",c):c}toJSON(e,i){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:i})}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 i=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return cm.stringifyDocument(this,e)}};function Ct(t){if(ee.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}al.Document=Ga});var vi=w(mi=>{"use strict";var pi=class extends Error{constructor(e,i,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=i}},Ua=class extends pi{constructor(e,i,r){super("YAMLParseError",e,i,r)}},Ka=class extends pi{constructor(e,i,r){super("YAMLWarning",e,i,r)}},dm=(t,e)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>e.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),r>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);s.length>80&&(s=s.substring(0,79)+`…
60
+ `}cl.stringifyDocument=lm});var pi=w(ul=>{"use strict";var um=Qt(),Rt=nr(),Z=x(),dm=We(),fm=Me(),hm=Ga(),pm=ll(),Ka=er(),mm=Zn(),vm=Zt(),Ya=Qn(),Xa=class t{constructor(e,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Z.NODE_TYPE,{value:Z.DOC});let n=null;typeof i=="function"||Array.isArray(i)?n=i:r===void 0&&i&&(r=i,i=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=a;let{version:o}=a;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Ya.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(t.prototype,{[Z.NODE_TYPE]:{value:Z.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=Z.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){At(this.contents)&&this.contents.add(e)}addIn(e,i){At(this.contents)&&this.contents.addIn(e,i)}createAlias(e,i){if(!e.anchor){let r=Ka.anchorNames(this);e.anchor=!i||r.has(i)?Ka.findNewAnchor(i||"a",r):i}return new um.Alias(e.anchor)}createNode(e,i,r){let n;if(typeof i=="function")e=i.call({"":e},"",e),n=i;else if(Array.isArray(i)){let m=N=>typeof N=="number"||N instanceof String||N instanceof Number,y=i.filter(m).map(String);y.length>0&&(i=i.concat(y)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:u}=r??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=Ka.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=vm.createNode(e,u,v);return s&&Z.isCollection(h)&&(h.flow=!0),f(),h}createPair(e,i,r={}){let n=this.createNode(e,null,r),a=this.createNode(i,null,r);return new dm.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,i){return Z.isCollection(this.contents)?this.contents.get(e,i):void 0}getIn(e,i){return Rt.isEmptyPath(e)?!i&&Z.isScalar(this.contents)?this.contents.value:this.contents:Z.isCollection(this.contents)?this.contents.getIn(e,i):void 0}has(e){return Z.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Rt.isEmptyPath(e)?this.contents!==void 0:Z.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,i){this.contents==null?this.contents=Rt.collectionFromPath(this.schema,[e],i):At(this.contents)&&this.contents.set(e,i)}setIn(e,i){Rt.isEmptyPath(e)?this.contents=i:this.contents==null?this.contents=Rt.collectionFromPath(this.schema,Array.from(e),i):At(this.contents)&&this.contents.setIn(e,i)}setSchema(e,i={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Ya.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Ya.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=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(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new hm.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=fm.toJS(this.contents,i??"",s);if(typeof a=="function")for(let{count:l,res:u}of s.anchors.values())a(u,l);return typeof o=="function"?mm.applyReviver(o,{"":c},"",c):c}toJSON(e,i){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:i})}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 i=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return pm.stringifyDocument(this,e)}};function At(t){if(Z.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}ul.Document=Xa});var gi=w(vi=>{"use strict";var mi=class extends Error{constructor(e,i,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=i}},Qa=class extends mi{constructor(e,i,r){super("YAMLParseError",e,i,r)}},Za=class extends mi{constructor(e,i,r){super("YAMLWarning",e,i,r)}},gm=(t,e)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>e.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),r>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);s.length>80&&(s=s.substring(0,79)+`…
61
61
  `),o=s+o}if(/[^ ]/.test(o)){let s=1,c=i.linePos[1];c?.line===r&&c.col>n&&(s=Math.max(1,Math.min(c.col-n,80-a)));let l=" ".repeat(a)+"^".repeat(s);i.message+=`:
62
62
 
63
63
  ${o}
64
64
  ${l}
65
- `}};mi.YAMLError=pi;mi.YAMLParseError=Ua;mi.YAMLWarning=Ka;mi.prettifyError=dm});var gi=w(ol=>{"use strict";function fm(t,{flow:e,indicator:i,next:r,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d="",f="",p=!1,v=!1,h=null,m=null,y=null,N=null,k=null,S=null,E=null;for(let b of t)switch(v&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&a(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&b.type!=="comment"&&b.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),b.type){case"space":!e&&(i!=="doc-start"||r?.type!=="flow-collection")&&b.source.includes(" ")&&(h=b),u=!0;break;case"comment":{u||a(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=b.source.substring(1)||" ";d?d+=f+_:d=_,f="",l=!1;break}case"newline":l?d?d+=b.source:(!S||i!=="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,v=!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,v=!0;break}case i:(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=i==="seq-item-ind"||i==="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 g=t[t.length-1],x=g?g.offset+g.source.length:n;return v&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&a(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:c,comment:d,hasNewline:p,anchor:m,tag:y,newlineAfterProp:N,end:x,start:E??x}}ol.resolveProps=fm});var Dr=w(sl=>{"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 i of e.start)if(i.type==="newline")return!0;if(e.sep){for(let i of e.sep)if(i.type==="newline")return!0}if(Ya(e.key)||Ya(e.value))return!0}return!1;default:return!0}}sl.containsNewline=Ya});var Xa=w(cl=>{"use strict";var hm=Dr();function pm(t,e,i){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&hm.containsNewline(e)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}cl.flowIndentCheck=pm});var Qa=w(ul=>{"use strict";var ll=P();function mm(t,e,i){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let n=typeof r=="function"?r:(a,o)=>a===o||ll.isScalar(a)&&ll.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,i))}ul.mapIncludes=mm});var vl=w(ml=>{"use strict";var dl=qe(),vm=ze(),fl=gi(),gm=Dr(),hl=Xa(),wm=Qa(),pl="All mapping items must start at the same column";function ym({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=a?.nodeClass??vm.YAMLMap,s=new o(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let u of r.items){let{start:d,key:f,sep:p,value:v}=u,h=fl.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:n,parentIndent:r.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!==r.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||gm.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",pl);i.atKey=!0;let y=h.end,N=f?t(i,f,h,n):e(i,y,d,null,h,n);i.schema.compat&&hl.flowIndentCheck(r.indent,f,n),i.atKey=!1,wm.mapIncludes(i,s.items,N)&&n(y,"DUPLICATE_KEY","Map keys must be unique");let k=fl.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=k.end,k.found){m&&(v?.type==="block-map"&&!k.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.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=v?t(i,v,k,n):e(i,c,p,null,k,n);i.schema.compat&&hl.flowIndentCheck(r.indent,v,n),c=S.range[2];let E=new dl.Pair(N,S);i.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 dl.Pair(N);i.options.keepSourceTokens&&(S.srcToken=u),s.items.push(S)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}ml.resolveBlockMap=ym});var wl=w(gl=>{"use strict";var Nm=Je(),bm=gi(),km=Xa();function Sm({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=a?.nodeClass??Nm.YAMLSeq,s=new o(i.schema);i.atRoot&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let c=r.offset,l=null;for(let{start:u,value:d}of r.items){let f=bm.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:r.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(i,d,f,n):e(i,f.end,u,null,f,n);i.schema.compat&&km.flowIndentCheck(r.indent,d,n),c=p.range[2],s.items.push(p)}return s.range=[r.offset,c,l??c],s}gl.resolveBlockSeq=Sm});var Rt=w(yl=>{"use strict";function Em(t,e,i,r){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":{i&&!a&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";n?n+=o+u:n=u,o="";break}case"newline":n&&(o+=c),a=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}yl.resolveEnd=Em});var Sl=w(kl=>{"use strict";var Pm=P(),xm=qe(),Nl=ze(),Cm=Je(),Rm=Rt(),bl=gi(),Am=Dr(),_m=Qa(),Za="Block collections are not allowed within flow collections",eo=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Tm({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=r.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Nl.YAMLMap:Cm.YAMLSeq),l=new c(i.schema);l.flow=!0;let u=i.atRoot;u&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let d=r.offset+r.start.source.length;for(let m=0;m<r.items.length;++m){let y=r.items[m],{start:N,key:k,sep:S,value:E}=y,g=bl.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:k??S?.[0],offset:d,onError:n,parentIndent:r.indent,startOnNewline:!1});if(!g.found){if(!g.anchor&&!g.tag&&!S&&!E){m===0&&g.comma?n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<r.items.length-1&&n(g.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),g.comment&&(l.comment?l.comment+=`
69
- `+g.comment:l.comment=g.comment),d=g.end;continue}!o&&i.options.strict&&Am.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)g.comma&&n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(g.comma||n(g.start,"MISSING_CHAR",`Missing , between ${s} items`),g.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];Pm.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
70
- `+x:b.comment=x,g.comment=g.comment.substring(x.length+1)}}if(!o&&!S&&!g.found){let x=E?t(i,E,g,n):e(i,g.end,S,null,g,n);l.items.push(x),d=x.range[2],eo(E)&&n(x.range,"BLOCK_IN_FLOW",Za)}else{i.atKey=!0;let x=g.end,b=k?t(i,k,g,n):e(i,x,N,null,g,n);eo(k)&&n(b.range,"BLOCK_IN_FLOW",Za),i.atKey=!1;let _=bl.resolveProps(S??[],{flow:s,indicator:"map-value-ind",next:E,offset:b.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!g.found&&i.options.strict){if(S)for(let $ of S){if($===_.found)break;if($.type==="newline"){n($,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}g.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 K=E?t(i,E,_,n):_.found?e(i,_.end,S,null,_,n):null;K?eo(E)&&n(K.range,"BLOCK_IN_FLOW",Za):_.comment&&(b.comment?b.comment+=`
71
- `+_.comment:b.comment=_.comment);let wt=new xm.Pair(b,K);if(i.options.keepSourceTokens&&(wt.srcToken=y),o){let $=l;_m.mapIncludes(i,$.items,b)&&n(x,"DUPLICATE_KEY","Map keys must be unique"),$.items.push(wt)}else{let $=new Nl.YAMLMap(i.schema);$.flow=!0,$.items.push(wt);let ks=(K??b).range;$.range=[b.range[0],ks[1],ks[2]],l.items.push($)}d=K?K.range[2]:_.end}}let f=o?"}":"]",[p,...v]=r.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&&v.unshift(p)}if(v.length>0){let m=Rm.resolveEnd(v,h,i.options.strict,n);m.comment&&(l.comment?l.comment+=`
72
- `+m.comment:l.comment=m.comment),l.range=[r.offset,h,m.offset]}else l.range=[r.offset,h,h];return l}kl.resolveFlowCollection=Tm});var Pl=w(El=>{"use strict";var Im=P(),jm=j(),$m=ze(),Om=Je(),Hm=vl(),Dm=wl(),Bm=Sl();function to(t,e,i,r,n,a){let o=i.type==="block-map"?Hm.resolveBlockMap(t,e,i,r,a):i.type==="block-seq"?Dm.resolveBlockSeq(t,e,i,r,a):Bm.resolveFlowCollection(t,e,i,r,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function Lm(t,e,i,r,n){let a=r.tag,o=a?e.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(i.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,v=f&&a?f.offset>a.offset?f:a:f??a;v&&(!p||p.offset<v.offset)&&n(v,"MISSING_CHAR","Missing newline after block sequence props")}let s=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===$m.YAMLMap.tagName&&s==="map"||o===Om.YAMLSeq.tagName&&s==="seq")return to(t,e,i,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,i,n,o)}let l=to(t,e,i,n,o,c),u=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),e.options)??l,d=Im.isNode(u)?u:new jm.Scalar(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}El.composeCollection=Lm});var ro=w(xl=>{"use strict";var io=j();function Mm(t,e,i){let r=e.offset,n=Fm(e,t.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let a=n.mode===">"?io.Scalar.BLOCK_FOLDED:io.Scalar.BLOCK_LITERAL,o=e.source?Vm(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
+ `}};vi.YAMLError=mi;vi.YAMLParseError=Qa;vi.YAMLWarning=Za;vi.prettifyError=gm});var wi=w(dl=>{"use strict";function wm(t,{flow:e,indicator:i,next:r,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d="",f="",p=!1,v=!1,h=null,m=null,y=null,N=null,k=null,S=null,E=null;for(let b of t)switch(v&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&a(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&b.type!=="comment"&&b.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),b.type){case"space":!e&&(i!=="doc-start"||r?.type!=="flow-collection")&&b.source.includes(" ")&&(h=b),u=!0;break;case"comment":{u||a(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=b.source.substring(1)||" ";d?d+=f+_:d=_,f="",l=!1;break}case"newline":l?d?d+=b.source:(!S||i!=="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,v=!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,v=!0;break}case i:(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=i==="seq-item-ind"||i==="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 g=t[t.length-1],P=g?g.offset+g.source.length:n;return v&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&a(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:c,comment:d,hasNewline:p,anchor:m,tag:y,newlineAfterProp:N,end:P,start:E??P}}dl.resolveProps=wm});var Lr=w(fl=>{"use strict";function eo(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 i of e.start)if(i.type==="newline")return!0;if(e.sep){for(let i of e.sep)if(i.type==="newline")return!0}if(eo(e.key)||eo(e.value))return!0}return!1;default:return!0}}fl.containsNewline=eo});var to=w(hl=>{"use strict";var ym=Lr();function Nm(t,e,i){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&ym.containsNewline(e)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}hl.flowIndentCheck=Nm});var io=w(ml=>{"use strict";var pl=x();function bm(t,e,i){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let n=typeof r=="function"?r:(a,o)=>a===o||pl.isScalar(a)&&pl.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,i))}ml.mapIncludes=bm});var bl=w(Nl=>{"use strict";var vl=We(),km=Je(),gl=wi(),Sm=Lr(),wl=to(),Em=io(),yl="All mapping items must start at the same column";function xm({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=a?.nodeClass??km.YAMLMap,s=new o(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let u of r.items){let{start:d,key:f,sep:p,value:v}=u,h=gl.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:n,parentIndent:r.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!==r.indent&&n(c,"BAD_INDENT",yl)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Sm.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",yl);i.atKey=!0;let y=h.end,N=f?t(i,f,h,n):e(i,y,d,null,h,n);i.schema.compat&&wl.flowIndentCheck(r.indent,f,n),i.atKey=!1,Em.mapIncludes(i,s.items,N)&&n(y,"DUPLICATE_KEY","Map keys must be unique");let k=gl.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=k.end,k.found){m&&(v?.type==="block-map"&&!k.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.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=v?t(i,v,k,n):e(i,c,p,null,k,n);i.schema.compat&&wl.flowIndentCheck(r.indent,v,n),c=S.range[2];let E=new vl.Pair(N,S);i.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 vl.Pair(N);i.options.keepSourceTokens&&(S.srcToken=u),s.items.push(S)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}Nl.resolveBlockMap=xm});var Sl=w(kl=>{"use strict";var Pm=Ge(),Cm=wi(),Rm=to();function Am({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=a?.nodeClass??Pm.YAMLSeq,s=new o(i.schema);i.atRoot&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let c=r.offset,l=null;for(let{start:u,value:d}of r.items){let f=Cm.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:r.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(i,d,f,n):e(i,f.end,u,null,f,n);i.schema.compat&&Rm.flowIndentCheck(r.indent,d,n),c=p.range[2],s.items.push(p)}return s.range=[r.offset,c,l??c],s}kl.resolveBlockSeq=Am});var _t=w(El=>{"use strict";function _m(t,e,i,r){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":{i&&!a&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";n?n+=o+u:n=u,o="";break}case"newline":n&&(o+=c),a=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}El.resolveEnd=_m});var Rl=w(Cl=>{"use strict";var Tm=x(),Im=We(),xl=Je(),jm=Ge(),$m=_t(),Pl=wi(),Om=Lr(),Hm=io(),ro="Block collections are not allowed within flow collections",no=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Dm({composeNode:t,composeEmptyNode:e},i,r,n,a){let o=r.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?xl.YAMLMap:jm.YAMLSeq),l=new c(i.schema);l.flow=!0;let u=i.atRoot;u&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let d=r.offset+r.start.source.length;for(let m=0;m<r.items.length;++m){let y=r.items[m],{start:N,key:k,sep:S,value:E}=y,g=Pl.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:k??S?.[0],offset:d,onError:n,parentIndent:r.indent,startOnNewline:!1});if(!g.found){if(!g.anchor&&!g.tag&&!S&&!E){m===0&&g.comma?n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<r.items.length-1&&n(g.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),g.comment&&(l.comment?l.comment+=`
69
+ `+g.comment:l.comment=g.comment),d=g.end;continue}!o&&i.options.strict&&Om.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)g.comma&&n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(g.comma||n(g.start,"MISSING_CHAR",`Missing , between ${s} items`),g.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];Tm.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
70
+ `+P:b.comment=P,g.comment=g.comment.substring(P.length+1)}}if(!o&&!S&&!g.found){let P=E?t(i,E,g,n):e(i,g.end,S,null,g,n);l.items.push(P),d=P.range[2],no(E)&&n(P.range,"BLOCK_IN_FLOW",ro)}else{i.atKey=!0;let P=g.end,b=k?t(i,k,g,n):e(i,P,N,null,g,n);no(k)&&n(b.range,"BLOCK_IN_FLOW",ro),i.atKey=!1;let _=Pl.resolveProps(S??[],{flow:s,indicator:"map-value-ind",next:E,offset:b.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!g.found&&i.options.strict){if(S)for(let $ of S){if($===_.found)break;if($.type==="newline"){n($,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}g.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 K=E?t(i,E,_,n):_.found?e(i,_.end,S,null,_,n):null;K?no(E)&&n(K.range,"BLOCK_IN_FLOW",ro):_.comment&&(b.comment?b.comment+=`
71
+ `+_.comment:b.comment=_.comment);let Nt=new Im.Pair(b,K);if(i.options.keepSourceTokens&&(Nt.srcToken=y),o){let $=l;Hm.mapIncludes(i,$.items,b)&&n(P,"DUPLICATE_KEY","Map keys must be unique"),$.items.push(Nt)}else{let $=new xl.YAMLMap(i.schema);$.flow=!0,$.items.push(Nt);let Cs=(K??b).range;$.range=[b.range[0],Cs[1],Cs[2]],l.items.push($)}d=K?K.range[2]:_.end}}let f=o?"}":"]",[p,...v]=r.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&&v.unshift(p)}if(v.length>0){let m=$m.resolveEnd(v,h,i.options.strict,n);m.comment&&(l.comment?l.comment+=`
72
+ `+m.comment:l.comment=m.comment),l.range=[r.offset,h,m.offset]}else l.range=[r.offset,h,h];return l}Cl.resolveFlowCollection=Dm});var _l=w(Al=>{"use strict";var Bm=x(),Lm=j(),Mm=Je(),Fm=Ge(),Vm=bl(),qm=Sl(),Wm=Rl();function ao(t,e,i,r,n,a){let o=i.type==="block-map"?Vm.resolveBlockMap(t,e,i,r,a):i.type==="block-seq"?qm.resolveBlockSeq(t,e,i,r,a):Wm.resolveFlowCollection(t,e,i,r,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function zm(t,e,i,r,n){let a=r.tag,o=a?e.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(i.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,v=f&&a?f.offset>a.offset?f:a:f??a;v&&(!p||p.offset<v.offset)&&n(v,"MISSING_CHAR","Missing newline after block sequence props")}let s=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===Mm.YAMLMap.tagName&&s==="map"||o===Fm.YAMLSeq.tagName&&s==="seq")return ao(t,e,i,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),ao(t,e,i,n,o)}let l=ao(t,e,i,n,o,c),u=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),e.options)??l,d=Bm.isNode(u)?u:new Lm.Scalar(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}Al.composeCollection=zm});var so=w(Tl=>{"use strict";var oo=j();function Jm(t,e,i){let r=e.offset,n=Gm(e,t.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let a=n.mode===">"?oo.Scalar.BLOCK_FOLDED:oo.Scalar.BLOCK_LITERAL,o=e.source?Um(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=r+n.length;return e.source&&(m+=e.source.length),{value:h,type:a,comment:n.comment,range:[r,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&&i(l+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=m.length),u=h,c===0&&!t.atRoot&&i(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"}`;i(l-y.length-(N?2:1),"BAD_INDENT",S),m=""}a===io.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"}`;i(l-y.length-(N?2:1),"BAD_INDENT",S),m=""}a===oo.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,66 +84,66 @@ ${l}
84
84
  `+o[h][0].slice(c);d[d.length-1]!==`
85
85
  `&&(d+=`
86
86
  `);break;default:d+=`
87
- `}let v=r+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[r,v,v]}}function Fm({offset:t,props:e},i,r){if(e[0].type!=="block-scalar-header")return r(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 v=Number(p);!o&&v?o=v:c===-1&&(c=t+f)}}c!==-1&&r(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":i&&!l&&r(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":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let v=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",v);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function Vm(t){let e=t.split(/\n( *)/),i=e[0],r=i.match(/^( *)/),a=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}xl.resolveBlockScalar=Mm});var ao=w(Rl=>{"use strict";var no=j(),qm=Rt();function Wm(t,e,i){let{offset:r,type:n,source:a,end:o}=t,s,c,l=(f,p,v)=>i(r+f,p,v);switch(n){case"scalar":s=no.Scalar.PLAIN,c=zm(a,l);break;case"single-quoted-scalar":s=no.Scalar.QUOTE_SINGLE,c=Jm(a,l);break;case"double-quoted-scalar":s=no.Scalar.QUOTE_DOUBLE,c=Gm(a,l);break;default:return i(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=qm.resolveEnd(o,u,e,i);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function zm(t,e){let i="";switch(t[0]){case" ":i="a tab character";break;case",":i="flow indicator character ,";break;case"%":i="directive indicator character %";break;case"|":case">":{i=`block scalar indicator ${t[0]}`;break}case"@":case"`":{i=`reserved character ${t[0]}`;break}}return i&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),Cl(t)}function Jm(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Cl(t.slice(1,-1)).replace(/''/g,"'")}function Cl(t){let e,i;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
+ `}let v=r+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[r,v,v]}}function Gm({offset:t,props:e},i,r){if(e[0].type!=="block-scalar-header")return r(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 v=Number(p);!o&&v?o=v:c===-1&&(c=t+f)}}c!==-1&&r(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":i&&!l&&r(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":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let v=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",v);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function Um(t){let e=t.split(/\n( *)/),i=e[0],r=i.match(/^( *)/),a=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}Tl.resolveBlockScalar=Jm});var lo=w(jl=>{"use strict";var co=j(),Km=_t();function Ym(t,e,i){let{offset:r,type:n,source:a,end:o}=t,s,c,l=(f,p,v)=>i(r+f,p,v);switch(n){case"scalar":s=co.Scalar.PLAIN,c=Xm(a,l);break;case"single-quoted-scalar":s=co.Scalar.QUOTE_SINGLE,c=Qm(a,l);break;case"double-quoted-scalar":s=co.Scalar.QUOTE_DOUBLE,c=Zm(a,l);break;default:return i(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=Km.resolveEnd(o,u,e,i);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function Xm(t,e){let i="";switch(t[0]){case" ":i="a tab character";break;case",":i="flow indicator character ,";break;case"%":i="directive indicator character %";break;case"|":case">":{i=`block scalar indicator ${t[0]}`;break}case"@":case"`":{i=`reserved character ${t[0]}`;break}}return i&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),Il(t)}function Qm(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Il(t.slice(1,-1)).replace(/''/g,"'")}function Il(t){let e,i;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
88
88
  `,"sy"),i=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
89
89
  `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let n=r[1],a=" ",o=e.lastIndex;for(i.lastIndex=o;r=i.exec(t);)r[1]===""?a===`
90
90
  `?n+=a:a=`
91
- `:(n+=a+r[1],a=" "),o=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(t),n+a+(r?.[1]??"")}function Gm(t,e){let i="";for(let r=1;r<t.length-1;++r){let n=t[r];if(!(n==="\r"&&t[r+1]===`
91
+ `:(n+=a+r[1],a=" "),o=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(t),n+a+(r?.[1]??"")}function Zm(t,e){let i="";for(let r=1;r<t.length-1;++r){let n=t[r];if(!(n==="\r"&&t[r+1]===`
92
92
  `))if(n===`
93
- `){let{fold:a,offset:o}=Um(t,r);i+=a,r=o}else if(n==="\\"){let a=t[++r],o=Km[a];if(o)i+=o;else if(a===`
93
+ `){let{fold:a,offset:o}=ev(t,r);i+=a,r=o}else if(n==="\\"){let a=t[++r],o=tv[a];if(o)i+=o;else if(a===`
94
94
  `)for(a=t[r+1];a===" "||a===" ";)a=t[++r+1];else if(a==="\r"&&t[r+1]===`
95
- `)for(a=t[++r+1];a===" "||a===" ";)a=t[++r+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;i+=Ym(t,r+1,s,e),r+=s}else{let s=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let a=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
95
+ `)for(a=t[++r+1];a===" "||a===" ";)a=t[++r+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;i+=iv(t,r+1,s,e),r+=s}else{let s=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let a=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
96
96
  `&&!(o==="\r"&&t[r+2]===`
97
- `)&&(i+=r>a?t.slice(a,r+1):n)}else i+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),i}function Um(t,e){let i="",r=t[e+1];for(;(r===" "||r===" "||r===`
97
+ `)&&(i+=r>a?t.slice(a,r+1):n)}else i+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),i}function ev(t,e){let i="",r=t[e+1];for(;(r===" "||r===" "||r===`
98
98
  `||r==="\r")&&!(r==="\r"&&t[e+2]!==`
99
99
  `);)r===`
100
100
  `&&(i+=`
101
- `),e+=1,r=t[e+1];return i||(i=" "),{fold:i,offset:e}}var Km={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Ym(t,e,i,r){let n=t.substr(e,i),o=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=t.substr(e-2,i+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Rl.resolveFlowScalar=Wm});var Tl=w(_l=>{"use strict";var ut=P(),Al=j(),Xm=ro(),Qm=ao();function Zm(t,e,i,r){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?Xm.resolveBlockScalar(t,e,r):Qm.resolveFlowScalar(e,t.options.strict,r),c=i?t.directives.tagName(i.source,d=>r(i,"TAG_RESOLVE_FAILED",d)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[ut.SCALAR]:c?l=ev(t.schema,n,c,i,r):e.type==="scalar"?l=tv(t,n,e,r):l=t.schema[ut.SCALAR];let u;try{let d=l.resolve(n,f=>r(i??e,"TAG_RESOLVE_FAILED",f),t.options);u=ut.isScalar(d)?d:new Al.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);r(i??e,"TAG_RESOLVE_FAILED",f),u=new Al.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 ev(t,e,i,r,n){if(i==="!")return t[ut.SCALAR];let a=[];for(let s of t.tags)if(!s.collection&&s.tag===i)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(e))return s;let o=t.knownTags[i];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),t[ut.SCALAR])}function tv({atKey:t,directives:e,schema:i},r,n,a){let o=i.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(r))||i[ut.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[ut.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}_l.composeScalar=Zm});var jl=w(Il=>{"use strict";function iv(t,e,i){if(e){i??(i=e.length);for(let r=i-1;r>=0;--r){let n=e[r];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++r];n?.type==="space";)t+=n.source.length,n=e[++r];break}}return t}Il.emptyScalarPosition=iv});var Hl=w(so=>{"use strict";var rv=Xt(),nv=P(),av=Pl(),$l=Tl(),ov=Rt(),sv=jl(),cv={composeNode:Ol,composeEmptyNode:oo};function Ol(t,e,i,r){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=i,l,u=!0;switch(e.type){case"alias":l=lv(t,e,r),(s||c)&&r(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=$l.composeScalar(t,e,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=av.composeCollection(cv,t,e,i,r),s&&(l.anchor=s.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);r(e,"RESOURCE_EXHAUSTION",f)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),u=!1}}return l??(l=oo(t,e.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!nv.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(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,i,r,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let u={type:"scalar",offset:sv.emptyScalarPosition(e,i,r),indent:-1,source:""},d=$l.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 lv({options:t},{offset:e,source:i,end:r},n){let a=new rv.Alias(i.substring(1));a.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(e+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+i.length,s=ov.resolveEnd(r,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}so.composeEmptyNode=oo;so.composeNode=Ol});var Ll=w(Bl=>{"use strict";var uv=hi(),Dl=Hl(),dv=Rt(),fv=gi();function hv(t,e,{offset:i,start:r,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new uv.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=fv.resolveProps(r,{indicator:"doc-start",next:n??a?.[0],offset:i,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Dl.composeNode(l,n,u,o):Dl.composeEmptyNode(l,u.end,r,null,u,o);let d=c.contents.range[2],f=dv.resolveEnd(a,d,!1,o);return f.comment&&(c.comment=f.comment),c.range=[i,d,f.offset],c}Bl.composeDoc=hv});var lo=w(Vl=>{"use strict";var pv=Gi("process"),mv=Un(),vv=hi(),wi=vi(),Ml=P(),gv=Ll(),wv=Rt();function yi(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:i}=t;return[e,e+(typeof i=="string"?i.length:1)]}function Fl(t){let e="",i=!1,r=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":r?`
101
+ `),e+=1,r=t[e+1];return i||(i=" "),{fold:i,offset:e}}var tv={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function iv(t,e,i,r){let n=t.substr(e,i),o=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=t.substr(e-2,i+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}jl.resolveFlowScalar=Ym});var Hl=w(Ol=>{"use strict";var ft=x(),$l=j(),rv=so(),nv=lo();function av(t,e,i,r){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?rv.resolveBlockScalar(t,e,r):nv.resolveFlowScalar(e,t.options.strict,r),c=i?t.directives.tagName(i.source,d=>r(i,"TAG_RESOLVE_FAILED",d)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[ft.SCALAR]:c?l=ov(t.schema,n,c,i,r):e.type==="scalar"?l=sv(t,n,e,r):l=t.schema[ft.SCALAR];let u;try{let d=l.resolve(n,f=>r(i??e,"TAG_RESOLVE_FAILED",f),t.options);u=ft.isScalar(d)?d:new $l.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);r(i??e,"TAG_RESOLVE_FAILED",f),u=new $l.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 ov(t,e,i,r,n){if(i==="!")return t[ft.SCALAR];let a=[];for(let s of t.tags)if(!s.collection&&s.tag===i)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(e))return s;let o=t.knownTags[i];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),t[ft.SCALAR])}function sv({atKey:t,directives:e,schema:i},r,n,a){let o=i.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(r))||i[ft.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[ft.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}Ol.composeScalar=av});var Bl=w(Dl=>{"use strict";function cv(t,e,i){if(e){i??(i=e.length);for(let r=i-1;r>=0;--r){let n=e[r];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++r];n?.type==="space";)t+=n.source.length,n=e[++r];break}}return t}Dl.emptyScalarPosition=cv});var Fl=w(fo=>{"use strict";var lv=Qt(),uv=x(),dv=_l(),Ll=Hl(),fv=_t(),hv=Bl(),pv={composeNode:Ml,composeEmptyNode:uo};function Ml(t,e,i,r){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=i,l,u=!0;switch(e.type){case"alias":l=mv(t,e,r),(s||c)&&r(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=Ll.composeScalar(t,e,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=dv.composeCollection(pv,t,e,i,r),s&&(l.anchor=s.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);r(e,"RESOURCE_EXHAUSTION",f)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),u=!1}}return l??(l=uo(t,e.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!uv.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(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 uo(t,e,i,r,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let u={type:"scalar",offset:hv.emptyScalarPosition(e,i,r),indent:-1,source:""},d=Ll.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 mv({options:t},{offset:e,source:i,end:r},n){let a=new lv.Alias(i.substring(1));a.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(e+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+i.length,s=fv.resolveEnd(r,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}fo.composeEmptyNode=uo;fo.composeNode=Ml});var Wl=w(ql=>{"use strict";var vv=pi(),Vl=Fl(),gv=_t(),wv=wi();function yv(t,e,{offset:i,start:r,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new vv.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=wv.resolveProps(r,{indicator:"doc-start",next:n??a?.[0],offset:i,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Vl.composeNode(l,n,u,o):Vl.composeEmptyNode(l,u.end,r,null,u,o);let d=c.contents.range[2],f=gv.resolveEnd(a,d,!1,o);return f.comment&&(c.comment=f.comment),c.range=[i,d,f.offset],c}ql.composeDoc=yv});var po=w(Gl=>{"use strict";var Nv=Ki("process"),bv=Qn(),kv=pi(),yi=gi(),zl=x(),Sv=Wl(),Ev=_t();function Ni(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:i}=t;return[e,e+(typeof i=="string"?i.length:1)]}function Jl(t){let e="",i=!1,r=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":r?`
103
103
 
104
104
  `:`
105
- `)+(a.substring(1)||" "),i=!0,r=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:e,afterEmptyLine:r}}var co=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,a)=>{let o=yi(i);a?this.warnings.push(new wi.YAMLWarning(o,r,n)):this.errors.push(new wi.YAMLParseError(o,r,n))},this.directives=new mv.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,i){let{comment:r,afterEmptyLine:n}=Fl(this.prelude);if(r){let a=e.contents;if(i)e.comment=e.comment?`${e.comment}
106
- ${r}`:r;else if(n||e.directives.docStart||!a)e.commentBefore=r;else if(Ml.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Ml.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${r}
105
+ `)+(a.substring(1)||" "),i=!0,r=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:e,afterEmptyLine:r}}var ho=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,a)=>{let o=Ni(i);a?this.warnings.push(new yi.YAMLWarning(o,r,n)):this.errors.push(new yi.YAMLParseError(o,r,n))},this.directives=new bv.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,i){let{comment:r,afterEmptyLine:n}=Jl(this.prelude);if(r){let a=e.contents;if(i)e.comment=e.comment?`${e.comment}
106
+ ${r}`:r;else if(n||e.directives.docStart||!a)e.commentBefore=r;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?`${r}
107
107
  ${s}`:r}else{let o=a.commentBefore;a.commentBefore=o?`${r}
108
- ${o}`:r}}if(i){for(let a=0;a<this.errors.length;++a)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:Fl(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,i=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(i,r)}*next(e){switch(pv.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(i,r,n)=>{let a=yi(e);a[0]+=i,this.onError(a,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let i=gv.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(i,!1),this.doc&&(yield this.doc),this.doc=i,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let i=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new wi.YAMLParseError(yi(e),"UNEXPECTED_TOKEN",i);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new wi.YAMLParseError(yi(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=wv.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),i.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
109
- ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new wi.YAMLParseError(yi(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new vv.Document(void 0,r);this.atDirectives&&this.onError(i,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,i,i],this.decorate(n,!1),yield n}}};Vl.Composer=co});var zl=w(Br=>{"use strict";var yv=ro(),Nv=ao(),bv=vi(),ql=ii();function kv(t,e=!0,i){if(t){let r=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(i)i(s,a,o);else throw new bv.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Nv.resolveFlowScalar(t,e,r);case"block-scalar":return yv.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function Sv(t,e){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=ql.stringifyString({type:o,value:t},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
108
+ ${o}`:r}}if(i){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:Jl(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,i=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(i,r)}*next(e){switch(Nv.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(i,r,n)=>{let a=Ni(e);a[0]+=i,this.onError(a,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let i=Sv.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(i,!1),this.doc&&(yield this.doc),this.doc=i,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let i=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new yi.YAMLParseError(Ni(e),"UNEXPECTED_TOKEN",i);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new yi.YAMLParseError(Ni(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=Ev.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),i.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
109
+ ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new yi.YAMLParseError(Ni(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new kv.Document(void 0,r);this.atDirectives&&this.onError(i,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,i,i],this.decorate(n,!1),yield n}}};Gl.Composer=ho});var Yl=w(Mr=>{"use strict";var xv=so(),Pv=lo(),Cv=gi(),Ul=ri();function Rv(t,e=!0,i){if(t){let r=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(i)i(s,a,o);else throw new Cv.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Pv.resolveFlowScalar(t,e,r);case"block-scalar":return xv.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function Av(t,e){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=Ul.stringifyString({type:o,value:t},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,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:r,source:u}];return Wl(f,c)||f.push({type:"newline",offset:-1,indent:r,source:`
113
- `}),{type:"block-scalar",offset:a,indent:r,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:r,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:r,source:s,end:c};default:return{type:"scalar",offset:a,indent:r,source:s,end:c}}}function Ev(t,e,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=i,s="indent"in t?t.indent:null;if(r&&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=ql.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">":Pv(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 Pv(t,e){let i=e.indexOf(`
112
+ `,f=[{type:"block-scalar-header",offset:a,indent:r,source:u}];return Kl(f,c)||f.push({type:"newline",offset:-1,indent:r,source:`
113
+ `}),{type:"block-scalar",offset:a,indent:r,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:r,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:r,source:s,end:c};default:return{type:"scalar",offset:a,indent:r,source:s,end:c}}}function _v(t,e,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=i,s="indent"in t?t.indent:null;if(r&&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=Ul.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">":Tv(t,c);break;case'"':mo(t,c,"double-quoted-scalar");break;case"'":mo(t,c,"single-quoted-scalar");break;default:mo(t,c,"scalar")}}function Tv(t,e){let i=e.indexOf(`
114
114
  `),r=e.substring(0,i),n=e.substring(i+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=r,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:r}];Wl(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 Wl(t,e){if(e)for(let i of e)switch(i.type){case"space":case"comment":t.push(i);break;case"newline":return t.push(i),!0}return!1}function uo(t,e,i){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=i,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let a of r)a.offset+=n;delete t.props,Object.assign(t,{type:i,source:e,end:r});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:i,source:e,end:[n]});break}default:{let r="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:i,indent:r,source:e,end:n})}}}Br.createScalarToken=Sv;Br.resolveAsScalar=kv;Br.setScalarValue=Ev});var Gl=w(Jl=>{"use strict";var xv=t=>"type"in t?Mr(t):Lr(t);function Mr(t){switch(t.type){case"block-scalar":{let e="";for(let i of t.props)e+=Mr(i);return e+t.source}case"block-map":case"block-seq":{let e="";for(let i of t.items)e+=Lr(i);return e}case"flow-collection":{let e=t.start.source;for(let i of t.items)e+=Lr(i);for(let i of t.end)e+=i.source;return e}case"document":{let e=Lr(t);if(t.end)for(let i of t.end)e+=i.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let i of t.end)e+=i.source;return e}}}function Lr({start:t,key:e,sep:i,value:r}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Mr(e)),i)for(let a of i)n+=a.source;return r&&(n+=Mr(r)),n}Jl.stringify=xv});var Xl=w(Yl=>{"use strict";var fo=Symbol("break visit"),Cv=Symbol("skip children"),Ul=Symbol("remove item");function dt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Kl(Object.freeze([]),t,e)}dt.BREAK=fo;dt.SKIP=Cv;dt.REMOVE=Ul;dt.itemAtPath=(t,e)=>{let i=t;for(let[r,n]of e){let a=i?.[r];if(a&&"items"in a)i=a.items[n];else return}return i};dt.parentCollection=(t,e)=>{let i=dt.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Kl(t,e,i){let r=i(e,t);if(typeof r=="symbol")return r;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=Kl(Object.freeze(t.concat([[n,o]])),a.items[o],i);if(typeof s=="number")o=s-1;else{if(s===fo)return fo;s===Ul&&(a.items.splice(o,1),o-=1)}}typeof r=="function"&&n==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Yl.visit=dt});var Fr=w(W=>{"use strict";var ho=zl(),Rv=Gl(),Av=Xl(),po="\uFEFF",mo="",vo="",go="",_v=t=>!!t&&"items"in t,Tv=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function Iv(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=r,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:r}];Kl(s,"end"in t?t.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
+ `});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:s,source:n})}}function Kl(t,e){if(e)for(let i of e)switch(i.type){case"space":case"comment":t.push(i);break;case"newline":return t.push(i),!0}return!1}function mo(t,e,i){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=i,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let a of r)a.offset+=n;delete t.props,Object.assign(t,{type:i,source:e,end:r});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:i,source:e,end:[n]});break}default:{let r="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:i,indent:r,source:e,end:n})}}}Mr.createScalarToken=Av;Mr.resolveAsScalar=Rv;Mr.setScalarValue=_v});var Ql=w(Xl=>{"use strict";var Iv=t=>"type"in t?Vr(t):Fr(t);function Vr(t){switch(t.type){case"block-scalar":{let e="";for(let i of t.props)e+=Vr(i);return e+t.source}case"block-map":case"block-seq":{let e="";for(let i of t.items)e+=Fr(i);return e}case"flow-collection":{let e=t.start.source;for(let i of t.items)e+=Fr(i);for(let i of t.end)e+=i.source;return e}case"document":{let e=Fr(t);if(t.end)for(let i of t.end)e+=i.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let i of t.end)e+=i.source;return e}}}function Fr({start:t,key:e,sep:i,value:r}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Vr(e)),i)for(let a of i)n+=a.source;return r&&(n+=Vr(r)),n}Xl.stringify=Iv});var iu=w(tu=>{"use strict";var vo=Symbol("break visit"),jv=Symbol("skip children"),Zl=Symbol("remove item");function ht(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),eu(Object.freeze([]),t,e)}ht.BREAK=vo;ht.SKIP=jv;ht.REMOVE=Zl;ht.itemAtPath=(t,e)=>{let i=t;for(let[r,n]of e){let a=i?.[r];if(a&&"items"in a)i=a.items[n];else return}return i};ht.parentCollection=(t,e)=>{let i=ht.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function eu(t,e,i){let r=i(e,t);if(typeof r=="symbol")return r;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=eu(Object.freeze(t.concat([[n,o]])),a.items[o],i);if(typeof s=="number")o=s-1;else{if(s===vo)return vo;s===Zl&&(a.items.splice(o,1),o-=1)}}typeof r=="function"&&n==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}tu.visit=ht});var qr=w(W=>{"use strict";var go=Yl(),$v=Ql(),Ov=iu(),wo="\uFEFF",yo="",No="",bo="",Hv=t=>!!t&&"items"in t,Dv=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function Bv(t){switch(t){case wo:return"<BOM>";case yo:return"<DOC>";case No:return"<FLOW_END>";case bo:return"<SCALAR>";default:return JSON.stringify(t)}}function Lv(t){switch(t){case wo:return"byte-order-mark";case yo:return"doc-mode";case No:return"flow-error-end";case bo: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}W.createScalarToken=ho.createScalarToken;W.resolveAsScalar=ho.resolveAsScalar;W.setScalarValue=ho.setScalarValue;W.stringify=Rv.stringify;W.visit=Av.visit;W.BOM=po;W.DOCUMENT=mo;W.FLOW_END=vo;W.SCALAR=go;W.isCollection=_v;W.isScalar=Tv;W.prettyToken=Iv;W.tokenType=jv});var No=w(Zl=>{"use strict";var Ni=Fr();function de(t){switch(t){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var Ql=new Set("0123456789ABCDEFabcdef"),$v=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Vr=new Set(",[]{}"),Ov=new Set(` ,[]{}
121
- \r `),wo=t=>!t||Ov.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,i=!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=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,i=this.buffer[e];for(;i===" "||i===" ";)i=this.buffer[++e];return!i||i==="#"||i===`
119
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(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}W.createScalarToken=go.createScalarToken;W.resolveAsScalar=go.resolveAsScalar;W.setScalarValue=go.setScalarValue;W.stringify=$v.stringify;W.visit=Ov.visit;W.BOM=wo;W.DOCUMENT=yo;W.FLOW_END=No;W.SCALAR=bo;W.isCollection=Hv;W.isScalar=Dv;W.prettyToken=Bv;W.tokenType=Lv});var Eo=w(nu=>{"use strict";var bi=qr();function ue(t){switch(t){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var ru=new Set("0123456789ABCDEFabcdef"),Mv=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Wr=new Set(",[]{}"),Fv=new Set(` ,[]{}
121
+ \r `),ko=t=>!t||Fv.has(t),So=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,i=!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=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,i=this.buffer[e];for(;i===" "||i===" ";)i=this.buffer[++e];return!i||i==="#"||i===`
122
122
  `?!0:i==="\r"?this.buffer[e+1]===`
123
123
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let i=this.buffer[e];if(this.indentNext>0){let r=0;for(;i===" ";)i=this.buffer[++r+e];if(i==="\r"){let n=this.buffer[r+e+1];if(n===`
124
124
  `||!n&&!this.atEnd)return e+r+1}return i===`
125
- `||r>=this.indentNext||!i&&!this.atEnd?e+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&de(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]===Ni.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let i=e.length,r=e.indexOf("#");for(;r!==-1;){let a=e[r-1];if(a===" "||a===" "){i=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let a=e[i-1];if(a===" "||a===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-i),yield*this.pushNewline(),"stream"}return yield Ni.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 i=this.peek(3);if((i==="---"||i==="...")&&de(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,i==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!de(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&de(i)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(e[i]){case"#":yield*this.pushCount(e.length-i);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(wo),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,i,r=-1;do e=yield*this.pushNewline(),e>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(e+i>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&de(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Ni.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||de(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),i=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;i!==-1&&this.buffer[i+1]==="'";)i=this.buffer.indexOf("'",i+2);else for(;i!==-1;){let a=0;for(;this.buffer[i-1-a]==="\\";)a+=1;if(a%2===0)break;i=this.buffer.indexOf('"',i+1)}let r=this.buffer.substring(0,i),n=r.indexOf(`
125
+ `||r>=this.indentNext||!i&&!this.atEnd?e+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&ue(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]===bi.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let i=e.length,r=e.indexOf("#");for(;r!==-1;){let a=e[r-1];if(a===" "||a===" "){i=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let a=e[i-1];if(a===" "||a===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-i),yield*this.pushNewline(),"stream"}return yield bi.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 i=this.peek(3);if((i==="---"||i==="...")&&ue(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,i==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ue(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ue(i)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(e[i]){case"#":yield*this.pushCount(e.length-i);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(ko),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,i,r=-1;do e=yield*this.pushNewline(),e>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(e+i>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&ue(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield bi.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(ko),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ue(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),i=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;i!==-1&&this.buffer[i+1]==="'";)i=this.buffer.indexOf("'",i+2);else for(;i!==-1;){let a=0;for(;this.buffer[i-1-a]==="\\";)a+=1;if(a%2===0)break;i=this.buffer.indexOf('"',i+1)}let r=this.buffer.substring(0,i),n=r.indexOf(`
127
127
  `,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=r.indexOf(`
128
- `,a)}n!==-1&&(i=n-(r[n-1]==="\r"?2:1))}if(i===-1){if(!this.atEnd)return this.setNext("quoted-scalar");i=this.buffer.length}return yield*this.pushToIndex(i+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let i=this.buffer[++e];if(i==="+")this.blockScalarKeep=!0;else if(i>"0"&&i<="9")this.blockScalarIndent=Number(i)-1;else if(i!=="-")break}return yield*this.pushUntil(i=>de(i)||i==="#")}*parseBlockScalar(){let e=this.pos-1,i=0,r;e:for(let a=this.pos;r=this.buffer[a];++a)switch(r){case" ":i+=1;break;case`
128
+ `,a)}n!==-1&&(i=n-(r[n-1]==="\r"?2:1))}if(i===-1){if(!this.atEnd)return this.setNext("quoted-scalar");i=this.buffer.length}return yield*this.pushToIndex(i+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let i=this.buffer[++e];if(i==="+")this.blockScalarKeep=!0;else if(i>"0"&&i<="9")this.blockScalarIndent=Number(i)-1;else if(i!=="-")break}return yield*this.pushUntil(i=>ue(i)||i==="#")}*parseBlockScalar(){let e=this.pos-1,i=0,r;e:for(let a=this.pos;r=this.buffer[a];++a)switch(r){case" ":i+=1;break;case`
129
129
  `:e=a,i=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
130
130
  `)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(i>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=i:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(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(r=this.buffer[n];r===" ";)r=this.buffer[++n];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
132
132
  `;)r=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+i>s)e=a;else break}while(!0);return yield Ni.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,i=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let a=this.buffer[r+1];if(de(a)||e&&Vr.has(a))break;i=r}else if(de(n)){let a=this.buffer[r+1];if(n==="\r"&&(a===`
133
+ `&&a>=this.pos&&a+1+i>s)e=a;else break}while(!0);return yield bi.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,i=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let a=this.buffer[r+1];if(ue(a)||e&&Wr.has(a))break;i=r}else if(ue(n)){let a=this.buffer[r+1];if(n==="\r"&&(a===`
134
134
  `?(r+=1,n=`
135
- `,a=this.buffer[r+1]):i=r),a==="#"||e&&Vr.has(a))break;if(n===`
136
- `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Vr.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Ni.SCALAR,yield*this.pushToIndex(i+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,i){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(i&&(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 i=this.flowLevel>0,r=this.charAt(1);if(de(r)||i&&Vr.has(r)){i?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,i=this.buffer[e];for(;!de(i)&&i!==">";)i=this.buffer[++e];return yield*this.pushToIndex(i===">"?e+1:e,!1)}else{let e=this.pos+1,i=this.buffer[e];for(;i;)if($v.has(i))i=this.buffer[++e];else if(i==="%"&&Ql.has(this.buffer[e+1])&&Ql.has(this.buffer[e+2]))i=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[r+1]):i=r),a==="#"||e&&Wr.has(a))break;if(n===`
136
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Wr.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield bi.SCALAR,yield*this.pushToIndex(i+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,i){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(i&&(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(ko),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let i=this.flowLevel>0,r=this.charAt(1);if(ue(r)||i&&Wr.has(r)){i?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,i=this.buffer[e];for(;!ue(i)&&i!==">";)i=this.buffer[++e];return yield*this.pushToIndex(i===">"?e+1:e,!1)}else{let e=this.pos+1,i=this.buffer[e];for(;i;)if(Mv.has(i))i=this.buffer[++e];else if(i==="%"&&ru.has(this.buffer[e+1])&&ru.has(this.buffer[e+2]))i=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 i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||e&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(e){let i=this.pos,r=this.buffer[i];for(;!e(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};Zl.Lexer=yo});var ko=w(eu=>{"use strict";var bo=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let i=0,r=this.lineStarts.length;for(;i<r;){let a=i+r>>1;this.lineStarts[a]<e?i=a+1:r=a}if(this.lineStarts[i]===e)return{line:i+1,col:1};if(i===0)return{line:0,col:e};let n=this.lineStarts[i-1];return{line:i,col:e-n+1}}}};eu.LineCounter=bo});var Eo=w(au=>{"use strict";var Hv=Gi("process"),tu=Fr(),Dv=No();function Ge(t,e){for(let i=0;i<t.length;++i)if(t[i].type===e)return!0;return!1}function iu(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 nu(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 qr(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 Wr(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let i=0;i<e.length;++i)t.push(e[i])}function ru(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,nu(e.value)?e.value.end?Wr(e.value.end,e.sep):e.value.end=e.sep:Wr(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 Dv.Lexer,this.onNewLine=e}*parse(e,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,i))yield*this.next(r);i||(yield*this.end())}*next(e){if(this.source=e,Hv.env.LOG_TOKENS&&console.log("|",tu.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let i=tu.tokenType(e);if(i)if(i==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=i,yield*this.step(),i){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+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 r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,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 i=e??this.stack.pop();if(!i)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield i;else{let r=this.peek(1);switch(i.type==="block-scalar"?i.indent="indent"in r?r.indent:0:i.type==="flow-collection"&&r.type==="document"&&(i.indent=0),i.type==="flow-collection"&&ru(i),r.type){case"document":r.value=i;break;case"block-scalar":r.props.push(i);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:i,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=i;else{Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];n.value?r.items.push({start:[],value:i}):n.value=i;break}case"flow-collection":{let n=r.items[r.items.length-1];!n||n.value?r.items.push({start:[],key:i,sep:[]}):n.sep?n.value=i:Object.assign(n,{key:i,sep:[]});return}default:yield*this.pop(),yield*this.pop(i)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(i.type==="block-map"||i.type==="block-seq")){let n=i.items[i.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&iu(n.start)===-1&&(i.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<i.indent))&&(r.type==="document"?r.end=n.start:r.items.push({start:n.start}),i.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let 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":{iu(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 i=this.startBlockValue(e);i?this.stack.push(i):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 i=qr(this.peek(2)),r=At(i),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:r,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 i=this.source.indexOf(`
138
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||e&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(e){let i=this.pos,r=this.buffer[i];for(;!e(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};nu.Lexer=So});var Po=w(au=>{"use strict";var xo=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let i=0,r=this.lineStarts.length;for(;i<r;){let a=i+r>>1;this.lineStarts[a]<e?i=a+1:r=a}if(this.lineStarts[i]===e)return{line:i+1,col:1};if(i===0)return{line:0,col:e};let n=this.lineStarts[i-1];return{line:i,col:e-n+1}}}};au.LineCounter=xo});var Ro=w(uu=>{"use strict";var Vv=Ki("process"),ou=qr(),qv=Eo();function Ue(t,e){for(let i=0;i<t.length;++i)if(t[i].type===e)return!0;return!1}function su(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 lu(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 zr(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 Jr(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let i=0;i<e.length;++i)t.push(e[i])}function cu(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Ue(e.start,"explicit-key-ind")&&!Ue(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,lu(e.value)?e.value.end?Jr(e.value.end,e.sep):e.value.end=e.sep:Jr(e.start,e.sep),delete e.sep)}var Co=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 qv.Lexer,this.onNewLine=e}*parse(e,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,i))yield*this.next(r);i||(yield*this.end())}*next(e){if(this.source=e,Vv.env.LOG_TOKENS&&console.log("|",ou.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let i=ou.tokenType(e);if(i)if(i==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=i,yield*this.step(),i){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+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 r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,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 i=e??this.stack.pop();if(!i)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield i;else{let r=this.peek(1);switch(i.type==="block-scalar"?i.indent="indent"in r?r.indent:0:i.type==="flow-collection"&&r.type==="document"&&(i.indent=0),i.type==="flow-collection"&&cu(i),r.type){case"document":r.value=i;break;case"block-scalar":r.props.push(i);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:i,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=i;else{Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];n.value?r.items.push({start:[],value:i}):n.value=i;break}case"flow-collection":{let n=r.items[r.items.length-1];!n||n.value?r.items.push({start:[],key:i,sep:[]}):n.sep?n.value=i:Object.assign(n,{key:i,sep:[]});return}default:yield*this.pop(),yield*this.pop(i)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(i.type==="block-map"||i.type==="block-seq")){let n=i.items[i.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&su(n.start)===-1&&(i.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<i.indent))&&(r.type==="document"?r.end=n.start:r.items.push({start:n.start}),i.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let 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":{su(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 i=this.startBlockValue(e);i?this.stack.push(i):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 i=zr(this.peek(2)),r=Tt(i),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:r,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 i=this.source.indexOf(`
139
139
  `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
140
- `,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Wr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&i.sep&&!i.value){let o=[];for(let s=0;s<i.sep.length;++s){let c=i.sep[s];switch(c.type){case"newline":o.push(s);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=i.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||i.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):n||i.value?(a.push(this.sourceToken),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(i.explicitKey)if(i.sep)if(i.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ge(i.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(nu(i.key)&&!Ge(i.sep,"newline")){let o=At(i.start),s=i.key,c=i.sep;c.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?i.sep=i.sep.concat(a,this.sourceToken):i.sep.push(this.sourceToken);else if(Ge(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let o=At(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||n?e.items.push({start:a,key:null,sep:[this.sourceToken]}):Ge(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||i.value?(e.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(o):(Object.assign(i,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!i.explicitKey&&i.sep&&!Ge(i.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Wr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=e.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;i.value||Ge(i.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let i=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!i||i.value?e.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!i||i.value?e.items.push({start:[],key:n,sep:[]}):i.sep?this.stack.push(n):Object.assign(i,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=qr(r),a=At(n);ru(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 i=this.source.indexOf(`
140
+ `,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Jr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&i.sep&&!i.value){let o=[];for(let s=0;s<i.sep.length;++s){let c=i.sep[s];switch(c.type){case"newline":o.push(s);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=i.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||i.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):n||i.value?(a.push(this.sourceToken),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(i.explicitKey)if(i.sep)if(i.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ue(i.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(lu(i.key)&&!Ue(i.sep,"newline")){let o=Tt(i.start),s=i.key,c=i.sep;c.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?i.sep=i.sep.concat(a,this.sourceToken):i.sep.push(this.sourceToken);else if(Ue(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let o=Tt(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||n?e.items.push({start:a,key:null,sep:[this.sourceToken]}):Ue(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||i.value?(e.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(o):(Object.assign(i,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!i.explicitKey&&i.sep&&!Ue(i.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Jr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=e.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;i.value||Ue(i.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let i=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!i||i.value?e.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!i||i.value?e.items.push({start:[],key:n,sep:[]}):i.sep?this.stack.push(n):Object.assign(i,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=zr(r),a=Tt(n);cu(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 i=this.source.indexOf(`
141
141
  `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
142
- `,i)+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 i=qr(e),r=At(i);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=qr(e),r=At(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,i){return this.type!=="comment"||this.indent<=i?!1:e.every(r=>r.type==="newline"||r.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())}}};au.Parser=So});var uu=w(ki=>{"use strict";var ou=lo(),Bv=hi(),bi=vi(),Lv=sa(),Mv=P(),Fv=ko(),su=Eo();function cu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Fv.LineCounter||null,prettyErrors:e}}function Vv(t,e={}){let{lineCounter:i,prettyErrors:r}=cu(e),n=new su.Parser(i?.addNewLine),a=new ou.Composer(e),o=Array.from(a.compose(n.parse(t)));if(r&&i)for(let s of o)s.errors.forEach(bi.prettifyError(t,i)),s.warnings.forEach(bi.prettifyError(t,i));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function lu(t,e={}){let{lineCounter:i,prettyErrors:r}=cu(e),n=new su.Parser(i?.addNewLine),a=new ou.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 bi.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(o.errors.forEach(bi.prettifyError(t,i)),o.warnings.forEach(bi.prettifyError(t,i))),o}function qv(t,e,i){let r;typeof e=="function"?r=e:i===void 0&&e&&typeof e=="object"&&(i=e);let n=lu(t,i);if(!n)return null;if(n.warnings.forEach(a=>Lv.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:r},i))}function Wv(t,e,i){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:i===void 0&&e&&(i=e),typeof i=="string"&&(i=i.length),typeof i=="number"){let n=Math.round(i);i=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=i??e??{};if(!n)return}return Mv.isDocument(t)&&!r?t.toString(i):new Bv.Document(t,r,i).toString(i)}ki.parse=qv;ki.parseAllDocuments=Vv;ki.parseDocument=lu;ki.stringify=Wv});var _t=w(C=>{"use strict";var zv=lo(),Jv=hi(),Gv=qa(),Po=vi(),Uv=Xt(),Ue=P(),Kv=qe(),Yv=j(),Xv=ze(),Qv=Je(),Zv=Fr(),eg=No(),tg=ko(),ig=Eo(),zr=uu(),du=Gt();C.Composer=zv.Composer;C.Document=Jv.Document;C.Schema=Gv.Schema;C.YAMLError=Po.YAMLError;C.YAMLParseError=Po.YAMLParseError;C.YAMLWarning=Po.YAMLWarning;C.Alias=Uv.Alias;C.isAlias=Ue.isAlias;C.isCollection=Ue.isCollection;C.isDocument=Ue.isDocument;C.isMap=Ue.isMap;C.isNode=Ue.isNode;C.isPair=Ue.isPair;C.isScalar=Ue.isScalar;C.isSeq=Ue.isSeq;C.Pair=Kv.Pair;C.Scalar=Yv.Scalar;C.YAMLMap=Xv.YAMLMap;C.YAMLSeq=Qv.YAMLSeq;C.CST=Zv;C.Lexer=eg.Lexer;C.LineCounter=tg.LineCounter;C.Parser=ig.Parser;C.parse=zr.parse;C.parseAllDocuments=zr.parseAllDocuments;C.parseDocument=zr.parseDocument;C.stringify=zr.stringify;C.visit=du.visit;C.visitAsync=du.visitAsync});import Tg from"path";var Si=Jt(_t(),1);import Gr from"path";var Ei=64*1024,Ur=1024,Kr=64,Co=5,rg=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],ng=["**/.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"],ag=[...rg,...ng].sort((t,e)=>t.localeCompare(e,"en"));var Y={include:["**/*"],exclude:[...ag],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4},Jr={en:{schema:"# Configuration schema used by Comet. Do not edit this value.",default_workflow:"# Default workflow entered by /comet. Must also appear in workflows.",workflows:"# Workflows enabled in this project: native, classic, or both.",ambient_resume:`# Enables automatic recovery through the read-only Ambient Resume probe for both Native and Classic. Set false to disable it.
142
+ `,i)+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 i=zr(e),r=Tt(i);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=zr(e),r=Tt(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,i){return this.type!=="comment"||this.indent<=i?!1:e.every(r=>r.type==="newline"||r.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())}}};uu.Parser=Co});var mu=w(Si=>{"use strict";var du=po(),Wv=pi(),ki=gi(),zv=da(),Jv=x(),Gv=Po(),fu=Ro();function hu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Gv.LineCounter||null,prettyErrors:e}}function Uv(t,e={}){let{lineCounter:i,prettyErrors:r}=hu(e),n=new fu.Parser(i?.addNewLine),a=new du.Composer(e),o=Array.from(a.compose(n.parse(t)));if(r&&i)for(let s of o)s.errors.forEach(ki.prettifyError(t,i)),s.warnings.forEach(ki.prettifyError(t,i));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function pu(t,e={}){let{lineCounter:i,prettyErrors:r}=hu(e),n=new fu.Parser(i?.addNewLine),a=new du.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 ki.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(o.errors.forEach(ki.prettifyError(t,i)),o.warnings.forEach(ki.prettifyError(t,i))),o}function Kv(t,e,i){let r;typeof e=="function"?r=e:i===void 0&&e&&typeof e=="object"&&(i=e);let n=pu(t,i);if(!n)return null;if(n.warnings.forEach(a=>zv.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:r},i))}function Yv(t,e,i){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:i===void 0&&e&&(i=e),typeof i=="string"&&(i=i.length),typeof i=="number"){let n=Math.round(i);i=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=i??e??{};if(!n)return}return Jv.isDocument(t)&&!r?t.toString(i):new Wv.Document(t,r,i).toString(i)}Si.parse=Kv;Si.parseAllDocuments=Uv;Si.parseDocument=pu;Si.stringify=Yv});var It=w(C=>{"use strict";var Xv=po(),Qv=pi(),Zv=Ga(),Ao=gi(),eg=Qt(),Ke=x(),tg=We(),ig=j(),rg=Je(),ng=Ge(),ag=qr(),og=Eo(),sg=Po(),cg=Ro(),Gr=mu(),vu=Ut();C.Composer=Xv.Composer;C.Document=Qv.Document;C.Schema=Zv.Schema;C.YAMLError=Ao.YAMLError;C.YAMLParseError=Ao.YAMLParseError;C.YAMLWarning=Ao.YAMLWarning;C.Alias=eg.Alias;C.isAlias=Ke.isAlias;C.isCollection=Ke.isCollection;C.isDocument=Ke.isDocument;C.isMap=Ke.isMap;C.isNode=Ke.isNode;C.isPair=Ke.isPair;C.isScalar=Ke.isScalar;C.isSeq=Ke.isSeq;C.Pair=tg.Pair;C.Scalar=ig.Scalar;C.YAMLMap=rg.YAMLMap;C.YAMLSeq=ng.YAMLSeq;C.CST=ag;C.Lexer=og.Lexer;C.LineCounter=sg.LineCounter;C.Parser=cg.Parser;C.parse=Gr.parse;C.parseAllDocuments=Gr.parseAllDocuments;C.parseDocument=Gr.parseDocument;C.stringify=Gr.stringify;C.visit=vu.visit;C.visitAsync=vu.visitAsync});import Mg from"path";var Ei=Gt(It(),1);import jt from"path";var xi=64*1024,Kr=1024,Yr=64,To=5,lg=12e4,gu=6e5,ug=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],dg=["**/.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=[...ug,...dg].sort((t,e)=>t.localeCompare(e,"en"));var Y={include:["**/*"],exclude:[...fg],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4},Ur={en:{schema:"# Configuration schema used by Comet. Do not edit this value.",default_workflow:"# Default workflow entered by /comet. Must also appear in workflows.",workflows:"# Workflows enabled in this project: native, classic, or both.",ambient_resume:`# Enables automatic recovery through the read-only Ambient Resume probe for both Native and Classic. Set false to disable it.
143
143
  # ambient_resume: true | false`,hook:"# Hook write policy shared by Native and Classic. Paths are project-relative.","hook.allow_paths":"# Project-relative directories allowed during guarded phases. Use one path per list item; empty by default.",native:"# Native workflow settings. They do not change Classic state or behavior.","native.artifact_root":"# Root directory where Native stores Comet specs and changes. Runtime data stays under .comet.","native.language":`# Artifact language used by Native workflow documents.
144
144
  # language: en | zh-CN`,"native.clarification_mode":`# Controls how Native asks clarifying questions: batch asks every currently answerable question per round (default), sequential asks one at a time.
145
145
  # clarification_mode: batch | sequential`,"native.archive_confirmation":`# Controls whether Native archives automatically after a successful preview or waits for explicit user confirmation.
146
- # archive_confirmation: automatic | required`,"native.max_verify_failures":"# Maximum failed Verify outcomes allowed for one confirmed acceptance target before Native stops the completion loop.","native.snapshot":"# Controls the auditable project scope and bounded work used by Native content snapshots.","native.snapshot.include":"# Selects the project-relative paths included in Native snapshots. Patterns use / and support *, **, and ?.","native.snapshot.exclude":"# Removes paths from the included scope. Exclusions are bound into each new change baseline.","native.snapshot.max_files":"# Bounds the number of files captured by one snapshot. Increase it for large monorepos.","native.snapshot.max_total_bytes":"# Bounds the total file content hashed by one snapshot. Content is streamed and does not depend on Git hashes.","native.snapshot.max_duration_ms":"# Bounds snapshot capture time in milliseconds. Increase it together with the byte budget on slower or larger repositories.",classic:"# Classic workflow settings. They do not change Native state or behavior.","classic.artifact_layout":`# Selects the Classic artifact layout. The default is docs; update preserves detected root-level legacy artifacts.
146
+ # archive_confirmation: automatic | required`,"native.max_verify_failures":"# Maximum failed Verify outcomes allowed for one confirmed acceptance target before Native stops the completion loop.","native.finish":"# Optional repository-owned finish providers. Native keeps commit, push, generic remote verification, and recovery ownership.","native.snapshot":"# Controls the auditable project scope and bounded work used by Native content snapshots.","native.snapshot.include":"# Selects the project-relative paths included in Native snapshots. Patterns use / and support *, **, and ?.","native.snapshot.exclude":"# Removes paths from the included scope. Exclusions are bound into each new change baseline.","native.snapshot.max_files":"# Bounds the number of files captured by one snapshot. Increase it for large monorepos.","native.snapshot.max_total_bytes":"# Bounds the total file content hashed by one snapshot. Content is streamed and does not depend on Git hashes.","native.snapshot.max_duration_ms":"# Bounds snapshot capture time in milliseconds. Increase it together with the byte budget on slower or larger repositories.",classic:"# Classic workflow settings. They do not change Native state or behavior.","classic.artifact_layout":`# Selects the Classic artifact layout. The default is docs; update preserves detected root-level legacy artifacts.
147
147
  # artifact_layout: legacy | docs`,"classic.language":`# Artifact language used by Classic workflow documents.
148
148
  # language: en | zh-CN`,"classic.context_compression":`# Controls beta context compression for new Classic changes.
149
149
  # context_compression: off | beta`,"classic.review_mode":`# Sets the default review depth for new Classic changes.
@@ -152,27 +152,27 @@ ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.pus
152
152
  # ambient_resume: true | false`,hook:"# Native 和 Classic 共享的 Hook 写入策略;路径必须是项目相对路径。","hook.allow_paths":"# 在受保护阶段允许写入的项目相对目录;每项填写一个目录,默认为空。",native:"# Native 工作流配置,不会改变 Classic 的状态或行为。","native.artifact_root":"# Native 规格和 change 的存放根目录;运行时数据始终位于 .comet。","native.language":`# Native 工作流文档使用的产物语言。
153
153
  # 可选值:en | zh-CN`,"native.clarification_mode":`# Native 提问澄清问题的方式:batch 每轮一次提出当前所有可回答的问题(默认),sequential 每轮只问一个。
154
154
  # 可选值:batch | sequential`,"native.archive_confirmation":`# Native 归档检查成功后自动归档,或等待用户明确确认。
155
- # 可选值:automatic | required`,"native.max_verify_failures":"# 同一个已确认验收目标最多允许的 Verify 失败次数;达到上限后停止完成循环。","native.snapshot":"# Native 内容快照使用的可审计项目范围与有界工作预算。","native.snapshot.include":"# Native 快照纳入的项目相对路径;模式使用 /,支持 *、** 和 ?。","native.snapshot.exclude":"# 从纳入范围中排除路径;新 change 会把排除策略绑定到 baseline。","native.snapshot.max_files":"# 单次快照最多捕获的文件数;大型 monorepo 可按需提高。","native.snapshot.max_total_bytes":"# 单次快照最多哈希的文件内容总字节数;内容采用流式读取,不依赖 Git hash。","native.snapshot.max_duration_ms":"# 单次快照的最长执行时间(毫秒);较慢或更大的仓库应与字节预算一并提高。",classic:"# Classic 工作流配置,不会改变 Native 的状态或行为。","classic.artifact_layout":`# Classic 产物布局;默认使用 docs,update 检测到根目录 legacy 产物时予以保留。
155
+ # 可选值:automatic | required`,"native.max_verify_failures":"# 同一个已确认验收目标最多允许的 Verify 失败次数;达到上限后停止完成循环。","native.finish":"# 可选的仓库自有收尾 provider;提交、推送、通用远端核验和恢复仍由 Native 负责。","native.snapshot":"# Native 内容快照使用的可审计项目范围与有界工作预算。","native.snapshot.include":"# Native 快照纳入的项目相对路径;模式使用 /,支持 *、** 和 ?。","native.snapshot.exclude":"# 从纳入范围中排除路径;新 change 会把排除策略绑定到 baseline。","native.snapshot.max_files":"# 单次快照最多捕获的文件数;大型 monorepo 可按需提高。","native.snapshot.max_total_bytes":"# 单次快照最多哈希的文件内容总字节数;内容采用流式读取,不依赖 Git hash。","native.snapshot.max_duration_ms":"# 单次快照的最长执行时间(毫秒);较慢或更大的仓库应与字节预算一并提高。",classic:"# Classic 工作流配置,不会改变 Native 的状态或行为。","classic.artifact_layout":`# Classic 产物布局;默认使用 docs,update 检测到根目录 legacy 产物时予以保留。
156
156
  # 可选值:legacy | docs`,"classic.language":`# Classic 工作流文档使用的产物语言。
157
157
  # 可选值:en | zh-CN`,"classic.context_compression":`# 新建 Classic change 是否启用 beta 上下文压缩。
158
158
  # 可选值:off | beta`,"classic.review_mode":`# 新建 Classic change 默认使用的审查深度。
159
159
  # 可选值:off | standard | thorough`,"classic.auto_transition":`# Classic 阶段通过后是否自动进入下一阶段。
160
- # 可选值:true | false`}};function hu(t,e){return Jr[e][t]}function og(t,e,i){let r=/^(\s*)([a-z_]+):/u.exec(t);if(!r)return null;let n=r[1].length,a=r[2];if(n===0&&a in Jr.en)return a;if(n===2&&e){let o=`${e}.${a}`;if(o in Jr.en)return o}if(n===2&&e===null&&a==="hook")return"hook";if(n===2&&e==="hook"&&a==="allow_paths")return"hook.allow_paths";if(n===4&&e==="native"&&i==="snapshot"){let o=`native.snapshot.${a}`;if(o in Jr.en)return o}return null}function Pi(t,e){let i=[],r=null,n=null;for(let a of(0,Si.stringify)(t).trimEnd().split(`
161
- `)){let o=og(a,r,n);if(o){let s=a.match(/^\s*/u)?.[0]??"";for(let c of hu(o,e).split(`
160
+ # 可选值:true | false`}};function yu(t,e){return Ur[e][t]}function hg(t,e,i){let r=/^(\s*)([a-z_]+):/u.exec(t);if(!r)return null;let n=r[1].length,a=r[2];if(n===0&&a in Ur.en)return a;if(n===2&&e){let o=`${e}.${a}`;if(o in Ur.en)return o}if(n===2&&e===null&&a==="hook")return"hook";if(n===2&&e==="hook"&&a==="allow_paths")return"hook.allow_paths";if(n===4&&e==="native"&&i==="snapshot"){let o=`native.snapshot.${a}`;if(o in Ur.en)return o}return null}function Pi(t,e){let i=[],r=null,n=null;for(let a of(0,Ei.stringify)(t).trimEnd().split(`
161
+ `)){let o=hg(a,r,n);if(o){let s=a.match(/^\s*/u)?.[0]??"";for(let c of yu(o,e).split(`
162
162
  `))i.push(`${s}${c}`)}i.push(a),/^[a-z_]+:/u.test(a)?(a.startsWith("native:")?r="native":a.startsWith("classic:")?r="classic":a.startsWith("hook:")?r="hook":r=null,n=null):/^ {2}[a-z_]+:/u.test(a)&&r==="native"&&(n=a.startsWith(" snapshot:")?"snapshot":null)}return i.push(""),i.join(`
163
- `)}function sg(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim();if(i.length===0||Gr.posix.isAbsolute(i)||Gr.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function ft(t){let e=sg(t,"native.artifact_root");return e.length===0?".":e.join("/")}function pu(t,e="docs"){let i=t??e;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function Yr(t,e,i=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim().replaceAll("\\","/");if(r.length===0||Gr.posix.isAbsolute(r)||Gr.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let n=r.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(!i&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function It(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function mu(t,e,i){let r=t??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function Xr(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>Ur)throw new Error(`${e} exceeds ${Ur} characters`);let i=0;for(let r=0;r<t.length;r+=1)t[r]==="?"?i+=1:t[r]==="*"&&(i+=1,t[r+1]==="*"&&(r+=1));if(i>Kr)throw new Error(`${e} contains more than ${Kr} wildcard tokens`);return t}function fu(t,e,i){if(t===void 0)return[...i];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(r=>Xr(r,e)))].sort((r,n)=>r.localeCompare(n,"en"))}function xo(t,e,i){let r=t??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function cg(t){if(t===void 0)return{...Y,include:[...Y.include],exclude:[...Y.exclude]};let e=It(t,"native.snapshot");return{include:fu(e.include,"native.snapshot.include",Y.include),exclude:fu(e.exclude,"native.snapshot.exclude",Y.exclude),max_files:xo(e.max_files,Y.max_files,"native.snapshot.max_files"),max_total_bytes:xo(e.max_total_bytes,Y.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:xo(e.max_duration_ms,Y.max_duration_ms,"native.snapshot.max_duration_ms")}}function lg(t){if(t===void 0)return;let e=It(t,"native.pending_root_move"),i=e.id,r=e.from_artifact_root,n=e.to_artifact_root,a=e.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(e.cleanup!==void 0){let s=It(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:i,fromArtifactRoot:ft(r),toArtifactRoot:ft(n),stage:a,...o?{cleanup:o}:{}}}function ug(t,e={}){let i=It(t,"native"),r=i.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let n=i.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=i.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=i.max_verify_failures??Co;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=lg(i.pending_root_move);return{artifact_root:ft(r),language:mu(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:cg(i.snapshot),...s?{pending_root_move:s}:{}}}function dg(t){let e=It(t,"classic"),i=e.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="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:pu(e.artifact_layout),language:mu(e.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function fg(t){let i=It(t,"hook").allow_paths??[];if(!Array.isArray(i))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(i.map((r,n)=>Yr(r,`hook.allow_paths[${n}]`)))]}}function hg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function pg(t,e,i,r,n,a){let o=t.schema!==void 0;if(!(o||t.default_workflow!==void 0||t.workflows!==void 0||!a.allowPartialProject&&t.native!==void 0)||a.allowPartialProject&&!o)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 c=t.workflows??[t.default_workflow];if(!Array.isArray(c)||c.length===0||c.some(u=>u!=="native"&&u!=="classic"))throw new Error("workflows must contain native and/or classic");let l=[...new Set(c)];if(!l.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(l.includes("native")&&!i)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:l,ambient_resume:n,...e?{hook:e}:{},...i?{native:i}:{},...r?{classic:r}:{}}}function jt(t,e={}){let i=(0,Si.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let r=i.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=r,a=hg(n.ambient_resume),o=n.hook===void 0?void 0:fg(n.hook),s=n.native===void 0?void 0:ug(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),c=n.classic===void 0?void 0:dg(n.classic),l=pg(n,o,s,c,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:l,ambient_resume:a,...o?{hook:o}:{},...s?{native:s}:{},...c?{classic:c}:{}}}function vu(t){return{id:t.id,from_artifact_root:t.fromArtifactRoot,to_artifact_root:t.toArtifactRoot,stage:t.stage,...t.cleanup?{cleanup:{kind:t.cleanup.kind,state:t.cleanup.state,manifest_hash:t.cleanup.manifestHash}}:{}}}function gu(t){return{schema:t.schema,default_workflow:t.default_workflow,workflows:t.workflows??[t.default_workflow],ambient_resume:t.ambient_resume,...t.hook?{hook:{allow_paths:[...t.hook.allow_paths]}}:{},...t.native?{native:{artifact_root:t.native.artifact_root,language:t.native.language,clarification_mode:t.native.clarification_mode,archive_confirmation:t.native.archive_confirmation,max_verify_failures:t.native.max_verify_failures,...t.native.pending_root_move?{pending_root_move:vu(t.native.pending_root_move)}:{}}}:{},...t.classic?{classic:{artifact_layout:t.classic.artifact_layout,language:t.classic.language,context_compression:t.classic.context_compression,review_mode:t.classic.review_mode,auto_transition:t.classic.auto_transition}}:{}}}function Tt(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function xi(t,e){let i=gu(e),r=jt((0,Si.stringify)(i)).config;if(!r)throw new Error("Unsupported Comet project schema");let n={...t,schema:r.schema,default_workflow:r.default_workflow,workflows:r.workflows,ambient_resume:r.ambient_resume};if(r.hook&&(n.hook={...Tt(t.hook),allow_paths:[...r.hook.allow_paths]}),r.native){let a=Tt(t.native),o={...a,artifact_root:r.native.artifact_root,language:r.native.language,clarification_mode:r.native.clarification_mode,archive_confirmation:r.native.archive_confirmation,max_verify_failures:r.native.max_verify_failures};if(delete o.snapshot,r.native.pending_root_move){let s=Tt(a.pending_root_move),c=vu(r.native.pending_root_move),l=Tt(s.cleanup),u=Tt(c.cleanup);o.pending_root_move={...s,...c,...c.cleanup?{cleanup:{...l,...u}}:{}}}else delete o.pending_root_move;n.native=o}return r.classic&&(n.classic={...Tt(t.classic),artifact_layout:r.classic.artifact_layout,language:r.classic.language,context_compression:r.classic.context_compression,review_mode:r.classic.review_mode,auto_transition:r.classic.auto_transition}),n}function Qr(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:ft(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Co,snapshot:{...Y,include:[...Y.include],exclude:[...Y.exclude]}}}}import{createHash as vg}from"crypto";import{promises as tn}from"fs";import Ye from"path";import{constants as Zr,promises as ht}from"fs";function Ke(t){return t!==0&&t!==0n&&t!=="0"}function X(t,e){return Ke(t.dev)&&Ke(e.dev)&&Ke(t.ino)&&Ke(e.ino)}function T(t,e){let i=Ke(t.dev)&&Ke(e.dev);if(i&&t.dev!==e.dev)return!1;let r=Ke(t.ino)&&Ke(e.ino);return r&&t.ino!==e.ino?!1:i&&r?!0:t.birthtime===e.birthtime}var fe=class extends Error{reason;constructor(e,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=e}};function Ro(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function wu(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function Ci(t){return{dev:t.dev,ino:t.ino,birthtime:Ro(t)}}function en(t,e){let i=Ci(t),r=Ci(e);return X(i,r)?T(i,r):T(i,r)&&Ro(t)===Ro(e)&&wu(t)===wu(e)&&t.size===e.size}async function $t(t,e,i={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=i.label??"file",n=i.bigint===!0,a=await ht.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new fe("not-regular-file",`${r} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new fe("too-large",`${r} exceeds ${e} bytes`);let o=await ht.realpath(t);await i.verify?.("pre-open",{realPath:o,identity:Ci(a)});let s=process.platform==="win32"?Zr.O_RDONLY:Zr.O_RDONLY|Zr.O_NOFOLLOW|Zr.O_NONBLOCK,c;try{c=await ht.open(t,s)}catch(l){throw l.code==="ELOOP"?new fe("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,d]=await Promise.all([c.stat({bigint:n}),ht.lstat(t,{bigint:n}),ht.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!en(a,l)||!en(a,u))throw new fe("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:d,identity:Ci(l)}),await i.hooks?.afterOpen?.();let f=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let N=e+1-p,{bytesRead:k}=await c.read(v,0,Math.min(v.length,N),null);if(k===0)break;if(p+=k,p>e)throw new fe("too-large",`${r} exceeds ${e} bytes`);f.push(Buffer.from(v.subarray(0,k)))}await i.hooks?.beforeFinalCheck?.();let[h,m,y]=await Promise.all([c.stat({bigint:n}),ht.lstat(t,{bigint:n}),ht.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||y!==o||!en(a,h)||!en(a,m))throw new fe("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:y,identity:Ci(h)}),{bytes:Buffer.concat(f,p),stat:h,realPath:y}}finally{await c.close()}}function mg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Ao(t,e){let i=Ye.relative(t,e);return i===""||!Ye.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Ye.sep}`)}async function yu(t,e){let i=Ye.resolve(t),r=await tn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return tn.realpath(i)}async function Nu(t,e,i,r){let n=t;for(let a=0;a<i.length;a++){n=Ye.join(n,i[a]);let o;try{o=await tn.lstat(n)}catch(u){if(mg(u))return{exists:!1,kind:"missing"};throw u}let s=Ye.relative(t,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${s}`);let c=a===i.length-1;if(!c&&!o.isDirectory())throw new Error(`${r.label} ancestor ${s} must be a real directory`);if(c&&(r.expected==="file"&&!o.isFile()||r.expected==="directory"&&!o.isDirectory()||r.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await tn.realpath(n);if(!Ao(e,l))throw new Error(`${r.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function Ot(t,e,i){let r=Yr(e,i.label),n=Ye.resolve(t),a=await yu(n,i.label),o=r.split("/"),s=Ye.resolve(n,...o);if(!Ao(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await Nu(n,a,o,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function Xe(t,e,i,r){let n=await Ot(t,e,{label:r.label,expected:"file"});if(!n.exists){let o=new Error(`${r.label} does not exist`);throw o.code="ENOENT",o}let a=await yu(n.projectRoot,r.label);return $t(n.target,i,{...r,verify:async(o,s)=>{if(!Ao(a,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await Nu(n.projectRoot,a,n.relative.split("/"),{label:r.label,expected:"file"})}})}var Ri=".comet/config.yaml";function _o(t,e){return t.exists===e.exists&&t.sha256===e.sha256}function gg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function rn(t,e={}){return(await Ai(t,e)).document}async function bu(t){try{return(await Xe(t,Ri,Ei,{label:Ri})).bytes}catch(e){if(gg(e))return null;throw e}}function ku(t){return t?{exists:!0,sha256:vg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function nn(t){return ku(await bu(t))}async function Ai(t,e={}){let i=await bu(t);return{document:i?jt(i.toString("utf8"),e):null,identity:ku(i)}}async function To(t){return(await rn(t))?.config??null}var bS=16*1024;async function Io(t,e){if(!e)return;let i=await nn(t);if(!_o(i,e))throw new Error("Project config changed before commit; rerun the operation")}import{randomUUID as bg}from"crypto";import{promises as M}from"fs";import he from"path";function $o(t,e){let i=he.relative(t,e);return i===""||!he.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${he.sep}`)}function kg(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function jo(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return X(i,r)?T(i,r):T(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Su(t){let e=await M.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 M.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Ti(t){for(let e of t){let i=await M.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!kg(e,i)||await M.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Sg(t,e){let i=he.resolve(t),r=he.resolve(e);if(!$o(i,r))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Su(i)],a=he.relative(i,r).split(he.sep).filter(Boolean),o=i;for(let s of a){await Ti(n),o=he.join(o,s);try{await M.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Su(o);if(!$o(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await Ti(n),n}async function Eg(t){let e;try{e=await M.open(t,"r"),await e.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await e?.close()}}async function Pg(t,e,i={}){let r=he.dirname(t),n=i.containedRoot?await Sg(i.containedRoot,r):null;n||await M.mkdir(r,{recursive:!0});let a=he.join(r,`.${he.basename(t)}.${bg()}.tmp`),o,s;try{if(await i.beforeTemporaryOpen?.(),o=await M.open(a,"wx"),s=await o.stat(),n){let[c,l]=await Promise.all([M.lstat(a),M.realpath(a)]);if(await Ti(n),!c.isFile()||c.isSymbolicLink()||!jo(s,c)||!$o(n[0].realPath,l))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(),!jo(s,await o.stat()))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await i.beforeCommit?.(),n){await Ti(n);let c=await M.lstat(a);if(!c.isFile()||c.isSymbolicLink()||!s||!jo(c,s))throw new Error("Native atomic write temporary file changed before commit")}i.exclusive?(await M.link(a,t),await M.unlink(a)):await M.rename(a,t),await Eg(r)}catch(c){if(await o?.close(),!n)await M.rm(a,{force:!0});else try{await Ti(n),await M.rm(a,{force:!0})}catch{}throw c}}async function te(t,e,i={}){await Pg(t,e,i)}async function Se(t,e,i={}){await te(t,JSON.stringify(e,null,2)+`
164
- `,i)}import{existsSync as Eu,promises as Ae}from"fs";import R from"path";import xg from"os";var an=".comet/config.yaml",Cg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function Oo(t){try{return await Ae.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Rg(t){try{let e=await Ae.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 i=R.relative(t,e);return i===""||!R.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${R.sep}`)}async function Ht(t){let e=[],i=t;for(;!await Oo(i);){let n=R.dirname(i);if(n===i)break;e.push(R.basename(i)),i=n}let r=await Ae.realpath(i);return R.resolve(r,...e.reverse())}async function Ho(t){try{return(await Ae.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Do(t){let e=R.resolve(t);try{(await Ae.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let i=e,r=R.resolve(xg.homedir());for(;;){if(!(e===r&&i!==r)){let o=R.join(e,...an.split("/")),s=e===i||await Rg(o);if(await Oo(o)&&s)return e}if(await Oo(R.join(e,".git")))return e;let a=R.dirname(e);if(a===e)return i;e=a}}function Bo(t){return ft(t)}async function Ag(t,e){let i=Bo(e),r=R.resolve(t,...i.split("/")),n=await Ae.realpath(t),a=await Ht(r);if(!Dt(n,a))throw new Error("native.artifact_root resolves outside the project root");return r}async function _e(t,e){let i=Bo(e),r=await Ag(t,i),n=R.join(r,"comet");if(await Ho(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([Ht(r),Ht(n)]);if(!Dt(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=R.resolve(t),c=R.join(s,".comet","runtime","native");if(await Ho(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,u]=await Promise.all([Ae.realpath(s),Ht(c)]);if(!Dt(l,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(t,...an.split("/")),artifactRoot:r,artifactRootRef:i,nativeRoot:n,specsDir:R.join(n,"specs"),changesDir:R.join(n,"changes"),archiveDir:R.join(n,"archive"),runtimeDir:c,changesRuntimeDir:R.join(c,"changes"),locksDir:R.join(c,"locks"),transactionsDir:R.join(c,"transactions")}}async function Pu(t){await Promise.all([t.specsDir,t.changesDir,t.archiveDir].map(async e=>{await A(t.nativeRoot,e),await Ae.mkdir(e,{recursive:!0})})),await Promise.all([t.changesRuntimeDir,t.locksDir,t.transactionsDir].map(async e=>{await A(t.projectRoot,e),await Ae.mkdir(e,{recursive:!0})}))}function xu(t){if(!Cg.test(t))throw new Error(`Invalid Native change name: ${t}`)}function pt(t,e){xu(e);let i=R.join(t.changesRuntimeDir,e);if(!F(t.changesRuntimeDir,i))throw new Error("Native change Runtime path escaped");return i}function _g(t,e){xu(e);let i=R.join(t.changesDir,e,"runtime");if(!F(t.changesDir,i))throw new Error("Legacy Native change Runtime path escaped");return i}function ie(t,e){let i=pt(t,e);if(Eu(i))return i;let r=_g(t,e);return Eu(r)?r:i}function pe(t,e){let i=R.resolve(e);if(F(t.runtimeDir,i))return t.runtimeDir;if(F(t.nativeRoot,i))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function F(t,e){return Dt(R.resolve(t),R.resolve(e))}async function A(t,e){let i=R.resolve(t),r=R.resolve(e);if(!Dt(i,r))throw new Error(`Path is outside the Native root: ${e}`);if(await Ho(i))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([Ht(i),Ht(r)]);if(!Dt(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return r}var on=Xr;function Cu(t="docs",e="en"){return Qr(t,e)}async function z(t){let e=(await rn(t))?.config??null;return e?.native?e:null}async function sn(t){let e=await z(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function Ii(t,e,i={}){let r=await Ai(t,{allowPartialProject:!0}),n=xi(r.document?.value??{},e),a=Tg.join(t,...an.split("/"));await te(a,Pi(n,e.native.language==="zh-CN"?"zh-CN":"en"),{containedRoot:t,beforeCommit:async()=>{await i.beforeCommit?.(),await Io(t,r.identity)}})}function Ru(t,e){let i={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[]},r=n=>({kind:n,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...i,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:r("none")};if(t.status==="await-user")return t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...i,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","user-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:r("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...i,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","user-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:r("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...i,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--resolve-verifier-blocker"],requiredInputs:["summary","user-resolution"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...i,disposition:"await-user",action:"resolve-loop-stop",commandArgs:["comet","native","next",t.name,"--return-to-build","--summary","<summary>"],requiredInputs:["summary","user-decision"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")}:{...i,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:r("none")};if(t.status==="blocked"){let n=t.blockers.some(({resolution_action:a})=>a==="retry-verifier");return{...i,disposition:"blocked",action:n?"retry-verifier":"none",commandArgs:n?["comet","native","next",t.name,"--retry-verifier","--summary","<summary>"]:null,requiredInputs:n?["summary"]:["repair-runtime"],inputOptions:n?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:r(n?"retry-verifier":"none")}}if(t.phase==="shape")return{...i,disposition:"continue",action:"confirm-shape",commandArgs:["comet","native","next",t.name,"--summary","<summary>","--confirmed"],requiredInputs:["summary","shared-understanding-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:r("none")};if(t.phase==="build"){if(e){if(!e.confirmed)return{...i,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")};if(t.loop.stage==="repairing"&&t.verification_result==="fail")return{...i,disposition:"continue",action:"repair",commandArgs:null,requiredInputs:["repair-child"],inputOptions:[],runnerAction:r("none")};if(e.allDone)return{...i,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")};let n=e.children.some(({status:o})=>o==="blocked"),a=e.children.some(({status:o})=>o==="ready"||o==="active");return{...i,disposition:n&&!a?"blocked":"continue",action:"advance-children",commandArgs:null,requiredInputs:n&&!a?["resolve-child-blocker"]:["ready-children"],inputOptions:[],runnerAction:r("none")}}return{...i,disposition:"continue",action:t.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[]}}],runnerAction:r("builder-handoff")}}if(t.phase==="verify"){let n=t.loop.next_action==="await-verifier-result";return{...i,disposition:"continue",action:n?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[n?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:n?[{kind:"verifier-response",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}]}},{kind:"verifier-response",response:{kind:"final-result",result:{iteration:t.loop.iteration,attempt:t.loop.attempt,verdict:"<pass|fail|blocked>",acceptance:[{id:"<acceptance-id>",result:"<passed|failed|blocked>",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:[]}}],runnerAction:r(n?"await-verifier":"dispatch-verifier")}}return{...i,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:r("none")}}import{promises as rt}from"node:fs";import Wi from"node:path";import{execFileSync as Ig}from"child_process";import ji from"path";function Qe(t,e){return Ig("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function jg(t,e){let i=ji.normalize(t),r=ji.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function re(t){try{let e=ji.resolve(Qe(t,["rev-parse","--show-toplevel"])),r=Qe(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=r?ji.resolve(r.slice(9)):e,a=null;try{a=Qe(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!jg(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function cn(t){try{Qe(t,["rev-parse","--is-inside-work-tree"]);let e=Qe(t,["worktree","list","--porcelain"]).split(/\r?\n/u),i=[],r=null;for(let n of e)n.startsWith("worktree ")?(r&&i.push(r),r={root:ji.resolve(n.slice(9)),branch:null,detached:!1}):r&&n.startsWith("branch refs/heads/")?r.branch=n.slice(18):r&&n==="detached"&&(r.detached=!0);return r&&i.push(r),i}catch{return[]}}function $i(t){return cn(t).map(e=>e.root)}function Oi(t,e){try{return Qe(t,["check-ref-format","--branch",e]),Qe(t,["show-ref","--verify",`refs/heads/${e}`]),!0}catch{return!1}}function Lo(t,e){try{let i=Qe(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(i)?i:null}catch{return null}}import{createHash as Dg}from"node:crypto";import{promises as me}from"node:fs";import ne from"node:path";import{TextDecoder as Bg}from"node:util";var $g=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Og=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Hg(t){return t.toLowerCase().startsWith(".env")}function Hi(t){let i=t.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>Hg(r))?"environment-file":i.some(r=>Og.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>$g.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}var un=1024*1024;function Mo(t,e){let i=ne.relative(t,e);return i===""||!ne.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ne.sep}`)}function Lg(t){let e=ne.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})||ne.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 i=t.toLowerCase(),r=Hi(t);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${t}`);return t}function Mg(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Fg(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function ln(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return X(i,r)?T(i,r):T(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Au(t){let e=await me.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await me.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Vg(t,e){let i=ne.resolve(t),r=ne.resolve(e);if(!Mo(i,r))throw new Error("Native artifact path is outside its root");let n=[await Au(i)],a=i;for(let o of ne.relative(i,r).split(ne.sep).filter(Boolean)){a=ne.join(a,o);let s=await Au(a);if(!Mo(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function _u(t){for(let e of t){let i=await me.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!Fg(e,i)||await me.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function ae(t){let e=Lg(t.ref),i=t.maxBytes===null?null:Mg(t.maxBytes??un),r=ne.resolve(t.root,...e.split("/")),n=await Vg(t.root,ne.dirname(r));await t.hooks?.afterParentChainCaptured?.();let a=await me.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(i!==null&&a.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);let o=await me.realpath(r);if(!Mo(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await me.open(r,"r");try{let[c,l,u]=await Promise.all([s.stat(),me.lstat(r),me.realpath(r)]);if(await _u(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!ln(a,c)||!ln(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],f=0,p=Buffer.allocUnsafe(i===null?64*1024:Math.min(64*1024,i+1));for(;;){let k=i===null?p.length:i+1-f,S=await s.read(p,0,Math.min(p.length,k),null);if(S.bytesRead===0)break;if(f+=S.bytesRead,i!==null&&f>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);d.push(Buffer.from(p.subarray(0,S.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),me.lstat(r),me.realpath(r)]);if(await _u(n),!h.isFile()||h.isSymbolicLink()||m!==o||!ln(c,v)||!ln(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let y=Buffer.concat(d,f),N;try{N=new Bg("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:Dg("sha256").update(y).digest("hex"),text:N}}finally{await s.close()}}var yw=Jt(_t(),1);import{execFileSync as qg}from"node:child_process";var Wg=3e4,zg=8*1024*1024,Fo=class extends Error{constructor(i,r,n){super(`git ${r.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=i;this.args=r;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr};function Jg(t,e){try{return qg("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:Wg,maxBuffer:zg,windowsHide:!0})}catch(i){let r=typeof i.stderr=="string"?i.stderr.trim():Buffer.isBuffer(i.stderr)?i.stderr.toString("utf8").trim():"";throw new Fo(t,e,r)}}function Te(t,e){return Jg(t,e).trim()}function Tu(t){return Te(t,["status","--porcelain=v1","-z","--untracked-files=all"])===""}function Vo(t,e){Te(t,["check-ref-format","--branch",e])}import{createHash as Gg}from"crypto";function ve(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function Ug(t,e){e.has(t)&&ve("cyclic structures are not supported"),e.add(t);try{let i=Object.keys(t);for(let r=0;r<t.length;r+=1)Object.prototype.hasOwnProperty.call(t,r)||ve("sparse arrays are not supported");return(i.length!==t.length||i.some((r,n)=>r!==String(n)))&&ve("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&ve("symbol properties are not supported"),`[${t.map(r=>qo(r,e)).join(",")}]`}finally{e.delete(t)}}function Kg(t,e){let i=Object.getPrototypeOf(t);i!==Object.prototype&&i!==null&&ve("only plain objects are supported"),e.has(t)&&ve("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&ve("symbol properties are not supported"),e.add(t);try{let r=Object.getOwnPropertyDescriptors(t);return`{${Object.keys(t).sort().map(o=>{let s=r[o];return(!s||!("value"in s))&&ve("accessor properties are not supported"),`${JSON.stringify(o)}:${qo(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function qo(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)||ve("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?Ug(t,e):Kg(t,e);case"bigint":case"function":case"symbol":case"undefined":return ve(`${typeof t} values are not supported`)}return ve("unsupported value type")}function Wo(t){return qo(t,new Set)}function oe(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 Gg("sha256").update(`${t}
165
- ${Wo(e)}`).digest("hex")}var dn=Jt(_t(),1);import{promises as Yg}from"node:fs";var Bt="comet.native.v4",Di="comet.native.local-execution.v4";function zo(){return{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}}}var Xg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Qg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Zg=/^A[1-9][0-9]*$/u,ew=/^[a-f0-9]{64}$/u,tw=new Set(["schema","name","language","phase","status","state_version","brief","children_contract_hash","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]);function J(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function G(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function L(t,e,i){if(typeof t!="string"||!i?.empty&&t.length===0)throw new Error(`${e} must be ${i?.empty?"a string":"a non-empty string"}`);return t}function Jo(t,e){return t===null?null:L(t,e)}function iw(t,e){let i=L(t,e);if(!ew.test(i))throw new Error(`${e} must be a SHA-256 hash`);return i}function Lt(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function I(t,e,i=0){if(!Number.isSafeInteger(t)||t<i)throw new Error(`${e} must be a safe integer greater than or equal to ${i}`);return t}function rw(t,e){return t===null?null:I(t,e,Number.MIN_SAFE_INTEGER)}function B(t,e,i){if(typeof t!="string"||!e.includes(t))throw new Error(`${i} must be one of: ${e.join(", ")}`);return t}function Ee(t,e,i){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((r,n)=>i(r,n))}function fn(t,e){return Ee(t,e,(i,r)=>L(i,`${e}[${r}]`))}function mt(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Mt(t,e){let i=L(t,e);if(Number.isNaN(Date.parse(i)))throw new Error(`${e} must be an ISO date or timestamp`);return i}function Go(t,e,i=!1){let r=L(t,e);if(r.includes("\\")||r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").includes("..")||!i&&(r==="."||r.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return r}function ge(t,e){let i=J(t,e);return G(i,new Set(["text","truncated"]),e),{text:L(i.text,`${e}.text`,{empty:!0}),truncated:Lt(i.truncated,`${e}.truncated`)}}function nw(t,e){let i=`Native spec_changes[${e}]`,r=J(t,i);G(r,new Set(["capability","operation","source"]),i);let n=L(r.capability,`${i}.capability`);if(!Qg.test(n))throw new Error(`${i}.capability is invalid`);let a=B(r.operation,["create","modify","remove"],`${i}.operation`),o=r.source===null?null:Go(r.source,`${i}.source`);if(a==="remove"&&o!==null)throw new Error(`${i} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${i} ${a} requires a source`);return{capability:n,operation:a,source:o}}function aw(t){let e="Native workspace",i=J(t,e);G(i,new Set(["isolation","change_branch","target_branch","finish"]),e);let r=B(i.isolation,["current","branch","worktree"],`${e}.isolation`),n=Jo(i.change_branch,`${e}.change_branch`),a=Jo(i.target_branch,`${e}.target_branch`),o=i.finish===null?null:B(i.finish,["merge","push","pull-request","keep"],`${e}.finish`);if(r==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(r==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(r!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:r,change_branch:n,target_branch:a,finish:o}}function ow(t){let e="Native loop",i=J(t,e);G(i,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 r=fn(i.previous_unresolved_ids,`${e}.previous_unresolved_ids`);return mt(r,`${e}.previous_unresolved_ids`),{stage:B(i.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:I(i.goal_cycle,`${e}.goal_cycle`,1),iteration:I(i.iteration,`${e}.iteration`),attempt:I(i.attempt,`${e}.attempt`),retry_epoch:I(i.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:I(i.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:I(i.no_progress_count,`${e}.no_progress_count`),execution_failure_count:I(i.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:r,next_action:Jo(i.next_action,`${e}.next_action`)}}function sw(t,e){let i=`Native acceptance[${e}]`,r=J(t,i);G(r,new Set(["id","source","text","result","reason"]),i);let n=L(r.id,`${i}.id`);if(!Zg.test(n))throw new Error(`${i}.id must use A1, A2, ...`);return{id:n,source:Go(r.source,`${i}.source`),text:L(r.text,`${i}.text`),result:B(r.result,["pending","passed","failed","blocked"],`${i}.result`),reason:r.reason===null?null:ge(r.reason,`${i}.reason`)}}function cw(t,e){let i=`Native builder_handoff.checks[${e}]`,r=J(t,i);return G(r,new Set(["name","result","note"]),i),{name:ge(r.name,`${i}.name`),result:B(r.result,["passed","failed","not-run"],`${i}.result`),note:r.note===null?null:ge(r.note,`${i}.note`)}}function lw(t){let e="Native builder_handoff",i=J(t,e);G(i,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","submitted_at"]),e);let r=fn(i.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);return mt(r,`${e}.addressed_acceptance_ids`),{candidate_id:L(i.candidate_id,`${e}.candidate_id`),identity_provider:L(i.identity_provider,`${e}.identity_provider`),builder_execution_ref:L(i.builder_execution_ref,`${e}.builder_execution_ref`),iteration:I(i.iteration,`${e}.iteration`,1),summary:ge(i.summary,`${e}.summary`),addressed_acceptance_ids:r,checks:Ee(i.checks,`${e}.checks`,cw),checks_truncated:Lt(i.checks_truncated,`${e}.checks_truncated`),known_limits:Ee(i.known_limits,`${e}.known_limits`,(n,a)=>ge(n,`${e}.known_limits[${a}]`)),known_limits_truncated:Lt(i.known_limits_truncated,`${e}.known_limits_truncated`),submitted_at:Mt(i.submitted_at,`${e}.submitted_at`)}}function uw(t,e){let i=`Native blockers[${e}]`,r=J(t,i);G(r,new Set(["owner","reason","acceptance_ids","resolution_action"]),i);let n=fn(r.acceptance_ids,`${i}.acceptance_ids`);return mt(n,`${i}.acceptance_ids`),{owner:B(r.owner,["builder","runtime","verifier","user","external"],`${i}.owner`),reason:ge(r.reason,`${i}.reason`),acceptance_ids:n,resolution_action:B(r.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${i}.resolution_action`)}}function dw(t,e){let i=`Native verification.checks[${e}]`,r=J(t,i);return G(r,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),i),{id:L(r.id,`${i}.id`),name:ge(r.name,`${i}.name`),argv_display:Ee(r.argv_display,`${i}.argv_display`,(n,a)=>ge(n,`${i}.argv_display[${a}]`)),argv_truncated:Lt(r.argv_truncated,`${i}.argv_truncated`),cwd_ref:Go(r.cwd_ref,`${i}.cwd_ref`,!0),status:B(r.status,["passed","failed","interrupted"],`${i}.status`),exit_code:rw(r.exit_code,`${i}.exit_code`),duration_ms:I(r.duration_ms,`${i}.duration_ms`)}}function fw(t){let e="Native verification",i=J(t,e);G(i,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let r=Ee(i.checks,`${e}.checks`,dw);mt(r.map(a=>a.id),`${e}.checks IDs`);let n=L(i.identity_provider,`${e}.identity_provider`);return{candidate_id:L(i.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:L(i.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:I(i.iteration,`${e}.iteration`,1),attempt:I(i.attempt,`${e}.attempt`,1),assurance:i.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":B(i.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:B(i.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:r,summary:ge(i.summary,`${e}.summary`),risks:Ee(i.risks,`${e}.risks`,(a,o)=>ge(a,`${e}.risks[${o}]`)),risks_truncated:Lt(i.risks_truncated,`${e}.risks_truncated`),completed_at:Mt(i.completed_at,`${e}.completed_at`)}}function hw(t,e){let i=`Native history[${e}]`,r=J(t,i);G(r,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),i);let n=fn(r.unresolved_ids,`${i}.unresolved_ids`);return mt(n,`${i}.unresolved_ids`),{goal_cycle:I(r.goal_cycle,`${i}.goal_cycle`,1),iteration:I(r.iteration,`${i}.iteration`),attempt:I(r.attempt,`${i}.attempt`),outcome:B(r.outcome,["pass","fail","blocked","execution-error","recovery"],`${i}.outcome`),unresolved_ids:n,summary:ge(r.summary,`${i}.summary`),completed_at:Mt(r.completed_at,`${i}.completed_at`)}}function pw(t){let e="Native history_overflow.outcome_counts",i=J(t,e),r=["pass","fail","blocked","execution-error","recovery"];return G(i,new Set(r),e),{pass:I(i.pass,`${e}.pass`),fail:I(i.fail,`${e}.fail`),blocked:I(i.blocked,`${e}.blocked`),"execution-error":I(i["execution-error"],`${e}.execution-error`),recovery:I(i.recovery,`${e}.recovery`)}}function mw(t){let e="Native history_overflow",i=J(t,e);G(i,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let r=I(i.dropped_entries,`${e}.dropped_entries`),n=i.first_dropped_at===null?null:Mt(i.first_dropped_at,`${e}.first_dropped_at`),a=i.last_dropped_at===null?null:Mt(i.last_dropped_at,`${e}.last_dropped_at`);if(r===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(r>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=pw(i.outcome_counts);if(Object.values(o).reduce((c,l)=>c+l,0)!==r)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:r,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function vw(t){let e=new Set(t.acceptance.map(i=>i.id));for(let i of t.loop.previous_unresolved_ids)if(!e.has(i))throw new Error(`Native loop references unknown acceptance ID ${i}`);for(let i of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(i))throw new Error(`Native builder handoff references unknown ID ${i}`);for(let i of t.blockers)for(let r of i.acceptance_ids)if(!e.has(r))throw new Error(`Native blocker references unknown ID ${r}`);if(t.builder_handoff&&!(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.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 r=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(!r&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function gw(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 i=t.status==="await-user"?"await-user":t.status==="blocked"?"blocked":t.status==="done"?"done":null;if(i!==null&&t.loop.stage!==i)throw new Error(`Native status ${t.status} requires loop stage ${i}`);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(r=>r.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(t.verification.checks.some(r=>r.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 Ft(t){let e=J(t,"Native portable state");if(G(e,tw,"Native portable state"),e.schema!==Bt)throw new Error(`Native portable state schema must be ${Bt}`);let i=L(e.name,"Native state name");if(!Xg.test(i))throw new Error("Native state name is invalid");if(e.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let r=Ee(e.spec_changes,"Native spec_changes",nw);mt(r.map(s=>s.capability),"Native spec change capabilities");let n=Ee(e.acceptance,"Native acceptance",sw);mt(n.map(s=>s.id),"Native acceptance IDs");let a=Ee(e.history,"Native history",hw);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Bt,name:i,language:B(e.language,["en","zh-CN"],"Native state language"),phase:B(e.phase,["shape","build","verify","archive"],"Native state phase"),status:B(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:I(e.state_version,"Native state_version",1),brief:"brief.md",...e.children_contract_hash===void 0?{}:{children_contract_hash:iw(e.children_contract_hash,"Native children contract hash")},spec_changes:r,workspace:aw(e.workspace),loop:ow(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:lw(e.builder_handoff),blockers:Ee(e.blockers,"Native blockers",uw),verification:e.verification===null?null:fw(e.verification),history:a,history_overflow:mw(e.history_overflow),verification_result:B(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:B(e.verification_report,["verification.md"],"Native verification_report"),archived:Lt(e.archived,"Native archived"),created_at:Mt(e.created_at,"Native created_at")};return vw(o),gw(o),o}function ju(t){let e=t.createdAt instanceof Date?t.createdAt.toISOString():t.createdAt??new Date().toISOString();return Ft({schema:Bt,name:t.name,language:t.language,phase:"shape",status:"active",state_version:1,brief:"brief.md",spec_changes:[],workspace:t.workspace??{isolation:"current",change_branch:null,target_branch:null,finish:null},loop:{stage:"shape",goal_cycle:1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:t.nextAction??null},acceptance:[],builder_handoff:null,blockers:[],verification:null,history:[],history_overflow:zo(),verification_result:"pending",verification_report:null,archived:!1,created_at:e})}function ww(t,e){let i=(0,dn.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`${e} is invalid YAML: ${i.errors[0].message}`);return i.toJS({mapAsMap:!1})}async function Uo(t){let e=await Yg.readFile(t,"utf8");return Ft(ww(e,"Native portable state"))}async function $u(t,e,i={}){let r=Ft(e);await te(t,(0,dn.stringify)(r),i)}var ds=Jt(_t(),1);import{promises as Tn}from"fs";import U from"path";import{promises as hy}from"fs";import py from"path";import{AsyncLocalStorage as Nw}from"async_hooks";import{randomUUID as Du}from"crypto";import{promises as se}from"fs";import Bu from"os";import H from"path";var Ou=16*1024,Lu=".coordinator",bw=5e3,Hu=new Nw,hn=new Map;function kw(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function Sw(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let i=t;if(typeof i.id!="string"||i.id.length===0||typeof i.pid!="number"||!Number.isSafeInteger(i.pid)||i.pid<1||typeof i.hostname!="string"||i.hostname.length===0||typeof i.createdAt!="string"||i.createdAt.length===0||typeof i.operation!="string"||i.operation.length===0)throw new Error(`Invalid Native lock metadata: ${e}`);return i}function Mu(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 Ko(t,e){let i={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},r={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return X(i,r)?T(i,r):T(i,r)&&t.size===e.size}function Yo(t,e){return Ko(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}async function Ie(t){let e,i;try{let r=await $t(t,Ou,{bigint:!0,label:"Native lock"});e=r.bytes,i=r.stat}catch(r){if(r.code==="ENOENT")return null;throw r instanceof fe?r.reason==="too-large"?new Error(`Native lock metadata exceeds ${Ou} bytes: ${t}`,{cause:r}):r.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:r}):new Error(`Native lock changed while reading: ${t}`,{cause:r}):r}return{file:t,owner:Sw(JSON.parse(e.toString("utf8")),t),identity:Mu(i)}}async function Ew(t){return(await Ie(t))?.owner??null}function Fu(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==Bu.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=_w(t.owner.pid);return{status:e===!0?"active":e===!1?"stale":"unknown",owner:t.owner,identity:t.identity}}async function Pw(t,e){try{await se.lstat(e);return}catch(i){if(i.code!=="ENOENT")throw i}try{await se.rename(t,e)}catch(i){if(i.code!=="ENOENT")throw i}}async function Xo(t,e){let i=await Ie(t.file);if(!i)return"missing";if(i.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!Yo(i.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await se.mkdir(e,{recursive:!0});let r=H.join(e,`${H.basename(t.file)}.${t.owner.id}.${Du()}.removed`);try{await se.rename(t.file,r)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await Ie(r);if(!n||n.owner.id!==t.owner.id||!Ko(n.identity,t.identity))throw await Pw(r,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await se.rm(r,{force:!0}),"removed"}function Vu(t){return{id:Du(),pid:process.pid,hostname:Bu.hostname(),createdAt:new Date().toISOString(),operation:t}}async function qu(t,e){let i;try{i=await se.open(t,"wx")}catch(r){if(r.code==="EEXIST"){let n=await Ew(t);throw new Error(`Native lock is already held: ${t}${n?` by pid ${n.pid} for ${n.operation}`:""}`,{cause:r})}throw r}try{return await i.writeFile(JSON.stringify(e,null,2)+`
166
- `,"utf8"),await i.sync(),Mu(await i.stat({bigint:!0}))}finally{await i.close()}}async function xw(t,e){let i=await A(t.runtimeDir,t.locksDir);await se.mkdir(i,{recursive:!0});let r=await A(t.runtimeDir,H.join(i,Lu));await se.mkdir(r,{recursive:!0});let n=Vu(e),a=H.join(r,`.${n.id}.tmp`),o=H.join(r,`${n.id}.claim`);try{let s=await qu(a,n);await se.rename(a,o);let c=await Ie(o);if(!c||!Ko(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:i,owner:n,identity:c.identity}}finally{await se.rm(a,{force:!0})}}async function Cw(t){let e=H.dirname(t.file),i=!1,r=H.basename(t.file);for(let n of await se.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=H.join(e,n.name);if(H.resolve(a)!==H.resolve(t.file))try{let o=await Ie(a),s=Fu(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await Xo(o,e);continue}n.name<r&&(i=!0)}catch{n.name<r&&(i=!0)}}return i}async function Wu(t){let e=await Ie(t.file);if(e){if(e.owner.id!==t.owner.id||!Yo(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await Xo(e,H.dirname(t.file))}}async function Rw(t,e){let i=Date.now()+bw;for(;;){let r=await xw(t,e);if(!await Cw(r))return r;if(await Wu(r),Date.now()>=i)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function Aw(t){let e=hn.get(t)??Promise.resolve(),i,r=new Promise(a=>{i=a}),n=e.then(()=>r);return hn.set(t,n),await e,()=>{i(),hn.get(t)===n&&hn.delete(t)}}async function Qo(t,e,i){let r=H.resolve(t.locksDir),n=Hu.getStore();if(n?.has(r))return i();let a=await Aw(r);try{let o=await Rw(t,e),s=new Map(n??[]);return s.set(r,o),await Hu.run(s,async()=>{try{return await i()}finally{await Wu(o)}})}finally{a()}}async function zu(t,e,i){let r=[...new Map(t.map(a=>[H.resolve(a.locksDir),a])).values()].sort((a,o)=>H.resolve(a.locksDir).localeCompare(H.resolve(o.locksDir))),n=async a=>{let o=r[a];return o?Qo(o,e,()=>n(a+1)):i()};return n(0)}async function pn(t,e,i){return Qo(t,`acquire ${e}`,async()=>{let r=await A(t.runtimeDir,t.locksDir);await se.mkdir(r,{recursive:!0});let n=await A(t.runtimeDir,H.join(r,kw(e))),a=Vu(i),o=await qu(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:r,owner:a,identity:o}})}async function mn(t){await Ie(t.file)&&await Qo({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${H.basename(t.file)}`,async()=>{let e=await Ie(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!Yo(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let i=H.join(t.locksDir,Lu);await Xo(e,i)})}function _w(t){try{return process.kill(t,0),!0}catch(e){let i=e.code;return i==="ESRCH"?!1:i==="EPERM"?!0:null}}async function Ju(t){return Fu(await Ie(t))}import Fw from"node:path";var OE=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Gu=Object.freeze({maxCriteria:1024});var je="comet.native.v3",$e="comet.native.v2",Oe="comet.native.v1";var Uu="comet.native.portable-migration.v1",$w=new Set(["schema","id","change","fromSchema","status","createdAt"]),Ow=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Hw=/^[a-z0-9][a-z0-9-]{7,127}$/u,Dw=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),Bw=new Set([Oe,$e,je]);function Lw(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Mw(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let i=new Date(t);if(Number.isNaN(i.valueOf())||i.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function Yu(t){let e=Lw(t,"Native portable migration transaction"),i=Object.keys(e).filter(r=>!$w.has(r));if(i.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${i.join(", ")}`);if(e.schema!==Uu)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!Hw.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!Ow.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!Bw.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!Dw.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:Uu,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:Mw(e.createdAt,"Native portable migration transaction createdAt")}}var Xu="comet.native.archive-transaction.v4",Qu="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",Vw=new RegExp(`^portable-archive-(${Qu})\\.json$`,"u"),qw=new RegExp(`^portable-migration-(${Qu})\\.json$`,"u"),Ww=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,zw=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Jw=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),Gw=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),Uw=new Set(["capability","operation","source","content"]),Zu=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function ed(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function td(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`);if(Object.keys(t).length!==e.size)throw new Error(`${i} fields are invalid`)}function Kw(t,e){let i=`Native portable Archive spec_changes[${e}]`,r=ed(t,i);if(td(r,Uw,i),typeof r.capability!="string"||!Zu.test(r.capability))throw new Error(`${i}.capability is invalid`);if(!["create","modify","remove"].includes(String(r.operation)))throw new Error(`${i}.operation is invalid`);let n=r.operation;if(n==="remove"){if(r.source!==null||r.content!==null)throw new Error(`${i} remove requires source and content null`);return{capability:r.capability,operation:n,source:null,content:null}}if(typeof r.source!="string"||r.source.length===0||r.source.includes("\\")||r.source.startsWith("/")||/^[A-Za-z]:/u.test(r.source)||r.source.split("/").some(a=>a==="."||a===".."))throw new Error(`${i}.${n} source is invalid`);if(typeof r.content!="string")throw new Error(`${i}.${n} content is invalid`);return{capability:r.capability,operation:n,source:r.source,content:r.content}}function Yw(t){let e=ed(t,"Native portable Archive transaction");if(td(e,Gw,"Native portable Archive transaction"),e.schema!==Xu)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!Ww.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!Zu.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"||!zw.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"||!Jw.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 i=e.spec_changes.map(Kw);if(new Set(i.map(({capability:n})=>n)).size!==i.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>i.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 r=new Date(e.created_at);if(Number.isNaN(r.valueOf())||r.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:Xu,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:i,created_at:e.created_at}}function Zo(t){let e=Vw.exec(t);if(e)return{kind:"archive",change:e[1]};let i=qw.exec(t);return i?{kind:"migration",change:i[1]}:null}async function id(t,e){let i=Zo(e);if(!i)return null;let r=await ae({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(r.text),a=Fw.join(t.transactionsDir,e);if(i.kind==="archive"){let s=Yw(n);if(s.change!==i.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:i.change,file:a,journal:s}}let o=Yu(n);if(o.change!==i.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:i.change,file:a,journal:o}}function rd(t){return t.kind==="archive"||t.journal.status!=="committed"}import De from"path";import{TextDecoder as ry}from"util";import{createHash as Xw}from"node:crypto";import{constants as yn,promises as Q}from"node:fs";import we from"node:path";import{TextDecoder as Qw}from"node:util";function bn(t,e){let i=we.relative(t,e);return i===""||!we.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${we.sep}`)}function nd(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function Zw(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function ey(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function Nn(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 es(t,e){let i=await Q.lstat(t);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await Q.realpath(t),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function ad(t,e,i){let r=we.resolve(t),n=we.resolve(e);if(!bn(r,n))throw new Error(`${i} is outside its managed root`);let a=[await es(r,i)],o=r;for(let s of we.relative(r,n).split(we.sep).filter(Boolean)){await He(a,i),o=we.join(o,s);let c=await es(o,i);if(!bn(a[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${o}`);a.push(c)}return await He(a,i),a}async function He(t,e){for(let i of t){let r=await Q.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!Zw(i,r)||await Q.realpath(i.path)!==i.realPath)throw new Error(`${e} parent changed during I/O: ${i.path}`)}}async function ty(t,e,i){let r=[],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(`${i} exceeds ${e} bytes`);r.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(r,n)}async function vt(t){let e=nd(t.maxBytes),i=we.resolve(t.file),r=await ad(t.root,we.dirname(i),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(u=>es(we.resolve(u),t.label)));await t.hooks?.afterParentChainCaptured?.(),await He(r,t.label);let a=await Q.lstat(i);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=ey(a),s=await Q.realpath(i);if(!bn(r[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(u=>bn(u.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?yn.O_RDONLY:yn.O_RDONLY|yn.O_NOFOLLOW|yn.O_NONBLOCK,l=await Q.open(i,c);try{let u=await l.stat();await t.hooks?.afterOpen?.();let[d,f]=await Promise.all([Q.lstat(i),Q.realpath(i)]);if(await He(r,t.label),await He(n,t.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!Nn(o,u)||!Nn(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let p=await ty(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),Q.lstat(i),Q.realpath(i)]);if(await He(r,t.label),await He(n,t.label),!h.isFile()||h.isSymbolicLink()||m!==s||!Nn(o,v)||!Nn(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:p,hash:Xw("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}async function od(t){let e=await vt(t),i;try{i=new Qw("utf-8",{fatal:!0}).decode(e.bytes)}catch(r){throw new Error(`${t.label} is not valid UTF-8`,{cause:r})}return{...e,text:i}}async function Bi(t){let e=await ad(t.root,t.directory,t.label),i;if(t.maxEntries===void 0)i=await Q.readdir(t.directory,{withFileTypes:!0});else{let r=nd(t.maxEntries);i=[];let n=await Q.opendir(t.directory);try{for await(let a of n)if(i.push(a),i.length>r)throw new Error(`${t.label} exceeds ${r} entries`)}finally{await n.close().catch(a=>{if(a.code!=="ERR_DIR_CLOSED")throw a})}}return await He(e,t.label),{entries:i,verify:()=>He(e,t.label)}}var ny=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),ay=new Set(["id","type","source","target","staged","backup"]),oy=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),sy=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var ld=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var cy=256*1024,mP=1024*1024,vP=16*1024;var gP=64*1024*1024;var ly=new ry("utf-8",{fatal:!0});function Sn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function En(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function ud(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function ts(t,e){if(typeof t!="string"||t.length===0||De.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function kn(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function sd(t,e){if(ts(t,e),t.includes("\\")||t!==De.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 uy(t,e){let i=Sn(t,`transaction operations[${e}]`);if(En(i,ay,`transaction operations[${e}]`),typeof i.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.id))throw new Error(`transaction operations[${e}].id is invalid`);if(i.type!=="write"&&i.type!=="remove"&&i.type!=="move")throw new Error(`transaction operation ${i.id} has an invalid type`);ts(i.target,`transaction operation ${i.id} target`);for(let r of["source","staged","backup"])i[r]!==void 0&&ts(i[r],`transaction operation ${i.id} ${r}`);if(i.type==="write"){if(i.staged===void 0||i.source!==void 0)throw new Error(`write operation ${i.id} requires staged and forbids source`)}else if(i.type==="remove"){if(i.source!==void 0||i.staged!==void 0)throw new Error(`remove operation ${i.id} forbids source and staged`)}else if(i.source===void 0||i.staged!==void 0||i.backup!==void 0)throw new Error(`move operation ${i.id} requires source and forbids staged and backup`);return i}function dd(t){let e=Sn(t,"Native Archive transaction journal");if(En(e,oy,"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"||!ld.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(!ud(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(kn(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 i=e.operations.map((s,c)=>{let l=Sn(s,`Archive transaction operations[${c}]`);if(En(l,sy,`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`);sd(l.target,`Archive transaction operation ${l.id} target`);for(let u of["source","staged","backup"])l[u]!==void 0&&sd(l[u],`Archive transaction operation ${l.id} ${u}`);if(l.expectedTargetHash!==null&&kn(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(kn(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`);kn(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),r=i.map(s=>s.id);if(new Set(r).size!==r.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=i.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)||i.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of i.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:i}}function dy(t){let e=Sn(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return dd(e);if(En(e,ny,"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"||!ld.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!De.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!De.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(!ud(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 i=e.operations.map(uy),r=i.map(n=>n.id);if(new Set(r).size!==r.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id: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:i}}function fy(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return De.join(t.transactionsDir,e)}function fd(t,e){let i=fy(t,e);return{directory:i,journal:De.join(i,"transaction.json"),events:De.join(i,"events.jsonl"),staged:De.join(i,"staged"),backups:De.join(i,"backups")}}async function is(t,e){let i=fd(t,e);return await Promise.all(Object.values(i).map(r=>A(t.runtimeDir,r))),i}async function rs(t,e,i={}){let r=await is(t,e),n=await vt({root:t.runtimeDir,file:r.journal,maxBytes:cy,label:`Native transaction journal ${e}`,hooks:i.hooks}),a=JSON.parse(ly.decode(n.bytes)),o=dy(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}async function my(t,e,i){let r;try{r=await hy.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await rs(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of r)if(Zo(n.name))try{let a=await id(t,n.name);if(!a||i?.kind===a.kind&&i.change===a.change)continue;if(rd(a))return!0}catch{return!0}return!1}async function vy(t,e){let i=Date.now()+5e3,r=py.join(t.locksDir,"root-move.lock");for(;;)try{return await pn(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Ju(r);if(o.status==="missing")continue;if(o.status!=="active"||Date.now()>=i)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function ye(t,e,i,r){let n=await vy(t,e);try{if(await sn(t.projectRoot),await my(t,r?.allowedTransactionId,r?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await i()}finally{await mn(n)}}import as from"path";import{createHash as gy}from"crypto";function Z(t){return gy("sha256").update(t).digest("hex")}var DP={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},yy=1e3,Ny=8*1024*1024,by=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,ky=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),Sy=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),Ey=new Set(["schema","include","exclude","hash"]),Py=new Set(["provider","gitSelection","physicalSelection","projection"]),xy=new Set(["provider","selection"]),Cy=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),Ry=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),Ay=new Set(["schema","status","before","after"]),_y=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),Ty=new Set(["path","hash","size","type","gitObjectId"]),Iy=new Set(["path","size","type","reason"]),jy=new Set(["ref","hash","count"]),$y=new Set(["change-created","legacy-migration","explicit"]),Oy=new Set(["file","directory","other"]),Hy=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"]),xn=/^[a-f0-9]{64}$/u,Dy=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var BP=64*1024,LP=64*1024;var MP={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},FP={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function Pn(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var VP=(1n<<256n)-1n;function By(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 Ly(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
167
- `)}function My(t,e){return Z(`comet.native.snapshot-policy.v1
168
- ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function ns(t,e,i){let r=new Set(e),n=[...e];for(;n.length>0;){if(i&&!i())return null;let a=n.pop(),o=t[a];o&&(o.kind==="star"||o.kind==="globstar"||o.kind==="globstar-slash")&&!r.has(a+1)&&(r.add(a+1),n.push(a+1))}return r}function Fy(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function hd(t){let e=on(t,"Native snapshot pattern"),i=[];for(let r=0;r<e.length;r+=1){let n=e[r];n==="*"&&e[r+1]==="*"?(r+=1,e[r+1]==="/"?(r+=1,i.push({kind:"globstar-slash"})):i.push({kind:"globstar"})):n==="*"?i.push({kind:"star"}):n==="?"?i.push({kind:"question"}):i.push({kind:"literal",value:n})}return(r,n)=>{let a=n?Fy(n):void 0;if(a&&!a())return!1;let o=ns(i,new Set([0]),a);if(o===null)return!1;for(let s of r){if(a&&!a())return!1;let c=new Set;for(let l of o){if(a&&!a())return!1;let u=i[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(i,c,a),o===null||o.size===0)return!1}return ns(i,o,a)?.has(i.length)??!1}}function Vy(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>on(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),i=[...new Set(t.exclude.map(n=>on(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 r=My(e,i);if("hash"in t&&t.hash!==r)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:i,hash:r},includeMatchers:e.map(hd),excludeMatchers:i.map(hd),excludedDirectoryPrefixes:i.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 ce(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function le(t,e,i){let r=Object.keys(t).find(n=>!e.has(n));if(r)throw new Error(`${i} contains unknown field: ${r}`)}function qt(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 vd(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 i=as.posix.normalize(t);if(i!==t||as.posix.isAbsolute(t)||i===".."||i.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function qy(t,e){let i=ce(t,`Native snapshot entry ${e}`);le(i,Ty,`Native snapshot entry ${e}`);let r=vd(i.path,`Native snapshot entry ${e} path`);if(typeof i.hash!="string"||!xn.test(i.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(i.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:r,hash:i.hash,size:Pe(i.size,`Native snapshot entry ${e} size`),type:"file"};if(i.gitObjectId!==void 0){if(typeof i.gitObjectId!="string"||!Dy.test(i.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=i.gitObjectId}return n}function Wy(t,e){let i=ce(t,`Native snapshot omission ${e}`);if(le(i,Iy,`Native snapshot omission ${e}`),!Oy.has(i.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!Hy.has(i.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:vd(i.path,`Native snapshot omission ${e} path`),size:i.size===null?null:Pe(i.size,`Native snapshot omission ${e} size`),type:i.type,reason:i.reason}}function zy(t){let e=ce(t,"Native snapshot omission overflow");if(le(e,jy,"Native snapshot omission overflow"),typeof e.hash!="string"||!xn.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let i=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==i)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:i,hash:e.hash,count:qt(e.count,"Native snapshot omission overflow count")}}function Vt(t,e){let i=ce(t,e);if(le(i,Ry,e),typeof i.hash!="string"||!xn.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let r=Pe(i.recordCount,`${e} recordCount`),n=Pe(i.storedRecordCount,`${e} storedRecordCount`),a=Pe(i.stdoutBytes,`${e} stdoutBytes`);if(n>r||!i.overflow&&n!==r)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,recordCount:r,storedRecordCount:n,stdoutBytes:a,overflow:i.overflow}}function pd(t){let e=ce(t,"Native Git selection evidence");if(le(e,Cy,"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 i=Vt(e.stageBefore,"Native Git selection stageBefore"),r=Vt(e.combined,"Native Git selection combined"),n=Vt(e.stageAfter,"Native Git selection stageAfter"),a=Vt(e.finalStageBefore,"Native Git selection finalStageBefore"),o=Vt(e.finalCombined,"Native Git selection finalCombined"),s=Vt(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[i,r,n,a,o,s].some(d=>d.overflow),l=!Pn(i,n)||!Pn(n,a)||!Pn(r,o)||!Pn(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:i,combined:r,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function md(t,e){let i=ce(t,e);if(le(i,_y,e),typeof i.hash!="string"||!xn.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean"||typeof i.unstable!="boolean")throw new Error(`${e} flags are invalid`);let r=Pe(i.visitedNodeCount,`${e} visitedNodeCount`),n=Pe(i.recordCount,`${e} recordCount`),a=Pe(i.storedRecordCount,`${e} storedRecordCount`),o=Pe(i.encodedBytes,`${e} encodedBytes`);if(a>n||!i.overflow&&a!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,visitedNodeCount:r,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:i.overflow,unstable:i.unstable}}function Jy(t){let e=ce(t,"Native physical selection evidence");if(le(e,Ay,"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 i=md(e.before,"Native physical selection before"),r=md(e.after,"Native physical selection after"),n=i.overflow||r.overflow,a=i.unstable||r.unstable||!By(i,r);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:i,after:r}}function gd(t){let e=ce(t,"Native content snapshot manifest");if(le(e,ky,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!$y.has(e.origin))throw new Error("Native content snapshot origin is invalid");let i;if(e.capture!==void 0){let g=ce(e.capture,"Native content snapshot capture");if(le(g,Py,"Native content snapshot capture"),g.provider!=="git"&&g.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let x=g.gitSelection===void 0?void 0:pd(g.gitSelection),b=g.physicalSelection===void 0?void 0:Jy(g.physicalSelection),_=null;if(g.projection!==void 0){let K=ce(g.projection,"Native content snapshot projection");if(le(K,xy,"Native content snapshot projection"),K.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");_={provider:"git",...K.selection===void 0?{}:{selection:pd(K.selection)}}}if(g.provider==="git"){if(b||_)throw new Error("Native Git capture cannot include physical or projection evidence");i={provider:"git",...x?{gitSelection:x}:{}}}else{if(x)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");i=_?{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 r=ce(e.limits,"Native content snapshot limits");le(r,Sy,"Native content snapshot limits");let n={maxFiles:qt(r.maxFiles,"Native snapshot maxFiles"),maxFileBytes:qt(r.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:qt(r.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:qt(r.maxManifestBytes,"Native snapshot maxManifestBytes"),...r.maxDurationMs===void 0?{}:{maxDurationMs:qt(r.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let g=ce(e.policy,"Native snapshot policy");if(le(g,Ey,"Native snapshot policy"),g.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(g.include)||!Array.isArray(g.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=Vy({include:g.include,exclude:g.exclude,hash:g.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(qy),s=e.omitted.map(Wy),c=Pe(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:zy(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(g=>g.size>n.maxFileBytes)||o.reduce((g,x)=>g+x.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(g=>g.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>yy||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(g=>g.reason==="git-enumeration-limit"),f=s.filter(g=>g.reason==="git-selection-changed");for(let g of[...d,...f])if(g.path!=="."||g.size!==null||g.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=i?.provider==="git"?i.gitSelection:i?.projection?.selection,v=p?.status==="overflow"||p?.status==="overflow-and-changed",h=p?.status==="changed"||p?.status==="overflow-and-changed";if(v!==(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(g=>g.reason==="physical-enumeration-limit"),y=s.filter(g=>g.reason==="physical-selection-changed");for(let g of[...m,...y])if(g.path!=="."||g.size!==null||g.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=i?.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,...i?{capture:i}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}};if(Ly(E)>n.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function Gy(t,e){if(!by.test(e))throw new Error(`Invalid Native change name: ${e}`);return as.join(ie(t,e),"baseline-manifest.json")}async function wd(t,e){let i=Gy(t,e),r=pe(t,i);await A(r,i);try{let n=await od({root:r,file:i,maxBytes:Ny,label:"Native baseline snapshot manifest"});return gd(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var Zy=Jt(_t(),1);var nx=4*1024*1024;var eN=null;function tN(t,e){let i=t;for(let r of e)i+="\0"+(typeof r=="string"?r:JSON.stringify(r));return i}function yd(t,e){return(...i)=>{let r=eN;if(r===null)return e(...i);let n=tN(`async:${t}`,i),a=r.entries.get(n);if(a)return a.value;let o=e(...i).catch(s=>{throw r.entries.delete(n),s});return r.entries.set(n,{value:o}),o}}var lx=yd("hookWritePolicy",async t=>(await To(t))?.hook??{allow_paths:[]});var iC=256*1024;var mC={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 rN}from"node:crypto";import{promises as Cn}from"node:fs";import Ze from"node:path";var Li=/^[a-f0-9]{64}$/u,bd=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,nN=16*1024,ss=process.platform;function Ed(t,e){let i=Ze.relative(t,e);return Ze.isAbsolute(i)||i===".."||i.startsWith(`..${Ze.sep}`)?null:i.replaceAll("\\","/")||"."}function Pd(t){return Array.from(t).some(e=>{let i=e.codePointAt(0)??0;return i<=31||i===127})}function xd(t,e){if(t.length===0||Pd(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 i=Ze.posix.normalize(t);if(i!==t||i===".."||i.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return i}function cs(t,e){return rN("sha256").update(`${t}
169
- ${e}`).digest("hex")}async function kd(t,e){let i=await Cn.realpath(e),r=await Cn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=ss==="win32"?Ze.normalize(i).toLowerCase():i;return cs(t,`${n}
163
+ `)}function pg(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim();if(i.length===0||jt.posix.isAbsolute(i)||jt.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function pt(t){let e=pg(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Nu(t,e="docs"){let i=t??e;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function Xr(t,e,i=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim().replaceAll("\\","/");if(r.length===0||jt.posix.isAbsolute(r)||jt.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let n=r.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(!i&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function Ye(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function bu(t,e,i){let r=t??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function Qr(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>Kr)throw new Error(`${e} exceeds ${Kr} characters`);let i=0;for(let r=0;r<t.length;r+=1)t[r]==="?"?i+=1:t[r]==="*"&&(i+=1,t[r+1]==="*"&&(r+=1));if(i>Yr)throw new Error(`${e} contains more than ${Yr} wildcard tokens`);return t}function wu(t,e,i){if(t===void 0)return[...i];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(r=>Qr(r,e)))].sort((r,n)=>r.localeCompare(n,"en"))}function _o(t,e,i){let r=t??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function mg(t){if(t===void 0)return{...Y,include:[...Y.include],exclude:[...Y.exclude]};let e=Ye(t,"native.snapshot");return{include:wu(e.include,"native.snapshot.include",Y.include),exclude:wu(e.exclude,"native.snapshot.exclude",Y.exclude),max_files:_o(e.max_files,Y.max_files,"native.snapshot.max_files"),max_total_bytes:_o(e.max_total_bytes,Y.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:_o(e.max_duration_ms,Y.max_duration_ms,"native.snapshot.max_duration_ms")}}function vg(t){if(t===void 0)return;let e=Ye(t,"native.pending_root_move"),i=e.id,r=e.from_artifact_root,n=e.to_artifact_root,a=e.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(e.cleanup!==void 0){let s=Ye(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:i,fromArtifactRoot:pt(r),toArtifactRoot:pt(n),stage:a,...o?{cleanup:o}:{}}}function gg(t){if(t===void 0)return;let e=Ye(t,"native.finish");if(e.pull_request===void 0)return{};let i=Ye(e.pull_request,"native.finish.pull_request");if(i.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(i.command)||i.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(i.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let r=i.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(jt.posix.isAbsolute(r[0])||jt.win32.isAbsolute(r[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=i.timeout_ms??lg;if(!Number.isSafeInteger(n)||n<1||n>gu)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${gu}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:n}}}function wg(t,e={}){let i=Ye(t,"native"),r=i.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let n=i.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=i.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=i.max_verify_failures??To;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=vg(i.pending_root_move),c=gg(i.finish);return{artifact_root:pt(r),language:bu(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:mg(i.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function yg(t){let e=Ye(t,"classic"),i=e.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="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:Nu(e.artifact_layout),language:bu(e.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function Ng(t){let i=Ye(t,"hook").allow_paths??[];if(!Array.isArray(i))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(i.map((r,n)=>Xr(r,`hook.allow_paths[${n}]`)))]}}function bg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function kg(t,e,i,r,n,a){let o=t.schema!==void 0;if(!(o||t.default_workflow!==void 0||t.workflows!==void 0||!a.allowPartialProject&&t.native!==void 0)||a.allowPartialProject&&!o)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 c=t.workflows??[t.default_workflow];if(!Array.isArray(c)||c.length===0||c.some(u=>u!=="native"&&u!=="classic"))throw new Error("workflows must contain native and/or classic");let l=[...new Set(c)];if(!l.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(l.includes("native")&&!i)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:l,ambient_resume:n,...e?{hook:e}:{},...i?{native:i}:{},...r?{classic:r}:{}}}function $t(t,e={}){let i=(0,Ei.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let r=i.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=r,a=bg(n.ambient_resume),o=n.hook===void 0?void 0:Ng(n.hook),s=n.native===void 0?void 0:wg(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),c=n.classic===void 0?void 0:yg(n.classic),l=kg(n,o,s,c,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:l,ambient_resume:a,...o?{hook:o}:{},...s?{native:s}:{},...c?{classic:c}:{}}}function ku(t){return{id:t.id,from_artifact_root:t.fromArtifactRoot,to_artifact_root:t.toArtifactRoot,stage:t.stage,...t.cleanup?{cleanup:{kind:t.cleanup.kind,state:t.cleanup.state,manifest_hash:t.cleanup.manifestHash}}:{}}}function Su(t){return{schema:t.schema,default_workflow:t.default_workflow,workflows:t.workflows??[t.default_workflow],ambient_resume:t.ambient_resume,...t.hook?{hook:{allow_paths:[...t.hook.allow_paths]}}:{},...t.native?{native:{artifact_root:t.native.artifact_root,language:t.native.language,clarification_mode:t.native.clarification_mode,archive_confirmation:t.native.archive_confirmation,max_verify_failures:t.native.max_verify_failures,...t.native.finish?.pull_request?{finish:{pull_request:{provider:t.native.finish.pull_request.provider,command:[...t.native.finish.pull_request.command],timeout_ms:t.native.finish.pull_request.timeout_ms}}}:{},...t.native.pending_root_move?{pending_root_move:ku(t.native.pending_root_move)}:{}}}:{},...t.classic?{classic:{artifact_layout:t.classic.artifact_layout,language:t.classic.language,context_compression:t.classic.context_compression,review_mode:t.classic.review_mode,auto_transition:t.classic.auto_transition}}:{}}}function Ae(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Ci(t,e){let i=Su(e),r=$t((0,Ei.stringify)(i)).config;if(!r)throw new Error("Unsupported Comet project schema");let n={...t,schema:r.schema,default_workflow:r.default_workflow,workflows:r.workflows,ambient_resume:r.ambient_resume};if(r.hook&&(n.hook={...Ae(t.hook),allow_paths:[...r.hook.allow_paths]}),r.native){let a=Ae(t.native),o={...a,artifact_root:r.native.artifact_root,language:r.native.language,clarification_mode:r.native.clarification_mode,archive_confirmation:r.native.archive_confirmation,max_verify_failures:r.native.max_verify_failures};if(r.native.finish?.pull_request){let s=Ae(a.finish);o.finish={...s,pull_request:{...Ae(s.pull_request),provider:r.native.finish.pull_request.provider,command:[...r.native.finish.pull_request.command],timeout_ms:r.native.finish.pull_request.timeout_ms}}}else{let s={...Ae(a.finish)};delete s.pull_request,Object.keys(s).length>0?o.finish=s:delete o.finish}if(delete o.snapshot,r.native.pending_root_move){let s=Ae(a.pending_root_move),c=ku(r.native.pending_root_move),l=Ae(s.cleanup),u=Ae(c.cleanup);o.pending_root_move={...s,...c,...c.cleanup?{cleanup:{...l,...u}}:{}}}else delete o.pending_root_move;n.native=o}return r.classic&&(n.classic={...Ae(t.classic),artifact_layout:r.classic.artifact_layout,language:r.classic.language,context_compression:r.classic.context_compression,review_mode:r.classic.review_mode,auto_transition:r.classic.auto_transition}),n}function Zr(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:pt(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:To,snapshot:{...Y,include:[...Y.include],exclude:[...Y.exclude]}}}}import{createHash as Eg}from"crypto";import{promises as rn}from"fs";import Qe from"path";import{constants as en,promises as mt}from"fs";function Xe(t){return t!==0&&t!==0n&&t!=="0"}function ke(t,e){return Xe(t.dev)&&Xe(e.dev)&&Xe(t.ino)&&Xe(e.ino)}function T(t,e){let i=Xe(t.dev)&&Xe(e.dev);if(i&&t.dev!==e.dev)return!1;let r=Xe(t.ino)&&Xe(e.ino);return r&&t.ino!==e.ino?!1:i&&r?!0:t.birthtime===e.birthtime}var de=class extends Error{reason;constructor(e,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=e}};function Io(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Eu(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function Ri(t){return{dev:t.dev,ino:t.ino,birthtime:Io(t)}}function tn(t,e){let i=Ri(t),r=Ri(e);return ke(i,r)?T(i,r):T(i,r)&&Io(t)===Io(e)&&Eu(t)===Eu(e)&&t.size===e.size}async function Ot(t,e,i={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=i.label??"file",n=i.bigint===!0,a=await mt.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new de("not-regular-file",`${r} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new de("too-large",`${r} exceeds ${e} bytes`);let o=await mt.realpath(t);await i.verify?.("pre-open",{realPath:o,identity:Ri(a)});let s=process.platform==="win32"?en.O_RDONLY:en.O_RDONLY|en.O_NOFOLLOW|en.O_NONBLOCK,c;try{c=await mt.open(t,s)}catch(l){throw l.code==="ELOOP"?new de("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,d]=await Promise.all([c.stat({bigint:n}),mt.lstat(t,{bigint:n}),mt.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!tn(a,l)||!tn(a,u))throw new de("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:d,identity:Ri(l)}),await i.hooks?.afterOpen?.();let f=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let N=e+1-p,{bytesRead:k}=await c.read(v,0,Math.min(v.length,N),null);if(k===0)break;if(p+=k,p>e)throw new de("too-large",`${r} exceeds ${e} bytes`);f.push(Buffer.from(v.subarray(0,k)))}await i.hooks?.beforeFinalCheck?.();let[h,m,y]=await Promise.all([c.stat({bigint:n}),mt.lstat(t,{bigint:n}),mt.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||y!==o||!tn(a,h)||!tn(a,m))throw new de("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:y,identity:Ri(h)}),{bytes:Buffer.concat(f,p),stat:h,realPath:y}}finally{await c.close()}}function Sg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function jo(t,e){let i=Qe.relative(t,e);return i===""||!Qe.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Qe.sep}`)}async function xu(t,e){let i=Qe.resolve(t),r=await rn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return rn.realpath(i)}async function Pu(t,e,i,r){let n=t;for(let a=0;a<i.length;a++){n=Qe.join(n,i[a]);let o;try{o=await rn.lstat(n)}catch(u){if(Sg(u))return{exists:!1,kind:"missing"};throw u}let s=Qe.relative(t,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${s}`);let c=a===i.length-1;if(!c&&!o.isDirectory())throw new Error(`${r.label} ancestor ${s} must be a real directory`);if(c&&(r.expected==="file"&&!o.isFile()||r.expected==="directory"&&!o.isDirectory()||r.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await rn.realpath(n);if(!jo(e,l))throw new Error(`${r.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function Ht(t,e,i){let r=Xr(e,i.label),n=Qe.resolve(t),a=await xu(n,i.label),o=r.split("/"),s=Qe.resolve(n,...o);if(!jo(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await Pu(n,a,o,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function Ze(t,e,i,r){let n=await Ht(t,e,{label:r.label,expected:"file"});if(!n.exists){let o=new Error(`${r.label} does not exist`);throw o.code="ENOENT",o}let a=await xu(n.projectRoot,r.label);return Ot(n.target,i,{...r,verify:async(o,s)=>{if(!jo(a,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await Pu(n.projectRoot,a,n.relative.split("/"),{label:r.label,expected:"file"})}})}var Ai=".comet/config.yaml";function $o(t,e){return t.exists===e.exists&&t.sha256===e.sha256}function xg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function nn(t,e={}){return(await _i(t,e)).document}async function Cu(t){try{return(await Ze(t,Ai,xi,{label:Ai})).bytes}catch(e){if(xg(e))return null;throw e}}function Ru(t){return t?{exists:!0,sha256:Eg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function an(t){return Ru(await Cu(t))}async function _i(t,e={}){let i=await Cu(t);return{document:i?$t(i.toString("utf8"),e):null,identity:Ru(i)}}async function Oo(t){return(await nn(t))?.config??null}var IS=16*1024;async function Ho(t,e){if(!e)return;let i=await an(t);if(!$o(i,e))throw new Error("Project config changed before commit; rerun the operation")}import{randomUUID as Ag}from"crypto";import{promises as M}from"fs";import fe from"path";function Do(t,e){let i=fe.relative(t,e);return i===""||!fe.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${fe.sep}`)}function _g(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Bo(t,e){return T({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function Tg(t,e){return Bo(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Au(t){let e=await M.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 M.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Ii(t){for(let e of t){let i=await M.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!_g(e,i)||await M.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function Ig(t,e){let i=fe.resolve(t),r=fe.resolve(e);if(!Do(i,r))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Au(i)],a=fe.relative(i,r).split(fe.sep).filter(Boolean),o=i;for(let s of a){await Ii(n),o=fe.join(o,s);try{await M.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Au(o);if(!Do(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await Ii(n),n}async function jg(t){let e;try{e=await M.open(t,"r"),await e.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await e?.close()}}async function $g(t,e,i={}){let r=fe.dirname(t),n=i.containedRoot?await Ig(i.containedRoot,r):null;n||await M.mkdir(r,{recursive:!0});let a=fe.join(r,`.${fe.basename(t)}.${Ag()}.tmp`),o,s,c;try{if(await i.beforeTemporaryOpen?.(),o=await M.open(a,"wx"),s=await o.stat(),n){let[l,u]=await Promise.all([M.lstat(a),M.realpath(a)]);if(await Ii(n),!l.isFile()||l.isSymbolicLink()||!Bo(s,l)||!Do(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(),!Bo(s,c))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await i.beforeCommit?.(),n){await Ii(n);let l=await M.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!Tg(l,c))throw new Error("Native atomic write temporary file changed before commit")}i.exclusive?(await M.link(a,t),await M.unlink(a)):await M.rename(a,t),await jg(r)}catch(l){if(await o?.close(),!n)await M.rm(a,{force:!0});else try{await Ii(n),await M.rm(a,{force:!0})}catch{}throw l}}async function ee(t,e,i={}){await $g(t,e,i)}async function Se(t,e,i={}){await ee(t,JSON.stringify(e,null,2)+`
164
+ `,i)}import{existsSync as _u,promises as _e}from"fs";import R from"path";import Og from"os";var on=".comet/config.yaml",Hg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function Lo(t){try{return await _e.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Dg(t){try{let e=await _e.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Bt(t,e){let i=R.relative(t,e);return i===""||!R.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${R.sep}`)}async function Dt(t){let e=[],i=t;for(;!await Lo(i);){let n=R.dirname(i);if(n===i)break;e.push(R.basename(i)),i=n}let r=await _e.realpath(i);return R.resolve(r,...e.reverse())}async function Mo(t){try{return(await _e.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Fo(t){let e=R.resolve(t);try{(await _e.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let i=e,r=R.resolve(Og.homedir());for(;;){if(!(e===r&&i!==r)){let o=R.join(e,...on.split("/")),s=e===i||await Dg(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 i;e=a}}function Vo(t){return pt(t)}async function Bg(t,e){let i=Vo(e),r=R.resolve(t,...i.split("/")),n=await _e.realpath(t),a=await Dt(r);if(!Bt(n,a))throw new Error("native.artifact_root resolves outside the project root");return r}async function Te(t,e){let i=Vo(e),r=await Bg(t,i),n=R.join(r,"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([Dt(r),Dt(n)]);if(!Bt(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([_e.realpath(s),Dt(c)]);if(!Bt(l,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(t,...on.split("/")),artifactRoot:r,artifactRootRef:i,nativeRoot:n,specsDir:R.join(n,"specs"),changesDir:R.join(n,"changes"),archiveDir:R.join(n,"archive"),runtimeDir:c,changesRuntimeDir:R.join(c,"changes"),locksDir:R.join(c,"locks"),transactionsDir:R.join(c,"transactions")}}async function Tu(t){await Promise.all([t.specsDir,t.changesDir,t.archiveDir].map(async e=>{await A(t.nativeRoot,e),await _e.mkdir(e,{recursive:!0})})),await Promise.all([t.changesRuntimeDir,t.locksDir,t.transactionsDir].map(async e=>{await A(t.projectRoot,e),await _e.mkdir(e,{recursive:!0})}))}function Iu(t){if(!Hg.test(t))throw new Error(`Invalid Native change name: ${t}`)}function vt(t,e){Iu(e);let i=R.join(t.changesRuntimeDir,e);if(!F(t.changesRuntimeDir,i))throw new Error("Native change Runtime path escaped");return i}function Lg(t,e){Iu(e);let i=R.join(t.changesDir,e,"runtime");if(!F(t.changesDir,i))throw new Error("Legacy Native change Runtime path escaped");return i}function te(t,e){let i=vt(t,e);if(_u(i))return i;let r=Lg(t,e);return _u(r)?r:i}function he(t,e){let i=R.resolve(e);if(F(t.runtimeDir,i))return t.runtimeDir;if(F(t.nativeRoot,i))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function F(t,e){return Bt(R.resolve(t),R.resolve(e))}async function A(t,e){let i=R.resolve(t),r=R.resolve(e);if(!Bt(i,r))throw new Error(`Path is outside the Native root: ${e}`);if(await Mo(i))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([Dt(i),Dt(r)]);if(!Bt(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return r}var sn=Qr;function ju(t="docs",e="en"){return Zr(t,e)}async function z(t){let e=(await nn(t))?.config??null;return e?.native?e:null}async function cn(t){let e=await z(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function ji(t,e,i={}){let r=await _i(t,{allowPartialProject:!0}),n=Ci(r.document?.value??{},e),a=Mg.join(t,...on.split("/"));await ee(a,Pi(n,e.native.language==="zh-CN"?"zh-CN":"en"),{containedRoot:t,beforeCommit:async()=>{await i.beforeCommit?.(),await Ho(t,r.identity)}})}function ln(t){return["comet","native","next",t.change,"--summary","<summary>",t.flag,"--expected-state-version",String(t.stateVersion),"--expected-action",t.action]}function un(t,e){return{name:t,flag:e,valueKind:"text",required:!0,template:null}}function Fg(t,e){return{name:t,flag:e,valueKind:"confirmation",required:!0,template:null}}function dn(t){return{name:t.name,stateVersion:t.stateVersion,expectedAction:t.expectedAction,commandArgs:ln({change:t.change,stateVersion:t.stateVersion,action:t.expectedAction,flag:t.flag}),requiredInputs:["summary",t.confirmationInput],inputOptions:[un("summary","--summary"),Fg(t.name,t.flag)]}}function qo(t){return[dn({name:"revise-implementation",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),dn({name:"revise-requirements",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function $u(t,e){let i={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[]},r=n=>({kind:n,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...i,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:r("none")};if(t.status==="await-user")return t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...i,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[un("summary","--summary")],commandAlternatives:[dn({name:"accept-result",change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...qo({change:t.name,stateVersion:t.state_version})],runnerAction:r("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...i,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:ln({change:t.name,stateVersion:t.state_version,action:"confirm-verifier-unavailable",flag:"--confirmed"}),requiredInputs:["summary","user-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:r("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...i,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[un("summary","--summary")],commandAlternatives:[dn({name:"resolve-verifier-blocker",change:t.name,stateVersion:t.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...qo({change:t.name,stateVersion:t.state_version})],runnerAction:r("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...i,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[un("summary","--summary")],commandAlternatives:qo({change:t.name,stateVersion:t.state_version}),runnerAction:r("none")}:{...i,disposition:"await-user",action:"none",commandArgs:null,requiredInputs:["resolve-blocker"],runnerAction:r("none")};if(t.status==="blocked"){let n=t.blockers.some(({resolution_action:a})=>a==="retry-verifier");return{...i,disposition:"blocked",action:n?"retry-verifier":"none",commandArgs:n?ln({change:t.name,stateVersion:t.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:n?["summary"]:["repair-runtime"],inputOptions:n?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:r(n?"retry-verifier":"none")}}if(t.phase==="shape")return{...i,disposition:"continue",action:"confirm-shape",commandArgs:ln({change:t.name,stateVersion:t.state_version,action:"confirm-shape",flag:"--confirmed"}),requiredInputs:["summary","shared-understanding-confirmation"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},{name:"confirmed",flag:"--confirmed",valueKind:"confirmation",required:!0,template:null}],runnerAction:r("none")};if(t.phase==="build"){if(e){if(!e.confirmed)return{...i,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")};if(t.loop.stage==="repairing"&&t.verification_result==="fail")return{...i,disposition:"continue",action:"repair",commandArgs:null,requiredInputs:["repair-child"],inputOptions:[],runnerAction:r("none")};if(e.allDone)return{...i,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:r("none")};let n=e.children.some(({status:o})=>o==="blocked"),a=e.children.some(({status:o})=>o==="ready"||o==="active");return{...i,disposition:n&&!a?"blocked":"continue",action:"advance-children",commandArgs:null,requiredInputs:n&&!a?["resolve-child-blocker"]:["ready-children"],inputOptions:[],runnerAction:r("none")}}return{...i,disposition:"continue",action:t.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],known_limits:[]}}],runnerAction:r("builder-handoff")}}if(t.phase==="verify"){let n=t.loop.next_action==="await-verifier-result";return{...i,disposition:"continue",action:n?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[n?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:n?[{kind:"verifier-response",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}]}},{kind:"verifier-response",response:{kind:"final-result",result:{iteration:t.loop.iteration,attempt:t.loop.attempt,verdict:"<pass|fail|blocked>",acceptance:[{id:"<acceptance-id>",result:"<passed|failed|blocked>",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:[]}}],runnerAction:r(n?"await-verifier":"dispatch-verifier")}}return{...i,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:r("none")}}import{promises as at}from"node:fs";import zi from"node:path";import{execFileSync as Vg}from"child_process";import $i from"path";function et(t,e){return Vg("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function qg(t,e){let i=$i.normalize(t),r=$i.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function ie(t){try{let e=$i.resolve(et(t,["rev-parse","--show-toplevel"])),r=et(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=r?$i.resolve(r.slice(9)):e,a=null;try{a=et(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!qg(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function fn(t){try{et(t,["rev-parse","--is-inside-work-tree"]);let e=et(t,["worktree","list","--porcelain"]).split(/\r?\n/u),i=[],r=null;for(let n of e)n.startsWith("worktree ")?(r&&i.push(r),r={root:$i.resolve(n.slice(9)),branch:null,detached:!1}):r&&n.startsWith("branch refs/heads/")?r.branch=n.slice(18):r&&n==="detached"&&(r.detached=!0);return r&&i.push(r),i}catch{return[]}}function Oi(t){return fn(t).map(e=>e.root)}function Hi(t,e){try{return et(t,["check-ref-format","--branch",e]),et(t,["show-ref","--verify",`refs/heads/${e}`]),!0}catch{return!1}}function Wo(t,e){try{let i=et(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(i)?i:null}catch{return null}}import{createHash as Gg}from"node:crypto";import{promises as pe}from"node:fs";import re from"node:path";import{TextDecoder as Ug}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"]),zg=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Jg(t){return t.toLowerCase().startsWith(".env")}function Di(t){let i=t.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>Jg(r))?"environment-file":i.some(r=>zg.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>Wg.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}var pn=1024*1024;function zo(t,e){let i=re.relative(t,e);return i===""||!re.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${re.sep}`)}function Kg(t){let e=re.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})||re.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 i=t.toLowerCase(),r=Di(t);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${t}`);return t}function Yg(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Xg(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function hn(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return ke(i,r)?T(i,r):T(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Ou(t){let e=await pe.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await pe.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Qg(t,e){let i=re.resolve(t),r=re.resolve(e);if(!zo(i,r))throw new Error("Native artifact path is outside its root");let n=[await Ou(i)],a=i;for(let o of re.relative(i,r).split(re.sep).filter(Boolean)){a=re.join(a,o);let s=await Ou(a);if(!zo(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Hu(t){for(let e of t){let i=await pe.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!Xg(e,i)||await pe.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function ne(t){let e=Kg(t.ref),i=t.maxBytes===null?null:Yg(t.maxBytes??pn),r=re.resolve(t.root,...e.split("/")),n=await Qg(t.root,re.dirname(r));await t.hooks?.afterParentChainCaptured?.();let a=await pe.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(i!==null&&a.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);let o=await pe.realpath(r);if(!zo(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await pe.open(r,"r");try{let[c,l,u]=await Promise.all([s.stat(),pe.lstat(r),pe.realpath(r)]);if(await Hu(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!hn(a,c)||!hn(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],f=0,p=Buffer.allocUnsafe(i===null?64*1024:Math.min(64*1024,i+1));for(;;){let k=i===null?p.length:i+1-f,S=await s.read(p,0,Math.min(p.length,k),null);if(S.bytesRead===0)break;if(f+=S.bytesRead,i!==null&&f>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);d.push(Buffer.from(p.subarray(0,S.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),pe.lstat(r),pe.realpath(r)]);if(await Hu(n),!h.isFile()||h.isSymbolicLink()||m!==o||!hn(c,v)||!hn(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let y=Buffer.concat(d,f),N;try{N=new Ug("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:Gg("sha256").update(y).digest("hex"),text:N}}finally{await s.close()}}var Aw=Gt(It(),1);import{execFileSync as Zg}from"node:child_process";var ew=3e4,tw=8*1024*1024,Jo=class extends Error{constructor(i,r,n){super(`git ${r.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=i;this.args=r;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr};function iw(t,e){try{return Zg("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:ew,maxBuffer:tw,windowsHide:!0})}catch(i){let r=typeof i.stderr=="string"?i.stderr.trim():Buffer.isBuffer(i.stderr)?i.stderr.toString("utf8").trim():"";throw new Jo(t,e,r)}}function Ie(t,e){return iw(t,e).trim()}function Du(t){return Ie(t,["status","--porcelain=v1","-z","--untracked-files=all"])===""}function Go(t,e){Ie(t,["check-ref-format","--branch",e])}import{createHash as rw}from"crypto";function me(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function nw(t,e){e.has(t)&&me("cyclic structures are not supported"),e.add(t);try{let i=Object.keys(t);for(let r=0;r<t.length;r+=1)Object.prototype.hasOwnProperty.call(t,r)||me("sparse arrays are not supported");return(i.length!==t.length||i.some((r,n)=>r!==String(n)))&&me("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&me("symbol properties are not supported"),`[${t.map(r=>Uo(r,e)).join(",")}]`}finally{e.delete(t)}}function aw(t,e){let i=Object.getPrototypeOf(t);i!==Object.prototype&&i!==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 r=Object.getOwnPropertyDescriptors(t);return`{${Object.keys(t).sort().map(o=>{let s=r[o];return(!s||!("value"in s))&&me("accessor properties are not supported"),`${JSON.stringify(o)}:${Uo(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function Uo(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)?nw(t,e):aw(t,e);case"bigint":case"function":case"symbol":case"undefined":return me(`${typeof t} values are not supported`)}return me("unsupported value type")}function Ko(t){return Uo(t,new Set)}function ae(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 rw("sha256").update(`${t}
165
+ ${Ko(e)}`).digest("hex")}var mn=Gt(It(),1);import{promises as ow}from"node:fs";var Lt="comet.native.v4",Bi="comet.native.local-execution.v4";function Yo(){return{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}}}var sw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,cw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,lw=/^A[1-9][0-9]*$/u,uw=/^[a-f0-9]{64}$/u,dw=new Set(["schema","name","language","phase","status","state_version","brief","children_contract_hash","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]);function J(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function G(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function L(t,e,i){if(typeof t!="string"||!i?.empty&&t.length===0)throw new Error(`${e} must be ${i?.empty?"a string":"a non-empty string"}`);return t}function Xo(t,e){return t===null?null:L(t,e)}function fw(t,e){let i=L(t,e);if(!uw.test(i))throw new Error(`${e} must be a SHA-256 hash`);return i}function Mt(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function I(t,e,i=0){if(!Number.isSafeInteger(t)||t<i)throw new Error(`${e} must be a safe integer greater than or equal to ${i}`);return t}function hw(t,e){return t===null?null:I(t,e,Number.MIN_SAFE_INTEGER)}function B(t,e,i){if(typeof t!="string"||!e.includes(t))throw new Error(`${i} must be one of: ${e.join(", ")}`);return t}function Ee(t,e,i){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((r,n)=>i(r,n))}function vn(t,e){return Ee(t,e,(i,r)=>L(i,`${e}[${r}]`))}function gt(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Ft(t,e){let i=L(t,e);if(Number.isNaN(Date.parse(i)))throw new Error(`${e} must be an ISO date or timestamp`);return i}function Qo(t,e,i=!1){let r=L(t,e);if(r.includes("\\")||r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").includes("..")||!i&&(r==="."||r.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return r}function ve(t,e){let i=J(t,e);return G(i,new Set(["text","truncated"]),e),{text:L(i.text,`${e}.text`,{empty:!0}),truncated:Mt(i.truncated,`${e}.truncated`)}}function pw(t,e){let i=`Native spec_changes[${e}]`,r=J(t,i);G(r,new Set(["capability","operation","source"]),i);let n=L(r.capability,`${i}.capability`);if(!cw.test(n))throw new Error(`${i}.capability is invalid`);let a=B(r.operation,["create","modify","remove"],`${i}.operation`),o=r.source===null?null:Qo(r.source,`${i}.source`);if(a==="remove"&&o!==null)throw new Error(`${i} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${i} ${a} requires a source`);return{capability:n,operation:a,source:o}}function mw(t){let e="Native workspace",i=J(t,e);G(i,new Set(["isolation","change_branch","target_branch","finish"]),e);let r=B(i.isolation,["current","branch","worktree"],`${e}.isolation`),n=Xo(i.change_branch,`${e}.change_branch`),a=Xo(i.target_branch,`${e}.target_branch`),o=i.finish===null?null:B(i.finish,["merge","push","pull-request","keep"],`${e}.finish`);if(r==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(r==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(r!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:r,change_branch:n,target_branch:a,finish:o}}function vw(t){let e="Native loop",i=J(t,e);G(i,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 r=vn(i.previous_unresolved_ids,`${e}.previous_unresolved_ids`);return gt(r,`${e}.previous_unresolved_ids`),{stage:B(i.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:I(i.goal_cycle,`${e}.goal_cycle`,1),iteration:I(i.iteration,`${e}.iteration`),attempt:I(i.attempt,`${e}.attempt`),retry_epoch:I(i.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:I(i.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:I(i.no_progress_count,`${e}.no_progress_count`),execution_failure_count:I(i.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:r,next_action:Xo(i.next_action,`${e}.next_action`)}}function gw(t,e){let i=`Native acceptance[${e}]`,r=J(t,i);G(r,new Set(["id","source","text","result","reason"]),i);let n=L(r.id,`${i}.id`);if(!lw.test(n))throw new Error(`${i}.id must use A1, A2, ...`);return{id:n,source:Qo(r.source,`${i}.source`),text:L(r.text,`${i}.text`),result:B(r.result,["pending","passed","failed","blocked"],`${i}.result`),reason:r.reason===null?null:ve(r.reason,`${i}.reason`)}}function ww(t,e){let i=`Native builder_handoff.checks[${e}]`,r=J(t,i);return G(r,new Set(["name","result","note"]),i),{name:ve(r.name,`${i}.name`),result:B(r.result,["passed","failed","not-run"],`${i}.result`),note:r.note===null?null:ve(r.note,`${i}.note`)}}function yw(t){let e="Native builder_handoff",i=J(t,e);G(i,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","submitted_at"]),e);let r=vn(i.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);return gt(r,`${e}.addressed_acceptance_ids`),{candidate_id:L(i.candidate_id,`${e}.candidate_id`),identity_provider:L(i.identity_provider,`${e}.identity_provider`),builder_execution_ref:L(i.builder_execution_ref,`${e}.builder_execution_ref`),iteration:I(i.iteration,`${e}.iteration`,1),summary:ve(i.summary,`${e}.summary`),addressed_acceptance_ids:r,checks:Ee(i.checks,`${e}.checks`,ww),checks_truncated:Mt(i.checks_truncated,`${e}.checks_truncated`),known_limits:Ee(i.known_limits,`${e}.known_limits`,(n,a)=>ve(n,`${e}.known_limits[${a}]`)),known_limits_truncated:Mt(i.known_limits_truncated,`${e}.known_limits_truncated`),submitted_at:Ft(i.submitted_at,`${e}.submitted_at`)}}function Nw(t,e){let i=`Native blockers[${e}]`,r=J(t,i);G(r,new Set(["owner","reason","acceptance_ids","resolution_action"]),i);let n=vn(r.acceptance_ids,`${i}.acceptance_ids`);return gt(n,`${i}.acceptance_ids`),{owner:B(r.owner,["builder","runtime","verifier","user","external"],`${i}.owner`),reason:ve(r.reason,`${i}.reason`),acceptance_ids:n,resolution_action:B(r.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${i}.resolution_action`)}}function bw(t,e){let i=`Native verification.checks[${e}]`,r=J(t,i);return G(r,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),i),{id:L(r.id,`${i}.id`),name:ve(r.name,`${i}.name`),argv_display:Ee(r.argv_display,`${i}.argv_display`,(n,a)=>ve(n,`${i}.argv_display[${a}]`)),argv_truncated:Mt(r.argv_truncated,`${i}.argv_truncated`),cwd_ref:Qo(r.cwd_ref,`${i}.cwd_ref`,!0),status:B(r.status,["passed","failed","interrupted"],`${i}.status`),exit_code:hw(r.exit_code,`${i}.exit_code`),duration_ms:I(r.duration_ms,`${i}.duration_ms`)}}function kw(t){let e="Native verification",i=J(t,e);G(i,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let r=Ee(i.checks,`${e}.checks`,bw);gt(r.map(a=>a.id),`${e}.checks IDs`);let n=L(i.identity_provider,`${e}.identity_provider`);return{candidate_id:L(i.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:L(i.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:I(i.iteration,`${e}.iteration`,1),attempt:I(i.attempt,`${e}.attempt`,1),assurance:i.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":B(i.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:B(i.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:r,summary:ve(i.summary,`${e}.summary`),risks:Ee(i.risks,`${e}.risks`,(a,o)=>ve(a,`${e}.risks[${o}]`)),risks_truncated:Mt(i.risks_truncated,`${e}.risks_truncated`),completed_at:Ft(i.completed_at,`${e}.completed_at`)}}function Sw(t,e){let i=`Native history[${e}]`,r=J(t,i);G(r,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),i);let n=vn(r.unresolved_ids,`${i}.unresolved_ids`);return gt(n,`${i}.unresolved_ids`),{goal_cycle:I(r.goal_cycle,`${i}.goal_cycle`,1),iteration:I(r.iteration,`${i}.iteration`),attempt:I(r.attempt,`${i}.attempt`),outcome:B(r.outcome,["pass","fail","blocked","execution-error","recovery"],`${i}.outcome`),unresolved_ids:n,summary:ve(r.summary,`${i}.summary`),completed_at:Ft(r.completed_at,`${i}.completed_at`)}}function Ew(t){let e="Native history_overflow.outcome_counts",i=J(t,e),r=["pass","fail","blocked","execution-error","recovery"];return G(i,new Set(r),e),{pass:I(i.pass,`${e}.pass`),fail:I(i.fail,`${e}.fail`),blocked:I(i.blocked,`${e}.blocked`),"execution-error":I(i["execution-error"],`${e}.execution-error`),recovery:I(i.recovery,`${e}.recovery`)}}function xw(t){let e="Native history_overflow",i=J(t,e);G(i,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let r=I(i.dropped_entries,`${e}.dropped_entries`),n=i.first_dropped_at===null?null:Ft(i.first_dropped_at,`${e}.first_dropped_at`),a=i.last_dropped_at===null?null:Ft(i.last_dropped_at,`${e}.last_dropped_at`);if(r===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(r>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=Ew(i.outcome_counts);if(Object.values(o).reduce((c,l)=>c+l,0)!==r)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:r,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function Pw(t){let e=new Set(t.acceptance.map(i=>i.id));for(let i of t.loop.previous_unresolved_ids)if(!e.has(i))throw new Error(`Native loop references unknown acceptance ID ${i}`);for(let i of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(i))throw new Error(`Native builder handoff references unknown ID ${i}`);for(let i of t.blockers)for(let r of i.acceptance_ids)if(!e.has(r))throw new Error(`Native blocker references unknown ID ${r}`);if(t.builder_handoff&&!(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.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 r=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(!r&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Cw(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 i=t.status==="await-user"?"await-user":t.status==="blocked"?"blocked":t.status==="done"?"done":null;if(i!==null&&t.loop.stage!==i)throw new Error(`Native status ${t.status} requires loop stage ${i}`);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(r=>r.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(t.verification.checks.some(r=>r.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 Vt(t){let e=J(t,"Native portable state");if(G(e,dw,"Native portable state"),e.schema!==Lt)throw new Error(`Native portable state schema must be ${Lt}`);let i=L(e.name,"Native state name");if(!sw.test(i))throw new Error("Native state name is invalid");if(e.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let r=Ee(e.spec_changes,"Native spec_changes",pw);gt(r.map(s=>s.capability),"Native spec change capabilities");let n=Ee(e.acceptance,"Native acceptance",gw);gt(n.map(s=>s.id),"Native acceptance IDs");let a=Ee(e.history,"Native history",Sw);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Lt,name:i,language:B(e.language,["en","zh-CN"],"Native state language"),phase:B(e.phase,["shape","build","verify","archive"],"Native state phase"),status:B(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:fw(e.children_contract_hash,"Native children contract hash")},spec_changes:r,workspace:mw(e.workspace),loop:vw(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:yw(e.builder_handoff),blockers:Ee(e.blockers,"Native blockers",Nw),verification:e.verification===null?null:kw(e.verification),history:a,history_overflow:xw(e.history_overflow),verification_result:B(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:B(e.verification_report,["verification.md"],"Native verification_report"),archived:Mt(e.archived,"Native archived"),created_at:Ft(e.created_at,"Native created_at")};return Pw(o),Cw(o),o}function Lu(t){let e=t.createdAt instanceof Date?t.createdAt.toISOString():t.createdAt??new Date().toISOString();return Vt({schema:Lt,name:t.name,language:t.language,phase:"shape",status:"active",state_version:1,brief:"brief.md",spec_changes:[],workspace:t.workspace??{isolation:"current",change_branch:null,target_branch:null,finish:null},loop:{stage:"shape",goal_cycle:1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:t.nextAction??null},acceptance:[],builder_handoff:null,blockers:[],verification:null,history:[],history_overflow:Yo(),verification_result:"pending",verification_report:null,archived:!1,created_at:e})}function Rw(t,e){let i=(0,mn.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`${e} is invalid YAML: ${i.errors[0].message}`);return i.toJS({mapAsMap:!1})}async function Zo(t){let e=await ow.readFile(t,"utf8");return Vt(Rw(e,"Native portable state"))}async function Mu(t,e,i={}){let r=Vt(e);await ee(t,(0,mn.stringify)(r),i)}var vs=Gt(It(),1);import{promises as On}from"fs";import U from"path";import{promises as Sy}from"fs";import Ey from"path";import{AsyncLocalStorage as _w}from"async_hooks";import{randomUUID as qu}from"crypto";import{promises as oe}from"fs";import Wu from"os";import H from"path";var Fu=16*1024,zu=".coordinator",Tw=5e3,Vu=new _w,gn=new Map;function Iw(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function jw(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let i=t;if(typeof i.id!="string"||i.id.length===0||typeof i.pid!="number"||!Number.isSafeInteger(i.pid)||i.pid<1||typeof i.hostname!="string"||i.hostname.length===0||typeof i.createdAt!="string"||i.createdAt.length===0||typeof i.operation!="string"||i.operation.length===0)throw new Error(`Invalid Native lock metadata: ${e}`);return i}function Ju(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 es(t,e){let i={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},r={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return ke(i,r)?T(i,r):T(i,r)&&t.size===e.size}function ts(t,e){return es(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}async function je(t){let e,i;try{let r=await Ot(t,Fu,{bigint:!0,label:"Native lock"});e=r.bytes,i=r.stat}catch(r){if(r.code==="ENOENT")return null;throw r instanceof de?r.reason==="too-large"?new Error(`Native lock metadata exceeds ${Fu} bytes: ${t}`,{cause:r}):r.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:r}):new Error(`Native lock changed while reading: ${t}`,{cause:r}):r}return{file:t,owner:jw(JSON.parse(e.toString("utf8")),t),identity:Ju(i)}}async function $w(t){return(await je(t))?.owner??null}function Gu(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==Wu.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=Mw(t.owner.pid);return{status:e===!0?"active":e===!1?"stale":"unknown",owner:t.owner,identity:t.identity}}async function Ow(t,e){try{await oe.lstat(e);return}catch(i){if(i.code!=="ENOENT")throw i}try{await oe.rename(t,e)}catch(i){if(i.code!=="ENOENT")throw i}}async function is(t,e){let i=await je(t.file);if(!i)return"missing";if(i.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!ts(i.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await oe.mkdir(e,{recursive:!0});let r=H.join(e,`${H.basename(t.file)}.${t.owner.id}.${qu()}.removed`);try{await oe.rename(t.file,r)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await je(r);if(!n||n.owner.id!==t.owner.id||!es(n.identity,t.identity))throw await Ow(r,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await oe.rm(r,{force:!0}),"removed"}function Uu(t){return{id:qu(),pid:process.pid,hostname:Wu.hostname(),createdAt:new Date().toISOString(),operation:t}}async function Ku(t,e){let i;try{i=await oe.open(t,"wx")}catch(r){if(r.code==="EEXIST"){let n=await $w(t);throw new Error(`Native lock is already held: ${t}${n?` by pid ${n.pid} for ${n.operation}`:""}`,{cause:r})}throw r}try{return await i.writeFile(JSON.stringify(e,null,2)+`
166
+ `,"utf8"),await i.sync(),Ju(await i.stat({bigint:!0}))}finally{await i.close()}}async function Hw(t,e){let i=await A(t.runtimeDir,t.locksDir);await oe.mkdir(i,{recursive:!0});let r=await A(t.runtimeDir,H.join(i,zu));await oe.mkdir(r,{recursive:!0});let n=Uu(e),a=H.join(r,`.${n.id}.tmp`),o=H.join(r,`${n.id}.claim`);try{let s=await Ku(a,n);await oe.rename(a,o);let c=await je(o);if(!c||!es(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:i,owner:n,identity:c.identity}}finally{await oe.rm(a,{force:!0})}}async function Dw(t){let e=H.dirname(t.file),i=!1,r=H.basename(t.file);for(let n of await oe.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=H.join(e,n.name);if(H.resolve(a)!==H.resolve(t.file))try{let o=await je(a),s=Gu(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await is(o,e);continue}n.name<r&&(i=!0)}catch{n.name<r&&(i=!0)}}return i}async function Yu(t){let e=await je(t.file);if(e){if(e.owner.id!==t.owner.id||!ts(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await is(e,H.dirname(t.file))}}async function Bw(t,e){let i=Date.now()+Tw;for(;;){let r=await Hw(t,e);if(!await Dw(r))return r;if(await Yu(r),Date.now()>=i)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function Lw(t){let e=gn.get(t)??Promise.resolve(),i,r=new Promise(a=>{i=a}),n=e.then(()=>r);return gn.set(t,n),await e,()=>{i(),gn.get(t)===n&&gn.delete(t)}}async function rs(t,e,i){let r=H.resolve(t.locksDir),n=Vu.getStore();if(n?.has(r))return i();let a=await Lw(r);try{let o=await Bw(t,e),s=new Map(n??[]);return s.set(r,o),await Vu.run(s,async()=>{try{return await i()}finally{await Yu(o)}})}finally{a()}}async function Xu(t,e,i){let r=[...new Map(t.map(a=>[H.resolve(a.locksDir),a])).values()].sort((a,o)=>H.resolve(a.locksDir).localeCompare(H.resolve(o.locksDir))),n=async a=>{let o=r[a];return o?rs(o,e,()=>n(a+1)):i()};return n(0)}async function wn(t,e,i){return rs(t,`acquire ${e}`,async()=>{let r=await A(t.runtimeDir,t.locksDir);await oe.mkdir(r,{recursive:!0});let n=await A(t.runtimeDir,H.join(r,Iw(e))),a=Uu(i),o=await Ku(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:r,owner:a,identity:o}})}async function yn(t){await je(t.file)&&await rs({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${H.basename(t.file)}`,async()=>{let e=await je(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!ts(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let i=H.join(t.locksDir,zu);await is(e,i)})}function Mw(t){try{return process.kill(t,0),!0}catch(e){let i=e.code;return i==="ESRCH"?!1:i==="EPERM"?!0:null}}async function Qu(t){return Gu(await je(t))}import Xw from"node:path";var JE=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Zu=Object.freeze({maxCriteria:1024});var $e="comet.native.v3",Oe="comet.native.v2",He="comet.native.v1";var ed="comet.native.portable-migration.v1",Ww=new Set(["schema","id","change","fromSchema","status","createdAt"]),zw=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Jw=/^[a-z0-9][a-z0-9-]{7,127}$/u,Gw=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),Uw=new Set([He,Oe,$e]);function Kw(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Yw(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let i=new Date(t);if(Number.isNaN(i.valueOf())||i.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function id(t){let e=Kw(t,"Native portable migration transaction"),i=Object.keys(e).filter(r=>!Ww.has(r));if(i.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${i.join(", ")}`);if(e.schema!==ed)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!Jw.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!zw.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!Uw.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!Gw.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:ed,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:Yw(e.createdAt,"Native portable migration transaction createdAt")}}var rd="comet.native.archive-transaction.v4",nd="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",Qw=new RegExp(`^portable-archive-(${nd})\\.json$`,"u"),Zw=new RegExp(`^portable-migration-(${nd})\\.json$`,"u"),ey=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,ty=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,iy=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),ry=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"]),ad=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function od(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function sd(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`);if(Object.keys(t).length!==e.size)throw new Error(`${i} fields are invalid`)}function ay(t,e){let i=`Native portable Archive spec_changes[${e}]`,r=od(t,i);if(sd(r,ny,i),typeof r.capability!="string"||!ad.test(r.capability))throw new Error(`${i}.capability is invalid`);if(!["create","modify","remove"].includes(String(r.operation)))throw new Error(`${i}.operation is invalid`);let n=r.operation;if(n==="remove"){if(r.source!==null||r.content!==null)throw new Error(`${i} remove requires source and content null`);return{capability:r.capability,operation:n,source:null,content:null}}if(typeof r.source!="string"||r.source.length===0||r.source.includes("\\")||r.source.startsWith("/")||/^[A-Za-z]:/u.test(r.source)||r.source.split("/").some(a=>a==="."||a===".."))throw new Error(`${i}.${n} source is invalid`);if(typeof r.content!="string")throw new Error(`${i}.${n} content is invalid`);return{capability:r.capability,operation:n,source:r.source,content:r.content}}function oy(t){let e=od(t,"Native portable Archive transaction");if(sd(e,ry,"Native portable Archive transaction"),e.schema!==rd)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!ey.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!ad.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"||!ty.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"||!iy.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 i=e.spec_changes.map(ay);if(new Set(i.map(({capability:n})=>n)).size!==i.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>i.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 r=new Date(e.created_at);if(Number.isNaN(r.valueOf())||r.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:rd,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:i,created_at:e.created_at}}function ns(t){let e=Qw.exec(t);if(e)return{kind:"archive",change:e[1]};let i=Zw.exec(t);return i?{kind:"migration",change:i[1]}:null}async function cd(t,e){let i=ns(e);if(!i)return null;let r=await ne({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(r.text),a=Xw.join(t.transactionsDir,e);if(i.kind==="archive"){let s=oy(n);if(s.change!==i.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:i.change,file:a,journal:s}}let o=id(n);if(o.change!==i.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:i.change,file:a,journal:o}}function ld(t){return t.kind==="archive"||t.journal.status!=="committed"}import Be from"path";import{TextDecoder as hy}from"util";import{createHash as sy}from"node:crypto";import{constants as Sn,promises as X}from"node:fs";import ge from"node:path";import{TextDecoder as cy}from"node:util";function xn(t,e){let i=ge.relative(t,e);return i===""||!ge.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ge.sep}`)}function ud(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function ly(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function uy(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function En(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 as(t,e){let i=await X.lstat(t);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await X.realpath(t),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function dd(t,e,i){let r=ge.resolve(t),n=ge.resolve(e);if(!xn(r,n))throw new Error(`${i} is outside its managed root`);let a=[await as(r,i)],o=r;for(let s of ge.relative(r,n).split(ge.sep).filter(Boolean)){await De(a,i),o=ge.join(o,s);let c=await as(o,i);if(!xn(a[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${o}`);a.push(c)}return await De(a,i),a}async function De(t,e){for(let i of t){let r=await X.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!ly(i,r)||await X.realpath(i.path)!==i.realPath)throw new Error(`${e} parent changed during I/O: ${i.path}`)}}async function dy(t,e,i){let r=[],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(`${i} exceeds ${e} bytes`);r.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(r,n)}async function wt(t){let e=ud(t.maxBytes),i=ge.resolve(t.file),r=await dd(t.root,ge.dirname(i),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(u=>as(ge.resolve(u),t.label)));await t.hooks?.afterParentChainCaptured?.(),await De(r,t.label);let a=await X.lstat(i);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=uy(a),s=await X.realpath(i);if(!xn(r[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(u=>xn(u.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?Sn.O_RDONLY:Sn.O_RDONLY|Sn.O_NOFOLLOW|Sn.O_NONBLOCK,l=await X.open(i,c);try{let u=await l.stat();await t.hooks?.afterOpen?.();let[d,f]=await Promise.all([X.lstat(i),X.realpath(i)]);if(await De(r,t.label),await De(n,t.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!En(o,u)||!En(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let p=await dy(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),X.lstat(i),X.realpath(i)]);if(await De(r,t.label),await De(n,t.label),!h.isFile()||h.isSymbolicLink()||m!==s||!En(o,v)||!En(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 fd(t){let e=await wt(t),i;try{i=new cy("utf-8",{fatal:!0}).decode(e.bytes)}catch(r){throw new Error(`${t.label} is not valid UTF-8`,{cause:r})}return{...e,text:i}}async function Li(t){let e=await dd(t.root,t.directory,t.label),i;if(t.maxEntries===void 0)i=await X.readdir(t.directory,{withFileTypes:!0});else{let r=ud(t.maxEntries);i=[];let n=await X.opendir(t.directory);try{for await(let a of n)if(i.push(a),i.length>r)throw new Error(`${t.label} exceeds ${r} entries`)}finally{await n.close().catch(a=>{if(a.code!=="ERR_DIR_CLOSED")throw a})}}return await De(e,t.label),{entries:i,verify:()=>De(e,t.label)}}var py=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),my=new Set(["id","type","source","target","staged","backup"]),vy=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),gy=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]);var md=new Set(["prepared","applying","committed","rolling-back","rolled-back"]);var wy=256*1024,Px=1024*1024,Cx=16*1024;var Rx=64*1024*1024;var yy=new hy("utf-8",{fatal:!0});function Cn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Rn(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function vd(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function os(t,e){if(typeof t!="string"||t.length===0||Be.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function Pn(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function hd(t,e){if(os(t,e),t.includes("\\")||t!==Be.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 Ny(t,e){let i=Cn(t,`transaction operations[${e}]`);if(Rn(i,my,`transaction operations[${e}]`),typeof i.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.id))throw new Error(`transaction operations[${e}].id is invalid`);if(i.type!=="write"&&i.type!=="remove"&&i.type!=="move")throw new Error(`transaction operation ${i.id} has an invalid type`);os(i.target,`transaction operation ${i.id} target`);for(let r of["source","staged","backup"])i[r]!==void 0&&os(i[r],`transaction operation ${i.id} ${r}`);if(i.type==="write"){if(i.staged===void 0||i.source!==void 0)throw new Error(`write operation ${i.id} requires staged and forbids source`)}else if(i.type==="remove"){if(i.source!==void 0||i.staged!==void 0)throw new Error(`remove operation ${i.id} forbids source and staged`)}else if(i.source===void 0||i.staged!==void 0||i.backup!==void 0)throw new Error(`move operation ${i.id} requires source and forbids staged and backup`);return i}function gd(t){let e=Cn(t,"Native Archive transaction journal");if(Rn(e,vy,"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"||!md.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(!vd(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Pn(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 i=e.operations.map((s,c)=>{let l=Cn(s,`Archive transaction operations[${c}]`);if(Rn(l,gy,`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`);hd(l.target,`Archive transaction operation ${l.id} target`);for(let u of["source","staged","backup"])l[u]!==void 0&&hd(l[u],`Archive transaction operation ${l.id} ${u}`);if(l.expectedTargetHash!==null&&Pn(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(Pn(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`);Pn(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),r=i.map(s=>s.id);if(new Set(r).size!==r.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=i.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)||i.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of i.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:i}}function by(t){let e=Cn(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return gd(e);if(Rn(e,py,"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"||!md.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!Be.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!Be.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(!vd(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 i=e.operations.map(Ny),r=i.map(n=>n.id);if(new Set(r).size!==r.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id: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:i}}function ky(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return Be.join(t.transactionsDir,e)}function wd(t,e){let i=ky(t,e);return{directory:i,journal:Be.join(i,"transaction.json"),events:Be.join(i,"events.jsonl"),staged:Be.join(i,"staged"),backups:Be.join(i,"backups")}}async function ss(t,e){let i=wd(t,e);return await Promise.all(Object.values(i).map(r=>A(t.runtimeDir,r))),i}async function cs(t,e,i={}){let r=await ss(t,e),n=await wt({root:t.runtimeDir,file:r.journal,maxBytes:wy,label:`Native transaction journal ${e}`,hooks:i.hooks}),a=JSON.parse(yy.decode(n.bytes)),o=by(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}async function xy(t,e,i){let r;try{r=await Sy.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await cs(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of r)if(ns(n.name))try{let a=await cd(t,n.name);if(!a||i?.kind===a.kind&&i.change===a.change)continue;if(ld(a))return!0}catch{return!0}return!1}async function Py(t,e){let i=Date.now()+5e3,r=Ey.join(t.locksDir,"root-move.lock");for(;;)try{return await wn(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Qu(r);if(o.status==="missing")continue;if(o.status!=="active"||Date.now()>=i)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function we(t,e,i,r){let n=await Py(t,e);try{if(await cn(t.projectRoot),await xy(t,r?.allowedTransactionId,r?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await i()}finally{await yn(n)}}import us from"path";import{createHash as Cy}from"crypto";function Q(t){return Cy("sha256").update(t).digest("hex")}var Ux={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},Ay=1e3,_y=8*1024*1024,Ty=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Iy=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),jy=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),$y=new Set(["schema","include","exclude","hash"]),Oy=new Set(["provider","gitSelection","physicalSelection","projection"]),Hy=new Set(["provider","selection"]),Dy=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),By=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),Ly=new Set(["schema","status","before","after"]),My=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),Fy=new Set(["path","hash","size","type","gitObjectId"]),Vy=new Set(["path","size","type","reason"]),qy=new Set(["ref","hash","count"]),Wy=new Set(["change-created","legacy-migration","explicit"]),zy=new Set(["file","directory","other"]),Jy=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"]),_n=/^[a-f0-9]{64}$/u,Gy=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var Kx=64*1024,Yx=64*1024;var Xx={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},Qx={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function An(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var Zx=(1n<<256n)-1n;function Uy(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 Ky(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
167
+ `)}function Yy(t,e){return Q(`comet.native.snapshot-policy.v1
168
+ ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function ls(t,e,i){let r=new Set(e),n=[...e];for(;n.length>0;){if(i&&!i())return null;let a=n.pop(),o=t[a];o&&(o.kind==="star"||o.kind==="globstar"||o.kind==="globstar-slash")&&!r.has(a+1)&&(r.add(a+1),n.push(a+1))}return r}function Xy(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function yd(t){let e=sn(t,"Native snapshot pattern"),i=[];for(let r=0;r<e.length;r+=1){let n=e[r];n==="*"&&e[r+1]==="*"?(r+=1,e[r+1]==="/"?(r+=1,i.push({kind:"globstar-slash"})):i.push({kind:"globstar"})):n==="*"?i.push({kind:"star"}):n==="?"?i.push({kind:"question"}):i.push({kind:"literal",value:n})}return(r,n)=>{let a=n?Xy(n):void 0;if(a&&!a())return!1;let o=ls(i,new Set([0]),a);if(o===null)return!1;for(let s of r){if(a&&!a())return!1;let c=new Set;for(let l of o){if(a&&!a())return!1;let u=i[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=ls(i,c,a),o===null||o.size===0)return!1}return ls(i,o,a)?.has(i.length)??!1}}function Qy(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>sn(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),i=[...new Set(t.exclude.map(n=>sn(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 r=Yy(e,i);if("hash"in t&&t.hash!==r)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:i,hash:r},includeMatchers:e.map(yd),excludeMatchers:i.map(yd),excludedDirectoryPrefixes:i.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 se(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ce(t,e,i){let r=Object.keys(t).find(n=>!e.has(n));if(r)throw new Error(`${i} contains unknown field: ${r}`)}function Wt(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function xe(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function kd(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 i=us.posix.normalize(t);if(i!==t||us.posix.isAbsolute(t)||i===".."||i.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function Zy(t,e){let i=se(t,`Native snapshot entry ${e}`);ce(i,Fy,`Native snapshot entry ${e}`);let r=kd(i.path,`Native snapshot entry ${e} path`);if(typeof i.hash!="string"||!_n.test(i.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(i.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:r,hash:i.hash,size:xe(i.size,`Native snapshot entry ${e} size`),type:"file"};if(i.gitObjectId!==void 0){if(typeof i.gitObjectId!="string"||!Gy.test(i.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=i.gitObjectId}return n}function eN(t,e){let i=se(t,`Native snapshot omission ${e}`);if(ce(i,Vy,`Native snapshot omission ${e}`),!zy.has(i.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!Jy.has(i.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:kd(i.path,`Native snapshot omission ${e} path`),size:i.size===null?null:xe(i.size,`Native snapshot omission ${e} size`),type:i.type,reason:i.reason}}function tN(t){let e=se(t,"Native snapshot omission overflow");if(ce(e,qy,"Native snapshot omission overflow"),typeof e.hash!="string"||!_n.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let i=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==i)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:i,hash:e.hash,count:Wt(e.count,"Native snapshot omission overflow count")}}function qt(t,e){let i=se(t,e);if(ce(i,By,e),typeof i.hash!="string"||!_n.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let r=xe(i.recordCount,`${e} recordCount`),n=xe(i.storedRecordCount,`${e} storedRecordCount`),a=xe(i.stdoutBytes,`${e} stdoutBytes`);if(n>r||!i.overflow&&n!==r)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,recordCount:r,storedRecordCount:n,stdoutBytes:a,overflow:i.overflow}}function Nd(t){let e=se(t,"Native Git selection evidence");if(ce(e,Dy,"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 i=qt(e.stageBefore,"Native Git selection stageBefore"),r=qt(e.combined,"Native Git selection combined"),n=qt(e.stageAfter,"Native Git selection stageAfter"),a=qt(e.finalStageBefore,"Native Git selection finalStageBefore"),o=qt(e.finalCombined,"Native Git selection finalCombined"),s=qt(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[i,r,n,a,o,s].some(d=>d.overflow),l=!An(i,n)||!An(n,a)||!An(r,o)||!An(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:i,combined:r,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function bd(t,e){let i=se(t,e);if(ce(i,My,e),typeof i.hash!="string"||!_n.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean"||typeof i.unstable!="boolean")throw new Error(`${e} flags are invalid`);let r=xe(i.visitedNodeCount,`${e} visitedNodeCount`),n=xe(i.recordCount,`${e} recordCount`),a=xe(i.storedRecordCount,`${e} storedRecordCount`),o=xe(i.encodedBytes,`${e} encodedBytes`);if(a>n||!i.overflow&&a!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,visitedNodeCount:r,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:i.overflow,unstable:i.unstable}}function iN(t){let e=se(t,"Native physical selection evidence");if(ce(e,Ly,"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 i=bd(e.before,"Native physical selection before"),r=bd(e.after,"Native physical selection after"),n=i.overflow||r.overflow,a=i.unstable||r.unstable||!Uy(i,r);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:i,after:r}}function Sd(t){let e=se(t,"Native content snapshot manifest");if(ce(e,Iy,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!Wy.has(e.origin))throw new Error("Native content snapshot origin is invalid");let i;if(e.capture!==void 0){let g=se(e.capture,"Native content snapshot capture");if(ce(g,Oy,"Native content snapshot capture"),g.provider!=="git"&&g.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let P=g.gitSelection===void 0?void 0:Nd(g.gitSelection),b=g.physicalSelection===void 0?void 0:iN(g.physicalSelection),_=null;if(g.projection!==void 0){let K=se(g.projection,"Native content snapshot projection");if(ce(K,Hy,"Native content snapshot projection"),K.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");_={provider:"git",...K.selection===void 0?{}:{selection:Nd(K.selection)}}}if(g.provider==="git"){if(b||_)throw new Error("Native Git capture cannot include physical or projection evidence");i={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");i=_?{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 r=se(e.limits,"Native content snapshot limits");ce(r,jy,"Native content snapshot limits");let n={maxFiles:Wt(r.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Wt(r.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Wt(r.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Wt(r.maxManifestBytes,"Native snapshot maxManifestBytes"),...r.maxDurationMs===void 0?{}:{maxDurationMs:Wt(r.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let g=se(e.policy,"Native snapshot policy");if(ce(g,$y,"Native snapshot policy"),g.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(g.include)||!Array.isArray(g.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=Qy({include:g.include,exclude:g.exclude,hash:g.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(Zy),s=e.omitted.map(eN),c=xe(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:tN(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(g=>g.size>n.maxFileBytes)||o.reduce((g,P)=>g+P.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(g=>g.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>Ay||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(g=>g.reason==="git-enumeration-limit"),f=s.filter(g=>g.reason==="git-selection-changed");for(let g of[...d,...f])if(g.path!=="."||g.size!==null||g.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=i?.provider==="git"?i.gitSelection:i?.projection?.selection,v=p?.status==="overflow"||p?.status==="overflow-and-changed",h=p?.status==="changed"||p?.status==="overflow-and-changed";if(v!==(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(g=>g.reason==="physical-enumeration-limit"),y=s.filter(g=>g.reason==="physical-selection-changed");for(let g of[...m,...y])if(g.path!=="."||g.size!==null||g.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=i?.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,...i?{capture:i}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}};if(Ky(E)>n.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function rN(t,e){if(!Ty.test(e))throw new Error(`Invalid Native change name: ${e}`);return us.join(te(t,e),"baseline-manifest.json")}async function Ed(t,e){let i=rN(t,e),r=he(t,i);await A(r,i);try{let n=await fd({root:r,file:i,maxBytes:_y,label:"Native baseline snapshot manifest"});return Sd(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var lN=Gt(It(),1);var mP=4*1024*1024;var uN=null;function dN(t,e){let i=t;for(let r of e)i+="\0"+(typeof r=="string"?r:JSON.stringify(r));return i}function xd(t,e){return(...i)=>{let r=uN;if(r===null)return e(...i);let n=dN(`async:${t}`,i),a=r.entries.get(n);if(a)return a.value;let o=e(...i).catch(s=>{throw r.entries.delete(n),s});return r.entries.set(n,{value:o}),o}}var NP=xd("hookWritePolicy",async t=>(await Oo(t))?.hook??{allow_paths:[]});var hC=256*1024;var PC={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 hN}from"node:crypto";import{promises as Tn}from"node:fs";import tt from"node:path";var Mi=/^[a-f0-9]{64}$/u,Cd=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,pN=16*1024,fs=process.platform;function _d(t,e){let i=tt.relative(t,e);return tt.isAbsolute(i)||i===".."||i.startsWith(`..${tt.sep}`)?null:i.replaceAll("\\","/")||"."}function Td(t){return Array.from(t).some(e=>{let i=e.codePointAt(0)??0;return i<=31||i===127})}function Id(t,e){if(t.length===0||Td(t)||t.includes("\\")||tt.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let i=tt.posix.normalize(t);if(i!==t||i===".."||i.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return i}function hs(t,e){return hN("sha256").update(`${t}
169
+ ${e}`).digest("hex")}async function Rd(t,e){let i=await Tn.realpath(e),r=await Tn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=fs==="win32"?tt.normalize(i).toLowerCase():i;return hs(t,`${n}
170
170
  ${r.dev}
171
171
  ${r.ino}
172
- ${r.birthtimeMs}`)}async function Sd(t,e){let i=await Cn.realpath(e),r=await Cn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=ss==="win32"?Ze.normalize(i).toLowerCase():i;return cs(t,n)}function aN(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||Pd(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function Cd(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 oN(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,i=new Set(["provider","baseCommit","targetBranch","targetCommit"]),r=Object.keys(e).filter(n=>!i.has(n));if(r.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${r.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!bd.test(e.baseCommit)||typeof e.targetCommit!="string"||!bd.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");os(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,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(e).filter(o=>!i.has(o));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.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"||!Li.test(String(e.projectRootId))||!Li.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");aN(e.capturedAt),xd(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&&!Li.test(String(e.projectRootPathId))||a&&!Li.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!Li.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&oN(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(Cd(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 sN(t,e){return Ze.join(ie(t,e),"workspace.json")}function cN(t,e){let i=sN(t,e),r=pe(t,i),n=Ed(r,i);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:r,ref:xd(n,"Native workspace file ref")}}async function lN(t,e){try{let i=cN(t,e),r=await ae({root:i.root,ref:i.ref,maxBytes:nN});return JSON.parse(r.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function uN(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=Ed(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let i=re(t.paths.projectRoot),r=i.isGitWorktree?Lo(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??i.currentBranch,a=n==null?null:Lo(t.paths.projectRoot,n),o=r!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:r,targetBranch:n,targetCommit:a}:void 0,[s,c,l,u]=await Promise.all([kd("comet.native.workspace-project-root.v2",t.paths.projectRoot),kd("comet.native.workspace-native-root.v2",t.paths.nativeRoot),Sd("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),Sd("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&&Cd(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}
172
+ ${r.birthtimeMs}`)}async function Ad(t,e){let i=await Tn.realpath(e),r=await Tn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=fs==="win32"?tt.normalize(i).toLowerCase():i;return hs(t,n)}function mN(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 ds(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||Td(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function jd(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(ds(t.changeBranch,"Native workspace change branch"),ds(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 vN(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,i=new Set(["provider","baseCommit","targetBranch","targetCommit"]),r=Object.keys(e).filter(n=>!i.has(n));if(r.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${r.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!Cd.test(e.baseCommit)||typeof e.targetCommit!="string"||!Cd.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");ds(e.targetBranch,"Native workspace Git target branch")}function In(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(e).filter(o=>!i.has(o));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.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"||!Mi.test(String(e.projectRootId))||!Mi.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");mN(e.capturedAt),Id(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&&!Mi.test(String(e.projectRootPathId))||a&&!Mi.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!Mi.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&vN(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(jd(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 gN(t,e){return tt.join(te(t,e),"workspace.json")}function wN(t,e){let i=gN(t,e),r=he(t,i),n=_d(r,i);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:r,ref:Id(n,"Native workspace file ref")}}async function yN(t,e){try{let i=wN(t,e),r=await ne({root:i.root,ref:i.ref,maxBytes:pN});return JSON.parse(r.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function NN(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 i=ie(t.paths.projectRoot),r=i.isGitWorktree?Wo(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??i.currentBranch,a=n==null?null:Wo(t.paths.projectRoot,n),o=r!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:r,targetBranch:n,targetCommit:a}:void 0,[s,c,l,u]=await Promise.all([Rd("comet.native.workspace-project-root.v2",t.paths.projectRoot),Rd("comet.native.workspace-native-root.v2",t.paths.nativeRoot),Ad("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),Ad("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&&jd(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:hs("comet.native.workspace-session.v2",`${s}
173
173
  ${c}
174
- ${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 Wt(t,e){let i=await lN(t,e);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(Rn(i),i)}async function An(t){Rn(t.identity);let e=await uN({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),i=[],r=[];return e.nativeRootRef!==t.identity.nativeRootRef&&i.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&i.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&i.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&i.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&i.push("native-root-legacy-identity")),ss==="win32"&&i.length>0&&i.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?r.push("workspace-inspection-unavailable"):i.length>0&&r.push("workspace-root-changed"),{state:r.length===0?"aligned":r.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:r,driftComponents:i}}async function _n(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 An(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let i=re(t.paths.projectRoot);return t.identity.changeBranch===null?i.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}:i.isGitWorktree?i.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 ${i.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!i.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 Rd(t,e){let i=await Wt(t,e);if(i===null)return null;let r=await _n({paths:t,identity:i});if(r.state==="drifted")throw new Error(`${r.code}: ${r.message}`);return i}var Td=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],fN=new Set(Td),Id=new Set([...Td,"minimum_runtime_version","revision"]),hN=new Set([...Id,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),pN=new Set(["capability","operation","source","base_hash"]),mN=new Set(["shape","build","verify","archive"]),vN=new Set(["implicit","confirmed"]),gN=new Set(["pending","pass","fail"]),Be="comet-state.yaml",us=/^[a-f0-9]{64}$/u,jd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,wN=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,In=class extends Error{constructor(i,r){super(`Native change ${i} uses ${r}; run comet native doctor ${i} --repair before mutating it`);this.change=i;this.schema=r;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},gt=class extends Error{constructor(i,r){super(i!==je||r===null?`Unsupported Native change schema ${i} for runtime protocol ${3}`:`Native change ${i} requires runtime protocol ${r}; current protocol is ${3}`);this.schema=i;this.minimumRuntimeVersion=r;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"},jn=class extends Error{constructor(i,r,n){super(`Native change ${i} revision conflict: expected ${r}, actual ${n}`);this.change=i;this.expectedRevision=r;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},zt=class extends Error{constructor(i,r){super(`Native working directory already contains active change${r.length===1?"":"s"} ${r.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=i;this.activeChanges=r;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},$n=class extends Error{constructor(i,r,n,a,o,s=null,c=null){super(`Native change ${i} baseline is incomplete (${r} omitted entr${r===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=i;this.omittedCount=r;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},ZC=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
175
- `);function Fi(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function $d(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function On(t){if(!jd.test(t))throw new Error(`Invalid Native change name: ${t}`)}function yN(t){if(!jd.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Od(t,e){if(t.length===0||U.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function NN(t,e){let i=Fi(t,`spec_changes[${e}]`);if($d(i,pN,`spec_changes[${e}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(yN(i.capability),i.operation!=="create"&&i.operation!=="replace"&&i.operation!=="remove")throw new Error(`Invalid spec operation for ${i.capability}`);let r=i.source,n=i.base_hash;if(r!==void 0&&typeof r!="string")throw new Error(`Spec source for ${i.capability} must be a string`);if(typeof r=="string"&&Od(r,`Spec source for ${i.capability}`),i.operation==="create"){if(!r)throw new Error(`Create spec ${i.capability} requires source`);if(n!==null)throw new Error(`Create spec ${i.capability} requires null base_hash`)}else if(i.operation==="replace"){if(!r)throw new Error(`Replace spec ${i.capability} requires source`);if(typeof n!="string"||!us.test(n))throw new Error(`Replace spec ${i.capability} requires a SHA-256 base_hash`)}else{if(r!==void 0)throw new Error(`Remove spec ${i.capability} forbids source`);if(typeof n!="string"||!us.test(n))throw new Error(`Remove spec ${i.capability} requires a SHA-256 base_hash`)}return{capability:i.capability,operation:i.operation,...typeof r=="string"?{source:r}:{},base_hash:n}}function bN(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 fs(t,e){if($d(t,e,Be),typeof t.name!="string")throw new Error("Native change name is required");if(On(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"||!mN.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&&!vN.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 i=t.spec_changes.map(NN),r=i.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(r.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(r)].join(", ")}`);if(typeof t.verification_result!="string"||!gN.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"&&Od(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!bN(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:i,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function vn(t){let e=Fi(t,Be);if(e.schema!==Oe)throw new Error(`Expected ${Oe}`);return{schema:Oe,...fs(e,fN)}}function Mi(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function ls(t,e,i){if(t===null)return null;let r=typeof t=="string"?wN.exec(t):null;if(!r||r[1]!==i)throw new Error(`${e} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return t}function kN(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 SN(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 gn(t){let e=Fi(t,Be);if(e.schema!==$e)throw new Error(`Expected ${$e}`);if(Mi(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:Mi(e.revision,"Native v2 revision"),...fs(e,Id)}}function wn(t){let e=Fi(t,Be);if(e.schema!==je){if(e.schema===Oe||e.schema===$e){let o=e.schema===Oe?vn(e):gn(e);throw new In(o.name,o.schema)}throw new gt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let i=Mi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new gt(e.schema,i);if(i!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let r=Mi(e.revision,"Native revision"),n=fs(e,hN),a=kN(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:r,verification_protocol:SN(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 Hd(t){let e=Fi(t,Be);if(e.schema===Oe){let n=vn(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=gn(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 gt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let i=Mi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:i,state:null,message:new gt(e.schema,i).message};let r=wn(e);return{status:"current",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r}}function tt(t,e){On(e);let i=U.join(t.changesDir,e);if(!F(t.changesDir,i))throw new Error("Native change path escaped");return i}async function hs(t,e){let i=ie(t,e),r=U.join(i,"schema-migration.json");await A(F(t.runtimeDir,r)?t.runtimeDir:t.nativeRoot,r);try{return await Tn.lstat(r),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}var EN=256*1024;async function Dd(t,e=U.dirname(t)){let i=U.relative(e,t).split(U.sep).join("/"),r=await ae({root:e,ref:i,maxBytes:EN}),n=(0,ds.parseDocument)(r.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 PN(t,e){let i=U.join(tt(t,e),Be);await A(t.nativeRoot,i);let r=Hd(await Dd(i,t.nativeRoot));if(r.state&&r.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await hs(t,e)?{status:"migration-required",schema:r.schema,minimumRuntimeVersion:r.minimumRuntimeVersion,state:r.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(r.status==="current"&&r.state&&await CN(t,r.state),r)}async function xN(t,e){let i=U.join(tt(t,e),Be);await A(t.nativeRoot,i);let r=Hd(await Dd(i,t.nativeRoot));if(r.state&&r.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return r}async function CN(t,e){if(await wd(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function it(t,e){let i=await PN(t,e);if(i.status==="migration-required")throw new In(e,i.schema);if(i.status==="runtime-incompatible"||!i.state)throw new gt(i.schema,i.minimumRuntimeVersion);return await Rd(t,e),i.state}async function RN(t){let e;try{let r=await Bi({root:t.nativeRoot,directory:t.changesDir,label:"Native changes directory",maxEntries:Number.MAX_SAFE_INTEGER});await r.verify(),e=r.entries}catch(r){if(r.code==="ENOENT")return[];throw r}return e.filter(r=>r.isDirectory()&&!r.isSymbolicLink()).map(r=>r.name).sort()}async function Bd(t){let e=[];for(let i of await RN(t)){let r=await xN(t,i);if(!r.state){if(await _d(t,i))continue;e.push(i);continue}if(r.state.archived)continue;let n=await Wt(t,i);if(!(!n&&await _d(t,i))){if(n?.schema==="comet.native.workspace.v3"){if((await _n({paths:t,identity:n})).code==="workspace-binding-root-changed")continue}else if(n&&(await An({paths:t,identity:n})).state==="drifted")continue;e.push(i)}}return e}function Ad(t,e){let i=U.resolve(t),r=U.resolve(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}async function _d(t,e){for(let i of $i(t.projectRoot))if(!Ad(i,t.projectRoot))try{let r=await z(i);if(!r)continue;let n=await _e(i,r.native.artifact_root),a=U.join(n.changesDir,e),o=U.join(a,"comet-state.yaml");try{let l=await Tn.readFile(o,"utf8");if(/^schema:\s*comet\.native\.v4\s*$/mu.test(l)){let u=await Tn.readFile(U.join(pt(n,e),"state.json"),"utf8"),d=JSON.parse(u);if(d.schema==="comet.native.local-execution.v4"&&typeof d.workspace?.projectRoot=="string"&&Ad(d.workspace.projectRoot,i))return!0;continue}}catch(l){l.code}await Tn.access(U.join(a,Be));let s=await Wt(n,e);if(!s)continue;if(s.schema==="comet.native.workspace.v3"){if((await _n({paths:n,identity:s})).state==="aligned")return!0;continue}if((await An({paths:n,identity:s})).state!=="drifted")return!0}catch{}return!1}var tR=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");import{promises as $N}from"node:fs";import qi from"node:path";function Hn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Dn(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function xe(t,e,i=!1){if(typeof t!="string"||!i&&t.length===0)throw new Error(`${e} must be ${i?"a string":"a non-empty string"}`);return t}function Ld(t,e){return t===null?null:xe(t,e)}function Ln(t,e,i=0){if(!Number.isSafeInteger(t)||t<i)throw new Error(`${e} must be a safe integer greater than or equal to ${i}`);return t}function ON(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 HN(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function Bn(t,e,i){if(typeof t!="string"||!e.includes(t))throw new Error(`${i} must be one of: ${e.join(", ")}`);return t}function ps(t,e){if(t===null)return null;let i=xe(t,e);if(Number.isNaN(Date.parse(i)))throw new Error(`${e} must be an ISO timestamp`);return i}function ms(t,e){let i=xe(t,e);if(!qi.isAbsolute(i))throw new Error(`${e} must be absolute`);return qi.resolve(i)}function DN(t,e){let i=`Native local checks[${e}]`,r=Hn(t,i);if(Dn(r,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),i),!Array.isArray(r.argv)||r.argv.length===0)throw new Error(`${i}.argv must be a non-empty array`);let n=r.argv.map((l,u)=>xe(l,`${i}.argv[${u}]`,!0)),a=Bn(r.status,["planned","running","passed","failed","interrupted"],`${i}.status`),o=ps(r.startedAt,`${i}.startedAt`),s=ps(r.completedAt,`${i}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${i} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${i} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${i} completed check requires startedAt and completedAt`);let c=Ln(r.timeoutMs,`${i}.timeoutMs`);if(c<1)throw new Error(`${i}.timeoutMs must be positive`);return{id:xe(r.id,`${i}.id`),name:xe(r.name,`${i}.name`),operationId:xe(r.operationId,`${i}.operationId`),status:a,repeatable:HN(r.repeatable,`${i}.repeatable`),timeoutMs:c,executionCount:Ln(r.executionCount,`${i}.executionCount`),argv:n,cwd:ms(r.cwd,`${i}.cwd`),exitCode:ON(r.exitCode,`${i}.exitCode`),startedAt:o,completedAt:s,log:xe(r.log,`${i}.log`)}}function Md(t){let e="Native local execution state",i=Hn(t,e);if(Dn(i,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),e),i.schema!==Di)throw new Error(`Native local execution schema must be ${Di}`);let r=Hn(i.workspace,"Native local workspace");Dn(r,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(i.execution!==null){let o=Hn(i.execution,"Native local execution");Dn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=ps(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:xe(o.operationId,"Native local execution.operationId"),stage:Bn(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Bn(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Ld(o.executionId,"Native local execution.executionId"),status:Bn(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Ln(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(i.checks))throw new Error("Native local checks must be an array");let a=i.checks.map(DN);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:Di,change:xe(i.change,"Native local change"),basedOnStateVersion:Ln(i.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:ms(r.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:ms(r.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Ld(r.branch,"Native local workspace.branch")},execution:n,checks:a}}function Fd(t){return Md({schema:Di,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,workspace:{projectRoot:qi.resolve(t.projectRoot),worktreeRoot:qi.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null},execution:null,checks:[]})}async function Vd(t,e,i={}){let r=Md(e);await $N.mkdir(qi.dirname(t),{recursive:!0}),await Se(t,r,i)}var qd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,BN="comet-state.yaml",LN="state.json",MN=`# Outcome
174
+ ${t.sessionId}`)}:{}},p=t.binding?{schema:"comet.native.workspace.v3",...f,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...f};return In(p),p}async function zt(t,e){let i=await yN(t,e);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(In(i),i)}async function jn(t){In(t.identity);let e=await NN({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),i=[],r=[];return e.nativeRootRef!==t.identity.nativeRootRef&&i.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&i.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&i.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&i.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&i.push("native-root-legacy-identity")),fs==="win32"&&i.length>0&&i.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?r.push("workspace-inspection-unavailable"):i.length>0&&r.push("workspace-root-changed"),{state:r.length===0?"aligned":r.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:r,driftComponents:i}}async function $n(t){if(In(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 jn(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let i=ie(t.paths.projectRoot);return t.identity.changeBranch===null?i.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}:i.isGitWorktree?i.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 ${i.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!i.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 i=await zt(t,e);if(i===null)return null;let r=await $n({paths:t,identity:i});if(r.state==="drifted")throw new Error(`${r.code}: ${r.message}`);return i}var Dd=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],kN=new Set(Dd),Bd=new Set([...Dd,"minimum_runtime_version","revision"]),SN=new Set([...Bd,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),EN=new Set(["capability","operation","source","base_hash"]),xN=new Set(["shape","build","verify","archive"]),PN=new Set(["implicit","confirmed"]),CN=new Set(["pending","pass","fail"]),Le="comet-state.yaml",ms=/^[a-f0-9]{64}$/u,Ld=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,RN=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Hn=class extends Error{constructor(i,r){super(`Native change ${i} uses ${r}; run comet native doctor ${i} --repair before mutating it`);this.change=i;this.schema=r;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},yt=class extends Error{constructor(i,r){super(i!==$e||r===null?`Unsupported Native change schema ${i} for runtime protocol ${3}`:`Native change ${i} requires runtime protocol ${r}; current protocol is ${3}`);this.schema=i;this.minimumRuntimeVersion=r;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"},Dn=class extends Error{constructor(i,r,n){super(`Native change ${i} revision conflict: expected ${r}, actual ${n}`);this.change=i;this.expectedRevision=r;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},Jt=class extends Error{constructor(i,r){super(`Native working directory already contains active change${r.length===1?"":"s"} ${r.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=i;this.activeChanges=r;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},Bn=class extends Error{constructor(i,r,n,a,o,s=null,c=null){super(`Native change ${i} baseline is incomplete (${r} omitted entr${r===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=i;this.omittedCount=r;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},uR=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
175
+ `);function Vi(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Md(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Ln(t){if(!Ld.test(t))throw new Error(`Invalid Native change name: ${t}`)}function AN(t){if(!Ld.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Fd(t,e){if(t.length===0||U.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function _N(t,e){let i=Vi(t,`spec_changes[${e}]`);if(Md(i,EN,`spec_changes[${e}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(AN(i.capability),i.operation!=="create"&&i.operation!=="replace"&&i.operation!=="remove")throw new Error(`Invalid spec operation for ${i.capability}`);let r=i.source,n=i.base_hash;if(r!==void 0&&typeof r!="string")throw new Error(`Spec source for ${i.capability} must be a string`);if(typeof r=="string"&&Fd(r,`Spec source for ${i.capability}`),i.operation==="create"){if(!r)throw new Error(`Create spec ${i.capability} requires source`);if(n!==null)throw new Error(`Create spec ${i.capability} requires null base_hash`)}else if(i.operation==="replace"){if(!r)throw new Error(`Replace spec ${i.capability} requires source`);if(typeof n!="string"||!ms.test(n))throw new Error(`Replace spec ${i.capability} requires a SHA-256 base_hash`)}else{if(r!==void 0)throw new Error(`Remove spec ${i.capability} forbids source`);if(typeof n!="string"||!ms.test(n))throw new Error(`Remove spec ${i.capability} requires a SHA-256 base_hash`)}return{capability:i.capability,operation:i.operation,...typeof r=="string"?{source:r}:{},base_hash:n}}function TN(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 gs(t,e){if(Md(t,e,Le),typeof t.name!="string")throw new Error("Native change name is required");if(Ln(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"||!xN.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&&!PN.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 i=t.spec_changes.map(_N),r=i.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(r.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(r)].join(", ")}`);if(typeof t.verification_result!="string"||!CN.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"&&Fd(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!TN(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:i,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function Nn(t){let e=Vi(t,Le);if(e.schema!==He)throw new Error(`Expected ${He}`);return{schema:He,...gs(e,kN)}}function Fi(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function ps(t,e,i){if(t===null)return null;let r=typeof t=="string"?RN.exec(t):null;if(!r||r[1]!==i)throw new Error(`${e} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return t}function IN(t){if(t==null)return null;if(typeof t!="string"||!ms.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function jN(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 bn(t){let e=Vi(t,Le);if(e.schema!==Oe)throw new Error(`Expected ${Oe}`);if(Fi(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Oe} minimum_runtime_version must be 2`);return{schema:Oe,minimum_runtime_version:2,revision:Fi(e.revision,"Native v2 revision"),...gs(e,Bd)}}function kn(t){let e=Vi(t,Le);if(e.schema!==$e){if(e.schema===He||e.schema===Oe){let o=e.schema===He?Nn(e):bn(e);throw new Hn(o.name,o.schema)}throw new yt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let i=Fi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new yt(e.schema,i);if(i!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let r=Fi(e.revision,"Native revision"),n=gs(e,SN),a=IN(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:$e,minimum_runtime_version:3,revision:r,verification_protocol:jN(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:ps(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:ps(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:ps(e.partial_allowance,"Native partial_allowance","allowances")}}function Vd(t){let e=Vi(t,Le);if(e.schema===He){let n=Nn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${$e}`}}if(e.schema===Oe){let n=bn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${$e}`}}if(e.schema!==$e){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new yt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let i=Fi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:i,state:null,message:new yt(e.schema,i).message};let r=kn(e);return{status:"current",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r}}function rt(t,e){Ln(e);let i=U.join(t.changesDir,e);if(!F(t.changesDir,i))throw new Error("Native change path escaped");return i}async function ws(t,e){let i=te(t,e),r=U.join(i,"schema-migration.json");await A(F(t.runtimeDir,r)?t.runtimeDir:t.nativeRoot,r);try{return await On.lstat(r),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}var $N=256*1024;async function qd(t,e=U.dirname(t)){let i=U.relative(e,t).split(U.sep).join("/"),r=await ne({root:e,ref:i,maxBytes:$N}),n=(0,vs.parseDocument)(r.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 ON(t,e){let i=U.join(rt(t,e),Le);await A(t.nativeRoot,i);let r=Vd(await qd(i,t.nativeRoot));if(r.state&&r.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await ws(t,e)?{status:"migration-required",schema:r.schema,minimumRuntimeVersion:r.minimumRuntimeVersion,state:r.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(r.status==="current"&&r.state&&await DN(t,r.state),r)}async function HN(t,e){let i=U.join(rt(t,e),Le);await A(t.nativeRoot,i);let r=Vd(await qd(i,t.nativeRoot));if(r.state&&r.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return r}async function DN(t,e){if(await Ed(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function nt(t,e){let i=await ON(t,e);if(i.status==="migration-required")throw new Hn(e,i.schema);if(i.status==="runtime-incompatible"||!i.state)throw new yt(i.schema,i.minimumRuntimeVersion);return await $d(t,e),i.state}async function BN(t){let e;try{let r=await Li({root:t.nativeRoot,directory:t.changesDir,label:"Native changes directory",maxEntries:Number.MAX_SAFE_INTEGER});await r.verify(),e=r.entries}catch(r){if(r.code==="ENOENT")return[];throw r}return e.filter(r=>r.isDirectory()&&!r.isSymbolicLink()).map(r=>r.name).sort()}async function Wd(t){let e=[];for(let i of await BN(t)){let r=await HN(t,i);if(!r.state){if(await Hd(t,i))continue;e.push(i);continue}if(r.state.archived)continue;let n=await zt(t,i);if(!(!n&&await Hd(t,i))){if(n?.schema==="comet.native.workspace.v3"){if((await $n({paths:t,identity:n})).code==="workspace-binding-root-changed")continue}else if(n&&(await jn({paths:t,identity:n})).state==="drifted")continue;e.push(i)}}return e}function Od(t,e){let i=U.resolve(t),r=U.resolve(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}async function Hd(t,e){for(let i of Oi(t.projectRoot))if(!Od(i,t.projectRoot))try{let r=await z(i);if(!r)continue;let n=await Te(i,r.native.artifact_root),a=U.join(n.changesDir,e),o=U.join(a,"comet-state.yaml");try{let l=await On.readFile(o,"utf8");if(/^schema:\s*comet\.native\.v4\s*$/mu.test(l)){let u=await On.readFile(U.join(vt(n,e),"state.json"),"utf8"),d=JSON.parse(u);if(d.schema==="comet.native.local-execution.v4"&&typeof d.workspace?.projectRoot=="string"&&Od(d.workspace.projectRoot,i))return!0;continue}}catch(l){l.code}await On.access(U.join(a,Le));let s=await zt(n,e);if(!s)continue;if(s.schema==="comet.native.workspace.v3"){if((await $n({paths:n,identity:s})).state==="aligned")return!0;continue}if((await jn({paths:n,identity:s})).state!=="drifted")return!0}catch{}return!1}var fR=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");import{promises as WN}from"node:fs";import Wi from"node:path";function Mn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Fn(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Pe(t,e,i=!1){if(typeof t!="string"||!i&&t.length===0)throw new Error(`${e} must be ${i?"a string":"a non-empty string"}`);return t}function zd(t,e){return t===null?null:Pe(t,e)}function qn(t,e,i=0){if(!Number.isSafeInteger(t)||t<i)throw new Error(`${e} must be a safe integer greater than or equal to ${i}`);return t}function zN(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 JN(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function Vn(t,e,i){if(typeof t!="string"||!e.includes(t))throw new Error(`${i} must be one of: ${e.join(", ")}`);return t}function ys(t,e){if(t===null)return null;let i=Pe(t,e);if(Number.isNaN(Date.parse(i)))throw new Error(`${e} must be an ISO timestamp`);return i}function Ns(t,e){let i=Pe(t,e);if(!Wi.isAbsolute(i))throw new Error(`${e} must be absolute`);return Wi.resolve(i)}function GN(t,e){let i=`Native local checks[${e}]`,r=Mn(t,i);if(Fn(r,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),i),!Array.isArray(r.argv)||r.argv.length===0)throw new Error(`${i}.argv must be a non-empty array`);let n=r.argv.map((l,u)=>Pe(l,`${i}.argv[${u}]`,!0)),a=Vn(r.status,["planned","running","passed","failed","interrupted"],`${i}.status`),o=ys(r.startedAt,`${i}.startedAt`),s=ys(r.completedAt,`${i}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${i} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${i} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${i} completed check requires startedAt and completedAt`);let c=qn(r.timeoutMs,`${i}.timeoutMs`);if(c<1)throw new Error(`${i}.timeoutMs must be positive`);return{id:Pe(r.id,`${i}.id`),name:Pe(r.name,`${i}.name`),operationId:Pe(r.operationId,`${i}.operationId`),status:a,repeatable:JN(r.repeatable,`${i}.repeatable`),timeoutMs:c,executionCount:qn(r.executionCount,`${i}.executionCount`),argv:n,cwd:Ns(r.cwd,`${i}.cwd`),exitCode:zN(r.exitCode,`${i}.exitCode`),startedAt:o,completedAt:s,log:Pe(r.log,`${i}.log`)}}function Jd(t){let e="Native local execution state",i=Mn(t,e);if(Fn(i,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),e),i.schema!==Bi)throw new Error(`Native local execution schema must be ${Bi}`);let r=Mn(i.workspace,"Native local workspace");Fn(r,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(i.execution!==null){let o=Mn(i.execution,"Native local execution");Fn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=ys(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:Vn(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Vn(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:zd(o.executionId,"Native local execution.executionId"),status:Vn(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:qn(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(i.checks))throw new Error("Native local checks must be an array");let a=i.checks.map(GN);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:Bi,change:Pe(i.change,"Native local change"),basedOnStateVersion:qn(i.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:Ns(r.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Ns(r.worktreeRoot,"Native local workspace.worktreeRoot"),branch:zd(r.branch,"Native local workspace.branch")},execution:n,checks:a}}function Gd(t){return Jd({schema:Bi,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,workspace:{projectRoot:Wi.resolve(t.projectRoot),worktreeRoot:Wi.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null},execution:null,checks:[]})}async function Ud(t,e,i={}){let r=Jd(e);await WN.mkdir(Wi.dirname(t),{recursive:!0}),await Se(t,r,i)}var Kd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,UN="comet-state.yaml",KN="state.json",YN=`# Outcome
176
176
 
177
177
  # Scope
178
178
 
@@ -187,21 +187,21 @@ ${t.sessionId}`)}:{}},p=t.binding?{schema:"comet.native.workspace.v3",...f,...t.
187
187
  # Open questions
188
188
 
189
189
  # Verification expectations
190
- `;function Wd(t,e){if(!qd.test(e))throw new Error(`Invalid Native change name: ${e}`);let i=Wi.join(t.changesDir,e);if(!F(t.changesDir,i))throw new Error("Native change path escaped");return i}function vs(t,e){return Wi.join(Wd(t,e),BN)}function FN(t,e){return Wi.join(pt(t,e),LN)}async function zd(t,e){try{let i=await rt.readFile(vs(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(i)}catch(i){if(i.code==="ENOENT")return!1;throw i}}function VN(t){return{isolation:t?.isolation??"current",change_branch:t?.changeBranch??null,target_branch:t?.targetBranch??null,finish:null}}function qN(t){return re(t).currentBranch}function WN(t,e){if(!e)return;let i=re(t);if(e.changeBranch!==null&&(!i.isGitWorktree||i.currentBranch!==e.changeBranch))throw new Error(`Native workspace binding ${e.changeBranch??"(missing)"} does not match the current branch ${i.currentBranch??"(detached)"}`);if(e.isolation==="worktree"&&!i.isSecondaryWorktree)throw new Error("Native worktree isolation must use a linked Git worktree")}async function Jd(t){return ye(t.paths,`create portable change ${t.name}`,async()=>{if(!qd.test(t.name))throw new Error(`Invalid Native change name: ${t.name}`);t.initialProjectConfig&&await z(t.paths.projectRoot)===null&&await Ii(t.paths.projectRoot,t.initialProjectConfig),WN(t.paths.projectRoot,t.workspaceBinding);let e=(await Bd(t.paths)).filter(o=>o!==t.name);if(e.length>0)throw new zt(t.workspaceBinding?.isolation??"current",e);let i=Wd(t.paths,t.name),r=pt(t.paths,t.name);await Promise.all([A(t.paths.nativeRoot,i),A(t.paths.runtimeDir,r)]);let n=!1,a=!1;try{await rt.mkdir(t.paths.changesDir,{recursive:!0}),await rt.mkdir(i,{recursive:!1}),n=!0,await rt.mkdir(t.paths.changesRuntimeDir,{recursive:!0}),await rt.mkdir(r,{recursive:!1}),a=!0,await rt.mkdir(Wi.join(i,"specs"),{recursive:!0}),await te(Wi.join(i,"brief.md"),MN);let o=ju({name:t.name,language:t.language,workspace:VN(t.workspaceBinding),createdAt:t.now,nextAction:"confirm-shape"});return await $u(vs(t.paths,t.name),o,{containedRoot:t.paths.nativeRoot}),await Vd(FN(t.paths,t.name),Fd({portableState:o,projectRoot:t.paths.projectRoot,branch:qN(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),o}catch(o){throw a&&await rt.rm(r,{recursive:!0,force:!0}),n&&await rt.rm(i,{recursive:!0,force:!0}),o}})}async function Gd(t,e){return Uo(vs(t,e))}import{randomUUID as zN}from"crypto";import{promises as Mn}from"fs";import Kd from"path";var gs="comet.selection.v2",CA=16*1024;function Yd(t){return Kd.join(t,".comet","current-change.json")}function JN(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ud(t){return t===null||typeof t=="string"}function GN(t){let e;try{e=JSON.parse(t)}catch(i){throw new Error(`current change selection contains invalid JSON: ${i instanceof Error?i.message:String(i)}`,{cause:i})}if(!JN(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&&!Ud(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(!Ud(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 Xd(t,e){let i=GN(JSON.stringify(e));if(i.legacy)throw new Error("cannot write a legacy current change selection");let r=Yd(t),n=`${r}.${zN()}.tmp`;await Mn.mkdir(Kd.dirname(r),{recursive:!0});try{await Mn.writeFile(n,`${JSON.stringify(i.selection,null,2)}
191
- `,"utf8"),await Mn.rename(n,r)}catch(a){throw await Mn.rm(n,{force:!0}),a}}var DA=16*1024;async function Qd(t,e){return ye(t,`select change ${e}`,async()=>{On(e),await zd(t,e)?await Gd(t,e):await it(t,e),await Xd(t.projectRoot,{schema:"comet.selection.v2",workflow:"native",change:e,branch:null})})}import{promises as zi}from"node:fs";import V from"node:path";var nt=class extends Error{constructor(i,r,n){super(i,n);this.preparation=r;this.name="NativeWorkspacePreparationError"}preparation};function ws(t,e){let i=V.normalize(t),r=V.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function tf(t,e){let i=V.relative(t,e);return i===""||!V.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${V.sep}`)}function Zd(t){return JSON.stringify(t.native)}async function Fn(t,e){let i=await z(t);if(i&&e){if(Zd(i)!==Zd(e))throw new Error(`Native worktree configuration differs from the source project: ${V.join(t,".comet","config.yaml")}`);return!1}return!i&&e?(await Ii(t,e),!0):!1}async function UN(t,e){if(!tf(t,e))return!1;let r=`/${V.relative(t,e).replaceAll("\\","/").replace(/\/+$/u,"")}/`,n=Te(t,["rev-parse","--git-common-dir"]),a=V.resolve(t,n),o=V.join(a,"info","exclude"),s="";try{s=await zi.readFile(o,"utf8")}catch(l){if(l.code!=="ENOENT")throw l}if(s.split(/\r?\n/u).includes(r))return!1;await zi.mkdir(V.dirname(o),{recursive:!0});let c=s.length===0||s.endsWith(`
190
+ `;function Yd(t,e){if(!Kd.test(e))throw new Error(`Invalid Native change name: ${e}`);let i=zi.join(t.changesDir,e);if(!F(t.changesDir,i))throw new Error("Native change path escaped");return i}function bs(t,e){return zi.join(Yd(t,e),UN)}function XN(t,e){return zi.join(vt(t,e),KN)}async function Xd(t,e){try{let i=await at.readFile(bs(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(i)}catch(i){if(i.code==="ENOENT")return!1;throw i}}function QN(t){return{isolation:t?.isolation??"current",change_branch:t?.changeBranch??null,target_branch:t?.targetBranch??null,finish:null}}function ZN(t){return ie(t).currentBranch}function eb(t,e){if(!e)return;let i=ie(t);if(e.changeBranch!==null&&(!i.isGitWorktree||i.currentBranch!==e.changeBranch))throw new Error(`Native workspace binding ${e.changeBranch??"(missing)"} does not match the current branch ${i.currentBranch??"(detached)"}`);if(e.isolation==="worktree"&&!i.isSecondaryWorktree)throw new Error("Native worktree isolation must use a linked Git worktree")}async function Qd(t){return we(t.paths,`create portable change ${t.name}`,async()=>{if(!Kd.test(t.name))throw new Error(`Invalid Native change name: ${t.name}`);t.initialProjectConfig&&await z(t.paths.projectRoot)===null&&await ji(t.paths.projectRoot,t.initialProjectConfig),eb(t.paths.projectRoot,t.workspaceBinding);let e=(await Wd(t.paths)).filter(o=>o!==t.name);if(e.length>0)throw new Jt(t.workspaceBinding?.isolation??"current",e);let i=Yd(t.paths,t.name),r=vt(t.paths,t.name);await Promise.all([A(t.paths.nativeRoot,i),A(t.paths.runtimeDir,r)]);let n=!1,a=!1;try{await at.mkdir(t.paths.changesDir,{recursive:!0}),await at.mkdir(i,{recursive:!1}),n=!0,await at.mkdir(t.paths.changesRuntimeDir,{recursive:!0}),await at.mkdir(r,{recursive:!1}),a=!0,await at.mkdir(zi.join(i,"specs"),{recursive:!0}),await ee(zi.join(i,"brief.md"),YN);let o=Lu({name:t.name,language:t.language,workspace:QN(t.workspaceBinding),createdAt:t.now,nextAction:"confirm-shape"});return await Mu(bs(t.paths,t.name),o,{containedRoot:t.paths.nativeRoot}),await Ud(XN(t.paths,t.name),Gd({portableState:o,projectRoot:t.paths.projectRoot,branch:ZN(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),o}catch(o){throw a&&await at.rm(r,{recursive:!0,force:!0}),n&&await at.rm(i,{recursive:!0,force:!0}),o}})}async function Zd(t,e){return Zo(bs(t,e))}import{randomUUID as tb}from"crypto";import{promises as Wn}from"fs";import tf from"path";var ks="comet.selection.v2",LA=16*1024;function rf(t){return tf.join(t,".comet","current-change.json")}function ib(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ef(t){return t===null||typeof t=="string"}function rb(t){let e;try{e=JSON.parse(t)}catch(i){throw new Error(`current change selection contains invalid JSON: ${i instanceof Error?i.message:String(i)}`,{cause:i})}if(!ib(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&&!ef(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:ks,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==ks)throw new Error(`current change selection schema must be ${ks}`);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(!ef(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 nf(t,e){let i=rb(JSON.stringify(e));if(i.legacy)throw new Error("cannot write a legacy current change selection");let r=rf(t),n=`${r}.${tb()}.tmp`;await Wn.mkdir(tf.dirname(r),{recursive:!0});try{await Wn.writeFile(n,`${JSON.stringify(i.selection,null,2)}
191
+ `,"utf8"),await Wn.rename(n,r)}catch(a){throw await Wn.rm(n,{force:!0}),a}}var KA=16*1024;async function af(t,e){return we(t,`select change ${e}`,async()=>{Ln(e),await Xd(t,e)?await Zd(t,e):await nt(t,e),await nf(t.projectRoot,{schema:"comet.selection.v2",workflow:"native",change:e,branch:null})})}import{promises as Ji}from"node:fs";import V from"node:path";var ot=class extends Error{constructor(i,r,n){super(i,n);this.preparation=r;this.name="NativeWorkspacePreparationError"}preparation};function Ss(t,e){let i=V.normalize(t),r=V.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function cf(t,e){let i=V.relative(t,e);return i===""||!V.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${V.sep}`)}function of(t){return JSON.stringify(t.native)}async function zn(t,e){let i=await z(t);if(i&&e){if(of(i)!==of(e))throw new Error(`Native worktree configuration differs from the source project: ${V.join(t,".comet","config.yaml")}`);return!1}return!i&&e?(await ji(t,e),!0):!1}async function nb(t,e){if(!cf(t,e))return!1;let r=`/${V.relative(t,e).replaceAll("\\","/").replace(/\/+$/u,"")}/`,n=Ie(t,["rev-parse","--git-common-dir"]),a=V.resolve(t,n),o=V.join(a,"info","exclude"),s="";try{s=await Ji.readFile(o,"utf8")}catch(l){if(l.code!=="ENOENT")throw l}if(s.split(/\r?\n/u).includes(r))return!1;await Ji.mkdir(V.dirname(o),{recursive:!0});let c=s.length===0||s.endsWith(`
192
192
  `)?"":`
193
- `;return await zi.appendFile(o,`${c}${r}
194
- `,"utf8"),!0}function KN(t,e,i){let r=V.resolve(t,i??V.join(".worktrees",e)),n=V.resolve(t,Te(t,["rev-parse","--git-common-dir"]));if(tf(n,r))throw new Error("Native worktree path cannot be inside the Git common directory");if($i(t).some(a=>ws(a,r)))throw new Error(`Native worktree path is already registered: ${r}`);return r}async function YN(t){try{throw await zi.lstat(t),new Error(`Native worktree path already exists: ${t}`)}catch(e){if(e.code!=="ENOENT")throw e}}async function ef(t){try{return await zi.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function rf(t){let e=V.resolve(t.projectRoot);if(t.isolation==="current"){if(t.changeBranch||t.targetBranch||t.worktreePath)throw new Error("Native current isolation does not accept --change-branch, --target-branch, or --worktree-path");let r=re(e);if(r.isGitWorktree&&r.currentBranch===null)throw new Error("Native workspace binding requires a branch; detached HEAD is not supported");return{projectRoot:e,binding:{isolation:"current",changeBranch:r.currentBranch,targetBranch:r.currentBranch},preparation:{isolation:"current",projectRoot:e,changeBranch:r.currentBranch,targetBranch:r.currentBranch,worktreePath:null,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:!1}}}let i=await _e(e,t.sourceConfig?.native.artifact_root??"docs");return zu([{runtimeDir:i.runtimeDir,locksDir:i.locksDir}],`prepare Native ${t.isolation} workspace`,async()=>{let r=re(e);if(!r.isGitWorktree||r.currentBranch===null||r.primaryWorktreeRoot===null||r.currentWorktreeRoot===null)throw new Error("Native branch and worktree isolation require an attached Git branch");let n=t.changeBranch??`comet/${t.name}`;Vo(e,n);let a=r.currentBranch===n,o=t.targetBranch??(a?void 0:r.currentBranch);if(!o)throw new Error("Native isolated workspace already on its change branch requires --target-branch");if(Vo(e,o),!Oi(e,o))throw new Error(`Native target branch is not a verified local branch: ${o}`);if(t.isolation==="branch"){if(t.worktreePath)throw new Error("--worktree-path is only valid with --isolation worktree");let p=!1;if(!a){if(!Tu(e))throw new Error("Native branch isolation requires a clean current working directory");if(Oi(e,n))throw new Error(`Native change branch already exists: ${n}`);Te(e,["switch","-c",n,o]),p=!0}let v;try{v=await Fn(e,t.sourceConfig)}catch(h){throw new nt(`Native branch preparation is incomplete: ${h.message}`,{isolation:"branch",projectRoot:e,changeBranch:n,targetBranch:o,worktreePath:null,createdBranch:p,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:!1},{cause:h})}return{projectRoot:e,binding:{isolation:"branch",changeBranch:n,targetBranch:o},preparation:{isolation:"branch",projectRoot:e,changeBranch:n,targetBranch:o,worktreePath:null,createdBranch:p,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:v}}}if(a){if(!r.isSecondaryWorktree)throw new Error("Native worktree isolation must use a linked Git worktree");let p=t.worktreePath?V.resolve(r.primaryWorktreeRoot,t.worktreePath):void 0;if(p&&!ws(p,r.currentWorktreeRoot))throw new Error(`Native worktree path ${p} does not match the current worktree ${r.currentWorktreeRoot}`);let v;try{v=await Fn(e,t.sourceConfig)}catch(h){throw new nt(`Native worktree preparation is incomplete: ${h.message}`,{isolation:"worktree",projectRoot:e,changeBranch:n,targetBranch:o,worktreePath:e,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:!1},{cause:h})}return{projectRoot:e,binding:{isolation:"worktree",changeBranch:n,targetBranch:o},preparation:{isolation:"worktree",projectRoot:e,changeBranch:n,targetBranch:o,worktreePath:e,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:v}}}let s=cn(r.primaryWorktreeRoot),c=s.find(p=>p.branch===n);if(c&&await ef(c.root)){let p=t.worktreePath?V.resolve(r.primaryWorktreeRoot,t.worktreePath):void 0;if(p&&!ws(p,c.root))throw new Error(`Native worktree branch ${n} is already checked out at ${c.root}`);let v;try{v=await Fn(c.root,t.sourceConfig)}catch(h){throw new nt(`Native worktree preparation is incomplete: ${h.message}`,{isolation:"worktree",projectRoot:c.root,changeBranch:n,targetBranch:o,worktreePath:c.root,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:!1},{cause:h})}return{projectRoot:c.root,binding:{isolation:"worktree",changeBranch:n,targetBranch:o},preparation:{isolation:"worktree",projectRoot:c.root,changeBranch:n,targetBranch:o,worktreePath:c.root,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:v}}}c&&!await ef(c.root)&&(Te(r.primaryWorktreeRoot,["worktree","prune"]),s=cn(r.primaryWorktreeRoot));let l=Oi(e,n);if(s.some(p=>p.branch===n))throw new Error(`Native change branch ${n} is already registered to a worktree`);let u=KN(r.primaryWorktreeRoot,t.name,t.worktreePath);await YN(u);let d=await UN(r.primaryWorktreeRoot,u),f={isolation:"worktree",projectRoot:u,changeBranch:n,targetBranch:o,worktreePath:u,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:d,configInitialized:!1};try{Te(r.primaryWorktreeRoot,l?["worktree","add",u,n]:["worktree","add","-b",n,u,o]),f.createdBranch=!l,f.createdWorktree=!0,f.configInitialized=await Fn(u,t.sourceConfig)}catch(p){throw new nt(`Native worktree preparation is incomplete: ${p.message}`,f,{cause:p})}return{projectRoot:u,binding:{isolation:"worktree",changeBranch:n,targetBranch:o},preparation:f}})}import bs from"path";var QN=["Outcome","Scope","Non-goals","Acceptance examples"],o_=[...QN,"Constraints and invariants","Decisions","Open questions","Verification expectations"];var ZN=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 nf=1024*1024;var of="scoped-text-safety",eb=1,tb=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var ib="comet.native.checker-policy.v1";var b_=oe(ib,{policy:of,version:eb,limits:tb,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var rb=["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"],k_=new Set(rb);var ob=nf,L_=3*ob;var sf={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:[]},cb=Z("comet-native-runtime:v3:scope-reopen"),fT=[{skillVersion:"3",skillHash:Z("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:Z("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:Z("comet-native-runtime:v1")}];var lf=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],JT=new Set(lf),pb=new Set([...lf,"minimum_runtime_version","revision"]),GT=new Set([...pb,"operation"]),UT=512*1024,mb=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),KT=new Set([...mb,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var ZT={maxAcceptanceCriteria:Gu.maxCriteria};var nI={maxSpecs:64,maxFileBytes:un,maxTotalBytes:4*1024*1024};import{execFile as Eb}from"node:child_process";import{promisify as Pb}from"node:util";var pI={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var OI=512*1024;var Ji=class extends Error{recovery;constructor(e,i){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=i}};var nj=64*1024;var aj=3600*1e3;var oj=Pb(Eb);var Vn=class extends Error{details;constructor(e){let i=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(r=>`${r.ref}${r.acceptanceId?`[${r.acceptanceId}]`:""} -> ${r.mismatches.join("; ")}`).join(" | ")}`;super(i),this.name="NativeVerificationReceiptBindingError",this.details=e}};var zj={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var t$=16*1024*1024,i$=256*1024,r$=16*1024;var c$=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var Q$=16*1024*1024,qn=class extends Error{constructor(i,r,n,a){super(`Canonical spec conflict for ${i}: expected ${r??"(missing)"}, actual ${n??"(missing)"}`);this.capability=i;this.expectedHash=r;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},Wn=class extends Error{constructor(i,r=i.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${i.findingCodes.join(", ")}`){super(r);this.preflight=i;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};var ff=["--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."],Ns=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec remove Record a complete capability removal intent.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:ff,output:"Human-readable text by default; use --json for a structured command envelope.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:"comet native spec remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page.","--details Include acceptance, Spec, workspace, and report details."],output:"A v2 status page or one portable Loop projection with local execution availability and continuation.runnerAction; parent changes also expose children and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--confirmed|--return-to-build|--retry-verifier|--resolve-verifier-blocker]
195
- comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm Shape, a completed skill-coordinated pass, or an explicitly degraded verifier-unavailable fallback before Archive.","--return-to-build Return Verify or Archive to Build after invalidation or user choice.","--retry-verifier Retry a blocked Verifier execution when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."],output:"The portable state, explicit skill-coordinated label, Runtime-owned check results, complete verifierDispatch, bounded request-check response, continuation.runnerAction, and machine-readable continuation.inputOptions. This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.",examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed','comet native next session-timeout --summary "Implementation changed" --return-to-build','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep]
196
- 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 ys(t,e){return`${t}:
193
+ `;return await Ji.appendFile(o,`${c}${r}
194
+ `,"utf8"),!0}function ab(t,e,i){let r=V.resolve(t,i??V.join(".worktrees",e)),n=V.resolve(t,Ie(t,["rev-parse","--git-common-dir"]));if(cf(n,r))throw new Error("Native worktree path cannot be inside the Git common directory");if(Oi(t).some(a=>Ss(a,r)))throw new Error(`Native worktree path is already registered: ${r}`);return r}async function ob(t){try{throw await Ji.lstat(t),new Error(`Native worktree path already exists: ${t}`)}catch(e){if(e.code!=="ENOENT")throw e}}async function sf(t){try{return await Ji.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function lf(t){let e=V.resolve(t.projectRoot);if(t.isolation==="current"){if(t.changeBranch||t.targetBranch||t.worktreePath)throw new Error("Native current isolation does not accept --change-branch, --target-branch, or --worktree-path");let r=ie(e);if(r.isGitWorktree&&r.currentBranch===null)throw new Error("Native workspace binding requires a branch; detached HEAD is not supported");return{projectRoot:e,binding:{isolation:"current",changeBranch:r.currentBranch,targetBranch:r.currentBranch},preparation:{isolation:"current",projectRoot:e,changeBranch:r.currentBranch,targetBranch:r.currentBranch,worktreePath:null,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:!1}}}let i=await Te(e,t.sourceConfig?.native.artifact_root??"docs");return Xu([{runtimeDir:i.runtimeDir,locksDir:i.locksDir}],`prepare Native ${t.isolation} workspace`,async()=>{let r=ie(e);if(!r.isGitWorktree||r.currentBranch===null||r.primaryWorktreeRoot===null||r.currentWorktreeRoot===null)throw new Error("Native branch and worktree isolation require an attached Git branch");let n=t.changeBranch??`comet/${t.name}`;Go(e,n);let a=r.currentBranch===n,o=t.targetBranch??(a?void 0:r.currentBranch);if(!o)throw new Error("Native isolated workspace already on its change branch requires --target-branch");if(Go(e,o),!Hi(e,o))throw new Error(`Native target branch is not a verified local branch: ${o}`);if(t.isolation==="branch"){if(t.worktreePath)throw new Error("--worktree-path is only valid with --isolation worktree");let p=!1;if(!a){if(!Du(e))throw new Error("Native branch isolation requires a clean current working directory");if(Hi(e,n))throw new Error(`Native change branch already exists: ${n}`);Ie(e,["switch","-c",n,o]),p=!0}let v;try{v=await zn(e,t.sourceConfig)}catch(h){throw new ot(`Native branch preparation is incomplete: ${h.message}`,{isolation:"branch",projectRoot:e,changeBranch:n,targetBranch:o,worktreePath:null,createdBranch:p,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:!1},{cause:h})}return{projectRoot:e,binding:{isolation:"branch",changeBranch:n,targetBranch:o},preparation:{isolation:"branch",projectRoot:e,changeBranch:n,targetBranch:o,worktreePath:null,createdBranch:p,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:v}}}if(a){if(!r.isSecondaryWorktree)throw new Error("Native worktree isolation must use a linked Git worktree");let p=t.worktreePath?V.resolve(r.primaryWorktreeRoot,t.worktreePath):void 0;if(p&&!Ss(p,r.currentWorktreeRoot))throw new Error(`Native worktree path ${p} does not match the current worktree ${r.currentWorktreeRoot}`);let v;try{v=await zn(e,t.sourceConfig)}catch(h){throw new ot(`Native worktree preparation is incomplete: ${h.message}`,{isolation:"worktree",projectRoot:e,changeBranch:n,targetBranch:o,worktreePath:e,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:!1},{cause:h})}return{projectRoot:e,binding:{isolation:"worktree",changeBranch:n,targetBranch:o},preparation:{isolation:"worktree",projectRoot:e,changeBranch:n,targetBranch:o,worktreePath:e,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:v}}}let s=fn(r.primaryWorktreeRoot),c=s.find(p=>p.branch===n);if(c&&await sf(c.root)){let p=t.worktreePath?V.resolve(r.primaryWorktreeRoot,t.worktreePath):void 0;if(p&&!Ss(p,c.root))throw new Error(`Native worktree branch ${n} is already checked out at ${c.root}`);let v;try{v=await zn(c.root,t.sourceConfig)}catch(h){throw new ot(`Native worktree preparation is incomplete: ${h.message}`,{isolation:"worktree",projectRoot:c.root,changeBranch:n,targetBranch:o,worktreePath:c.root,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:!1},{cause:h})}return{projectRoot:c.root,binding:{isolation:"worktree",changeBranch:n,targetBranch:o},preparation:{isolation:"worktree",projectRoot:c.root,changeBranch:n,targetBranch:o,worktreePath:c.root,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:!1,configInitialized:v}}}c&&!await sf(c.root)&&(Ie(r.primaryWorktreeRoot,["worktree","prune"]),s=fn(r.primaryWorktreeRoot));let l=Hi(e,n);if(s.some(p=>p.branch===n))throw new Error(`Native change branch ${n} is already registered to a worktree`);let u=ab(r.primaryWorktreeRoot,t.name,t.worktreePath);await ob(u);let d=await nb(r.primaryWorktreeRoot,u),f={isolation:"worktree",projectRoot:u,changeBranch:n,targetBranch:o,worktreePath:u,createdBranch:!1,createdWorktree:!1,gitExcludeUpdated:d,configInitialized:!1};try{Ie(r.primaryWorktreeRoot,l?["worktree","add",u,n]:["worktree","add","-b",n,u,o]),f.createdBranch=!l,f.createdWorktree=!0,f.configInitialized=await zn(u,t.sourceConfig)}catch(p){throw new ot(`Native worktree preparation is incomplete: ${p.message}`,f,{cause:p})}return{projectRoot:u,binding:{isolation:"worktree",changeBranch:n,targetBranch:o},preparation:f}})}import Ui from"path";import{realpathSync as Wb}from"fs";var cb=["Outcome","Scope","Non-goals","Acceptance examples"],y_=[...cb,"Constraints and invariants","Decisions","Open questions","Verification expectations"];var lb=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 uf=1024*1024;var ff="scoped-text-safety",ub=1,db=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var fb="comet.native.checker-policy.v1";var $_=ae(fb,{policy:ff,version:ub,limits:db,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var hb=["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"],O_=new Set(hb);var vb=uf,Q_=3*vb;var hf={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:[]},wb=Q("comet-native-runtime:v3:scope-reopen"),xT=[{skillVersion:"3",skillHash:Q("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:Q("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:Q("comet-native-runtime:v1")}];var mf=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],aI=new Set(mf),Eb=new Set([...mf,"minimum_runtime_version","revision"]),oI=new Set([...Eb,"operation"]),sI=512*1024,xb=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),cI=new Set([...xb,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var fI={maxAcceptanceCriteria:Zu.maxCriteria};var gI={maxSpecs:64,maxFileBytes:pn,maxTotalBytes:4*1024*1024};import{execFile as $b}from"node:child_process";import{promisify as Ob}from"node:util";var CI={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var UI=512*1024;var Gi=class extends Error{recovery;constructor(e,i){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=i}};var gj=64*1024;var wj=3600*1e3;var yj=Ob($b);var Jn=class extends Error{details;constructor(e){let i=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(r=>`${r.ref}${r.acceptanceId?`[${r.acceptanceId}]`:""} -> ${r.mismatches.join("; ")}`).join(" | ")}`;super(i),this.name="NativeVerificationReceiptBindingError",this.details=e}};var n$={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var p$=16*1024*1024,m$=256*1024,v$=16*1024;var b$=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var dO=16*1024*1024,Gn=class extends Error{constructor(i,r,n,a){super(`Canonical spec conflict for ${i}: expected ${r??"(missing)"}, actual ${n??"(missing)"}`);this.capability=i;this.expectedHash=r;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},Un=class extends Error{constructor(i,r=i.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${i.findingCodes.join(", ")}`){super(r);this.preflight=i;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};var wf=["--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."],xs=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec remove Record a complete capability removal intent.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:wf,output:"Human-readable text by default; use --json for a structured command envelope.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:"comet native spec remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page.","--details Include acceptance, Spec, workspace, and report details."],output:"A v2 status page or one portable Loop projection with local execution availability and continuation.runnerAction; parent changes also expose children and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--confirmed|--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker]
195
+ comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm Shape or an explicitly degraded verifier-unavailable fallback before Archive.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a blocked Verifier execution when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."],output:"The portable state, explicit skill-coordinated label, Runtime-owned check results, complete verifierDispatch, bounded request-check response, continuation.runnerAction, and machine-readable continuation.inputOptions. This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.",examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep]
196
+ 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 Es(t,e){return`${t}:
197
197
  ${e.map(i=>` ${i}`).join(`
198
- `)}`}function Tb(t){let e=t.filter(r=>r!=="--help");if(e.length===0)return"";let i=e.slice(0,2).join(" ");return Ns[i]||e.length>1&&Ns[e[0]]?.subcommands?i:e[0]}function Ib(t=[]){let e=Tb(t),i=Ns[e];if(!i)throw new Error(`Unknown Native help topic: ${e}`);let r=[`Usage: ${i.usage}`,"",i.purpose];i.subcommands&&r.push("",ys("Commands",i.subcommands));let n=e===""?i.options:[...i.options??[],...ff];return n&&n.length>0&&r.push("",ys("Options",n)),r.push("",`Output:
199
- ${i.output}`),i.examples&&r.push("",ys("Examples",i.examples)),e===""&&r.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${r.join(`
198
+ `)}`}function Fb(t){let e=t.filter(r=>r!=="--help");if(e.length===0)return"";let i=e.slice(0,2).join(" ");return xs[i]||e.length>1&&xs[e[0]]?.subcommands?i:e[0]}function Vb(t=[]){let e=Fb(t),i=xs[e];if(!i)throw new Error(`Unknown Native help topic: ${e}`);let r=[`Usage: ${i.usage}`,"",i.purpose];i.subcommands&&r.push("",Es("Commands",i.subcommands));let n=e===""?i.options:[...i.options??[],...wf];return n&&n.length>0&&r.push("",Es("Options",n)),r.push("",`Output:
199
+ ${i.output}`),i.examples&&r.push("",Es("Examples",i.examples)),e===""&&r.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${r.join(`
200
200
  `)}
201
- `}}var jb=Ib().usage;var fO=10*1024*1024,Ne=class extends Error{};function pf(t,e){let i=t.flatMap((r,n)=>r===e?[n]:[]);if(i.length>1)throw new Ne(`${e} may only be provided once`);return i.length===0?!1:(t.splice(i[0],1),!0)}function at(t,e){let i=t.flatMap((a,o)=>a===e?[o]:[]);if(i.length>1)throw new Ne(`${e} may only be provided once`);if(i.length===0)return;let r=i[0],n=t[r+1];if(n===void 0||n.startsWith("--"))throw new Ne(`${e} requires a value`);return t.splice(r,2),n}function mf(t){if(t.length>0)throw new Ne(`Unexpected argument: ${t[0]}`)}function vf(t,e){let i=t.shift();if(!i||i.startsWith("--"))throw new Ne(`${e} is required`);return i}function gf(t,e="en"){let i=at(t,"--language")??e;if(i!=="en"&&i!=="zh-CN")throw new Ne("--language must be en or zh-CN");return i}function hf(t,e){let i=bs.normalize(t),r=bs.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function $b(t){let e=bs.resolve(t),i=re(process.cwd());if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return e;let r=re(e);return!r.isGitWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null||!hf(i.primaryWorktreeRoot,r.primaryWorktreeRoot)||hf(i.currentWorktreeRoot,r.currentWorktreeRoot)?e:i.currentWorktreeRoot}async function wf(t){return t?$b(t):Do(process.cwd())}function yf(t,e,i){return{command:t,exitCode:0,data:e,text:i??JSON.stringify(e,null,2)+`
202
- `}}function Nf(t,e){if(e instanceof Ne)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 jn)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 zt)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 nt)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof $n)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 Ji)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let i=e.code;if(i&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(i))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let r=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:r?73:65,error:{code:r?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function bf(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}})+`
203
- `}:t.error?{exitCode:t.exitCode,stderr:t.error.message}:{exitCode:t.exitCode,stdout:t.text}}async function kf(t,e){let i=vf(t,"change name"),r=await z(e),n=gf(t,r?.native.language??"en"),a=at(t,"--isolation")??"current";if(a!=="current"&&a!=="branch"&&a!=="worktree")throw new Ne("--isolation must be current, branch, or worktree");let o=at(t,"--change-branch"),s=at(t,"--target-branch"),c=at(t,"--worktree-path");mf(t);let l=r;if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete`);let u=await rf({projectRoot:e,name:i,isolation:a,...o?{changeBranch:o}:{},...s?{targetBranch:s}:{},...c?{worktreePath:c}:{},sourceConfig:l});e=u.projectRoot,r=await z(e);let d=r===null?Cu("docs",n):void 0;if(r||(r=d),r.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete`);let f=await _e(e,r.native.artifact_root);await Pu(f);let p=await Jd({paths:f,name:i,language:n,workspaceBinding:u.binding,...d?{initialProjectConfig:d}:{}});return await Qd(f,p.name),yf("new",{...p,preparation:u.preparation,continuation:Ru(p)},`Created Native change ${p.name}
204
- `)}function Ob(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}})+`
205
- `}}async function Sf(t,e,i=process.argv.slice(2)){let r=i.indexOf("--"),n=r<0?[...i]:i.slice(0,r),a=r<0?[]:i.slice(r),o=n.includes("--json"),s,c;try{pf(n,"--json"),s=at(n,"--project-root");let u=[...n,...a],d=await wf(s);c=await e(u,d)}catch(u){c=Nf(t,u)}let l=o?Ob(c):bf(c,!1);return l.stdout&&process.stdout.write(l.stdout),l.stderr&&process.stderr.write(l.stderr+(l.stderr.endsWith(`
201
+ `}}var qb=Vb().usage;var RO=10*1024*1024,ye=class extends Error{};function Nf(t,e){let i=t.flatMap((r,n)=>r===e?[n]:[]);if(i.length>1)throw new ye(`${e} may only be provided once`);return i.length===0?!1:(t.splice(i[0],1),!0)}function st(t,e){let i=t.flatMap((a,o)=>a===e?[o]:[]);if(i.length>1)throw new ye(`${e} may only be provided once`);if(i.length===0)return;let r=i[0],n=t[r+1];if(n===void 0||n.startsWith("--"))throw new ye(`${e} requires a value`);return t.splice(r,2),n}function bf(t){if(t.length>0)throw new ye(`Unexpected argument: ${t[0]}`)}function kf(t,e){let i=t.shift();if(!i||i.startsWith("--"))throw new ye(`${e} is required`);return i}function Sf(t,e="en"){let i=st(t,"--language")??e;if(i!=="en"&&i!=="zh-CN")throw new ye("--language must be en or zh-CN");return i}function Ps(t,e){let i=Ui.normalize(yf(t)),r=Ui.normalize(yf(e));return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function yf(t){let e=Ui.resolve(t);try{return Wb.native(e)}catch{return e}}function zb(t){let e=Ui.resolve(t),i=ie(process.cwd());if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return e;let r=ie(e);return!r.isGitWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null||!Ps(i.primaryWorktreeRoot,r.primaryWorktreeRoot)||Ps(i.currentWorktreeRoot,r.currentWorktreeRoot)?e:Ps(process.cwd(),i.currentWorktreeRoot)?Ui.resolve(process.cwd()):i.currentWorktreeRoot}async function Ef(t){return t?zb(t):Fo(process.cwd())}function xf(t,e,i){return{command:t,exitCode:0,data:e,text:i??JSON.stringify(e,null,2)+`
202
+ `}}function Pf(t,e){if(e instanceof ye)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof Gn)return{command:t,exitCode:73,data:{capability:e.capability,expectedHash:e.expectedHash,actualHash:e.actualHash,canonicalPath:e.canonicalPath},error:{code:"conflict",message:e.message}};if(e instanceof Un)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof Dn)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 Jt)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 ot)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof Bn)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 Jn)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof Gi)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let i=e.code;if(i&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(i))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let r=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:r?73:65,error:{code:r?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function Cf(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}})+`
203
+ `}:t.error?{exitCode:t.exitCode,stderr:t.error.message}:{exitCode:t.exitCode,stdout:t.text}}async function Rf(t,e){let i=kf(t,"change name"),r=await z(e),n=Sf(t,r?.native.language??"en"),a=st(t,"--isolation")??"current";if(a!=="current"&&a!=="branch"&&a!=="worktree")throw new ye("--isolation must be current, branch, or worktree");let o=st(t,"--change-branch"),s=st(t,"--target-branch"),c=st(t,"--worktree-path");bf(t);let l=r;if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete`);let u=await lf({projectRoot:e,name:i,isolation:a,...o?{changeBranch:o}:{},...s?{targetBranch:s}:{},...c?{worktreePath:c}:{},sourceConfig:l});e=u.projectRoot,r=await z(e);let d=r===null?ju("docs",n):void 0;if(r||(r=d),r.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete`);let f=await Te(e,r.native.artifact_root);await Tu(f);let p=await Qd({paths:f,name:i,language:n,workspaceBinding:u.binding,...d?{initialProjectConfig:d}:{}});return await af(f,p.name),xf("new",{...p,preparation:u.preparation,continuation:$u(p)},`Created Native change ${p.name}
204
+ `)}function Jb(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}})+`
205
+ `}}async function Af(t,e,i=process.argv.slice(2)){let r=i.indexOf("--"),n=r<0?[...i]:i.slice(0,r),a=r<0?[]:i.slice(r),o=n.includes("--json"),s,c;try{Nf(n,"--json"),s=st(n,"--project-root");let u=[...n,...a],d=await Ef(s);c=await e(u,d)}catch(u){c=Pf(t,u)}let l=o?Jb(c):Cf(c,!1);return l.stdout&&process.stdout.write(l.stdout),l.stderr&&process.stderr.write(l.stderr+(l.stderr.endsWith(`
206
206
  `)?"":`
207
- `)),l.exitCode}process.exitCode=await Sf("new",kf);
207
+ `)),l.exitCode}process.exitCode=await Af("new",Rf);