@rpamis/comet 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (464) hide show
  1. package/README.md +372 -332
  2. package/assets/manifest.json +1 -1
  3. package/assets/skills/comet/scripts/comet-archive.mjs +113 -97
  4. package/assets/skills/comet/scripts/comet-check.mjs +117 -104
  5. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +59 -59
  6. package/assets/skills/comet/scripts/comet-guard.mjs +170 -157
  7. package/assets/skills/comet/scripts/comet-handoff.mjs +110 -97
  8. package/assets/skills/comet/scripts/comet-hook-guard.mjs +110 -97
  9. package/assets/skills/comet/scripts/comet-hook-router.mjs +272 -153
  10. package/assets/skills/comet/scripts/comet-intent.mjs +31 -31
  11. package/assets/skills/comet/scripts/comet-resume-probe.mjs +104 -91
  12. package/assets/skills/comet/scripts/comet-runtime.mjs +311 -296
  13. package/assets/skills/comet/scripts/comet-state.mjs +221 -207
  14. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +25 -25
  15. package/assets/skills/comet-archive/SKILL.md +13 -9
  16. package/assets/skills/comet-build/SKILL.md +4 -6
  17. package/assets/skills/comet-classic/SKILL.md +1 -1
  18. package/assets/skills/comet-classic/reference/scripts.md +9 -1
  19. package/assets/skills/comet-design/SKILL.md +0 -2
  20. package/assets/skills/comet-hotfix/SKILL.md +1 -3
  21. package/assets/skills/comet-native/SKILL.md +8 -7
  22. package/assets/skills/comet-native/reference/artifacts.md +51 -7
  23. package/assets/skills/comet-native/reference/clarification.md +5 -5
  24. package/assets/skills/comet-native/reference/commands.md +15 -13
  25. package/assets/skills/comet-native/reference/recovery.md +3 -3
  26. package/assets/skills/comet-native/reference/workspace.md +10 -4
  27. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +257 -169
  28. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +238 -153
  29. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +241 -124
  30. package/assets/skills/comet-native/scripts/comet-native-init.mjs +189 -108
  31. package/assets/skills/comet-native/scripts/comet-native-new.mjs +220 -139
  32. package/assets/skills/comet-native/scripts/comet-native-next.mjs +245 -160
  33. package/assets/skills/comet-native/scripts/comet-native-root.mjs +210 -129
  34. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +284 -196
  35. package/assets/skills/comet-native/scripts/comet-native-select.mjs +212 -128
  36. package/assets/skills/comet-native/scripts/comet-native-show.mjs +207 -126
  37. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +203 -118
  38. package/assets/skills/comet-native/scripts/comet-native-status.mjs +208 -124
  39. package/assets/skills/comet-open/SKILL.md +0 -2
  40. package/assets/skills/comet-tweak/SKILL.md +1 -1
  41. package/assets/skills/comet-verify/SKILL.md +0 -2
  42. package/assets/skills-zh/comet-archive/SKILL.md +13 -9
  43. package/assets/skills-zh/comet-build/SKILL.md +4 -6
  44. package/assets/skills-zh/comet-classic/SKILL.md +1 -1
  45. package/assets/skills-zh/comet-classic/reference/scripts.md +9 -1
  46. package/assets/skills-zh/comet-design/SKILL.md +0 -2
  47. package/assets/skills-zh/comet-hotfix/SKILL.md +1 -3
  48. package/assets/skills-zh/comet-native/SKILL.md +8 -7
  49. package/assets/skills-zh/comet-native/reference/artifacts.md +51 -7
  50. package/assets/skills-zh/comet-native/reference/clarification.md +5 -5
  51. package/assets/skills-zh/comet-native/reference/commands.md +16 -10
  52. package/assets/skills-zh/comet-native/reference/recovery.md +3 -3
  53. package/assets/skills-zh/comet-native/reference/workspace.md +10 -4
  54. package/assets/skills-zh/comet-open/SKILL.md +0 -2
  55. package/assets/skills-zh/comet-tweak/SKILL.md +1 -1
  56. package/assets/skills-zh/comet-verify/SKILL.md +0 -2
  57. package/bin/comet-daemon-router.js +23 -7
  58. package/bin/fast-runtime-router.js +1 -1
  59. package/dist/app/cli/index.js +1 -0
  60. package/dist/app/cli/index.js.map +1 -1
  61. package/dist/app/commands/daemon-server.d.ts.map +1 -1
  62. package/dist/app/commands/daemon-server.js +13 -2
  63. package/dist/app/commands/daemon-server.js.map +1 -1
  64. package/dist/app/commands/doctor.d.ts.map +1 -1
  65. package/dist/app/commands/doctor.js +17 -10
  66. package/dist/app/commands/doctor.js.map +1 -1
  67. package/dist/app/commands/i18n.d.ts +1 -1
  68. package/dist/app/commands/i18n.d.ts.map +1 -1
  69. package/dist/app/commands/i18n.js +4 -0
  70. package/dist/app/commands/i18n.js.map +1 -1
  71. package/dist/app/commands/project-knowledge.d.ts +2 -0
  72. package/dist/app/commands/project-knowledge.d.ts.map +1 -1
  73. package/dist/app/commands/project-knowledge.js +64 -7
  74. package/dist/app/commands/project-knowledge.js.map +1 -1
  75. package/dist/app/commands/uninstall.d.ts +1 -0
  76. package/dist/app/commands/uninstall.d.ts.map +1 -1
  77. package/dist/app/commands/uninstall.js +65 -10
  78. package/dist/app/commands/uninstall.js.map +1 -1
  79. package/dist/domains/agent-learning/coordinator.d.ts +8 -1
  80. package/dist/domains/agent-learning/coordinator.d.ts.map +1 -1
  81. package/dist/domains/agent-learning/coordinator.js +58 -0
  82. package/dist/domains/agent-learning/coordinator.js.map +1 -1
  83. package/dist/domains/agent-learning/experience-journal.d.ts +21 -1
  84. package/dist/domains/agent-learning/experience-journal.d.ts.map +1 -1
  85. package/dist/domains/agent-learning/experience-journal.js +190 -11
  86. package/dist/domains/agent-learning/experience-journal.js.map +1 -1
  87. package/dist/domains/bundle/bundle-platform.d.ts.map +1 -1
  88. package/dist/domains/bundle/bundle-platform.js +6 -1
  89. package/dist/domains/bundle/bundle-platform.js.map +1 -1
  90. package/dist/domains/comet-classic/classic-archive-entry.d.ts +1 -1
  91. package/dist/domains/comet-classic/classic-archive-entry.d.ts.map +1 -1
  92. package/dist/domains/comet-classic/classic-archive-entry.js +5 -2
  93. package/dist/domains/comet-classic/classic-archive-entry.js.map +1 -1
  94. package/dist/domains/comet-classic/classic-archive.d.ts.map +1 -1
  95. package/dist/domains/comet-classic/classic-archive.js +5 -1
  96. package/dist/domains/comet-classic/classic-archive.js.map +1 -1
  97. package/dist/domains/comet-classic/classic-branch-binding.d.ts.map +1 -1
  98. package/dist/domains/comet-classic/classic-branch-binding.js +5 -4
  99. package/dist/domains/comet-classic/classic-branch-binding.js.map +1 -1
  100. package/dist/domains/comet-classic/classic-check-entry.d.ts +1 -1
  101. package/dist/domains/comet-classic/classic-check-entry.d.ts.map +1 -1
  102. package/dist/domains/comet-classic/classic-check-entry.js +5 -2
  103. package/dist/domains/comet-classic/classic-check-entry.js.map +1 -1
  104. package/dist/domains/comet-classic/classic-check-snapshot.d.ts.map +1 -1
  105. package/dist/domains/comet-classic/classic-check-snapshot.js +68 -26
  106. package/dist/domains/comet-classic/classic-check-snapshot.js.map +1 -1
  107. package/dist/domains/comet-classic/classic-design-readiness.d.ts +1 -1
  108. package/dist/domains/comet-classic/classic-guard-entry.d.ts +1 -1
  109. package/dist/domains/comet-classic/classic-guard-entry.d.ts.map +1 -1
  110. package/dist/domains/comet-classic/classic-guard-entry.js +5 -2
  111. package/dist/domains/comet-classic/classic-guard-entry.js.map +1 -1
  112. package/dist/domains/comet-classic/classic-handoff-entry.d.ts +1 -1
  113. package/dist/domains/comet-classic/classic-handoff-entry.d.ts.map +1 -1
  114. package/dist/domains/comet-classic/classic-handoff-entry.js +5 -2
  115. package/dist/domains/comet-classic/classic-handoff-entry.js.map +1 -1
  116. package/dist/domains/comet-classic/classic-progress.d.ts +60 -2
  117. package/dist/domains/comet-classic/classic-progress.d.ts.map +1 -1
  118. package/dist/domains/comet-classic/classic-progress.js +199 -22
  119. package/dist/domains/comet-classic/classic-progress.js.map +1 -1
  120. package/dist/domains/comet-classic/classic-recovery.d.ts +20 -1
  121. package/dist/domains/comet-classic/classic-recovery.d.ts.map +1 -1
  122. package/dist/domains/comet-classic/classic-resume-probe.d.ts.map +1 -1
  123. package/dist/domains/comet-classic/classic-resume-probe.js +3 -2
  124. package/dist/domains/comet-classic/classic-resume-probe.js.map +1 -1
  125. package/dist/domains/comet-classic/classic-script-entry.d.ts +3 -1
  126. package/dist/domains/comet-classic/classic-script-entry.d.ts.map +1 -1
  127. package/dist/domains/comet-classic/classic-script-entry.js +34 -3
  128. package/dist/domains/comet-classic/classic-script-entry.js.map +1 -1
  129. package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
  130. package/dist/domains/comet-classic/classic-state-command.js +3 -2
  131. package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
  132. package/dist/domains/comet-classic/classic-state-entry.d.ts +1 -1
  133. package/dist/domains/comet-classic/classic-state-entry.d.ts.map +1 -1
  134. package/dist/domains/comet-classic/classic-state-entry.js +5 -2
  135. package/dist/domains/comet-classic/classic-state-entry.js.map +1 -1
  136. package/dist/domains/comet-classic/classic-store.d.ts.map +1 -1
  137. package/dist/domains/comet-classic/classic-store.js +67 -1
  138. package/dist/domains/comet-classic/classic-store.js.map +1 -1
  139. package/dist/domains/comet-entry/resume-probe.d.ts.map +1 -1
  140. package/dist/domains/comet-entry/resume-probe.js +3 -2
  141. package/dist/domains/comet-entry/resume-probe.js.map +1 -1
  142. package/dist/domains/comet-native/native-acceptance.d.ts +5 -1
  143. package/dist/domains/comet-native/native-acceptance.d.ts.map +1 -1
  144. package/dist/domains/comet-native/native-acceptance.js +13 -2
  145. package/dist/domains/comet-native/native-acceptance.js.map +1 -1
  146. package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
  147. package/dist/domains/comet-native/native-archive-command.js +167 -37
  148. package/dist/domains/comet-native/native-archive-command.js.map +1 -1
  149. package/dist/domains/comet-native/native-artifact-language.d.ts +10 -1
  150. package/dist/domains/comet-native/native-artifact-language.d.ts.map +1 -1
  151. package/dist/domains/comet-native/native-artifact-language.js +65 -12
  152. package/dist/domains/comet-native/native-artifact-language.js.map +1 -1
  153. package/dist/domains/comet-native/native-artifacts.d.ts +10 -1
  154. package/dist/domains/comet-native/native-artifacts.d.ts.map +1 -1
  155. package/dist/domains/comet-native/native-artifacts.js +130 -21
  156. package/dist/domains/comet-native/native-artifacts.js.map +1 -1
  157. package/dist/domains/comet-native/native-builder-acceptance-review.d.ts +16 -0
  158. package/dist/domains/comet-native/native-builder-acceptance-review.d.ts.map +1 -0
  159. package/dist/domains/comet-native/native-builder-acceptance-review.js +65 -0
  160. package/dist/domains/comet-native/native-builder-acceptance-review.js.map +1 -0
  161. package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
  162. package/dist/domains/comet-native/native-cli-help.js +8 -4
  163. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  164. package/dist/domains/comet-native/native-cli-shared.d.ts +4 -2
  165. package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
  166. package/dist/domains/comet-native/native-cli-shared.js +37 -9
  167. package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
  168. package/dist/domains/comet-native/native-cli.d.ts +4 -1
  169. package/dist/domains/comet-native/native-cli.d.ts.map +1 -1
  170. package/dist/domains/comet-native/native-cli.js +9 -5
  171. package/dist/domains/comet-native/native-cli.js.map +1 -1
  172. package/dist/domains/comet-native/native-doctor-command.d.ts.map +1 -1
  173. package/dist/domains/comet-native/native-doctor-command.js +144 -3
  174. package/dist/domains/comet-native/native-doctor-command.js.map +1 -1
  175. package/dist/domains/comet-native/native-git-provenance.d.ts.map +1 -1
  176. package/dist/domains/comet-native/native-git-provenance.js +3 -2
  177. package/dist/domains/comet-native/native-git-provenance.js.map +1 -1
  178. package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
  179. package/dist/domains/comet-native/native-hook-guard.js +57 -26
  180. package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
  181. package/dist/domains/comet-native/native-local-execution.d.ts +1 -0
  182. package/dist/domains/comet-native/native-local-execution.d.ts.map +1 -1
  183. package/dist/domains/comet-native/native-local-execution.js +7 -0
  184. package/dist/domains/comet-native/native-local-execution.js.map +1 -1
  185. package/dist/domains/comet-native/native-lock.d.ts.map +1 -1
  186. package/dist/domains/comet-native/native-lock.js +12 -0
  187. package/dist/domains/comet-native/native-lock.js.map +1 -1
  188. package/dist/domains/comet-native/native-loop-runtime.d.ts +2 -0
  189. package/dist/domains/comet-native/native-loop-runtime.d.ts.map +1 -1
  190. package/dist/domains/comet-native/native-loop-runtime.js +6 -0
  191. package/dist/domains/comet-native/native-loop-runtime.js.map +1 -1
  192. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  193. package/dist/domains/comet-native/native-next-command.js +57 -28
  194. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  195. package/dist/domains/comet-native/native-output-language.d.ts.map +1 -1
  196. package/dist/domains/comet-native/native-output-language.js +7 -0
  197. package/dist/domains/comet-native/native-output-language.js.map +1 -1
  198. package/dist/domains/comet-native/native-portable-acceptance.d.ts +2 -0
  199. package/dist/domains/comet-native/native-portable-acceptance.d.ts.map +1 -1
  200. package/dist/domains/comet-native/native-portable-acceptance.js +11 -1
  201. package/dist/domains/comet-native/native-portable-acceptance.js.map +1 -1
  202. package/dist/domains/comet-native/native-portable-archive.d.ts +1 -0
  203. package/dist/domains/comet-native/native-portable-archive.d.ts.map +1 -1
  204. package/dist/domains/comet-native/native-portable-archive.js +3 -0
  205. package/dist/domains/comet-native/native-portable-archive.js.map +1 -1
  206. package/dist/domains/comet-native/native-portable-checks.d.ts +14 -4
  207. package/dist/domains/comet-native/native-portable-checks.d.ts.map +1 -1
  208. package/dist/domains/comet-native/native-portable-checks.js +159 -60
  209. package/dist/domains/comet-native/native-portable-checks.js.map +1 -1
  210. package/dist/domains/comet-native/native-portable-continuation.d.ts +2 -1
  211. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  212. package/dist/domains/comet-native/native-portable-continuation.js +121 -39
  213. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  214. package/dist/domains/comet-native/native-portable-requirements.d.ts +1 -0
  215. package/dist/domains/comet-native/native-portable-requirements.d.ts.map +1 -1
  216. package/dist/domains/comet-native/native-portable-requirements.js +68 -18
  217. package/dist/domains/comet-native/native-portable-requirements.js.map +1 -1
  218. package/dist/domains/comet-native/native-portable-shape-coordination.d.ts.map +1 -1
  219. package/dist/domains/comet-native/native-portable-shape-coordination.js +18 -5
  220. package/dist/domains/comet-native/native-portable-shape-coordination.js.map +1 -1
  221. package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
  222. package/dist/domains/comet-native/native-portable-state.js +12 -3
  223. package/dist/domains/comet-native/native-portable-state.js.map +1 -1
  224. package/dist/domains/comet-native/native-portable-status.d.ts.map +1 -1
  225. package/dist/domains/comet-native/native-portable-status.js +10 -4
  226. package/dist/domains/comet-native/native-portable-status.js.map +1 -1
  227. package/dist/domains/comet-native/native-portable-types.d.ts +2 -1
  228. package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
  229. package/dist/domains/comet-native/native-portable-types.js.map +1 -1
  230. package/dist/domains/comet-native/native-portable-verification.d.ts +3 -0
  231. package/dist/domains/comet-native/native-portable-verification.d.ts.map +1 -1
  232. package/dist/domains/comet-native/native-portable-verification.js +28 -35
  233. package/dist/domains/comet-native/native-portable-verification.js.map +1 -1
  234. package/dist/domains/comet-native/native-portable-verifier-coordination.d.ts +2 -0
  235. package/dist/domains/comet-native/native-portable-verifier-coordination.d.ts.map +1 -1
  236. package/dist/domains/comet-native/native-portable-verifier-coordination.js +9 -0
  237. package/dist/domains/comet-native/native-portable-verifier-coordination.js.map +1 -1
  238. package/dist/domains/comet-native/native-runner-input-artifacts.d.ts +9 -0
  239. package/dist/domains/comet-native/native-runner-input-artifacts.d.ts.map +1 -0
  240. package/dist/domains/comet-native/native-runner-input-artifacts.js +102 -0
  241. package/dist/domains/comet-native/native-runner-input-artifacts.js.map +1 -0
  242. package/dist/domains/comet-native/native-runner-input.d.ts +90 -64
  243. package/dist/domains/comet-native/native-runner-input.d.ts.map +1 -1
  244. package/dist/domains/comet-native/native-runner-input.js +107 -22
  245. package/dist/domains/comet-native/native-runner-input.js.map +1 -1
  246. package/dist/domains/comet-native/native-script-entry.d.ts.map +1 -1
  247. package/dist/domains/comet-native/native-script-entry.js +9 -3
  248. package/dist/domains/comet-native/native-script-entry.js.map +1 -1
  249. package/dist/domains/comet-native/native-snapshot.d.ts.map +1 -1
  250. package/dist/domains/comet-native/native-snapshot.js +7 -2
  251. package/dist/domains/comet-native/native-snapshot.js.map +1 -1
  252. package/dist/domains/comet-native/native-verification-receipt-runtime.d.ts.map +1 -1
  253. package/dist/domains/comet-native/native-verification-receipt-runtime.js +5 -4
  254. package/dist/domains/comet-native/native-verification-receipt-runtime.js.map +1 -1
  255. package/dist/domains/comet-native/native-workspace-finish.d.ts +26 -0
  256. package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -1
  257. package/dist/domains/comet-native/native-workspace-finish.js +520 -15
  258. package/dist/domains/comet-native/native-workspace-finish.js.map +1 -1
  259. package/dist/domains/comet-plugin/integration.d.ts +1 -0
  260. package/dist/domains/comet-plugin/integration.d.ts.map +1 -1
  261. package/dist/domains/comet-plugin/integration.js +20 -10
  262. package/dist/domains/comet-plugin/integration.js.map +1 -1
  263. package/dist/domains/comet-plugin/plugin-runtime.d.ts +8 -2
  264. package/dist/domains/comet-plugin/plugin-runtime.d.ts.map +1 -1
  265. package/dist/domains/comet-plugin/plugin-runtime.js +18 -4
  266. package/dist/domains/comet-plugin/plugin-runtime.js.map +1 -1
  267. package/dist/domains/dashboard/project-directory.d.ts +4 -0
  268. package/dist/domains/dashboard/project-directory.d.ts.map +1 -1
  269. package/dist/domains/dashboard/project-directory.js +30 -2
  270. package/dist/domains/dashboard/project-directory.js.map +1 -1
  271. package/dist/domains/dashboard/server.d.ts.map +1 -1
  272. package/dist/domains/dashboard/server.js +28 -3
  273. package/dist/domains/dashboard/server.js.map +1 -1
  274. package/dist/domains/dashboard/web/assets/{abnfDiagram-VCTEODGH-qlcciI25.js → abnfDiagram-VCTEODGH-m9_t3fwH.js} +1 -1
  275. package/dist/domains/dashboard/web/assets/{arc-KVm4k9kp.js → arc-CDiwRrMg.js} +1 -1
  276. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-ypJOsR2Y.js +1 -0
  277. package/dist/domains/dashboard/web/assets/{architectureDiagram-5GKGNRK7-C366RdBK.js → architectureDiagram-5GKGNRK7-Xwj-hlQB.js} +1 -1
  278. package/dist/domains/dashboard/web/assets/{blockDiagram-I7D4REHJ-DAuTc2OO.js → blockDiagram-I7D4REHJ-Cme6qNK_.js} +1 -1
  279. package/dist/domains/dashboard/web/assets/{c4Diagram-7LVT6UL2-CFB0RZmL.js → c4Diagram-7LVT6UL2-Cxs1dU7y.js} +1 -1
  280. package/dist/domains/dashboard/web/assets/channel-BFTjR7Ng.js +1 -0
  281. package/dist/domains/dashboard/web/assets/{chunk-4HAMMTFA-DTV6lyGQ.js → chunk-4HAMMTFA-DBQykIWE.js} +1 -1
  282. package/dist/domains/dashboard/web/assets/{chunk-75Z2AOVW-DgJm4cEX.js → chunk-75Z2AOVW-Dh-E6TAx.js} +1 -1
  283. package/dist/domains/dashboard/web/assets/{chunk-DU6HZSFF-NAtcgGZr.js → chunk-DU6HZSFF-W3lPaoVP.js} +2 -2
  284. package/dist/domains/dashboard/web/assets/{chunk-F27PBJKO-BcFXHZMJ.js → chunk-F27PBJKO-dzf1fpYi.js} +1 -1
  285. package/dist/domains/dashboard/web/assets/{chunk-GMAD6QVW-wNemar9b.js → chunk-GMAD6QVW-CeuSGVHV.js} +1 -1
  286. package/dist/domains/dashboard/web/assets/{chunk-GVQU2GXP-BiVCDO9d.js → chunk-GVQU2GXP-BrGrIBgk.js} +1 -1
  287. package/dist/domains/dashboard/web/assets/{chunk-IMKFNOWR-D9GDj4b6.js → chunk-IMKFNOWR-DXiTC1Xo.js} +1 -1
  288. package/dist/domains/dashboard/web/assets/{chunk-L3NEJ4N5-DkPl5vac.js → chunk-L3NEJ4N5-DnyD3Ocj.js} +1 -1
  289. package/dist/domains/dashboard/web/assets/{chunk-OSK3NFVY-RbbxGqtJ.js → chunk-OSK3NFVY-6vxhPm51.js} +1 -1
  290. package/dist/domains/dashboard/web/assets/{chunk-P2QGCYS3-B9_X57eT.js → chunk-P2QGCYS3-DChNsVqO.js} +1 -1
  291. package/dist/domains/dashboard/web/assets/{chunk-POPQ4Y6H-DE4bOH0D.js → chunk-POPQ4Y6H-RBgha6dE.js} +1 -1
  292. package/dist/domains/dashboard/web/assets/{chunk-PWAF6VOD-Bo-W1iA1.js → chunk-PWAF6VOD-CayoKmnh.js} +1 -1
  293. package/dist/domains/dashboard/web/assets/{chunk-SHT3W25Y-BhLxs4rZ.js → chunk-SHT3W25Y-sOkLJZoB.js} +1 -1
  294. package/dist/domains/dashboard/web/assets/{chunk-SVP7TREG-BCXfn8uF.js → chunk-SVP7TREG-j0QRwmsq.js} +1 -1
  295. package/dist/domains/dashboard/web/assets/{chunk-TICWLB2K-DqSBgE5L.js → chunk-TICWLB2K-D7Re_d_T.js} +1 -1
  296. package/dist/domains/dashboard/web/assets/{chunk-XXDRQBXY-Dbkt1xEZ.js → chunk-XXDRQBXY-BFV70fKF.js} +1 -1
  297. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-gDSLbV2K.js +1 -0
  298. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-gDSLbV2K.js +1 -0
  299. package/dist/domains/dashboard/web/assets/{cose-bilkent-JH36ORCC-DrwNpMyX.js → cose-bilkent-JH36ORCC-k7gqx2Br.js} +1 -1
  300. package/dist/domains/dashboard/web/assets/{cynefin-OW5HDTMX-BbDlivxs.js → cynefin-OW5HDTMX-CWI6FZT8.js} +1 -1
  301. package/dist/domains/dashboard/web/assets/{cynefinDiagram-5FMLGOSQ-DmLmRN42.js → cynefinDiagram-5FMLGOSQ-D-O3RrOu.js} +1 -1
  302. package/dist/domains/dashboard/web/assets/{dagre-GXQ25YYZ-Cgm5DNgI.js → dagre-GXQ25YYZ-BR1jxWfn.js} +1 -1
  303. package/dist/domains/dashboard/web/assets/{diagram-S7CK7UJ4-Bnht1X2m.js → diagram-S7CK7UJ4-B6gXFYBj.js} +1 -1
  304. package/dist/domains/dashboard/web/assets/{diagram-UQ7AKVKN-LELTI4PR.js → diagram-UQ7AKVKN-BBW6aRk8.js} +1 -1
  305. package/dist/domains/dashboard/web/assets/{diagram-VSXAHHWV-Do0fZuNG.js → diagram-VSXAHHWV-BC0CZeyH.js} +1 -1
  306. package/dist/domains/dashboard/web/assets/{diagram-VX7I27RA-B0rZTUwt.js → diagram-VX7I27RA-BmwBIkwS.js} +1 -1
  307. package/dist/domains/dashboard/web/assets/{diagram-Z3DM3KII-wn8xCc_j.js → diagram-Z3DM3KII-DTZgX9SF.js} +1 -1
  308. package/dist/domains/dashboard/web/assets/{dist-CYwDKy2m.js → dist-brXLwleg.js} +1 -1
  309. package/dist/domains/dashboard/web/assets/{ebnfDiagram-PWID7BFC-CMDOpP2T.js → ebnfDiagram-PWID7BFC-CsMXo0C6.js} +1 -1
  310. package/dist/domains/dashboard/web/assets/{erDiagram-RLTQ6QDP-C2d43bdq.js → erDiagram-RLTQ6QDP-DQ9ewX94.js} +1 -1
  311. package/dist/domains/dashboard/web/assets/{es-BzaOcXwu.js → es-CgcAhzLf.js} +1 -1
  312. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-Ll12Q19y.js +1 -0
  313. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-Bf2-9XUn.js +1 -0
  314. package/dist/domains/dashboard/web/assets/{ganttDiagram-EL5Y4UJY-hTH7TzhY.js → ganttDiagram-EL5Y4UJY-DIFkXe6G.js} +1 -1
  315. package/dist/domains/dashboard/web/assets/{gitGraph-4MIJSDKK-C3CCywb-.js → gitGraph-4MIJSDKK-BHY8ZnpE.js} +1 -1
  316. package/dist/domains/dashboard/web/assets/{gitGraphDiagram-WWUBYQGX-DW6jDckj.js → gitGraphDiagram-WWUBYQGX-cBn9dMzs.js} +1 -1
  317. package/dist/domains/dashboard/web/assets/{index-CTZPz_mx.js → index-C_6nf1Fw.js} +3 -3
  318. package/dist/domains/dashboard/web/assets/{index-CWNqBYyI.css → index-Gaxnq6Jd.css} +1 -1
  319. package/dist/domains/dashboard/web/assets/{info-A6RAGUB7-Bg3eKis8.js → info-A6RAGUB7-DtUaS9jN.js} +1 -1
  320. package/dist/domains/dashboard/web/assets/{infoDiagram-27XIBGKW-7zk6ytVJ.js → infoDiagram-27XIBGKW-CIl0e_EN.js} +1 -1
  321. package/dist/domains/dashboard/web/assets/{ishikawaDiagram-5VMMS53U-CGDCTmCQ.js → ishikawaDiagram-5VMMS53U-DAdtPZ_c.js} +1 -1
  322. package/dist/domains/dashboard/web/assets/{journeyDiagram-3NMN7TZE-C8_L_e8a.js → journeyDiagram-3NMN7TZE-CBokRgde.js} +1 -1
  323. package/dist/domains/dashboard/web/assets/{kanban-definition-UXKFOSKX-D5x6qTgM.js → kanban-definition-UXKFOSKX-DrqCYJ-7.js} +1 -1
  324. package/dist/domains/dashboard/web/assets/katex-D29apahB.js +257 -0
  325. package/dist/domains/dashboard/web/assets/{line-DC93oja4.js → line-BDlVqlh4.js} +1 -1
  326. package/dist/domains/dashboard/web/assets/{linear-81TNubkB.js → linear-DTAzui9x.js} +1 -1
  327. package/dist/domains/dashboard/web/assets/{mermaid-parser.core-D60d8uy9.js → mermaid-parser.core-CFw-xbYY.js} +3 -3
  328. package/dist/domains/dashboard/web/assets/{mermaid.core-l4Wgjz2Q.js → mermaid.core-Ck7fB8UD.js} +4 -4
  329. package/dist/domains/dashboard/web/assets/{mindmap-definition-YA3MSWOX-Dfqu1201.js → mindmap-definition-YA3MSWOX-C7kb9KL9.js} +1 -1
  330. package/dist/domains/dashboard/web/assets/{packet-AYTQ26CC-CsFZBhTs.js → packet-AYTQ26CC-P8Mtt0tp.js} +1 -1
  331. package/dist/domains/dashboard/web/assets/{pegDiagram-XKGWAZYB-myFMaA7n.js → pegDiagram-XKGWAZYB-DUDD9qv5.js} +1 -1
  332. package/dist/domains/dashboard/web/assets/{pie-WAS4IAKB-FMuCTNSk.js → pie-WAS4IAKB-dEmLxiDR.js} +1 -1
  333. package/dist/domains/dashboard/web/assets/{pieDiagram-E7YTZNPT-CSR4B4Z1.js → pieDiagram-E7YTZNPT-BUssAcqk.js} +1 -1
  334. package/dist/domains/dashboard/web/assets/purify.es-Bvo9QlJ8.js +3 -0
  335. package/dist/domains/dashboard/web/assets/{quadrantDiagram-AXDQQJYC-BiE4kEeP.js → quadrantDiagram-AXDQQJYC-BzaAWdQL.js} +1 -1
  336. package/dist/domains/dashboard/web/assets/{radar-RG4KPBEZ-BZ-n7JtG.js → radar-RG4KPBEZ-mqtvaz9w.js} +1 -1
  337. package/dist/domains/dashboard/web/assets/{railroad-74A4TZTK-CWVtRfHu.js → railroad-74A4TZTK-7tTnGpoz.js} +1 -1
  338. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CpJvyBJM.js +1 -0
  339. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-BJ5g77l6.js +1 -0
  340. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-BslCK-Gr.js +1 -0
  341. package/dist/domains/dashboard/web/assets/{railroadDiagram-O6MQD6OU-CBj7v1de.js → railroadDiagram-O6MQD6OU-DM1AKXm0.js} +1 -1
  342. package/dist/domains/dashboard/web/assets/{requirementDiagram-BXWQKSXE-DSDgb54n.js → requirementDiagram-BXWQKSXE--H5KiPSc.js} +1 -1
  343. package/dist/domains/dashboard/web/assets/{sankeyDiagram-P5KCCOFB-1-oXLUAP.js → sankeyDiagram-P5KCCOFB-JweUq_u2.js} +1 -1
  344. package/dist/domains/dashboard/web/assets/{sequenceDiagram-WJ2MYXX4-DAF4nGs_.js → sequenceDiagram-WJ2MYXX4-pxb1iTGb.js} +1 -1
  345. package/dist/domains/dashboard/web/assets/{src-CTWLVUqE.js → src-joFOxopw.js} +1 -1
  346. package/dist/domains/dashboard/web/assets/{stateDiagram-D77RDMKH-DzENBaJT.js → stateDiagram-D77RDMKH-CDu5crd8.js} +1 -1
  347. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-wV5AqWaM.js +1 -0
  348. package/dist/domains/dashboard/web/assets/{swimlanes-42K2YHIH-CnxFUZJc.js → swimlanes-42K2YHIH-ioSqowJ4.js} +1 -1
  349. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-DOPLn-V5.js +8 -0
  350. package/dist/domains/dashboard/web/assets/{timeline-definition-24CTP7MA-KtvPzpZM.js → timeline-definition-24CTP7MA-2YXSYkS3.js} +1 -1
  351. package/dist/domains/dashboard/web/assets/{treeView-Q6P3EWNA-Bdu3P9iY.js → treeView-Q6P3EWNA-DEGims38.js} +1 -1
  352. package/dist/domains/dashboard/web/assets/{treemap-WGGIJYW6-DFnn23JR.js → treemap-WGGIJYW6-CJvBhTlR.js} +1 -1
  353. package/dist/domains/dashboard/web/assets/{vennDiagram-4TSXK5OY-BjpviP26.js → vennDiagram-4TSXK5OY-CHdNWhBK.js} +1 -1
  354. package/dist/domains/dashboard/web/assets/{wardley-WFR3VGLG-CEo4a-j4.js → wardley-WFR3VGLG-CVO9PCjo.js} +1 -1
  355. package/dist/domains/dashboard/web/assets/{wardleyDiagram-VM6X3IG4-Bf54n6im.js → wardleyDiagram-VM6X3IG4-RToPmij6.js} +1 -1
  356. package/dist/domains/dashboard/web/assets/{xychartDiagram-S5SC5T6Z-CU-hI0Cm.js → xychartDiagram-S5SC5T6Z-DaWHnpHE.js} +1 -1
  357. package/dist/domains/dashboard/web/index.html +2 -2
  358. package/dist/domains/project-knowledge/host-review.d.ts +15 -2
  359. package/dist/domains/project-knowledge/host-review.d.ts.map +1 -1
  360. package/dist/domains/project-knowledge/host-review.js +65 -25
  361. package/dist/domains/project-knowledge/host-review.js.map +1 -1
  362. package/dist/domains/project-knowledge/index.d.ts +1 -0
  363. package/dist/domains/project-knowledge/index.d.ts.map +1 -1
  364. package/dist/domains/project-knowledge/index.js +1 -0
  365. package/dist/domains/project-knowledge/index.js.map +1 -1
  366. package/dist/domains/project-knowledge/learning.d.ts +2 -1
  367. package/dist/domains/project-knowledge/learning.d.ts.map +1 -1
  368. package/dist/domains/project-knowledge/learning.js +6 -0
  369. package/dist/domains/project-knowledge/learning.js.map +1 -1
  370. package/dist/domains/project-knowledge/plugin.d.ts.map +1 -1
  371. package/dist/domains/project-knowledge/plugin.js +3 -1
  372. package/dist/domains/project-knowledge/plugin.js.map +1 -1
  373. package/dist/domains/skill/dsh-adapter.d.ts +5 -1
  374. package/dist/domains/skill/dsh-adapter.d.ts.map +1 -1
  375. package/dist/domains/skill/dsh-adapter.js +222 -87
  376. package/dist/domains/skill/dsh-adapter.js.map +1 -1
  377. package/dist/domains/skill/platform-inspect.d.ts +1 -0
  378. package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
  379. package/dist/domains/skill/platform-inspect.js +8 -4
  380. package/dist/domains/skill/platform-inspect.js.map +1 -1
  381. package/dist/domains/skill/platform-install.d.ts.map +1 -1
  382. package/dist/domains/skill/platform-install.js +7 -7
  383. package/dist/domains/skill/platform-install.js.map +1 -1
  384. package/dist/domains/workflow-contract/hook-target-scope.d.ts.map +1 -1
  385. package/dist/domains/workflow-contract/hook-target-scope.js +2 -1
  386. package/dist/domains/workflow-contract/hook-target-scope.js.map +1 -1
  387. package/dist/platform/fs/file-system.d.ts +2 -0
  388. package/dist/platform/fs/file-system.d.ts.map +1 -1
  389. package/dist/platform/fs/file-system.js +11 -0
  390. package/dist/platform/fs/file-system.js.map +1 -1
  391. package/dist/platform/install/dsh-profiles.d.ts +3 -0
  392. package/dist/platform/install/dsh-profiles.d.ts.map +1 -0
  393. package/dist/platform/install/dsh-profiles.js +40 -0
  394. package/dist/platform/install/dsh-profiles.js.map +1 -0
  395. package/dist/platform/install/platforms.d.ts.map +1 -1
  396. package/dist/platform/install/platforms.js +1 -0
  397. package/dist/platform/install/platforms.js.map +1 -1
  398. package/dist/platform/install/project-registry.d.ts +7 -1
  399. package/dist/platform/install/project-registry.d.ts.map +1 -1
  400. package/dist/platform/install/project-registry.js +49 -5
  401. package/dist/platform/install/project-registry.js.map +1 -1
  402. package/dist/platform/paths/git-worktree-cache.d.ts +3 -0
  403. package/dist/platform/paths/git-worktree-cache.d.ts.map +1 -0
  404. package/dist/platform/paths/git-worktree-cache.js +109 -0
  405. package/dist/platform/paths/git-worktree-cache.js.map +1 -0
  406. package/dist/platform/paths/git-worktree.d.ts +6 -0
  407. package/dist/platform/paths/git-worktree.d.ts.map +1 -1
  408. package/dist/platform/paths/git-worktree.js +191 -30
  409. package/dist/platform/paths/git-worktree.js.map +1 -1
  410. package/dist/platform/paths/project-worktree-root.d.ts +3 -0
  411. package/dist/platform/paths/project-worktree-root.d.ts.map +1 -0
  412. package/dist/platform/paths/project-worktree-root.js +14 -0
  413. package/dist/platform/paths/project-worktree-root.js.map +1 -0
  414. package/dist/platform/process/comet-daemon.d.ts +3 -0
  415. package/dist/platform/process/comet-daemon.d.ts.map +1 -1
  416. package/dist/platform/process/comet-daemon.js +8 -6
  417. package/dist/platform/process/comet-daemon.js.map +1 -1
  418. package/dist/platform/process/external-command.d.ts +3 -0
  419. package/dist/platform/process/external-command.d.ts.map +1 -1
  420. package/dist/platform/process/external-command.js +69 -2
  421. package/dist/platform/process/external-command.js.map +1 -1
  422. package/dist/platform/process/git.d.ts.map +1 -1
  423. package/dist/platform/process/git.js +3 -4
  424. package/dist/platform/process/git.js.map +1 -1
  425. package/dist/platform/process/hook-adapter.d.ts +2 -0
  426. package/dist/platform/process/hook-adapter.d.ts.map +1 -1
  427. package/dist/platform/process/hook-adapter.js +45 -3
  428. package/dist/platform/process/hook-adapter.js.map +1 -1
  429. package/dist/platform/process/hook-read-cache.d.ts +2 -0
  430. package/dist/platform/process/hook-read-cache.d.ts.map +1 -1
  431. package/dist/platform/process/hook-read-cache.js +25 -13
  432. package/dist/platform/process/hook-read-cache.js.map +1 -1
  433. package/dist/platform/process/process-identity.d.ts.map +1 -1
  434. package/dist/platform/process/process-identity.js +18 -51
  435. package/dist/platform/process/process-identity.js.map +1 -1
  436. package/dist/platform/process/runtime-metrics.d.ts +10 -1
  437. package/dist/platform/process/runtime-metrics.d.ts.map +1 -1
  438. package/dist/platform/process/runtime-metrics.js +37 -2
  439. package/dist/platform/process/runtime-metrics.js.map +1 -1
  440. package/dist/platform/process/windows-process-broker.d.ts +1 -0
  441. package/dist/platform/process/windows-process-broker.d.ts.map +1 -1
  442. package/dist/platform/process/windows-process-broker.js +70 -11
  443. package/dist/platform/process/windows-process-broker.js.map +1 -1
  444. package/dist/platform/process/windows-process-identity.d.ts +6 -0
  445. package/dist/platform/process/windows-process-identity.d.ts.map +1 -0
  446. package/dist/platform/process/windows-process-identity.js +190 -0
  447. package/dist/platform/process/windows-process-identity.js.map +1 -0
  448. package/eval/local/tasks/comet-classic-layout-lifecycle/environment/current-comet-package.json +11 -3
  449. package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/environment/current-comet-package.json +11 -3
  450. package/eval/local/tests/scaffold/test_task_resolution.py +6 -2
  451. package/package.json +14 -8
  452. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-QeljAKq2.js +0 -1
  453. package/dist/domains/dashboard/web/assets/channel-_AqwP0KA.js +0 -1
  454. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-CRo4aB_7.js +0 -1
  455. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-CRo4aB_7.js +0 -1
  456. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-KYANo3DQ.js +0 -1
  457. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-CSROlLuj.js +0 -1
  458. package/dist/domains/dashboard/web/assets/katex-CXMH3UgJ.js +0 -257
  459. package/dist/domains/dashboard/web/assets/purify.es-ChwZkWde.js +0 -3
  460. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CkHwwI2i.js +0 -1
  461. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-8xzEHL6v.js +0 -1
  462. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-nSHBw0tH.js +0 -1
  463. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-CNw52Fkn.js +0 -1
  464. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-6TRvbqqI.js +0 -8
@@ -1,79 +1,79 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var sv=Object.create;var hu=Object.defineProperty;var cv=Object.getOwnPropertyDescriptor;var lv=Object.getOwnPropertyNames;var uv=Object.getPrototypeOf,dv=Object.prototype.hasOwnProperty;var sn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var S=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(i){throw r=[i],i}};var y=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var fv=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of lv(t))!dv.call(e,n)&&n!==r&&hu(e,n,{get:()=>t[n],enumerable:!(i=cv(t,n))||i.enumerable});return e};var mt=(e,t,r)=>(r=e!=null?sv(uv(e)):{},fv(t||!e||!e.__esModule?hu(r,"default",{value:e,enumerable:!0}):r,e));function Bo(){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 cr,Gr,mu,Jr=S(()=>{"use strict";cr="comet.native.v4",Gr="comet.native.local-execution.v4",mu=["multi-session","single-session"]});import{createHash as pv}from"crypto";function be(e){throw new TypeError(`Value is not valid canonical JSON: ${e}`)}function hv(e,t){t.has(e)&&be("cyclic structures are not supported"),t.add(e);try{let r=Object.keys(e);for(let i=0;i<e.length;i+=1)Object.prototype.hasOwnProperty.call(e,i)||be("sparse arrays are not supported");return(r.length!==e.length||r.some((i,n)=>i!==String(n)))&&be("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(e).length>0&&be("symbol properties are not supported"),`[${e.map(i=>Mo(i,t)).join(",")}]`}finally{t.delete(e)}}function mv(e,t){let r=Object.getPrototypeOf(e);r!==Object.prototype&&r!==null&&be("only plain objects are supported"),t.has(e)&&be("cyclic structures are not supported"),Object.getOwnPropertySymbols(e).length>0&&be("symbol properties are not supported"),t.add(e);try{let i=Object.getOwnPropertyDescriptors(e);return`{${Object.keys(e).sort().map(o=>{let s=i[o];return(!s||!("value"in s))&&be("accessor properties are not supported"),`${JSON.stringify(o)}:${Mo(s.value,t)}`}).join(",")}}`}finally{t.delete(e)}}function Mo(e,t){if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"string":return JSON.stringify(e);case"number":return Number.isFinite(e)||be("numbers must be finite"),JSON.stringify(Object.is(e,-0)?0:e);case"object":return Array.isArray(e)?hv(e,t):mv(e,t);case"bigint":case"function":case"symbol":case"undefined":return be(`${typeof e} values are not supported`)}return be("unsupported value type")}function Fo(e){return Mo(e,new Set)}function O(e,t){if(e.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(e))throw new TypeError("Canonical hash tag must not contain a line break");return pv("sha256").update(`${e}
5
- ${Fo(t)}`).digest("hex")}var J=S(()=>{"use strict"});var cn,Vo=S(()=>{"use strict";cn=class extends Error{issues;constructor(t){let r=[t.missingFields.length?`missing: ${t.missingFields.join(", ")}`:"",t.unknownFields.length?`unknown: ${t.unknownFields.join(", ")}`:""].filter(Boolean).join("; ");super(`${t.context} fields are invalid at ${t.path||"/"} (${r})`),this.name="NativeInputValidationError",this.issues=[t]}}});var Ur=S(()=>{"use strict"});var ln=S(()=>{"use strict";Vo();Ur()});var un,$t=S(()=>{"use strict";J();ln();un=3});import{promises as Go}from"node:fs";async function Jo(e,t){let r;for(let i=0;i<=zo.length;i+=1)try{return await e()}catch(n){r=n;let a=n.code;if(i===zo.length||!Pv.has(a??""))throw n;await new Promise(o=>setTimeout(o,zo[i]))}throw r}async function Uo(e,t){await Jo(()=>Go.rename(e,t),`rename ${t}`)}async function Ko(e){await Jo(()=>Go.unlink(e),`unlink ${e}`)}async function Yo(e,t){await Jo(()=>Go.link(e,t),`link ${t}`)}var Pv,zo,Xo=S(()=>{"use strict";Pv=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),zo=[50,100,200]});function gt(e){return e!==0&&e!==0n&&e!=="0"}function Se(e,t){return gt(e.dev)&&gt(t.dev)&&gt(e.ino)&&gt(t.ino)}function j(e,t){let r=gt(e.dev)&&gt(t.dev);if(r&&e.dev!==t.dev)return!1;let i=gt(e.ino)&&gt(t.ino);return i&&e.ino!==t.ino?!1:r&&i?!0:e.birthtime===t.birthtime}var Kr=S(()=>{"use strict"});var Le=S(()=>{"use strict";Kr()});import{randomUUID as Rv}from"crypto";import{promises as ee}from"fs";import Ee from"path";function hn(e,t){let r=Ee.relative(e,t);return r===""||!Ee.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ee.sep}`)}function _v(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function mn(e,t){return j({dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs},{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs})}function Av(e,t){return mn(e,t)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function ku(e){let t=await ee.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${e}`);return{path:e,realPath:await ee.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function lr(e){for(let t of e){let r=await ee.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!_v(t,r)||await ee.realpath(t.path)!==t.realPath)throw new Error(`Native atomic write parent changed before commit: ${t.path}`)}}async function Iv(e,t,r){let[i,n]=await Promise.all([ee.lstat(e),ee.realpath(e),r?lr(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!mn(i,t)||r&&!hn(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function Tv(e,t){let r=Ee.resolve(e),i=Ee.resolve(t);if(!hn(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${t}`);let n=[await ku(r)],a=Ee.relative(r,i).split(Ee.sep).filter(Boolean),o=r;for(let s of a){await lr(n),o=Ee.join(o,s);try{await ee.mkdir(o)}catch(c){if(c.code!=="EEXIST")throw c}let l=await ku(o);if(!hn(n[0].realPath,l.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(l)}return await lr(n),n}async function jv(e){let t;try{t=await ee.open(e,"r"),await t.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await t?.close()}}async function $v(e,t,r={}){let i=Ee.dirname(e),n=r.containedRoot?await Tv(r.containedRoot,i):null;n||await ee.mkdir(i,{recursive:!0});let a=Ee.join(i,`.${Ee.basename(e)}.${Rv()}.tmp`),o,s,l;try{if(await r.beforeTemporaryOpen?.(),o=await ee.open(a,"wx"),s=await o.stat(),n){let[c,u]=await Promise.all([ee.lstat(a),ee.realpath(a)]);if(await lr(n),!c.isFile()||c.isSymbolicLink()||!mn(s,c)||!hn(n[0].realPath,u))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof t=="string"?await o.writeFile(t,"utf8"):await o.writeFile(t),await o.sync(),l=await o.stat(),!mn(s,l))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await r.afterTemporaryClose?.(),!l)throw new Error("Native atomic write temporary file was not written");if(l=await Iv(a,l,n),await r.beforeCommit?.(),n){await lr(n);let c=await ee.lstat(a);if(!c.isFile()||c.isSymbolicLink()||!l||!Av(c,l))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await Yo(a,e),await Ko(a)):await Uo(a,e),await jv(i)}catch(c){if(await o?.close(),!n)await ee.rm(a,{force:!0});else try{await lr(n),await ee.rm(a,{force:!0})}catch{}throw c}}async function ue(e,t,r={}){await $v(e,t,r)}async function Q(e,t,r={}){await ue(e,JSON.stringify(t,null,2)+`
6
- `,r)}var L=S(()=>{"use strict";Xo();Le()});function Dv(e){return e.toLowerCase().startsWith(".env")}function Yr(e){let r=e.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>Dv(i))?"environment-file":r.some(i=>Hv.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>Ov.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var Ov,Hv,Xr=S(()=>{"use strict";Ov=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Hv=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"])});import{createHash as Lv}from"node:crypto";import{promises as xe}from"node:fs";import de from"node:path";import{TextDecoder as Bv}from"node:util";function Qo(e,t){let r=de.relative(e,t);return r===""||!de.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${de.sep}`)}function Mv(e){let t=de.posix.normalize(e);if(e.length===0||e!==e.trim()||e.includes("\\")||Array.from(e).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||de.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||t!==e||t==="."||e.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${e}`);let r=e.toLowerCase(),i=Yr(e);if(i||r==="runtime"||r.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${i??"native-runtime"}): ${e}`);return e}function Fv(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native artifact byte limit must be a positive integer");return e}function Vv(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function vn(e,t){let r={...e,birthtime:e.birthtimeMs},i={...t,birthtime:t.birthtimeMs};return Se(r,i)?j(r,i):j(r,i)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function Su(e){let t=await xe.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${e}`);return{path:e,realPath:await xe.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function qv(e,t){let r=de.resolve(e),i=de.resolve(t);if(!Qo(r,i))throw new Error("Native artifact path is outside its root");let n=[await Su(r)],a=r;for(let o of de.relative(r,i).split(de.sep).filter(Boolean)){a=de.join(a,o);let s=await Su(a);if(!Qo(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Eu(e){for(let t of e){let r=await xe.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!Vv(t,r)||await xe.realpath(t.path)!==t.realPath)throw new Error(`Native artifact parent changed while reading: ${t.path}`)}}async function T(e){let t=Mv(e.ref),r=e.maxBytes===null?null:Fv(e.maxBytes??Zo),i=de.resolve(e.root,...t.split("/")),n=await qv(e.root,de.dirname(i));await e.hooks?.afterParentChainCaptured?.();let a=await xe.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${t}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${t}`);let o=await xe.realpath(i);if(!Qo(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${t}`);let s=await xe.open(i,"r");try{let[l,c,u]=await Promise.all([s.stat(),xe.lstat(i),xe.realpath(i)]);if(await Eu(n),!l.isFile()||!c.isFile()||c.isSymbolicLink()||u!==o||!vn(a,l)||!vn(l,c))throw new Error(`Native artifact changed while opening: ${t}`);await e.hooks?.afterOpen?.();let d=[],f=0,h=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let N=r===null?h.length:r+1-f,k=await s.read(h,0,Math.min(h.length,N),null);if(k.bytesRead===0)break;if(f+=k.bytesRead,r!==null&&f>r)throw new Error(`Native artifact exceeds ${r} bytes: ${t}`);d.push(Buffer.from(h.subarray(0,k.bytesRead)))}await e.hooks?.beforeFinalCheck?.();let[m,p,v]=await Promise.all([s.stat(),xe.lstat(i),xe.realpath(i)]);if(await Eu(n),!p.isFile()||p.isSymbolicLink()||v!==o||!vn(l,m)||!vn(l,p))throw new Error(`Native artifact changed while reading: ${t}`);let g=Buffer.concat(d,f),w;try{w=new Bv("utf-8",{fatal:!0}).decode(g)}catch(N){throw new Error(`Native artifact is not valid UTF-8: ${t}`,{cause:N})}return{ref:t,size:f,hash:e.includeHash===!1?null:Lv("sha256").update(g).digest("hex"),text:w}}finally{await s.close()}}var Zo,fe=S(()=>{"use strict";Xr();Le();Zo=1024*1024});var R=y(Y=>{"use strict";var es=Symbol.for("yaml.alias"),xu=Symbol.for("yaml.document"),gn=Symbol.for("yaml.map"),Cu=Symbol.for("yaml.pair"),ts=Symbol.for("yaml.scalar"),wn=Symbol.for("yaml.seq"),Xe=Symbol.for("yaml.node.type"),Wv=e=>!!e&&typeof e=="object"&&e[Xe]===es,zv=e=>!!e&&typeof e=="object"&&e[Xe]===xu,Gv=e=>!!e&&typeof e=="object"&&e[Xe]===gn,Jv=e=>!!e&&typeof e=="object"&&e[Xe]===Cu,Pu=e=>!!e&&typeof e=="object"&&e[Xe]===ts,Uv=e=>!!e&&typeof e=="object"&&e[Xe]===wn;function Ru(e){if(e&&typeof e=="object")switch(e[Xe]){case gn:case wn:return!0}return!1}function Kv(e){if(e&&typeof e=="object")switch(e[Xe]){case es:case gn:case ts:case wn:return!0}return!1}var Yv=e=>(Pu(e)||Ru(e))&&!!e.anchor;Y.ALIAS=es;Y.DOC=xu;Y.MAP=gn;Y.NODE_TYPE=Xe;Y.PAIR=Cu;Y.SCALAR=ts;Y.SEQ=wn;Y.hasAnchor=Yv;Y.isAlias=Wv;Y.isCollection=Ru;Y.isDocument=zv;Y.isMap=Gv;Y.isNode=Kv;Y.isPair=Jv;Y.isScalar=Pu;Y.isSeq=Uv});var Qr=y(rs=>{"use strict";var z=R(),ne=Symbol("break visit"),_u=Symbol("skip children"),Be=Symbol("remove node");function yn(e,t){let r=Au(t);z.isDocument(e)?ur(null,e.contents,r,Object.freeze([e]))===Be&&(e.contents=null):ur(null,e,r,Object.freeze([]))}yn.BREAK=ne;yn.SKIP=_u;yn.REMOVE=Be;function ur(e,t,r,i){let n=Iu(e,t,r,i);if(z.isNode(n)||z.isPair(n))return Tu(e,i,n),ur(e,n,r,i);if(typeof n!="symbol"){if(z.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=ur(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ne)return ne;o===Be&&(t.items.splice(a,1),a-=1)}}}else if(z.isPair(t)){i=Object.freeze(i.concat(t));let a=ur("key",t.key,r,i);if(a===ne)return ne;a===Be&&(t.key=null);let o=ur("value",t.value,r,i);if(o===ne)return ne;o===Be&&(t.value=null)}}return n}async function Nn(e,t){let r=Au(t);z.isDocument(e)?await dr(null,e.contents,r,Object.freeze([e]))===Be&&(e.contents=null):await dr(null,e,r,Object.freeze([]))}Nn.BREAK=ne;Nn.SKIP=_u;Nn.REMOVE=Be;async function dr(e,t,r,i){let n=await Iu(e,t,r,i);if(z.isNode(n)||z.isPair(n))return Tu(e,i,n),dr(e,n,r,i);if(typeof n!="symbol"){if(z.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=await dr(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ne)return ne;o===Be&&(t.items.splice(a,1),a-=1)}}}else if(z.isPair(t)){i=Object.freeze(i.concat(t));let a=await dr("key",t.key,r,i);if(a===ne)return ne;a===Be&&(t.key=null);let o=await dr("value",t.value,r,i);if(o===ne)return ne;o===Be&&(t.value=null)}}return n}function Au(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Iu(e,t,r,i){if(typeof r=="function")return r(e,t,i);if(z.isMap(t))return r.Map?.(e,t,i);if(z.isSeq(t))return r.Seq?.(e,t,i);if(z.isPair(t))return r.Pair?.(e,t,i);if(z.isScalar(t))return r.Scalar?.(e,t,i);if(z.isAlias(t))return r.Alias?.(e,t,i)}function Tu(e,t,r){let i=t[t.length-1];if(z.isCollection(i))i.items[e]=r;else if(z.isPair(i))e==="key"?i.key=r:i.value=r;else if(z.isDocument(i))i.contents=r;else{let n=z.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}rs.visit=yn;rs.visitAsync=Nn});var is=y($u=>{"use strict";var ju=R(),Xv=Qr(),Qv={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Zv=e=>e.replace(/[!,[\]{}]/g,t=>Qv[t]),Zr=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||r(`The ${t} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,i]of Object.entries(this.tags))if(t.startsWith(i))return r+Zv(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(t&&i.length>0&&ju.isNode(t.contents)){let a={};Xv.visit(t.contents,(o,s)=>{ju.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(`
7
- `)}};Zr.defaultYaml={explicit:!1,version:"1.2"};Zr.defaultTags={"!!":"tag:yaml.org,2002:"};$u.Directives=Zr});var bn=y(ei=>{"use strict";var Ou=R(),eg=Qr();function tg(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function Hu(e){let t=new Set;return eg.visit(e,{Value(r,i){i.anchor&&t.add(i.anchor)}}),t}function Du(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function rg(e,t){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Hu(e));let o=Du(t,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Ou.isScalar(o.node)||Ou.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:i}}ei.anchorIsValid=tg;ei.anchorNames=Hu;ei.createNodeAnchors=rg;ei.findNewAnchor=Du});var ns=y(Lu=>{"use strict";function ti(e,t,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=ti(e,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=ti(e,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=ti(e,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=ti(e,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return e.call(t,r,i)}Lu.applyReviver=ti});var wt=y(Mu=>{"use strict";var ig=R();function Bu(e,t,r){if(Array.isArray(e))return e.map((i,n)=>Bu(i,String(n),r));if(e&&typeof e.toJSON=="function"){if(!r||!ig.hasAnchor(e))return e.toJSON(t,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=e.toJSON(t,r);return r.onCreate&&r.onCreate(n),n}return typeof e=="bigint"&&!r?.keep?Number(e):e}Mu.toJS=Bu});var kn=y(Vu=>{"use strict";var ng=ns(),Fu=R(),ag=wt(),as=class{constructor(t){Object.defineProperty(this,Fu.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!Fu.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=ag.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof a=="function"?ng.applyReviver(a,{"":s},"",s):s}};Vu.NodeBase=as});var ri=y(qu=>{"use strict";var og=bn(),sg=Qr(),fr=R(),cg=kn(),lg=wt(),os=class extends cg.NodeBase{constructor(t){super(fr.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],sg.visit(t,{Node:(a,o)=>{(fr.isAlias(o)||fr.hasAnchor(o))&&i.push(o)}}),r&&(r.aliasResolveCache=i));let n;for(let a of i){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(t,r){if(!r)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:a}=r,o=this.resolve(n,r);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let s=i.get(o);if(s||(lg.toJS(o,null,r),s=i.get(o)),s?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=Sn(n,o,i)),s.count*s.aliasCount>a)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return s.res}toString(t,r,i){let n=`*${this.source}`;if(t){if(og.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${n} `}return n}};function Sn(e,t,r){if(fr.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(fr.isCollection(t)){let i=0;for(let n of t.items){let a=Sn(e,n,r);a>i&&(i=a)}return i}else if(fr.isPair(t)){let i=Sn(e,t.key,r),n=Sn(e,t.value,r);return Math.max(i,n)}return 1}qu.Alias=os});var M=y(ss=>{"use strict";var ug=R(),dg=kn(),fg=wt(),pg=e=>!e||typeof e!="function"&&typeof e!="object",yt=class extends dg.NodeBase{constructor(t){super(ug.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:fg.toJS(this.value,t,r)}toString(){return String(this.value)}};yt.BLOCK_FOLDED="BLOCK_FOLDED";yt.BLOCK_LITERAL="BLOCK_LITERAL";yt.PLAIN="PLAIN";yt.QUOTE_DOUBLE="QUOTE_DOUBLE";yt.QUOTE_SINGLE="QUOTE_SINGLE";ss.Scalar=yt;ss.isScalarValue=pg});var ii=y(zu=>{"use strict";var hg=ri(),Ht=R(),Wu=M(),mg="tag:yaml.org,2002:";function vg(e,t,r){if(t){let i=r.filter(a=>a.tag===t),n=i.find(a=>!a.format)??i[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return r.find(i=>i.identify?.(e)&&!i.format)}function gg(e,t,r){if(Ht.isDocument(e)&&(e=e.contents),Ht.isNode(e))return e;if(Ht.isPair(e)){let d=r.schema[Ht.MAP].createNode?.(r.schema,null,r);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=r,l;if(i&&e&&typeof e=="object"){if(l=s.get(e),l)return l.anchor??(l.anchor=n(e)),new hg.Alias(l.anchor);l={anchor:null,node:null},s.set(e,l)}t?.startsWith("!!")&&(t=mg+t.slice(2));let c=vg(e,t,o.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new Wu.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?o[Ht.MAP]:Symbol.iterator in Object(e)?o[Ht.SEQ]:o[Ht.MAP]}a&&(a(c),delete r.onTagObj);let u=c?.createNode?c.createNode(r.schema,e,r):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(r.schema,e,r):new Wu.Scalar(e);return t?u.tag=t:c.default||(u.tag=c.tag),l&&(l.node=u),u}zu.createNode=gg});var xn=y(En=>{"use strict";var wg=ii(),Me=R(),yg=kn();function cs(e,t,r){let i=r;for(let n=t.length-1;n>=0;--n){let a=t[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return wg.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Gu=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,ls=class extends yg.NodeBase{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(i=>Me.isNode(i)||Me.isPair(i)?i.clone(t):i),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(Gu(t))this.add(r);else{let[i,...n]=t,a=this.get(i,!0);if(Me.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,cs(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(t){let[r,...i]=t;if(i.length===0)return this.delete(r);let n=this.get(r,!0);if(Me.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}getIn(t,r){let[i,...n]=t,a=this.get(i,!0);return n.length===0?!r&&Me.isScalar(a)?a.value:a:Me.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!Me.isPair(r))return!1;let i=r.value;return i==null||t&&Me.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[r,...i]=t;if(i.length===0)return this.has(r);let n=this.get(r,!0);return Me.isCollection(n)?n.hasIn(i):!1}setIn(t,r){let[i,...n]=t;if(n.length===0)this.set(i,r);else{let a=this.get(i,!0);if(Me.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,cs(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};En.Collection=ls;En.collectionFromPath=cs;En.isEmptyPath=Gu});var ni=y(Cn=>{"use strict";var Ng=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function us(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var bg=(e,t,r)=>e.endsWith(`
8
- `)?us(r,t):r.includes(`
4
+ var Bg=Object.create;var bd=Object.defineProperty;var Mg=Object.getOwnPropertyDescriptor;var Fg=Object.getOwnPropertyNames;var qg=Object.getPrototypeOf,Vg=Object.prototype.hasOwnProperty;var Fn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var S=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(i){throw r=[i],i}};var y=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var Wg=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Fg(t))!Vg.call(e,n)&&n!==r&&bd(e,n,{get:()=>t[n],enumerable:!(i=Mg(t,n))||i.enumerable});return e};var Ct=(e,t,r)=>(r=e!=null?Bg(qg(e)):{},Wg(t||!e||!e.__esModule?bd(r,"default",{value:e,enumerable:!0}):r,e));function Ps(){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 xr,hi,Nd,mi=S(()=>{"use strict";xr="comet.native.v4",hi="comet.native.local-execution.v4",Nd=["multi-session","single-session"]});import{createHash as zg}from"crypto";function Re(e){throw new TypeError(`Value is not valid canonical JSON: ${e}`)}function Gg(e,t){t.has(e)&&Re("cyclic structures are not supported"),t.add(e);try{let r=Object.keys(e);for(let i=0;i<e.length;i+=1)Object.prototype.hasOwnProperty.call(e,i)||Re("sparse arrays are not supported");return(r.length!==e.length||r.some((i,n)=>i!==String(n)))&&Re("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(e).length>0&&Re("symbol properties are not supported"),`[${e.map(i=>Rs(i,t)).join(",")}]`}finally{t.delete(e)}}function Jg(e,t){let r=Object.getPrototypeOf(e);r!==Object.prototype&&r!==null&&Re("only plain objects are supported"),t.has(e)&&Re("cyclic structures are not supported"),Object.getOwnPropertySymbols(e).length>0&&Re("symbol properties are not supported"),t.add(e);try{let i=Object.getOwnPropertyDescriptors(e);return`{${Object.keys(e).sort().map(o=>{let s=i[o];return(!s||!("value"in s))&&Re("accessor properties are not supported"),`${JSON.stringify(o)}:${Rs(s.value,t)}`}).join(",")}}`}finally{t.delete(e)}}function Rs(e,t){if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"string":return JSON.stringify(e);case"number":return Number.isFinite(e)||Re("numbers must be finite"),JSON.stringify(Object.is(e,-0)?0:e);case"object":return Array.isArray(e)?Gg(e,t):Jg(e,t);case"bigint":case"function":case"symbol":case"undefined":return Re(`${typeof e} values are not supported`)}return Re("unsupported value type")}function _s(e){return Rs(e,new Set)}function D(e,t){if(e.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(e))throw new TypeError("Canonical hash tag must not contain a line break");return zg("sha256").update(`${e}
5
+ ${_s(t)}`).digest("hex")}var K=S(()=>{"use strict"});function As(e,t,r,i=""){let n=Object.keys(e),a=t.filter(s=>!Object.hasOwn(e,s)),o=n.filter(s=>!t.includes(s));if(a.length||o.length)throw new vi({code:"invalid-fields",path:i,context:r,missingFields:a,unknownFields:o,expectedFields:[...t]})}var vi,qn=S(()=>{"use strict";vi=class extends Error{issues;constructor(t){let r=[t.missingFields.length?`missing: ${t.missingFields.join(", ")}`:"",t.unknownFields.length?`unknown: ${t.unknownFields.join(", ")}`:""].filter(Boolean).join("; ");super(`${t.context} fields are invalid at ${t.path||"/"} (${r})`),this.name="NativeInputValidationError",this.issues=[t]}}});var gi=S(()=>{"use strict"});var Vn=S(()=>{"use strict";qn();gi()});var Wn,zt=S(()=>{"use strict";K();Vn();Wn=3});import{AsyncLocalStorage as iw}from"node:async_hooks";import{performance as Jn}from"node:perf_hooks";function Is(e=0){nw+=1,aw+=e;let t=ow.getStore();t&&(t.gitCommands+=1,t.gitDurationMs+=e)}function Un(e){let t=Jn.now();try{return e()}finally{Is(Jn.now()-t)}}async function Ts(e){let t=Jn.now();try{return await e()}finally{Is(Jn.now()-t)}}var nw,aw,ow,Cr=S(()=>{"use strict";nw=0,aw=0,ow=new iw});import{existsSync as sw}from"node:fs";import wi from"node:path";function Cd(e,t){let r=t.toLowerCase();return Object.entries(e).find(([i,n])=>i.toLowerCase()===r&&n!==void 0)?.[1]}function lw(e){let t=(Cd(e,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").map(r=>r.trim().toLowerCase()).filter(Boolean);return[...new Set([...t,".ps1"])]}function uw(e,t,r){let n=wi.win32.isAbsolute(e)||/[\\/]/u.test(e)?[""]:(Cd(t,"PATH")??"").split(wi.delimiter).map(s=>s.trim().replace(/^"(.*)"$/u,"$1")).filter(Boolean),o=wi.win32.extname(e)?[e]:lw(t).map(s=>`${e}${s}`);return n.flatMap(s=>o.map(l=>s?wi.join(s,l):wi.resolve(r,l)))}function Kn(e,t,r){return uw(e,t,r).find(i=>sw(i))??e}function $s(e){if(e.some(t=>cw.test(t)))throw new Error("Windows batch check arguments must not contain shell syntax")}var cw,SA,yi=S(()=>{"use strict";cw=/[&|<>()^%"!\r\n]/u,SA=["$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{execFile as dw,execFileSync as CA}from"node:child_process";import Pd from"node:path";async function Pt(e,t,r={}){let i=r.timeoutMs??fw,n=r.maxBufferBytes??pw;if(!Number.isSafeInteger(i)||i<1||!Number.isSafeInteger(n)||n<1)throw new Error("External command limits must be positive integers");let a=Pd.resolve(r.cwd??process.cwd()),o=r.env??process.env,s=process.platform==="win32"?Kn(e,o,a):e,l=process.platform==="win32"&&/\.(?:bat|cmd)$/iu.test(s);l&&$s(t);let c=()=>new Promise((u,d)=>{let f=!1,h=dw(s,[...t],{cwd:a,env:o,encoding:"utf8",maxBuffer:n,windowsHide:!0,shell:l},(g,w,b)=>{f||(f=!0,clearTimeout(v),r.signal?.removeEventListener("abort",p),g?d(new bi(e,t,b.trim(),{cause:g,timedOut:hw(g)})):u(w))}),m=g=>{f||(f=!0,clearTimeout(v),r.signal?.removeEventListener("abort",p),h.kill("SIGKILL"),h.stdin?.destroy(),h.stdout?.destroy(),h.stderr?.destroy(),h.unref(),d(new bi(e,t,"",{timedOut:g})))},p=()=>m(!1),v=setTimeout(()=>m(!0),i);r.signal?.addEventListener("abort",p,{once:!0}),r.signal?.aborted&&p(),h.stdin?.end(r.input)});return/^(?:git|git\.exe)$/iu.test(Pd.win32.basename(e))?Ts(c):c()}function hw(e){return e instanceof Error&&(e.code==="ETIMEDOUT"||e.killed===!0&&e.signal==="SIGTERM")}var fw,pw,bi,Yn=S(()=>{"use strict";Cr();yi();fw=6e4,pw=8*1024*1024;bi=class extends Error{constructor(r,i,n,a){super(`${r} ${i.join(" ")} failed${n?`: ${n}`:""}`,a);this.command=r;this.args=i;this.stderr=n;this.name="ExternalCommandError",this.timedOut=a?.timedOut===!0}command;args;stderr;timedOut}});import{promises as Os}from"node:fs";async function Hs(e,t){let r;for(let i=0;i<=js.length;i+=1)try{return await e()}catch(n){r=n;let a=n.code;if(i===js.length||!Nw.has(a??""))throw n;await new Promise(o=>setTimeout(o,js[i]))}throw r}async function Ds(e,t){await Hs(()=>Os.rename(e,t),`rename ${t}`)}async function Ls(e){await Hs(()=>Os.unlink(e),`unlink ${e}`)}async function Bs(e,t){await Hs(()=>Os.link(e,t),`link ${t}`)}var Nw,js,Ms=S(()=>{"use strict";Nw=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),js=[50,100,200]});function Rt(e){return e!==0&&e!==0n&&e!=="0"}function Ae(e,t){return Rt(e.dev)&&Rt(t.dev)&&Rt(e.ino)&&Rt(t.ino)}function j(e,t){let r=Rt(e.dev)&&Rt(t.dev);if(r&&e.dev!==t.dev)return!1;let i=Rt(e.ino)&&Rt(t.ino);return i&&e.ino!==t.ino?!1:r&&i?!0:e.birthtime===t.birthtime}var ki=S(()=>{"use strict"});var Ge=S(()=>{"use strict";ki()});import{randomUUID as kw}from"crypto";import{promises as ie}from"fs";import Ie from"path";function Qn(e,t){let r=Ie.relative(e,t);return r===""||!Ie.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ie.sep}`)}function Sw(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Zn(e,t){return j({dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs},{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs})}function Ew(e,t){return Zn(e,t)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Td(e){let t=await ie.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${e}`);return{path:e,realPath:await ie.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function _r(e){for(let t of e){let r=await ie.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!Sw(t,r)||await ie.realpath(t.path)!==t.realPath)throw new Error(`Native atomic write parent changed before commit: ${t.path}`)}}async function xw(e,t,r){let[i,n]=await Promise.all([ie.lstat(e),ie.realpath(e),r?_r(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Zn(i,t)||r&&!Qn(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function Cw(e,t){let r=Ie.resolve(e),i=Ie.resolve(t);if(!Qn(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${t}`);let n=[await Td(r)],a=Ie.relative(r,i).split(Ie.sep).filter(Boolean),o=r;for(let s of a){await _r(n),o=Ie.join(o,s);try{await ie.mkdir(o)}catch(c){if(c.code!=="EEXIST")throw c}let l=await Td(o);if(!Qn(n[0].realPath,l.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(l)}return await _r(n),n}async function Pw(e){let t;try{t=await ie.open(e,"r"),await t.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await t?.close()}}async function Rw(e,t,r={}){let i=Ie.dirname(e),n=r.containedRoot?await Cw(r.containedRoot,i):null;n||await ie.mkdir(i,{recursive:!0});let a=Ie.join(i,`.${Ie.basename(e)}.${kw()}.tmp`),o,s,l;try{if(await r.beforeTemporaryOpen?.(),o=await ie.open(a,"wx"),s=await o.stat(),n){let[c,u]=await Promise.all([ie.lstat(a),ie.realpath(a)]);if(await _r(n),!c.isFile()||c.isSymbolicLink()||!Zn(s,c)||!Qn(n[0].realPath,u))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof t=="string"?await o.writeFile(t,"utf8"):await o.writeFile(t),await o.sync(),l=await o.stat(),!Zn(s,l))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await r.afterTemporaryClose?.(),!l)throw new Error("Native atomic write temporary file was not written");if(l=await xw(a,l,n),await r.beforeCommit?.(),n){await _r(n);let c=await ie.lstat(a);if(!c.isFile()||c.isSymbolicLink()||!l||!Ew(c,l))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await Bs(a,e),await Ls(a)):await Ds(a,e),await Pw(i)}catch(c){if(await o?.close(),!n)await ie.rm(a,{force:!0});else try{await _r(n),await ie.rm(a,{force:!0})}catch{}throw c}}async function ve(e,t,r={}){await Rw(e,t,r)}async function Z(e,t,r={}){await ve(e,JSON.stringify(t,null,2)+`
6
+ `,r)}var B=S(()=>{"use strict";Ms();Ge()});function Iw(e){return e.toLowerCase().startsWith(".env")}function Si(e){let r=e.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>Iw(i))?"environment-file":r.some(i=>Aw.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>_w.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var _w,Aw,Ei=S(()=>{"use strict";_w=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Aw=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"])});import{createHash as Tw}from"node:crypto";import{promises as Te}from"node:fs";import ge from"node:path";import{TextDecoder as $w}from"node:util";function Fs(e,t){let r=ge.relative(e,t);return r===""||!ge.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ge.sep}`)}function jw(e){let t=ge.posix.normalize(e);if(e.length===0||e!==e.trim()||e.includes("\\")||Array.from(e).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||ge.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||t!==e||t==="."||e.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${e}`);let r=e.toLowerCase(),i=Si(e);if(i||r==="runtime"||r.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${i??"native-runtime"}): ${e}`);return e}function Ow(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native artifact byte limit must be a positive integer");return e}function Hw(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function ea(e,t){let r={...e,birthtime:e.birthtimeMs},i={...t,birthtime:t.birthtimeMs};return Ae(r,i)?j(r,i):j(r,i)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function $d(e){let t=await Te.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${e}`);return{path:e,realPath:await Te.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function Dw(e,t){let r=ge.resolve(e),i=ge.resolve(t);if(!Fs(r,i))throw new Error("Native artifact path is outside its root");let n=[await $d(r)],a=r;for(let o of ge.relative(r,i).split(ge.sep).filter(Boolean)){a=ge.join(a,o);let s=await $d(a);if(!Fs(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function jd(e){for(let t of e){let r=await Te.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!Hw(t,r)||await Te.realpath(t.path)!==t.realPath)throw new Error(`Native artifact parent changed while reading: ${t.path}`)}}async function $(e){let t=jw(e.ref),r=e.maxBytes===null?null:Ow(e.maxBytes??qs),i=ge.resolve(e.root,...t.split("/")),n=await Dw(e.root,ge.dirname(i));await e.hooks?.afterParentChainCaptured?.();let a=await Te.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${t}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${t}`);let o=await Te.realpath(i);if(!Fs(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${t}`);let s=await Te.open(i,"r");try{let[l,c,u]=await Promise.all([s.stat(),Te.lstat(i),Te.realpath(i)]);if(await jd(n),!l.isFile()||!c.isFile()||c.isSymbolicLink()||u!==o||!ea(a,l)||!ea(l,c))throw new Error(`Native artifact changed while opening: ${t}`);await e.hooks?.afterOpen?.();let d=[],f=0,h=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let b=r===null?h.length:r+1-f,k=await s.read(h,0,Math.min(h.length,b),null);if(k.bytesRead===0)break;if(f+=k.bytesRead,r!==null&&f>r)throw new Error(`Native artifact exceeds ${r} bytes: ${t}`);d.push(Buffer.from(h.subarray(0,k.bytesRead)))}await e.hooks?.beforeFinalCheck?.();let[m,p,v]=await Promise.all([s.stat(),Te.lstat(i),Te.realpath(i)]);if(await jd(n),!p.isFile()||p.isSymbolicLink()||v!==o||!ea(l,m)||!ea(l,p))throw new Error(`Native artifact changed while reading: ${t}`);let g=Buffer.concat(d,f),w;try{w=new $w("utf-8",{fatal:!0}).decode(g)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${t}`,{cause:b})}return{ref:t,size:f,hash:e.includeHash===!1?null:Tw("sha256").update(g).digest("hex"),text:w}}finally{await s.close()}}var qs,we=S(()=>{"use strict";Ei();Ge();qs=1024*1024});var _=y(ee=>{"use strict";var Vs=Symbol.for("yaml.alias"),Od=Symbol.for("yaml.document"),ta=Symbol.for("yaml.map"),Hd=Symbol.for("yaml.pair"),Ws=Symbol.for("yaml.scalar"),ra=Symbol.for("yaml.seq"),ct=Symbol.for("yaml.node.type"),Lw=e=>!!e&&typeof e=="object"&&e[ct]===Vs,Bw=e=>!!e&&typeof e=="object"&&e[ct]===Od,Mw=e=>!!e&&typeof e=="object"&&e[ct]===ta,Fw=e=>!!e&&typeof e=="object"&&e[ct]===Hd,Dd=e=>!!e&&typeof e=="object"&&e[ct]===Ws,qw=e=>!!e&&typeof e=="object"&&e[ct]===ra;function Ld(e){if(e&&typeof e=="object")switch(e[ct]){case ta:case ra:return!0}return!1}function Vw(e){if(e&&typeof e=="object")switch(e[ct]){case Vs:case ta:case Ws:case ra:return!0}return!1}var Ww=e=>(Dd(e)||Ld(e))&&!!e.anchor;ee.ALIAS=Vs;ee.DOC=Od;ee.MAP=ta;ee.NODE_TYPE=ct;ee.PAIR=Hd;ee.SCALAR=Ws;ee.SEQ=ra;ee.hasAnchor=Ww;ee.isAlias=Lw;ee.isCollection=Ld;ee.isDocument=Bw;ee.isMap=Mw;ee.isNode=Vw;ee.isPair=Fw;ee.isScalar=Dd;ee.isSeq=qw});var xi=y(zs=>{"use strict";var J=_(),se=Symbol("break visit"),Bd=Symbol("skip children"),Je=Symbol("remove node");function ia(e,t){let r=Md(t);J.isDocument(e)?Ar(null,e.contents,r,Object.freeze([e]))===Je&&(e.contents=null):Ar(null,e,r,Object.freeze([]))}ia.BREAK=se;ia.SKIP=Bd;ia.REMOVE=Je;function Ar(e,t,r,i){let n=Fd(e,t,r,i);if(J.isNode(n)||J.isPair(n))return qd(e,i,n),Ar(e,n,r,i);if(typeof n!="symbol"){if(J.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=Ar(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===se)return se;o===Je&&(t.items.splice(a,1),a-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let a=Ar("key",t.key,r,i);if(a===se)return se;a===Je&&(t.key=null);let o=Ar("value",t.value,r,i);if(o===se)return se;o===Je&&(t.value=null)}}return n}async function na(e,t){let r=Md(t);J.isDocument(e)?await Ir(null,e.contents,r,Object.freeze([e]))===Je&&(e.contents=null):await Ir(null,e,r,Object.freeze([]))}na.BREAK=se;na.SKIP=Bd;na.REMOVE=Je;async function Ir(e,t,r,i){let n=await Fd(e,t,r,i);if(J.isNode(n)||J.isPair(n))return qd(e,i,n),Ir(e,n,r,i);if(typeof n!="symbol"){if(J.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=await Ir(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===se)return se;o===Je&&(t.items.splice(a,1),a-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let a=await Ir("key",t.key,r,i);if(a===se)return se;a===Je&&(t.key=null);let o=await Ir("value",t.value,r,i);if(o===se)return se;o===Je&&(t.value=null)}}return n}function Md(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Fd(e,t,r,i){if(typeof r=="function")return r(e,t,i);if(J.isMap(t))return r.Map?.(e,t,i);if(J.isSeq(t))return r.Seq?.(e,t,i);if(J.isPair(t))return r.Pair?.(e,t,i);if(J.isScalar(t))return r.Scalar?.(e,t,i);if(J.isAlias(t))return r.Alias?.(e,t,i)}function qd(e,t,r){let i=t[t.length-1];if(J.isCollection(i))i.items[e]=r;else if(J.isPair(i))e==="key"?i.key=r:i.value=r;else if(J.isDocument(i))i.contents=r;else{let n=J.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}zs.visit=ia;zs.visitAsync=na});var Gs=y(Wd=>{"use strict";var Vd=_(),zw=xi(),Gw={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Jw=e=>e.replace(/[!,[\]{}]/g,t=>Gw[t]),Ci=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||r(`The ${t} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,i]of Object.entries(this.tags))if(t.startsWith(i))return r+Jw(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(t&&i.length>0&&Vd.isNode(t.contents)){let a={};zw.visit(t.contents,(o,s)=>{Vd.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(`
7
+ `)}};Ci.defaultYaml={explicit:!1,version:"1.2"};Ci.defaultTags={"!!":"tag:yaml.org,2002:"};Wd.Directives=Ci});var aa=y(Pi=>{"use strict";var zd=_(),Uw=xi();function Kw(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function Gd(e){let t=new Set;return Uw.visit(e,{Value(r,i){i.anchor&&t.add(i.anchor)}}),t}function Jd(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function Yw(e,t){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Gd(e));let o=Jd(t,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(zd.isScalar(o.node)||zd.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:i}}Pi.anchorIsValid=Kw;Pi.anchorNames=Gd;Pi.createNodeAnchors=Yw;Pi.findNewAnchor=Jd});var Js=y(Ud=>{"use strict";function Ri(e,t,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=Ri(e,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=Ri(e,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=Ri(e,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=Ri(e,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return e.call(t,r,i)}Ud.applyReviver=Ri});var _t=y(Yd=>{"use strict";var Xw=_();function Kd(e,t,r){if(Array.isArray(e))return e.map((i,n)=>Kd(i,String(n),r));if(e&&typeof e.toJSON=="function"){if(!r||!Xw.hasAnchor(e))return e.toJSON(t,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=e.toJSON(t,r);return r.onCreate&&r.onCreate(n),n}return typeof e=="bigint"&&!r?.keep?Number(e):e}Yd.toJS=Kd});var oa=y(Qd=>{"use strict";var Qw=Js(),Xd=_(),Zw=_t(),Us=class{constructor(t){Object.defineProperty(this,Xd.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!Xd.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=Zw.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof a=="function"?Qw.applyReviver(a,{"":s},"",s):s}};Qd.NodeBase=Us});var _i=y(Zd=>{"use strict";var ey=aa(),ty=xi(),Tr=_(),ry=oa(),iy=_t(),Ks=class extends ry.NodeBase{constructor(t){super(Tr.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],ty.visit(t,{Node:(a,o)=>{(Tr.isAlias(o)||Tr.hasAnchor(o))&&i.push(o)}}),r&&(r.aliasResolveCache=i));let n;for(let a of i){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(t,r){if(!r)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:a}=r,o=this.resolve(n,r);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let s=i.get(o);if(s||(iy.toJS(o,null,r),s=i.get(o)),s?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=sa(n,o,i)),s.count*s.aliasCount>a)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return s.res}toString(t,r,i){let n=`*${this.source}`;if(t){if(ey.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${n} `}return n}};function sa(e,t,r){if(Tr.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(Tr.isCollection(t)){let i=0;for(let n of t.items){let a=sa(e,n,r);a>i&&(i=a)}return i}else if(Tr.isPair(t)){let i=sa(e,t.key,r),n=sa(e,t.value,r);return Math.max(i,n)}return 1}Zd.Alias=Ks});var q=y(Ys=>{"use strict";var ny=_(),ay=oa(),oy=_t(),sy=e=>!e||typeof e!="function"&&typeof e!="object",At=class extends ay.NodeBase{constructor(t){super(ny.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:oy.toJS(this.value,t,r)}toString(){return String(this.value)}};At.BLOCK_FOLDED="BLOCK_FOLDED";At.BLOCK_LITERAL="BLOCK_LITERAL";At.PLAIN="PLAIN";At.QUOTE_DOUBLE="QUOTE_DOUBLE";At.QUOTE_SINGLE="QUOTE_SINGLE";Ys.Scalar=At;Ys.isScalarValue=sy});var Ai=y(tf=>{"use strict";var cy=_i(),Ut=_(),ef=q(),ly="tag:yaml.org,2002:";function uy(e,t,r){if(t){let i=r.filter(a=>a.tag===t),n=i.find(a=>!a.format)??i[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return r.find(i=>i.identify?.(e)&&!i.format)}function dy(e,t,r){if(Ut.isDocument(e)&&(e=e.contents),Ut.isNode(e))return e;if(Ut.isPair(e)){let d=r.schema[Ut.MAP].createNode?.(r.schema,null,r);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=r,l;if(i&&e&&typeof e=="object"){if(l=s.get(e),l)return l.anchor??(l.anchor=n(e)),new cy.Alias(l.anchor);l={anchor:null,node:null},s.set(e,l)}t?.startsWith("!!")&&(t=ly+t.slice(2));let c=uy(e,t,o.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new ef.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?o[Ut.MAP]:Symbol.iterator in Object(e)?o[Ut.SEQ]:o[Ut.MAP]}a&&(a(c),delete r.onTagObj);let u=c?.createNode?c.createNode(r.schema,e,r):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(r.schema,e,r):new ef.Scalar(e);return t?u.tag=t:c.default||(u.tag=c.tag),l&&(l.node=u),u}tf.createNode=dy});var la=y(ca=>{"use strict";var fy=Ai(),Ue=_(),py=oa();function Xs(e,t,r){let i=r;for(let n=t.length-1;n>=0;--n){let a=t[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return fy.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var rf=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,Qs=class extends py.NodeBase{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(i=>Ue.isNode(i)||Ue.isPair(i)?i.clone(t):i),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(rf(t))this.add(r);else{let[i,...n]=t,a=this.get(i,!0);if(Ue.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,Xs(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(t){let[r,...i]=t;if(i.length===0)return this.delete(r);let n=this.get(r,!0);if(Ue.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}getIn(t,r){let[i,...n]=t,a=this.get(i,!0);return n.length===0?!r&&Ue.isScalar(a)?a.value:a:Ue.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!Ue.isPair(r))return!1;let i=r.value;return i==null||t&&Ue.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[r,...i]=t;if(i.length===0)return this.has(r);let n=this.get(r,!0);return Ue.isCollection(n)?n.hasIn(i):!1}setIn(t,r){let[i,...n]=t;if(n.length===0)this.set(i,r);else{let a=this.get(i,!0);if(Ue.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,Xs(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};ca.Collection=Qs;ca.collectionFromPath=Xs;ca.isEmptyPath=rf});var Ii=y(ua=>{"use strict";var hy=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Zs(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var my=(e,t,r)=>e.endsWith(`
8
+ `)?Zs(r,t):r.includes(`
9
9
  `)?`
10
- `+us(r,t):(e.endsWith(" ")?"":" ")+r;Cn.indentComment=us;Cn.lineComment=bg;Cn.stringifyComment=Ng});var Uu=y(ai=>{"use strict";var kg="flow",ds="block",Pn="quoted";function Sg(e,t,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return e;n<a&&(a=0);let l=Math.max(1+a,1+n-t.length);if(e.length<=l)return e;let c=[],u={},d=n-t.length;typeof i=="number"&&(i>n-Math.max(2,a)?c.push(0):d=n-i);let f,h,m=!1,p=-1,v=-1,g=-1;r===ds&&(p=Ju(e,p,t.length),p!==-1&&(d=p+l));for(let N;N=e[p+=1];){if(r===Pn&&N==="\\"){switch(v=p,e[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}g=p}if(N===`
11
- `)r===ds&&(p=Ju(e,p,t.length)),d=p+t.length+l,f=void 0;else{if(N===" "&&h&&h!==" "&&h!==`
10
+ `+Zs(r,t):(e.endsWith(" ")?"":" ")+r;ua.indentComment=Zs;ua.lineComment=my;ua.stringifyComment=hy});var af=y(Ti=>{"use strict";var vy="flow",ec="block",da="quoted";function gy(e,t,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return e;n<a&&(a=0);let l=Math.max(1+a,1+n-t.length);if(e.length<=l)return e;let c=[],u={},d=n-t.length;typeof i=="number"&&(i>n-Math.max(2,a)?c.push(0):d=n-i);let f,h,m=!1,p=-1,v=-1,g=-1;r===ec&&(p=nf(e,p,t.length),p!==-1&&(d=p+l));for(let b;b=e[p+=1];){if(r===da&&b==="\\"){switch(v=p,e[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}g=p}if(b===`
11
+ `)r===ec&&(p=nf(e,p,t.length)),d=p+t.length+l,f=void 0;else{if(b===" "&&h&&h!==" "&&h!==`
12
12
  `&&h!==" "){let k=e[p+1];k&&k!==" "&&k!==`
13
- `&&k!==" "&&(f=p)}if(p>=d)if(f)c.push(f),d=f+l,f=void 0;else if(r===Pn){for(;h===" "||h===" ";)h=N,N=e[p+=1],m=!0;let k=p>g+1?p-2:v-1;if(u[k])return e;c.push(k),u[k]=!0,d=k+l,f=void 0}else m=!0}h=N}if(m&&s&&s(),c.length===0)return e;o&&o();let w=e.slice(0,c[0]);for(let N=0;N<c.length;++N){let k=c[N],E=c[N+1]||e.length;k===0?w=`
14
- ${t}${e.slice(0,E)}`:(r===Pn&&u[k]&&(w+=`${e[k]}\\`),w+=`
15
- ${t}${e.slice(k+1,E)}`)}return w}function Ju(e,t,r){let i=t,n=t+1,a=e[n];for(;a===" "||a===" ";)if(t<n+r)a=e[++t];else{do a=e[++t];while(a&&a!==`
16
- `);i=t,n=t+1,a=e[n]}return i}ai.FOLD_BLOCK=ds;ai.FOLD_FLOW=kg;ai.FOLD_QUOTED=Pn;ai.foldFlowLines=Sg});var si=y(Ku=>{"use strict";var Ce=M(),Nt=Uu(),_n=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),An=e=>/^(%|---|\.\.\.)/m.test(e);function Eg(e,t,r){if(!t||t<0)return!1;let i=t-r,n=e.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(e[a]===`
17
- `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function oi(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(An(e)?" ":""),o="",s=0;for(let l=0,c=r[l];c;c=r[++l])if(c===" "&&r[l+1]==="\\"&&r[l+2]==="n"&&(o+=r.slice(s,l)+"\\ ",l+=1,s=l,c="\\"),c==="\\")switch(r[l+1]){case"u":{o+=r.slice(s,l);let u=r.substr(l+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=r.substr(l,6)}l+=5,s=l+1}break;case"n":if(i||r[l+2]==='"'||r.length<n)l+=1;else{for(o+=r.slice(s,l)+`
13
+ `&&k!==" "&&(f=p)}if(p>=d)if(f)c.push(f),d=f+l,f=void 0;else if(r===da){for(;h===" "||h===" ";)h=b,b=e[p+=1],m=!0;let k=p>g+1?p-2:v-1;if(u[k])return e;c.push(k),u[k]=!0,d=k+l,f=void 0}else m=!0}h=b}if(m&&s&&s(),c.length===0)return e;o&&o();let w=e.slice(0,c[0]);for(let b=0;b<c.length;++b){let k=c[b],x=c[b+1]||e.length;k===0?w=`
14
+ ${t}${e.slice(0,x)}`:(r===da&&u[k]&&(w+=`${e[k]}\\`),w+=`
15
+ ${t}${e.slice(k+1,x)}`)}return w}function nf(e,t,r){let i=t,n=t+1,a=e[n];for(;a===" "||a===" ";)if(t<n+r)a=e[++t];else{do a=e[++t];while(a&&a!==`
16
+ `);i=t,n=t+1,a=e[n]}return i}Ti.FOLD_BLOCK=ec;Ti.FOLD_FLOW=vy;Ti.FOLD_QUOTED=da;Ti.foldFlowLines=gy});var ji=y(of=>{"use strict";var $e=q(),It=af(),pa=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),ha=e=>/^(%|---|\.\.\.)/m.test(e);function wy(e,t,r){if(!t||t<0)return!1;let i=t-r,n=e.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(e[a]===`
17
+ `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function $i(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(ha(e)?" ":""),o="",s=0;for(let l=0,c=r[l];c;c=r[++l])if(c===" "&&r[l+1]==="\\"&&r[l+2]==="n"&&(o+=r.slice(s,l)+"\\ ",l+=1,s=l,c="\\"),c==="\\")switch(r[l+1]){case"u":{o+=r.slice(s,l);let u=r.substr(l+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=r.substr(l,6)}l+=5,s=l+1}break;case"n":if(i||r[l+2]==='"'||r.length<n)l+=1;else{for(o+=r.slice(s,l)+`
18
18
 
19
19
  `;r[l+2]==="\\"&&r[l+3]==="n"&&r[l+4]!=='"';)o+=`
20
- `,l+=2;o+=a,r[l+2]===" "&&(o+="\\"),l+=1,s=l+1}break;default:l+=1}return o=s?o+r.slice(s):r,i?o:Nt.foldFlowLines(o,a,Nt.FOLD_QUOTED,_n(t,!1))}function fs(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
21
- `)||/[ \t]\n|\n[ \t]/.test(e))return oi(e,t);let r=t.indent||(An(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
22
- ${r}`)+"'";return t.implicitKey?i:Nt.foldFlowLines(i,r,Nt.FOLD_FLOW,_n(t,!1))}function pr(e,t){let{singleQuote:r}=t.options,i;if(r===!1)i=oi;else{let n=e.includes('"'),a=e.includes("'");n&&!a?i=fs:a&&!n?i=oi:i=r?fs:oi}return i(e,t)}var ps;try{ps=new RegExp(`(^|(?<!
20
+ `,l+=2;o+=a,r[l+2]===" "&&(o+="\\"),l+=1,s=l+1}break;default:l+=1}return o=s?o+r.slice(s):r,i?o:It.foldFlowLines(o,a,It.FOLD_QUOTED,pa(t,!1))}function tc(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
21
+ `)||/[ \t]\n|\n[ \t]/.test(e))return $i(e,t);let r=t.indent||(ha(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
22
+ ${r}`)+"'";return t.implicitKey?i:It.foldFlowLines(i,r,It.FOLD_FLOW,pa(t,!1))}function $r(e,t){let{singleQuote:r}=t.options,i;if(r===!1)i=$i;else{let n=e.includes('"'),a=e.includes("'");n&&!a?i=tc:a&&!n?i=$i:i=r?tc:$i}return i(e,t)}var rc;try{rc=new RegExp(`(^|(?<!
23
23
  ))
24
24
  +(?!
25
- |$)`,"g")}catch{ps=/\n+(?!\n|$)/g}function Rn({comment:e,type:t,value:r},i,n,a){let{blockQuote:o,commentString:s,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(r))return pr(r,i);let c=i.indent||(i.forceBlockIndent||An(r)?" ":""),u=o==="literal"?!0:o==="folded"||t===Ce.Scalar.BLOCK_FOLDED?!1:t===Ce.Scalar.BLOCK_LITERAL?!0:!Eg(r,l,c.length);if(!r)return u?`|
25
+ |$)`,"g")}catch{rc=/\n+(?!\n|$)/g}function fa({comment:e,type:t,value:r},i,n,a){let{blockQuote:o,commentString:s,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(r))return $r(r,i);let c=i.indent||(i.forceBlockIndent||ha(r)?" ":""),u=o==="literal"?!0:o==="folded"||t===$e.Scalar.BLOCK_FOLDED?!1:t===$e.Scalar.BLOCK_LITERAL?!0:!wy(r,l,c.length);if(!r)return u?`|
26
26
  `:`>
27
- `;let d,f;for(f=r.length;f>0;--f){let E=r[f-1];if(E!==`
28
- `&&E!==" "&&E!==" ")break}let h=r.substring(f),m=h.indexOf(`
27
+ `;let d,f;for(f=r.length;f>0;--f){let x=r[f-1];if(x!==`
28
+ `&&x!==" "&&x!==" ")break}let h=r.substring(f),m=h.indexOf(`
29
29
  `);m===-1?d="-":r===h||m!==h.length-1?(d="+",a&&a()):d="",h&&(r=r.slice(0,-h.length),h[h.length-1]===`
30
- `&&(h=h.slice(0,-1)),h=h.replace(ps,`$&${c}`));let p=!1,v,g=-1;for(v=0;v<r.length;++v){let E=r[v];if(E===" ")p=!0;else if(E===`
31
- `)g=v;else break}let w=r.substring(0,g<v?g+1:v);w&&(r=r.substring(w.length),w=w.replace(/\n+/g,`$&${c}`));let k=(p?c?"2":"1":"")+d;if(e&&(k+=" "+s(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!u){let E=r.replace(/\n+/g,`
32
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),x=!1,$=_n(i,!0);o!=="folded"&&t!==Ce.Scalar.BLOCK_FOLDED&&($.onOverflow=()=>{x=!0});let b=Nt.foldFlowLines(`${w}${E}${h}`,c,Nt.FOLD_BLOCK,$);if(!x)return`>${k}
33
- ${c}${b}`}return r=r.replace(/\n+/g,`$&${c}`),`|${k}
34
- ${c}${w}${r}${h}`}function xg(e,t,r,i){let{type:n,value:a}=e,{actualString:o,implicitKey:s,indent:l,indentStep:c,inFlow:u}=t;if(s&&a.includes(`
35
- `)||u&&/[[\]{},]/.test(a))return pr(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
36
- `)?pr(a,t):Rn(e,t,r,i);if(!s&&!u&&n!==Ce.Scalar.PLAIN&&a.includes(`
37
- `))return Rn(e,t,r,i);if(An(a)){if(l==="")return t.forceBlockIndent=!0,Rn(e,t,r,i);if(s&&l===c)return pr(a,t)}let d=a.replace(/\n+/g,`$&
38
- ${l}`);if(o){let f=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(d),{compat:h,tags:m}=t.doc.schema;if(m.some(f)||h?.some(f))return pr(a,t)}return s?d:Nt.foldFlowLines(d,l,Nt.FOLD_FLOW,_n(t,!1))}function Cg(e,t,r,i){let{implicitKey:n,inFlow:a}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Ce.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Ce.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case Ce.Scalar.BLOCK_FOLDED:case Ce.Scalar.BLOCK_LITERAL:return n||a?pr(o.value,t):Rn(o,t,r,i);case Ce.Scalar.QUOTE_DOUBLE:return oi(o.value,t);case Ce.Scalar.QUOTE_SINGLE:return fs(o.value,t);case Ce.Scalar.PLAIN:return xg(o,t,r,i);default:return null}},c=l(s);if(c===null){let{defaultKeyType:u,defaultStringType:d}=t.options,f=n&&u||d;if(c=l(f),c===null)throw new Error(`Unsupported default string type ${f}`)}return c}Ku.stringifyString=Cg});var ci=y(hs=>{"use strict";var Pg=bn(),bt=R(),Rg=ni(),_g=si();function Ag(e,t){let r=Object.assign({blockQuote:!0,commentString:Rg.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function Ig(e,t){if(t.tag){let n=e.filter(a=>a.tag===t.tag);if(n.length>0)return n.find(a=>a.format===t.format)??n[0]}let r,i;if(bt.isScalar(t)){i=t.value;let n=e.filter(a=>a.identify?.(i));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}r=n.find(a=>a.format===t.format)??n.find(a=>!a.format)}else i=t,r=e.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return r}function Tg(e,t,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(bt.isScalar(e)||bt.isCollection(e))&&e.anchor;a&&Pg.anchorIsValid(a)&&(r.add(a),n.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function jg(e,t,r,i){if(bt.isPair(e))return e.toString(t,r,i);if(bt.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,a=bt.isNode(e)?e:t.doc.createNode(e,{onTagObj:l=>n=l});n??(n=Ig(t.doc.schema.tags,a));let o=Tg(a,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,t,r,i):bt.isScalar(a)?_g.stringifyString(a,t,r,i):a.toString(t,r,i);return o?bt.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
39
- ${t.indent}${s}`:s}hs.createStringifyContext=Ag;hs.stringify=jg});var Zu=y(Qu=>{"use strict";var Qe=R(),Yu=M(),Xu=ci(),li=ni();function $g({key:e,value:t},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:d}}=r,f=Qe.isNode(e)&&e.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(Qe.isCollection(e)||!Qe.isNode(e)&&typeof e=="object"){let $="With simple keys, collection cannot be used as a key value";throw new Error($)}}let h=!d&&(!e||f&&t==null&&!r.inFlow||Qe.isCollection(e)||(Qe.isScalar(e)?e.type===Yu.Scalar.BLOCK_FOLDED||e.type===Yu.Scalar.BLOCK_LITERAL:typeof e=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(d||!a),indent:s+l});let m=!1,p=!1,v=Xu.stringify(e,r,()=>m=!0,()=>p=!0);if(!h&&!r.inFlow&&v.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(a||t==null)return m&&i&&i(),v===""?"?":h?`? ${v}`:v}else if(a&&!d||t==null&&h)return v=`? ${v}`,f&&!m?v+=li.lineComment(v,r.indent,c(f)):p&&n&&n(),v;m&&(f=null),h?(f&&(v+=li.lineComment(v,r.indent,c(f))),v=`? ${v}
40
- ${s}:`):(v=`${v}:`,f&&(v+=li.lineComment(v,r.indent,c(f))));let g,w,N;Qe.isNode(t)?(g=!!t.spaceBefore,w=t.commentBefore,N=t.comment):(g=!1,w=null,N=null,t&&typeof t=="object"&&(t=o.createNode(t))),r.implicitKey=!1,!h&&!f&&Qe.isScalar(t)&&(r.indentAtStart=v.length+1),p=!1,!u&&l.length>=2&&!r.inFlow&&!h&&Qe.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(r.indent=r.indent.substring(2));let k=!1,E=Xu.stringify(t,r,()=>k=!0,()=>p=!0),x=" ";if(f||g||w){if(x=g?`
41
- `:"",w){let $=c(w);x+=`
42
- ${li.indentComment($,r.indent)}`}E===""&&!r.inFlow?x===`
43
- `&&N&&(x=`
30
+ `&&(h=h.slice(0,-1)),h=h.replace(rc,`$&${c}`));let p=!1,v,g=-1;for(v=0;v<r.length;++v){let x=r[v];if(x===" ")p=!0;else if(x===`
31
+ `)g=v;else break}let w=r.substring(0,g<v?g+1:v);w&&(r=r.substring(w.length),w=w.replace(/\n+/g,`$&${c}`));let k=(p?c?"2":"1":"")+d;if(e&&(k+=" "+s(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!u){let x=r.replace(/\n+/g,`
32
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),E=!1,H=pa(i,!0);o!=="folded"&&t!==$e.Scalar.BLOCK_FOLDED&&(H.onOverflow=()=>{E=!0});let N=It.foldFlowLines(`${w}${x}${h}`,c,It.FOLD_BLOCK,H);if(!E)return`>${k}
33
+ ${c}${N}`}return r=r.replace(/\n+/g,`$&${c}`),`|${k}
34
+ ${c}${w}${r}${h}`}function yy(e,t,r,i){let{type:n,value:a}=e,{actualString:o,implicitKey:s,indent:l,indentStep:c,inFlow:u}=t;if(s&&a.includes(`
35
+ `)||u&&/[[\]{},]/.test(a))return $r(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
36
+ `)?$r(a,t):fa(e,t,r,i);if(!s&&!u&&n!==$e.Scalar.PLAIN&&a.includes(`
37
+ `))return fa(e,t,r,i);if(ha(a)){if(l==="")return t.forceBlockIndent=!0,fa(e,t,r,i);if(s&&l===c)return $r(a,t)}let d=a.replace(/\n+/g,`$&
38
+ ${l}`);if(o){let f=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(d),{compat:h,tags:m}=t.doc.schema;if(m.some(f)||h?.some(f))return $r(a,t)}return s?d:It.foldFlowLines(d,l,It.FOLD_FLOW,pa(t,!1))}function by(e,t,r,i){let{implicitKey:n,inFlow:a}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==$e.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=$e.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case $e.Scalar.BLOCK_FOLDED:case $e.Scalar.BLOCK_LITERAL:return n||a?$r(o.value,t):fa(o,t,r,i);case $e.Scalar.QUOTE_DOUBLE:return $i(o.value,t);case $e.Scalar.QUOTE_SINGLE:return tc(o.value,t);case $e.Scalar.PLAIN:return yy(o,t,r,i);default:return null}},c=l(s);if(c===null){let{defaultKeyType:u,defaultStringType:d}=t.options,f=n&&u||d;if(c=l(f),c===null)throw new Error(`Unsupported default string type ${f}`)}return c}of.stringifyString=by});var Oi=y(ic=>{"use strict";var Ny=aa(),Tt=_(),ky=Ii(),Sy=ji();function Ey(e,t){let r=Object.assign({blockQuote:!0,commentString:ky.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function xy(e,t){if(t.tag){let n=e.filter(a=>a.tag===t.tag);if(n.length>0)return n.find(a=>a.format===t.format)??n[0]}let r,i;if(Tt.isScalar(t)){i=t.value;let n=e.filter(a=>a.identify?.(i));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}r=n.find(a=>a.format===t.format)??n.find(a=>!a.format)}else i=t,r=e.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return r}function Cy(e,t,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(Tt.isScalar(e)||Tt.isCollection(e))&&e.anchor;a&&Ny.anchorIsValid(a)&&(r.add(a),n.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function Py(e,t,r,i){if(Tt.isPair(e))return e.toString(t,r,i);if(Tt.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,a=Tt.isNode(e)?e:t.doc.createNode(e,{onTagObj:l=>n=l});n??(n=xy(t.doc.schema.tags,a));let o=Cy(a,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,t,r,i):Tt.isScalar(a)?Sy.stringifyString(a,t,r,i):a.toString(t,r,i);return o?Tt.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
39
+ ${t.indent}${s}`:s}ic.createStringifyContext=Ey;ic.stringify=Py});var uf=y(lf=>{"use strict";var lt=_(),sf=q(),cf=Oi(),Hi=Ii();function Ry({key:e,value:t},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:d}}=r,f=lt.isNode(e)&&e.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(lt.isCollection(e)||!lt.isNode(e)&&typeof e=="object"){let H="With simple keys, collection cannot be used as a key value";throw new Error(H)}}let h=!d&&(!e||f&&t==null&&!r.inFlow||lt.isCollection(e)||(lt.isScalar(e)?e.type===sf.Scalar.BLOCK_FOLDED||e.type===sf.Scalar.BLOCK_LITERAL:typeof e=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(d||!a),indent:s+l});let m=!1,p=!1,v=cf.stringify(e,r,()=>m=!0,()=>p=!0);if(!h&&!r.inFlow&&v.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(a||t==null)return m&&i&&i(),v===""?"?":h?`? ${v}`:v}else if(a&&!d||t==null&&h)return v=`? ${v}`,f&&!m?v+=Hi.lineComment(v,r.indent,c(f)):p&&n&&n(),v;m&&(f=null),h?(f&&(v+=Hi.lineComment(v,r.indent,c(f))),v=`? ${v}
40
+ ${s}:`):(v=`${v}:`,f&&(v+=Hi.lineComment(v,r.indent,c(f))));let g,w,b;lt.isNode(t)?(g=!!t.spaceBefore,w=t.commentBefore,b=t.comment):(g=!1,w=null,b=null,t&&typeof t=="object"&&(t=o.createNode(t))),r.implicitKey=!1,!h&&!f&&lt.isScalar(t)&&(r.indentAtStart=v.length+1),p=!1,!u&&l.length>=2&&!r.inFlow&&!h&&lt.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(r.indent=r.indent.substring(2));let k=!1,x=cf.stringify(t,r,()=>k=!0,()=>p=!0),E=" ";if(f||g||w){if(E=g?`
41
+ `:"",w){let H=c(w);E+=`
42
+ ${Hi.indentComment(H,r.indent)}`}x===""&&!r.inFlow?E===`
43
+ `&&b&&(E=`
44
44
 
45
- `):x+=`
46
- ${r.indent}`}else if(!h&&Qe.isCollection(t)){let $=E[0],b=E.indexOf(`
47
- `),q=b!==-1,ht=r.inFlow??t.flow??t.items.length===0;if(q||!ht){let sr=!1;if(q&&($==="&"||$==="!")){let W=E.indexOf(" ");$==="&"&&W!==-1&&W<b&&E[W+1]==="!"&&(W=E.indexOf(" ",W+1)),(W===-1||b<W)&&(sr=!0)}sr||(x=`
48
- ${r.indent}`)}}else(E===""||E[0]===`
49
- `)&&(x="");return v+=x+E,r.inFlow?k&&i&&i():N&&!k?v+=li.lineComment(v,r.indent,c(N)):p&&n&&n(),v}Qu.stringifyPair=$g});var vs=y(ms=>{"use strict";var ed=sn("process");function Og(e,...t){e==="debug"&&console.log(...t)}function Hg(e,t){(e==="debug"||e==="warn")&&(typeof ed.emitWarning=="function"?ed.emitWarning(t):console.warn(t))}ms.debug=Og;ms.warn=Hg});var On=y($n=>{"use strict";var jn=R(),td=M(),In="<<",Tn={identify:e=>e===In||typeof e=="symbol"&&e.description===In,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new td.Scalar(Symbol(In)),{addToJSMap:rd}),stringify:()=>In},Dg=(e,t)=>(Tn.identify(t)||jn.isScalar(t)&&(!t.type||t.type===td.Scalar.PLAIN)&&Tn.identify(t.value))&&e?.doc.schema.tags.some(r=>r.tag===Tn.tag&&r.default);function rd(e,t,r){let i=id(e,r);if(jn.isSeq(i))for(let n of i.items)gs(e,t,n);else if(Array.isArray(i))for(let n of i)gs(e,t,n);else gs(e,t,i)}function gs(e,t,r){let i=id(e,r);if(!jn.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[a,o]of n)t instanceof Map?t.has(a)||t.set(a,o):t instanceof Set?t.add(a):Object.prototype.hasOwnProperty.call(t,a)||Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function id(e,t){return e&&jn.isAlias(t)?t.resolve(e.doc,e):t}$n.addMergeToJSMap=rd;$n.isMergeKey=Dg;$n.merge=Tn});var ys=y(od=>{"use strict";var Lg=vs(),nd=On(),Bg=ci(),ad=R(),ws=wt();function Mg(e,t,{key:r,value:i}){if(ad.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,i);else if(nd.isMergeKey(e,r))nd.addMergeToJSMap(e,t,i);else{let n=ws.toJS(r,"",e);if(t instanceof Map)t.set(n,ws.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let a=Fg(r,n,e),o=ws.toJS(i,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Fg(e,t,r){if(t===null)return"";if(typeof t!="object")return String(t);if(ad.isNode(e)&&r?.doc){let i=Bg.createStringifyContext(r.doc,{});i.anchors=new Set;for(let a of r.anchors.keys())i.anchors.add(a.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=e.toString(i);if(!r.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Lg.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(t)}od.addPairToJSMap=Mg});var kt=y(Ns=>{"use strict";var sd=ii(),Vg=Zu(),qg=ys(),Hn=R();function Wg(e,t,r){let i=sd.createNode(e,void 0,r),n=sd.createNode(t,void 0,r);return new Dn(i,n)}var Dn=class e{constructor(t,r=null){Object.defineProperty(this,Hn.NODE_TYPE,{value:Hn.PAIR}),this.key=t,this.value=r}clone(t){let{key:r,value:i}=this;return Hn.isNode(r)&&(r=r.clone(t)),Hn.isNode(i)&&(i=i.clone(t)),new e(r,i)}toJSON(t,r){let i=r?.mapAsMap?new Map:{};return qg.addPairToJSMap(r,i,this)}toString(t,r,i){return t?.doc?Vg.stringifyPair(this,t,r,i):JSON.stringify(this)}};Ns.Pair=Dn;Ns.createPair=Wg});var bs=y(ld=>{"use strict";var Dt=R(),cd=ci(),Ln=ni();function zg(e,t,r){return(t.inFlow??e.flow?Jg:Gg)(e,t,r)}function Gg({comment:e,items:t},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:l,options:{commentString:c}}=r,u=Object.assign({},r,{indent:a,type:null}),d=!1,f=[];for(let m=0;m<t.length;++m){let p=t[m],v=null;if(Dt.isNode(p))!d&&p.spaceBefore&&f.push(""),Bn(r,f,p.commentBefore,d),p.comment&&(v=p.comment);else if(Dt.isPair(p)){let w=Dt.isNode(p.key)?p.key:null;w&&(!d&&w.spaceBefore&&f.push(""),Bn(r,f,w.commentBefore,d))}d=!1;let g=cd.stringify(p,u,()=>v=null,()=>d=!0);v&&(g+=Ln.lineComment(g,a,c(v))),d&&v&&(d=!1),f.push(i+g)}let h;if(f.length===0)h=n.start+n.end;else{h=f[0];for(let m=1;m<f.length;++m){let p=f[m];h+=p?`
45
+ `):E+=`
46
+ ${r.indent}`}else if(!h&&lt.isCollection(t)){let H=x[0],N=x.indexOf(`
47
+ `),z=N!==-1,xt=r.inFlow??t.flow??t.items.length===0;if(z||!xt){let Er=!1;if(z&&(H==="&"||H==="!")){let G=x.indexOf(" ");H==="&"&&G!==-1&&G<N&&x[G+1]==="!"&&(G=x.indexOf(" ",G+1)),(G===-1||N<G)&&(Er=!0)}Er||(E=`
48
+ ${r.indent}`)}}else(x===""||x[0]===`
49
+ `)&&(E="");return v+=E+x,r.inFlow?k&&i&&i():b&&!k?v+=Hi.lineComment(v,r.indent,c(b)):p&&n&&n(),v}lf.stringifyPair=Ry});var ac=y(nc=>{"use strict";var df=Fn("process");function _y(e,...t){e==="debug"&&console.log(...t)}function Ay(e,t){(e==="debug"||e==="warn")&&(typeof df.emitWarning=="function"?df.emitWarning(t):console.warn(t))}nc.debug=_y;nc.warn=Ay});var ya=y(wa=>{"use strict";var ga=_(),ff=q(),ma="<<",va={identify:e=>e===ma||typeof e=="symbol"&&e.description===ma,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ff.Scalar(Symbol(ma)),{addToJSMap:pf}),stringify:()=>ma},Iy=(e,t)=>(va.identify(t)||ga.isScalar(t)&&(!t.type||t.type===ff.Scalar.PLAIN)&&va.identify(t.value))&&e?.doc.schema.tags.some(r=>r.tag===va.tag&&r.default);function pf(e,t,r){let i=hf(e,r);if(ga.isSeq(i))for(let n of i.items)oc(e,t,n);else if(Array.isArray(i))for(let n of i)oc(e,t,n);else oc(e,t,i)}function oc(e,t,r){let i=hf(e,r);if(!ga.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[a,o]of n)t instanceof Map?t.has(a)||t.set(a,o):t instanceof Set?t.add(a):Object.prototype.hasOwnProperty.call(t,a)||Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function hf(e,t){return e&&ga.isAlias(t)?t.resolve(e.doc,e):t}wa.addMergeToJSMap=pf;wa.isMergeKey=Iy;wa.merge=va});var cc=y(gf=>{"use strict";var Ty=ac(),mf=ya(),$y=Oi(),vf=_(),sc=_t();function jy(e,t,{key:r,value:i}){if(vf.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,i);else if(mf.isMergeKey(e,r))mf.addMergeToJSMap(e,t,i);else{let n=sc.toJS(r,"",e);if(t instanceof Map)t.set(n,sc.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let a=Oy(r,n,e),o=sc.toJS(i,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Oy(e,t,r){if(t===null)return"";if(typeof t!="object")return String(t);if(vf.isNode(e)&&r?.doc){let i=$y.createStringifyContext(r.doc,{});i.anchors=new Set;for(let a of r.anchors.keys())i.anchors.add(a.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=e.toString(i);if(!r.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Ty.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(t)}gf.addPairToJSMap=jy});var $t=y(lc=>{"use strict";var wf=Ai(),Hy=uf(),Dy=cc(),ba=_();function Ly(e,t,r){let i=wf.createNode(e,void 0,r),n=wf.createNode(t,void 0,r);return new Na(i,n)}var Na=class e{constructor(t,r=null){Object.defineProperty(this,ba.NODE_TYPE,{value:ba.PAIR}),this.key=t,this.value=r}clone(t){let{key:r,value:i}=this;return ba.isNode(r)&&(r=r.clone(t)),ba.isNode(i)&&(i=i.clone(t)),new e(r,i)}toJSON(t,r){let i=r?.mapAsMap?new Map:{};return Dy.addPairToJSMap(r,i,this)}toString(t,r,i){return t?.doc?Hy.stringifyPair(this,t,r,i):JSON.stringify(this)}};lc.Pair=Na;lc.createPair=Ly});var uc=y(bf=>{"use strict";var Kt=_(),yf=Oi(),ka=Ii();function By(e,t,r){return(t.inFlow??e.flow?Fy:My)(e,t,r)}function My({comment:e,items:t},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:l,options:{commentString:c}}=r,u=Object.assign({},r,{indent:a,type:null}),d=!1,f=[];for(let m=0;m<t.length;++m){let p=t[m],v=null;if(Kt.isNode(p))!d&&p.spaceBefore&&f.push(""),Sa(r,f,p.commentBefore,d),p.comment&&(v=p.comment);else if(Kt.isPair(p)){let w=Kt.isNode(p.key)?p.key:null;w&&(!d&&w.spaceBefore&&f.push(""),Sa(r,f,w.commentBefore,d))}d=!1;let g=yf.stringify(p,u,()=>v=null,()=>d=!0);v&&(g+=ka.lineComment(g,a,c(v))),d&&v&&(d=!1),f.push(i+g)}let h;if(f.length===0)h=n.start+n.end;else{h=f[0];for(let m=1;m<f.length;++m){let p=f[m];h+=p?`
50
50
  ${l}${p}`:`
51
51
  `}}return e?(h+=`
52
- `+Ln.indentComment(c(e),l),s&&s()):d&&o&&o(),h}function Jg({items:e},t,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;i+=a;let l=Object.assign({},t,{indent:i,inFlow:!0,type:null}),c=!1,u=0,d=[];for(let m=0;m<e.length;++m){let p=e[m],v=null;if(Dt.isNode(p))p.spaceBefore&&d.push(""),Bn(t,d,p.commentBefore,!1),p.comment&&(v=p.comment);else if(Dt.isPair(p)){let w=Dt.isNode(p.key)?p.key:null;w&&(w.spaceBefore&&d.push(""),Bn(t,d,w.commentBefore,!1),w.comment&&(c=!0));let N=Dt.isNode(p.value)?p.value:null;N?(N.comment&&(v=N.comment),N.commentBefore&&(c=!0)):p.value==null&&w?.comment&&(v=w.comment)}v&&(c=!0);let g=cd.stringify(p,l,()=>v=null);c||(c=d.length>u||g.includes(`
53
- `)),m<e.length-1?g+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=d.reduce((w,N)=>w+N.length+2,2)+(g.length+2)>t.options.lineWidth)),c&&(g+=",")),v&&(g+=Ln.lineComment(g,i,s(v))),d.push(g),u=d.length}let{start:f,end:h}=r;if(d.length===0)return f+h;if(!c){let m=d.reduce((p,v)=>p+v.length+2,2);c=t.options.lineWidth>0&&m>t.options.lineWidth}if(c){let m=f;for(let p of d)m+=p?`
52
+ `+ka.indentComment(c(e),l),s&&s()):d&&o&&o(),h}function Fy({items:e},t,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;i+=a;let l=Object.assign({},t,{indent:i,inFlow:!0,type:null}),c=!1,u=0,d=[];for(let m=0;m<e.length;++m){let p=e[m],v=null;if(Kt.isNode(p))p.spaceBefore&&d.push(""),Sa(t,d,p.commentBefore,!1),p.comment&&(v=p.comment);else if(Kt.isPair(p)){let w=Kt.isNode(p.key)?p.key:null;w&&(w.spaceBefore&&d.push(""),Sa(t,d,w.commentBefore,!1),w.comment&&(c=!0));let b=Kt.isNode(p.value)?p.value:null;b?(b.comment&&(v=b.comment),b.commentBefore&&(c=!0)):p.value==null&&w?.comment&&(v=w.comment)}v&&(c=!0);let g=yf.stringify(p,l,()=>v=null);c||(c=d.length>u||g.includes(`
53
+ `)),m<e.length-1?g+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=d.reduce((w,b)=>w+b.length+2,2)+(g.length+2)>t.options.lineWidth)),c&&(g+=",")),v&&(g+=ka.lineComment(g,i,s(v))),d.push(g),u=d.length}let{start:f,end:h}=r;if(d.length===0)return f+h;if(!c){let m=d.reduce((p,v)=>p+v.length+2,2);c=t.options.lineWidth>0&&m>t.options.lineWidth}if(c){let m=f;for(let p of d)m+=p?`
54
54
  ${a}${n}${p}`:`
55
55
  `;return`${m}
56
- ${n}${h}`}else return`${f}${o}${d.join(" ")}${o}${h}`}function Bn({indent:e,options:{commentString:t}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=Ln.indentComment(t(i),e);r.push(a.trimStart())}}ld.stringifyCollection=zg});var Et=y(Ss=>{"use strict";var Ug=bs(),Kg=ys(),Yg=xn(),St=R(),Mn=kt(),Xg=M();function ui(e,t){let r=St.isScalar(t)?t.value:t;for(let i of e)if(St.isPair(i)&&(i.key===t||i.key===r||St.isScalar(i.key)&&i.key.value===r))return i}var ks=class extends Yg.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(St.MAP,t),this.items=[]}static from(t,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(t),s=(l,c)=>{if(typeof a=="function")c=a.call(r,l,c);else if(Array.isArray(a)&&!a.includes(l))return;(c!==void 0||n)&&o.items.push(Mn.createPair(l,c,i))};if(r instanceof Map)for(let[l,c]of r)s(l,c);else if(r&&typeof r=="object")for(let l of Object.keys(r))s(l,r[l]);return typeof t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,r){let i;St.isPair(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new Mn.Pair(t,t?.value):i=new Mn.Pair(t.key,t.value);let n=ui(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);St.isScalar(n.value)&&Xg.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(a){let o=this.items.findIndex(s=>a(i,s)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){let r=ui(this.items,t);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(t,r){let n=ui(this.items,t)?.value;return(!r&&St.isScalar(n)?n.value:n)??void 0}has(t){return!!ui(this.items,t)}set(t,r){this.add(new Mn.Pair(t,r),!0)}toJSON(t,r,i){let n=i?new i:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(n);for(let a of this.items)Kg.addPairToJSMap(r,n,a);return n}toString(t,r,i){if(!t)return JSON.stringify(this);for(let n of this.items)if(!St.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Ug.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:r})}};Ss.YAMLMap=ks;Ss.findPair=ui});var hr=y(dd=>{"use strict";var Qg=R(),ud=Et(),Zg={collection:"map",default:!0,nodeClass:ud.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return Qg.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,r)=>ud.YAMLMap.from(e,t,r)};dd.map=Zg});var xt=y(fd=>{"use strict";var ew=ii(),tw=bs(),rw=xn(),Vn=R(),iw=M(),nw=wt(),Es=class extends rw.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Vn.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let r=Fn(t);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(t,r){let i=Fn(t);if(typeof i!="number")return;let n=this.items[i];return!r&&Vn.isScalar(n)?n.value:n}has(t){let r=Fn(t);return typeof r=="number"&&r<this.items.length}set(t,r){let i=Fn(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];Vn.isScalar(n)&&iw.isScalarValue(r)?n.value=r:this.items[i]=r}toJSON(t,r){let i=[];r?.onCreate&&r.onCreate(i);let n=0;for(let a of this.items)i.push(nw.toJS(a,String(n++),r));return i}toString(t,r,i){return t?tw.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:i,onComment:r}):JSON.stringify(this)}static from(t,r,i){let{replacer:n}=i,a=new this(t);if(r&&Symbol.iterator in Object(r)){let o=0;for(let s of r){if(typeof n=="function"){let l=r instanceof Set?s:String(o++);s=n.call(r,l,s)}a.items.push(ew.createNode(s,void 0,i))}}return a}};function Fn(e){let t=Vn.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}fd.YAMLSeq=Es});var mr=y(hd=>{"use strict";var aw=R(),pd=xt(),ow={collection:"seq",default:!0,nodeClass:pd.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return aw.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,r)=>pd.YAMLSeq.from(e,t,r)};hd.seq=ow});var di=y(md=>{"use strict";var sw=si(),cw={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,r,i){return t=Object.assign({actualString:!0},t),sw.stringifyString(e,t,r,i)}};md.string=cw});var qn=y(wd=>{"use strict";var vd=M(),gd={identify:e=>e==null,createNode:()=>new vd.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new vd.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&gd.test.test(e)?e:t.options.nullStr};wd.nullTag=gd});var xs=y(Nd=>{"use strict";var lw=M(),yd={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new lw.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&yd.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?r.options.trueStr:r.options.falseStr}};Nd.boolTag=yd});var vr=y(bd=>{"use strict";function uw({format:e,minFractionDigits:t,tag:r,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=t-(a.length-o-1);for(;s-- >0;)a+="0"}return a}bd.stringifyNumber=uw});var Ps=y(Wn=>{"use strict";var dw=M(),Cs=vr(),fw={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Cs.stringifyNumber},pw={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Cs.stringifyNumber(e)}},hw={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new dw.Scalar(parseFloat(e)),r=e.indexOf(".");return r!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-r-1),t},stringify:Cs.stringifyNumber};Wn.float=hw;Wn.floatExp=pw;Wn.floatNaN=fw});var _s=y(Gn=>{"use strict";var kd=vr(),zn=e=>typeof e=="bigint"||Number.isInteger(e),Rs=(e,t,r,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),r);function Sd(e,t,r){let{value:i}=e;return zn(i)&&i>=0?r+i.toString(t):kd.stringifyNumber(e)}var mw={identify:e=>zn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>Rs(e,2,8,r),stringify:e=>Sd(e,8,"0o")},vw={identify:zn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>Rs(e,0,10,r),stringify:kd.stringifyNumber},gw={identify:e=>zn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>Rs(e,2,16,r),stringify:e=>Sd(e,16,"0x")};Gn.int=vw;Gn.intHex=gw;Gn.intOct=mw});var xd=y(Ed=>{"use strict";var ww=hr(),yw=qn(),Nw=mr(),bw=di(),kw=xs(),As=Ps(),Is=_s(),Sw=[ww.map,Nw.seq,bw.string,yw.nullTag,kw.boolTag,Is.intOct,Is.int,Is.intHex,As.floatNaN,As.floatExp,As.float];Ed.schema=Sw});var Rd=y(Pd=>{"use strict";var Ew=M(),xw=hr(),Cw=mr();function Cd(e){return typeof e=="bigint"||Number.isInteger(e)}var Jn=({value:e})=>JSON.stringify(e),Pw=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Jn},{identify:e=>e==null,createNode:()=>new Ew.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Jn},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Jn},{identify:Cd,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>Cd(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Jn}],Rw={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},_w=[xw.map,Cw.seq].concat(Pw,Rw);Pd.schema=_w});var js=y(_d=>{"use strict";var fi=sn("buffer"),Ts=M(),Aw=si(),Iw={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof fi.Buffer=="function")return fi.Buffer.from(e,"base64");if(typeof atob=="function"){let r=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof fi.Buffer=="function")s=o instanceof fi.Buffer?o.toString("base64"):fi.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);s=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Ts.Scalar.BLOCK_LITERAL),t!==Ts.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(s.length/l),u=new Array(c);for(let d=0,f=0;d<c;++d,f+=l)u[d]=s.substr(f,l);s=u.join(t===Ts.Scalar.BLOCK_LITERAL?`
57
- `:" ")}return Aw.stringifyString({comment:e,type:t,value:s},i,n,a)}};_d.binary=Iw});var Yn=y(Kn=>{"use strict";var Un=R(),$s=kt(),Tw=M(),jw=xt();function Ad(e,t){if(Un.isSeq(e))for(let r=0;r<e.items.length;++r){let i=e.items[r];if(!Un.isPair(i)){if(Un.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new $s.Pair(new Tw.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
56
+ ${n}${h}`}else return`${f}${o}${d.join(" ")}${o}${h}`}function Sa({indent:e,options:{commentString:t}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=ka.indentComment(t(i),e);r.push(a.trimStart())}}bf.stringifyCollection=By});var Ot=y(fc=>{"use strict";var qy=uc(),Vy=cc(),Wy=la(),jt=_(),Ea=$t(),zy=q();function Di(e,t){let r=jt.isScalar(t)?t.value:t;for(let i of e)if(jt.isPair(i)&&(i.key===t||i.key===r||jt.isScalar(i.key)&&i.key.value===r))return i}var dc=class extends Wy.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(jt.MAP,t),this.items=[]}static from(t,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(t),s=(l,c)=>{if(typeof a=="function")c=a.call(r,l,c);else if(Array.isArray(a)&&!a.includes(l))return;(c!==void 0||n)&&o.items.push(Ea.createPair(l,c,i))};if(r instanceof Map)for(let[l,c]of r)s(l,c);else if(r&&typeof r=="object")for(let l of Object.keys(r))s(l,r[l]);return typeof t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,r){let i;jt.isPair(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new Ea.Pair(t,t?.value):i=new Ea.Pair(t.key,t.value);let n=Di(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);jt.isScalar(n.value)&&zy.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(a){let o=this.items.findIndex(s=>a(i,s)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){let r=Di(this.items,t);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(t,r){let n=Di(this.items,t)?.value;return(!r&&jt.isScalar(n)?n.value:n)??void 0}has(t){return!!Di(this.items,t)}set(t,r){this.add(new Ea.Pair(t,r),!0)}toJSON(t,r,i){let n=i?new i:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(n);for(let a of this.items)Vy.addPairToJSMap(r,n,a);return n}toString(t,r,i){if(!t)return JSON.stringify(this);for(let n of this.items)if(!jt.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),qy.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:r})}};fc.YAMLMap=dc;fc.findPair=Di});var jr=y(kf=>{"use strict";var Gy=_(),Nf=Ot(),Jy={collection:"map",default:!0,nodeClass:Nf.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return Gy.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,r)=>Nf.YAMLMap.from(e,t,r)};kf.map=Jy});var Ht=y(Sf=>{"use strict";var Uy=Ai(),Ky=uc(),Yy=la(),Ca=_(),Xy=q(),Qy=_t(),pc=class extends Yy.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Ca.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let r=xa(t);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(t,r){let i=xa(t);if(typeof i!="number")return;let n=this.items[i];return!r&&Ca.isScalar(n)?n.value:n}has(t){let r=xa(t);return typeof r=="number"&&r<this.items.length}set(t,r){let i=xa(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];Ca.isScalar(n)&&Xy.isScalarValue(r)?n.value=r:this.items[i]=r}toJSON(t,r){let i=[];r?.onCreate&&r.onCreate(i);let n=0;for(let a of this.items)i.push(Qy.toJS(a,String(n++),r));return i}toString(t,r,i){return t?Ky.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:i,onComment:r}):JSON.stringify(this)}static from(t,r,i){let{replacer:n}=i,a=new this(t);if(r&&Symbol.iterator in Object(r)){let o=0;for(let s of r){if(typeof n=="function"){let l=r instanceof Set?s:String(o++);s=n.call(r,l,s)}a.items.push(Uy.createNode(s,void 0,i))}}return a}};function xa(e){let t=Ca.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}Sf.YAMLSeq=pc});var Or=y(xf=>{"use strict";var Zy=_(),Ef=Ht(),eb={collection:"seq",default:!0,nodeClass:Ef.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return Zy.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,r)=>Ef.YAMLSeq.from(e,t,r)};xf.seq=eb});var Li=y(Cf=>{"use strict";var tb=ji(),rb={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,r,i){return t=Object.assign({actualString:!0},t),tb.stringifyString(e,t,r,i)}};Cf.string=rb});var Pa=y(_f=>{"use strict";var Pf=q(),Rf={identify:e=>e==null,createNode:()=>new Pf.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Pf.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&Rf.test.test(e)?e:t.options.nullStr};_f.nullTag=Rf});var hc=y(If=>{"use strict";var ib=q(),Af={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new ib.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&Af.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?r.options.trueStr:r.options.falseStr}};If.boolTag=Af});var Hr=y(Tf=>{"use strict";function nb({format:e,minFractionDigits:t,tag:r,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=t-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Tf.stringifyNumber=nb});var vc=y(Ra=>{"use strict";var ab=q(),mc=Hr(),ob={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:mc.stringifyNumber},sb={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():mc.stringifyNumber(e)}},cb={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new ab.Scalar(parseFloat(e)),r=e.indexOf(".");return r!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-r-1),t},stringify:mc.stringifyNumber};Ra.float=cb;Ra.floatExp=sb;Ra.floatNaN=ob});var wc=y(Aa=>{"use strict";var $f=Hr(),_a=e=>typeof e=="bigint"||Number.isInteger(e),gc=(e,t,r,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),r);function jf(e,t,r){let{value:i}=e;return _a(i)&&i>=0?r+i.toString(t):$f.stringifyNumber(e)}var lb={identify:e=>_a(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>gc(e,2,8,r),stringify:e=>jf(e,8,"0o")},ub={identify:_a,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>gc(e,0,10,r),stringify:$f.stringifyNumber},db={identify:e=>_a(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>gc(e,2,16,r),stringify:e=>jf(e,16,"0x")};Aa.int=ub;Aa.intHex=db;Aa.intOct=lb});var Hf=y(Of=>{"use strict";var fb=jr(),pb=Pa(),hb=Or(),mb=Li(),vb=hc(),yc=vc(),bc=wc(),gb=[fb.map,hb.seq,mb.string,pb.nullTag,vb.boolTag,bc.intOct,bc.int,bc.intHex,yc.floatNaN,yc.floatExp,yc.float];Of.schema=gb});var Bf=y(Lf=>{"use strict";var wb=q(),yb=jr(),bb=Or();function Df(e){return typeof e=="bigint"||Number.isInteger(e)}var Ia=({value:e})=>JSON.stringify(e),Nb=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Ia},{identify:e=>e==null,createNode:()=>new wb.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ia},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Ia},{identify:Df,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>Df(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Ia}],kb={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Sb=[yb.map,bb.seq].concat(Nb,kb);Lf.schema=Sb});var kc=y(Mf=>{"use strict";var Bi=Fn("buffer"),Nc=q(),Eb=ji(),xb={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Bi.Buffer=="function")return Bi.Buffer.from(e,"base64");if(typeof atob=="function"){let r=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof Bi.Buffer=="function")s=o instanceof Bi.Buffer?o.toString("base64"):Bi.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);s=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Nc.Scalar.BLOCK_LITERAL),t!==Nc.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(s.length/l),u=new Array(c);for(let d=0,f=0;d<c;++d,f+=l)u[d]=s.substr(f,l);s=u.join(t===Nc.Scalar.BLOCK_LITERAL?`
57
+ `:" ")}return Eb.stringifyString({comment:e,type:t,value:s},i,n,a)}};Mf.binary=xb});var ja=y($a=>{"use strict";var Ta=_(),Sc=$t(),Cb=q(),Pb=Ht();function Ff(e,t){if(Ta.isSeq(e))for(let r=0;r<e.items.length;++r){let i=e.items[r];if(!Ta.isPair(i)){if(Ta.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new Sc.Pair(new Cb.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
58
58
  ${n.key.commentBefore}`:i.commentBefore),i.comment){let a=n.value??n.key;a.comment=a.comment?`${i.comment}
59
- ${a.comment}`:i.comment}i=n}e.items[r]=Un.isPair(i)?i:new $s.Pair(i)}}else t("Expected a sequence for this tag");return e}function Id(e,t,r){let{replacer:i}=r,n=new jw.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let a=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(a++),o));let s,l;if(Array.isArray(o))if(o.length===2)s=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)s=c[0],l=o[s];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else s=o;n.items.push($s.createPair(s,l,r))}return n}var $w={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ad,createNode:Id};Kn.createPairs=Id;Kn.pairs=$w;Kn.resolvePairs=Ad});var Ds=y(Hs=>{"use strict";var Td=R(),Os=wt(),pi=Et(),Ow=xt(),jd=Yn(),Lt=class e extends Ow.YAMLSeq{constructor(){super(),this.add=pi.YAMLMap.prototype.add.bind(this),this.delete=pi.YAMLMap.prototype.delete.bind(this),this.get=pi.YAMLMap.prototype.get.bind(this),this.has=pi.YAMLMap.prototype.has.bind(this),this.set=pi.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,r){if(!r)return super.toJSON(t);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if(Td.isPair(n)?(a=Os.toJS(n.key,"",r),o=Os.toJS(n.value,a,r)):a=Os.toJS(n,"",r),i.has(a))throw new Error("Ordered maps must not include duplicate keys");i.set(a,o)}return i}static from(t,r,i){let n=jd.createPairs(t,r,i),a=new this;return a.items=n.items,a}};Lt.tag="tag:yaml.org,2002:omap";var Hw={collection:"seq",identify:e=>e instanceof Map,nodeClass:Lt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=jd.resolvePairs(e,t),i=[];for(let{key:n}of r.items)Td.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Lt,r)},createNode:(e,t,r)=>Lt.from(e,t,r)};Hs.YAMLOMap=Lt;Hs.omap=Hw});var Ld=y(Ls=>{"use strict";var $d=M();function Od({value:e,source:t},r){return t&&(e?Hd:Dd).test.test(t)?t:e?r.options.trueStr:r.options.falseStr}var Hd={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new $d.Scalar(!0),stringify:Od},Dd={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new $d.Scalar(!1),stringify:Od};Ls.falseTag=Dd;Ls.trueTag=Hd});var Bd=y(Xn=>{"use strict";var Dw=M(),Bs=vr(),Lw={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Bs.stringifyNumber},Bw={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Bs.stringifyNumber(e)}},Mw={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Dw.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let i=e.substring(r+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Bs.stringifyNumber};Xn.float=Mw;Xn.floatExp=Bw;Xn.floatNaN=Lw});var Fd=y(mi=>{"use strict";var Md=vr(),hi=e=>typeof e=="bigint"||Number.isInteger(e);function Qn(e,t,r,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let a=parseInt(e,r);return n==="-"?-1*a:a}function Ms(e,t,r){let{value:i}=e;if(hi(i)){let n=i.toString(t);return i<0?"-"+r+n.substr(1):r+n}return Md.stringifyNumber(e)}var Fw={identify:hi,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>Qn(e,2,2,r),stringify:e=>Ms(e,2,"0b")},Vw={identify:hi,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>Qn(e,1,8,r),stringify:e=>Ms(e,8,"0")},qw={identify:hi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>Qn(e,0,10,r),stringify:Md.stringifyNumber},Ww={identify:hi,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>Qn(e,2,16,r),stringify:e=>Ms(e,16,"0x")};mi.int=qw;mi.intBin=Fw;mi.intHex=Ww;mi.intOct=Vw});var Vs=y(Fs=>{"use strict";var ta=R(),Zn=kt(),ea=Et(),Bt=class e extends ea.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let r;ta.isPair(t)?r=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?r=new Zn.Pair(t.key,null):r=new Zn.Pair(t,null),ea.findPair(this.items,r.key)||this.items.push(r)}get(t,r){let i=ea.findPair(this.items,t);return!r&&ta.isPair(i)?ta.isScalar(i.key)?i.key.value:i.key:i}set(t,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let i=ea.findPair(this.items,t);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Zn.Pair(t))}toJSON(t,r){return super.toJSON(t,r,Set)}toString(t,r,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),r,i);throw new Error("Set items must all have null values")}static from(t,r,i){let{replacer:n}=i,a=new this(t);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),a.items.push(Zn.createPair(o,null,i));return a}};Bt.tag="tag:yaml.org,2002:set";var zw={collection:"map",identify:e=>e instanceof Set,nodeClass:Bt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Bt.from(e,t,r),resolve(e,t){if(ta.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Bt,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Fs.YAMLSet=Bt;Fs.set=zw});var Ws=y(ra=>{"use strict";var Gw=vr();function qs(e,t){let r=e[0],i=r==="-"||r==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),a=i.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return r==="-"?n(-1)*a:a}function Vd(e){let{value:t}=e,r=o=>o;if(typeof t=="bigint")r=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Gw.stringifyNumber(e);let i="";t<0&&(i="-",t*=r(-1));let n=r(60),a=[t%n];return t<60?a.unshift(0):(t=(t-a[0])/n,a.unshift(t%n),t>=60&&(t=(t-a[0])/n,a.unshift(t))),i+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Jw={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>qs(e,r),stringify:Vd},Uw={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>qs(e,!1),stringify:Vd},qd={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(qd.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(r,i-1,n,a||0,o||0,s||0,l),u=t[8];if(u&&u!=="Z"){let d=qs(u,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ra.floatTime=Uw;ra.intTime=Jw;ra.timestamp=qd});var Gd=y(zd=>{"use strict";var Kw=hr(),Yw=qn(),Xw=mr(),Qw=di(),Zw=js(),Wd=Ld(),zs=Bd(),ia=Fd(),ey=On(),ty=Ds(),ry=Yn(),iy=Vs(),Gs=Ws(),ny=[Kw.map,Xw.seq,Qw.string,Yw.nullTag,Wd.trueTag,Wd.falseTag,ia.intBin,ia.intOct,ia.int,ia.intHex,zs.floatNaN,zs.floatExp,zs.float,Zw.binary,ey.merge,ty.omap,ry.pairs,iy.set,Gs.intTime,Gs.floatTime,Gs.timestamp];zd.schema=ny});var rf=y(Ks=>{"use strict";var Yd=hr(),ay=qn(),Xd=mr(),oy=di(),sy=xs(),Js=Ps(),Us=_s(),cy=xd(),ly=Rd(),Qd=js(),vi=On(),Zd=Ds(),ef=Yn(),Jd=Gd(),tf=Vs(),na=Ws(),Ud=new Map([["core",cy.schema],["failsafe",[Yd.map,Xd.seq,oy.string]],["json",ly.schema],["yaml11",Jd.schema],["yaml-1.1",Jd.schema]]),Kd={binary:Qd.binary,bool:sy.boolTag,float:Js.float,floatExp:Js.floatExp,floatNaN:Js.floatNaN,floatTime:na.floatTime,int:Us.int,intHex:Us.intHex,intOct:Us.intOct,intTime:na.intTime,map:Yd.map,merge:vi.merge,null:ay.nullTag,omap:Zd.omap,pairs:ef.pairs,seq:Xd.seq,set:tf.set,timestamp:na.timestamp},uy={"tag:yaml.org,2002:binary":Qd.binary,"tag:yaml.org,2002:merge":vi.merge,"tag:yaml.org,2002:omap":Zd.omap,"tag:yaml.org,2002:pairs":ef.pairs,"tag:yaml.org,2002:set":tf.set,"tag:yaml.org,2002:timestamp":na.timestamp};function dy(e,t,r){let i=Ud.get(t);if(i&&!e)return r&&!i.includes(vi.merge)?i.concat(vi.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let a=Array.from(Ud.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`)}if(Array.isArray(e))for(let a of e)n=n.concat(a);else typeof e=="function"&&(n=e(n.slice()));return r&&(n=n.concat(vi.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Kd[o]:o;if(!s){let l=JSON.stringify(o),c=Object.keys(Kd).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return a.includes(s)||a.push(s),a},[])}Ks.coreKnownTags=uy;Ks.getTags=dy});var Qs=y(nf=>{"use strict";var Ys=R(),fy=hr(),py=mr(),hy=di(),aa=rf(),my=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Xs=class e{constructor({compat:t,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(t)?aa.getTags(t,"compat"):t?aa.getTags(null,t):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?aa.coreKnownTags:{},this.tags=aa.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Ys.MAP,{value:fy.map}),Object.defineProperty(this,Ys.SCALAR,{value:hy.string}),Object.defineProperty(this,Ys.SEQ,{value:py.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?my:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};nf.Schema=Xs});var of=y(af=>{"use strict";var vy=R(),Zs=ci(),gi=ni();function gy(e,t){let r=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(r.push(l),i=!0):e.directives.docStart&&(i=!0)}i&&r.push("---");let n=Zs.createStringifyContext(e,t),{commentString:a}=n.options;if(e.commentBefore){r.length!==1&&r.unshift("");let l=a(e.commentBefore);r.unshift(gi.indentComment(l,""))}let o=!1,s=null;if(e.contents){if(vy.isNode(e.contents)){if(e.contents.spaceBefore&&i&&r.push(""),e.contents.commentBefore){let u=a(e.contents.commentBefore);r.push(gi.indentComment(u,""))}n.forceBlockIndent=!!e.comment,s=e.contents.comment}let l=s?void 0:()=>o=!0,c=Zs.stringify(e.contents,n,()=>s=null,l);s&&(c+=gi.lineComment(c,"",a(s))),(c[0]==="|"||c[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${c}`:r.push(c)}else r.push(Zs.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=a(e.comment);l.includes(`
60
- `)?(r.push("..."),r.push(gi.indentComment(l,""))):r.push(`... ${l}`)}else r.push("...");else{let l=e.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||s)&&r[r.length-1]!==""&&r.push(""),r.push(gi.indentComment(a(l),"")))}return r.join(`
59
+ ${a.comment}`:i.comment}i=n}e.items[r]=Ta.isPair(i)?i:new Sc.Pair(i)}}else t("Expected a sequence for this tag");return e}function qf(e,t,r){let{replacer:i}=r,n=new Pb.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let a=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(a++),o));let s,l;if(Array.isArray(o))if(o.length===2)s=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)s=c[0],l=o[s];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else s=o;n.items.push(Sc.createPair(s,l,r))}return n}var Rb={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ff,createNode:qf};$a.createPairs=qf;$a.pairs=Rb;$a.resolvePairs=Ff});var Cc=y(xc=>{"use strict";var Vf=_(),Ec=_t(),Mi=Ot(),_b=Ht(),Wf=ja(),Yt=class e extends _b.YAMLSeq{constructor(){super(),this.add=Mi.YAMLMap.prototype.add.bind(this),this.delete=Mi.YAMLMap.prototype.delete.bind(this),this.get=Mi.YAMLMap.prototype.get.bind(this),this.has=Mi.YAMLMap.prototype.has.bind(this),this.set=Mi.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,r){if(!r)return super.toJSON(t);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if(Vf.isPair(n)?(a=Ec.toJS(n.key,"",r),o=Ec.toJS(n.value,a,r)):a=Ec.toJS(n,"",r),i.has(a))throw new Error("Ordered maps must not include duplicate keys");i.set(a,o)}return i}static from(t,r,i){let n=Wf.createPairs(t,r,i),a=new this;return a.items=n.items,a}};Yt.tag="tag:yaml.org,2002:omap";var Ab={collection:"seq",identify:e=>e instanceof Map,nodeClass:Yt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=Wf.resolvePairs(e,t),i=[];for(let{key:n}of r.items)Vf.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Yt,r)},createNode:(e,t,r)=>Yt.from(e,t,r)};xc.YAMLOMap=Yt;xc.omap=Ab});var Kf=y(Pc=>{"use strict";var zf=q();function Gf({value:e,source:t},r){return t&&(e?Jf:Uf).test.test(t)?t:e?r.options.trueStr:r.options.falseStr}var Jf={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new zf.Scalar(!0),stringify:Gf},Uf={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new zf.Scalar(!1),stringify:Gf};Pc.falseTag=Uf;Pc.trueTag=Jf});var Yf=y(Oa=>{"use strict";var Ib=q(),Rc=Hr(),Tb={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Rc.stringifyNumber},$b={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Rc.stringifyNumber(e)}},jb={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Ib.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let i=e.substring(r+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Rc.stringifyNumber};Oa.float=jb;Oa.floatExp=$b;Oa.floatNaN=Tb});var Qf=y(qi=>{"use strict";var Xf=Hr(),Fi=e=>typeof e=="bigint"||Number.isInteger(e);function Ha(e,t,r,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let a=parseInt(e,r);return n==="-"?-1*a:a}function _c(e,t,r){let{value:i}=e;if(Fi(i)){let n=i.toString(t);return i<0?"-"+r+n.substr(1):r+n}return Xf.stringifyNumber(e)}var Ob={identify:Fi,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>Ha(e,2,2,r),stringify:e=>_c(e,2,"0b")},Hb={identify:Fi,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>Ha(e,1,8,r),stringify:e=>_c(e,8,"0")},Db={identify:Fi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>Ha(e,0,10,r),stringify:Xf.stringifyNumber},Lb={identify:Fi,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>Ha(e,2,16,r),stringify:e=>_c(e,16,"0x")};qi.int=Db;qi.intBin=Ob;qi.intHex=Lb;qi.intOct=Hb});var Ic=y(Ac=>{"use strict";var Ba=_(),Da=$t(),La=Ot(),Xt=class e extends La.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let r;Ba.isPair(t)?r=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?r=new Da.Pair(t.key,null):r=new Da.Pair(t,null),La.findPair(this.items,r.key)||this.items.push(r)}get(t,r){let i=La.findPair(this.items,t);return!r&&Ba.isPair(i)?Ba.isScalar(i.key)?i.key.value:i.key:i}set(t,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let i=La.findPair(this.items,t);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Da.Pair(t))}toJSON(t,r){return super.toJSON(t,r,Set)}toString(t,r,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),r,i);throw new Error("Set items must all have null values")}static from(t,r,i){let{replacer:n}=i,a=new this(t);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),a.items.push(Da.createPair(o,null,i));return a}};Xt.tag="tag:yaml.org,2002:set";var Bb={collection:"map",identify:e=>e instanceof Set,nodeClass:Xt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Xt.from(e,t,r),resolve(e,t){if(Ba.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Xt,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Ac.YAMLSet=Xt;Ac.set=Bb});var $c=y(Ma=>{"use strict";var Mb=Hr();function Tc(e,t){let r=e[0],i=r==="-"||r==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),a=i.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return r==="-"?n(-1)*a:a}function Zf(e){let{value:t}=e,r=o=>o;if(typeof t=="bigint")r=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Mb.stringifyNumber(e);let i="";t<0&&(i="-",t*=r(-1));let n=r(60),a=[t%n];return t<60?a.unshift(0):(t=(t-a[0])/n,a.unshift(t%n),t>=60&&(t=(t-a[0])/n,a.unshift(t))),i+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Fb={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>Tc(e,r),stringify:Zf},qb={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Tc(e,!1),stringify:Zf},ep={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(ep.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(r,i-1,n,a||0,o||0,s||0,l),u=t[8];if(u&&u!=="Z"){let d=Tc(u,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Ma.floatTime=qb;Ma.intTime=Fb;Ma.timestamp=ep});var ip=y(rp=>{"use strict";var Vb=jr(),Wb=Pa(),zb=Or(),Gb=Li(),Jb=kc(),tp=Kf(),jc=Yf(),Fa=Qf(),Ub=ya(),Kb=Cc(),Yb=ja(),Xb=Ic(),Oc=$c(),Qb=[Vb.map,zb.seq,Gb.string,Wb.nullTag,tp.trueTag,tp.falseTag,Fa.intBin,Fa.intOct,Fa.int,Fa.intHex,jc.floatNaN,jc.floatExp,jc.float,Jb.binary,Ub.merge,Kb.omap,Yb.pairs,Xb.set,Oc.intTime,Oc.floatTime,Oc.timestamp];rp.schema=Qb});var pp=y(Lc=>{"use strict";var sp=jr(),Zb=Pa(),cp=Or(),eN=Li(),tN=hc(),Hc=vc(),Dc=wc(),rN=Hf(),iN=Bf(),lp=kc(),Vi=ya(),up=Cc(),dp=ja(),np=ip(),fp=Ic(),qa=$c(),ap=new Map([["core",rN.schema],["failsafe",[sp.map,cp.seq,eN.string]],["json",iN.schema],["yaml11",np.schema],["yaml-1.1",np.schema]]),op={binary:lp.binary,bool:tN.boolTag,float:Hc.float,floatExp:Hc.floatExp,floatNaN:Hc.floatNaN,floatTime:qa.floatTime,int:Dc.int,intHex:Dc.intHex,intOct:Dc.intOct,intTime:qa.intTime,map:sp.map,merge:Vi.merge,null:Zb.nullTag,omap:up.omap,pairs:dp.pairs,seq:cp.seq,set:fp.set,timestamp:qa.timestamp},nN={"tag:yaml.org,2002:binary":lp.binary,"tag:yaml.org,2002:merge":Vi.merge,"tag:yaml.org,2002:omap":up.omap,"tag:yaml.org,2002:pairs":dp.pairs,"tag:yaml.org,2002:set":fp.set,"tag:yaml.org,2002:timestamp":qa.timestamp};function aN(e,t,r){let i=ap.get(t);if(i&&!e)return r&&!i.includes(Vi.merge)?i.concat(Vi.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let a=Array.from(ap.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`)}if(Array.isArray(e))for(let a of e)n=n.concat(a);else typeof e=="function"&&(n=e(n.slice()));return r&&(n=n.concat(Vi.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?op[o]:o;if(!s){let l=JSON.stringify(o),c=Object.keys(op).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return a.includes(s)||a.push(s),a},[])}Lc.coreKnownTags=nN;Lc.getTags=aN});var Fc=y(hp=>{"use strict";var Bc=_(),oN=jr(),sN=Or(),cN=Li(),Va=pp(),lN=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Mc=class e{constructor({compat:t,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(t)?Va.getTags(t,"compat"):t?Va.getTags(null,t):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Va.coreKnownTags:{},this.tags=Va.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Bc.MAP,{value:oN.map}),Object.defineProperty(this,Bc.SCALAR,{value:cN.string}),Object.defineProperty(this,Bc.SEQ,{value:sN.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?lN:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};hp.Schema=Mc});var vp=y(mp=>{"use strict";var uN=_(),qc=Oi(),Wi=Ii();function dN(e,t){let r=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(r.push(l),i=!0):e.directives.docStart&&(i=!0)}i&&r.push("---");let n=qc.createStringifyContext(e,t),{commentString:a}=n.options;if(e.commentBefore){r.length!==1&&r.unshift("");let l=a(e.commentBefore);r.unshift(Wi.indentComment(l,""))}let o=!1,s=null;if(e.contents){if(uN.isNode(e.contents)){if(e.contents.spaceBefore&&i&&r.push(""),e.contents.commentBefore){let u=a(e.contents.commentBefore);r.push(Wi.indentComment(u,""))}n.forceBlockIndent=!!e.comment,s=e.contents.comment}let l=s?void 0:()=>o=!0,c=qc.stringify(e.contents,n,()=>s=null,l);s&&(c+=Wi.lineComment(c,"",a(s))),(c[0]==="|"||c[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${c}`:r.push(c)}else r.push(qc.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=a(e.comment);l.includes(`
60
+ `)?(r.push("..."),r.push(Wi.indentComment(l,""))):r.push(`... ${l}`)}else r.push("...");else{let l=e.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||s)&&r[r.length-1]!==""&&r.push(""),r.push(Wi.indentComment(a(l),"")))}return r.join(`
61
61
  `)+`
62
- `}af.stringifyDocument=gy});var wi=y(sf=>{"use strict";var wy=ri(),gr=xn(),pe=R(),yy=kt(),Ny=wt(),by=Qs(),ky=of(),ec=bn(),Sy=ns(),Ey=ii(),tc=is(),rc=class e{constructor(t,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,pe.NODE_TYPE,{value:pe.DOC});let n=null;typeof r=="function"||Array.isArray(r)?n=r:i===void 0&&r&&(i=r,r=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=a;let{version:o}=a;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new tc.Directives({version:o}),this.setSchema(o,i),this.contents=t===void 0?null:this.createNode(t,n,i)}clone(){let t=Object.create(e.prototype,{[pe.NODE_TYPE]:{value:pe.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=pe.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){wr(this.contents)&&this.contents.add(t)}addIn(t,r){wr(this.contents)&&this.contents.addIn(t,r)}createAlias(t,r){if(!t.anchor){let i=ec.anchorNames(this);t.anchor=!r||i.has(r)?ec.findNewAnchor(r||"a",i):r}return new wy.Alias(t.anchor)}createNode(t,r,i){let n;if(typeof r=="function")t=r.call({"":t},"",t),n=r;else if(Array.isArray(r)){let v=w=>typeof w=="number"||w instanceof String||w instanceof Number,g=r.filter(v).map(String);g.length>0&&(r=r.concat(g)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:c,tag:u}=i??{},{onAnchor:d,setAnchors:f,sourceObjects:h}=ec.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:h},p=Ey.createNode(t,u,m);return s&&pe.isCollection(p)&&(p.flow=!0),f(),p}createPair(t,r,i={}){let n=this.createNode(t,null,i),a=this.createNode(r,null,i);return new yy.Pair(n,a)}delete(t){return wr(this.contents)?this.contents.delete(t):!1}deleteIn(t){return gr.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):wr(this.contents)?this.contents.deleteIn(t):!1}get(t,r){return pe.isCollection(this.contents)?this.contents.get(t,r):void 0}getIn(t,r){return gr.isEmptyPath(t)?!r&&pe.isScalar(this.contents)?this.contents.value:this.contents:pe.isCollection(this.contents)?this.contents.getIn(t,r):void 0}has(t){return pe.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return gr.isEmptyPath(t)?this.contents!==void 0:pe.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,r){this.contents==null?this.contents=gr.collectionFromPath(this.schema,[t],r):wr(this.contents)&&this.contents.set(t,r)}setIn(t,r){gr.isEmptyPath(t)?this.contents=r:this.contents==null?this.contents=gr.collectionFromPath(this.schema,Array.from(t),r):wr(this.contents)&&this.contents.setIn(t,r)}setSchema(t,r={}){typeof t=="number"&&(t=String(t));let i;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new tc.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new tc.Directives({version:t}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(i)this.schema=new by.Schema(Object.assign(i,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:r,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!t,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},l=Ny.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:c,res:u}of s.anchors.values())a(u,c);return typeof o=="function"?Sy.applyReviver(o,{"":l},"",l):l}toJSON(t,r){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:r})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let r=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return ky.stringifyDocument(this,t)}};function wr(e){if(pe.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}sf.Document=rc});var bi=y(Ni=>{"use strict";var yi=class extends Error{constructor(t,r,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=r}},ic=class extends yi{constructor(t,r,i){super("YAMLParseError",t,r,i)}},nc=class extends yi{constructor(t,r,i){super("YAMLWarning",t,r,i)}},xy=(e,t)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>t.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,a))){let s=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
62
+ `}mp.stringifyDocument=dN});var zi=y(gp=>{"use strict";var fN=_i(),Dr=la(),ye=_(),pN=$t(),hN=_t(),mN=Fc(),vN=vp(),Vc=aa(),gN=Js(),wN=Ai(),Wc=Gs(),zc=class e{constructor(t,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ye.NODE_TYPE,{value:ye.DOC});let n=null;typeof r=="function"||Array.isArray(r)?n=r:i===void 0&&r&&(i=r,r=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=a;let{version:o}=a;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Wc.Directives({version:o}),this.setSchema(o,i),this.contents=t===void 0?null:this.createNode(t,n,i)}clone(){let t=Object.create(e.prototype,{[ye.NODE_TYPE]:{value:ye.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=ye.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){Lr(this.contents)&&this.contents.add(t)}addIn(t,r){Lr(this.contents)&&this.contents.addIn(t,r)}createAlias(t,r){if(!t.anchor){let i=Vc.anchorNames(this);t.anchor=!r||i.has(r)?Vc.findNewAnchor(r||"a",i):r}return new fN.Alias(t.anchor)}createNode(t,r,i){let n;if(typeof r=="function")t=r.call({"":t},"",t),n=r;else if(Array.isArray(r)){let v=w=>typeof w=="number"||w instanceof String||w instanceof Number,g=r.filter(v).map(String);g.length>0&&(r=r.concat(g)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:c,tag:u}=i??{},{onAnchor:d,setAnchors:f,sourceObjects:h}=Vc.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:h},p=wN.createNode(t,u,m);return s&&ye.isCollection(p)&&(p.flow=!0),f(),p}createPair(t,r,i={}){let n=this.createNode(t,null,i),a=this.createNode(r,null,i);return new pN.Pair(n,a)}delete(t){return Lr(this.contents)?this.contents.delete(t):!1}deleteIn(t){return Dr.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):Lr(this.contents)?this.contents.deleteIn(t):!1}get(t,r){return ye.isCollection(this.contents)?this.contents.get(t,r):void 0}getIn(t,r){return Dr.isEmptyPath(t)?!r&&ye.isScalar(this.contents)?this.contents.value:this.contents:ye.isCollection(this.contents)?this.contents.getIn(t,r):void 0}has(t){return ye.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return Dr.isEmptyPath(t)?this.contents!==void 0:ye.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,r){this.contents==null?this.contents=Dr.collectionFromPath(this.schema,[t],r):Lr(this.contents)&&this.contents.set(t,r)}setIn(t,r){Dr.isEmptyPath(t)?this.contents=r:this.contents==null?this.contents=Dr.collectionFromPath(this.schema,Array.from(t),r):Lr(this.contents)&&this.contents.setIn(t,r)}setSchema(t,r={}){typeof t=="number"&&(t=String(t));let i;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Wc.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new Wc.Directives({version:t}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(i)this.schema=new mN.Schema(Object.assign(i,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:r,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!t,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},l=hN.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:c,res:u}of s.anchors.values())a(u,c);return typeof o=="function"?gN.applyReviver(o,{"":l},"",l):l}toJSON(t,r){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:r})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let r=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return vN.stringifyDocument(this,t)}};function Lr(e){if(ye.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}gp.Document=zc});var Ui=y(Ji=>{"use strict";var Gi=class extends Error{constructor(t,r,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=r}},Gc=class extends Gi{constructor(t,r,i){super("YAMLParseError",t,r,i)}},Jc=class extends Gi{constructor(t,r,i){super("YAMLWarning",t,r,i)}},yN=(e,t)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>t.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,a))){let s=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
63
63
  `),o=s+o}if(/[^ ]/.test(o)){let s=1,l=r.linePos[1];l?.line===i&&l.col>n&&(s=Math.max(1,Math.min(l.col-n,80-a)));let c=" ".repeat(a)+"^".repeat(s);r.message+=`:
64
64
 
65
65
  ${o}
66
66
  ${c}
67
- `}};Ni.YAMLError=yi;Ni.YAMLParseError=ic;Ni.YAMLWarning=nc;Ni.prettifyError=xy});var ki=y(cf=>{"use strict";function Cy(e,{flow:t,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let l=!1,c=s,u=s,d="",f="",h=!1,m=!1,p=null,v=null,g=null,w=null,N=null,k=null,E=null;for(let b of e)switch(m&&(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"),m=!1),p&&(c&&b.type!=="comment"&&b.type!=="newline"&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),b.type){case"space":!t&&(r!=="doc-start"||i?.type!=="flow-collection")&&b.source.includes(" ")&&(p=b),u=!0;break;case"comment":{u||a(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let q=b.source.substring(1)||" ";d?d+=f+q:d=q,f="",c=!1;break}case"newline":c?d?d+=b.source:(!k||r!=="seq-item-ind")&&(l=!0):f+=b.source,c=!0,h=!0,(v||g)&&(w=b),u=!0;break;case"anchor":v&&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),v=b,E??(E=b.offset),c=!1,u=!1,m=!0;break;case"tag":{g&&a(b,"MULTIPLE_TAGS","A node can have at most one tag"),g=b,E??(E=b.offset),c=!1,u=!1,m=!0;break}case r:(v||g)&&a(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),k&&a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${t??"collection"}`),k=b,c=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(t){N&&a(b,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),N=b,c=!1,u=!1;break}default:a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),c=!1,u=!1}let x=e[e.length-1],$=x?x.offset+x.source.length:n;return m&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(c&&p.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:N,found:k,spaceBefore:l,comment:d,hasNewline:h,anchor:v,tag:g,newlineAfterProp:w,end:$,start:E??$}}cf.resolveProps=Cy});var oa=y(lf=>{"use strict";function ac(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
68
- `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(ac(t.key)||ac(t.value))return!0}return!1;default:return!0}}lf.containsNewline=ac});var oc=y(uf=>{"use strict";var Py=oa();function Ry(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&Py.containsNewline(t)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}uf.flowIndentCheck=Ry});var sc=y(ff=>{"use strict";var df=R();function _y(e,t,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||df.isScalar(a)&&df.isScalar(o)&&a.value===o.value;return t.some(a=>n(a.key,r))}ff.mapIncludes=_y});var wf=y(gf=>{"use strict";var pf=kt(),Ay=Et(),hf=ki(),Iy=oa(),mf=oc(),Ty=sc(),vf="All mapping items must start at the same column";function jy({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=a?.nodeClass??Ay.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let l=i.offset,c=null;for(let u of i.items){let{start:d,key:f,sep:h,value:m}=u,p=hf.resolveProps(d,{indicator:"explicit-key-ind",next:f??h?.[0],offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0}),v=!p.found;if(v){if(f&&(f.type==="block-seq"?n(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==i.indent&&n(l,"BAD_INDENT",vf)),!p.anchor&&!p.tag&&!h){c=p.end,p.comment&&(s.comment?s.comment+=`
69
- `+p.comment:s.comment=p.comment);continue}(p.newlineAfterProp||Iy.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==i.indent&&n(l,"BAD_INDENT",vf);r.atKey=!0;let g=p.end,w=f?e(r,f,p,n):t(r,g,d,null,p,n);r.schema.compat&&mf.flowIndentCheck(i.indent,f,n),r.atKey=!1,Ty.mapIncludes(r,s.items,w)&&n(g,"DUPLICATE_KEY","Map keys must be unique");let N=hf.resolveProps(h??[],{indicator:"map-value-ind",next:m,offset:w.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(l=N.end,N.found){v&&(m?.type==="block-map"&&!N.hasNewline&&n(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&p.start<N.found.offset-1024&&n(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=m?e(r,m,N,n):t(r,l,h,null,N,n);r.schema.compat&&mf.flowIndentCheck(i.indent,m,n),l=k.range[2];let E=new pf.Pair(w,k);r.options.keepSourceTokens&&(E.srcToken=u),s.items.push(E)}else{v&&n(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),N.comment&&(w.comment?w.comment+=`
70
- `+N.comment:w.comment=N.comment);let k=new pf.Pair(w);r.options.keepSourceTokens&&(k.srcToken=u),s.items.push(k)}}return c&&c<l&&n(c,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,l,c??l],s}gf.resolveBlockMap=jy});var Nf=y(yf=>{"use strict";var $y=xt(),Oy=ki(),Hy=oc();function Dy({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=a?.nodeClass??$y.YAMLSeq,s=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let l=i.offset,c=null;for(let{start:u,value:d}of i.items){let f=Oy.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?n(f.end,"BAD_INDENT","All sequence items must start at the same column"):n(l,"MISSING_CHAR","Sequence item without - indicator");else{c=f.end,f.comment&&(s.comment=f.comment);continue}let h=d?e(r,d,f,n):t(r,f.end,u,null,f,n);r.schema.compat&&Hy.flowIndentCheck(i.indent,d,n),l=h.range[2],s.items.push(h)}return s.range=[i.offset,l,c??l],s}yf.resolveBlockSeq=Dy});var yr=y(bf=>{"use strict";function Ly(e,t,r,i){let n="";if(e){let a=!1,o="";for(let s of e){let{source:l,type:c}=s;switch(c){case"space":a=!0;break;case"comment":{r&&!a&&i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=l.substring(1)||" ";n?n+=o+u:n=u,o="";break}case"newline":n&&(o+=l),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:n,offset:t}}bf.resolveEnd=Ly});var xf=y(Ef=>{"use strict";var By=R(),My=kt(),kf=Et(),Fy=xt(),Vy=yr(),Sf=ki(),qy=oa(),Wy=sc(),cc="Block collections are not allowed within flow collections",lc=e=>e&&(e.type==="block-map"||e.type==="block-seq");function zy({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",l=a?.nodeClass??(o?kf.YAMLMap:Fy.YAMLSeq),c=new l(r.schema);c.flow=!0;let u=r.atRoot;u&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let d=i.offset+i.start.source.length;for(let v=0;v<i.items.length;++v){let g=i.items[v],{start:w,key:N,sep:k,value:E}=g,x=Sf.resolveProps(w,{flow:s,indicator:"explicit-key-ind",next:N??k?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!x.found){if(!x.anchor&&!x.tag&&!k&&!E){v===0&&x.comma?n(x.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):v<i.items.length-1&&n(x.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),x.comment&&(c.comment?c.comment+=`
71
- `+x.comment:c.comment=x.comment),d=x.end;continue}!o&&r.options.strict&&qy.containsNewline(N)&&n(N,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(v===0)x.comma&&n(x.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(x.comma||n(x.start,"MISSING_CHAR",`Missing , between ${s} items`),x.comment){let $="";e:for(let b of w)switch(b.type){case"comma":case"space":break;case"comment":$=b.source.substring(1);break e;default:break e}if($){let b=c.items[c.items.length-1];By.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
72
- `+$:b.comment=$,x.comment=x.comment.substring($.length+1)}}if(!o&&!k&&!x.found){let $=E?e(r,E,x,n):t(r,x.end,k,null,x,n);c.items.push($),d=$.range[2],lc(E)&&n($.range,"BLOCK_IN_FLOW",cc)}else{r.atKey=!0;let $=x.end,b=N?e(r,N,x,n):t(r,$,w,null,x,n);lc(N)&&n(b.range,"BLOCK_IN_FLOW",cc),r.atKey=!1;let q=Sf.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:E,offset:b.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(q.found){if(!o&&!x.found&&r.options.strict){if(k)for(let W of k){if(W===q.found)break;if(W.type==="newline"){n(W,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}x.start<q.found.offset-1024&&n(q.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(q.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let ht=E?e(r,E,q,n):q.found?t(r,q.end,k,null,q,n):null;ht?lc(E)&&n(ht.range,"BLOCK_IN_FLOW",cc):q.comment&&(b.comment?b.comment+=`
73
- `+q.comment:b.comment=q.comment);let sr=new My.Pair(b,ht);if(r.options.keepSourceTokens&&(sr.srcToken=g),o){let W=c;Wy.mapIncludes(r,W.items,b)&&n($,"DUPLICATE_KEY","Map keys must be unique"),W.items.push(sr)}else{let W=new kf.YAMLMap(r.schema);W.flow=!0,W.items.push(sr);let pu=(ht??b).range;W.range=[b.range[0],pu[1],pu[2]],c.items.push(W)}d=ht?ht.range[2]:q.end}}let f=o?"}":"]",[h,...m]=i.end,p=d;if(h?.source===f)p=h.offset+h.source.length;else{let v=s[0].toUpperCase()+s.substring(1),g=u?`${v} must end with a ${f}`:`${v} in block collection must be sufficiently indented and end with a ${f}`;n(d,u?"MISSING_CHAR":"BAD_INDENT",g),h&&h.source.length!==1&&m.unshift(h)}if(m.length>0){let v=Vy.resolveEnd(m,p,r.options.strict,n);v.comment&&(c.comment?c.comment+=`
74
- `+v.comment:c.comment=v.comment),c.range=[i.offset,p,v.offset]}else c.range=[i.offset,p,p];return c}Ef.resolveFlowCollection=zy});var Pf=y(Cf=>{"use strict";var Gy=R(),Jy=M(),Uy=Et(),Ky=xt(),Yy=wf(),Xy=Nf(),Qy=xf();function uc(e,t,r,i,n,a){let o=r.type==="block-map"?Yy.resolveBlockMap(e,t,r,i,a):r.type==="block-seq"?Xy.resolveBlockSeq(e,t,r,i,a):Qy.resolveFlowCollection(e,t,r,i,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function Zy(e,t,r,i,n){let a=i.tag,o=a?t.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:h}=i,m=f&&a?f.offset>a.offset?f:a:f??a;m&&(!h||h.offset<m.offset)&&n(m,"MISSING_CHAR","Missing newline after block sequence props")}let s=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===Uy.YAMLMap.tagName&&s==="map"||o===Ky.YAMLSeq.tagName&&s==="seq")return uc(e,t,r,n,o);let l=t.schema.tags.find(f=>f.tag===o&&f.collection===s);if(!l){let f=t.schema.knownTags[o];if(f?.collection===s)t.schema.tags.push(Object.assign({},f,{default:!1})),l=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),uc(e,t,r,n,o)}let c=uc(e,t,r,n,o,l),u=l.resolve?.(c,f=>n(a,"TAG_RESOLVE_FAILED",f),t.options)??c,d=Gy.isNode(u)?u:new Jy.Scalar(u);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}Cf.composeCollection=Zy});var fc=y(Rf=>{"use strict";var dc=M();function eN(e,t,r){let i=t.offset,n=tN(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?dc.Scalar.BLOCK_FOLDED:dc.Scalar.BLOCK_LITERAL,o=t.source?rN(t.source):[],s=o.length;for(let p=o.length-1;p>=0;--p){let v=o[p][1];if(v===""||v==="\r")s=p;else break}if(s===0){let p=n.chomp==="+"&&o.length>0?`
67
+ `}};Ji.YAMLError=Gi;Ji.YAMLParseError=Gc;Ji.YAMLWarning=Jc;Ji.prettifyError=yN});var Ki=y(wp=>{"use strict";function bN(e,{flow:t,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let l=!1,c=s,u=s,d="",f="",h=!1,m=!1,p=null,v=null,g=null,w=null,b=null,k=null,x=null;for(let N of e)switch(m&&(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma"&&a(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),p&&(c&&N.type!=="comment"&&N.type!=="newline"&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),N.type){case"space":!t&&(r!=="doc-start"||i?.type!=="flow-collection")&&N.source.includes(" ")&&(p=N),u=!0;break;case"comment":{u||a(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let z=N.source.substring(1)||" ";d?d+=f+z:d=z,f="",c=!1;break}case"newline":c?d?d+=N.source:(!k||r!=="seq-item-ind")&&(l=!0):f+=N.source,c=!0,h=!0,(v||g)&&(w=N),u=!0;break;case"anchor":v&&a(N,"MULTIPLE_ANCHORS","A node can have at most one anchor"),N.source.endsWith(":")&&a(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),v=N,x??(x=N.offset),c=!1,u=!1,m=!0;break;case"tag":{g&&a(N,"MULTIPLE_TAGS","A node can have at most one tag"),g=N,x??(x=N.offset),c=!1,u=!1,m=!0;break}case r:(v||g)&&a(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`),k&&a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${t??"collection"}`),k=N,c=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(t){b&&a(N,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),b=N,c=!1,u=!1;break}default:a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),c=!1,u=!1}let E=e[e.length-1],H=E?E.offset+E.source.length:n;return m&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(c&&p.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:k,spaceBefore:l,comment:d,hasNewline:h,anchor:v,tag:g,newlineAfterProp:w,end:H,start:x??H}}wp.resolveProps=bN});var Wa=y(yp=>{"use strict";function Uc(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
68
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(Uc(t.key)||Uc(t.value))return!0}return!1;default:return!0}}yp.containsNewline=Uc});var Kc=y(bp=>{"use strict";var NN=Wa();function kN(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&NN.containsNewline(t)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}bp.flowIndentCheck=kN});var Yc=y(kp=>{"use strict";var Np=_();function SN(e,t,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||Np.isScalar(a)&&Np.isScalar(o)&&a.value===o.value;return t.some(a=>n(a.key,r))}kp.mapIncludes=SN});var Rp=y(Pp=>{"use strict";var Sp=$t(),EN=Ot(),Ep=Ki(),xN=Wa(),xp=Kc(),CN=Yc(),Cp="All mapping items must start at the same column";function PN({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=a?.nodeClass??EN.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let l=i.offset,c=null;for(let u of i.items){let{start:d,key:f,sep:h,value:m}=u,p=Ep.resolveProps(d,{indicator:"explicit-key-ind",next:f??h?.[0],offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0}),v=!p.found;if(v){if(f&&(f.type==="block-seq"?n(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==i.indent&&n(l,"BAD_INDENT",Cp)),!p.anchor&&!p.tag&&!h){c=p.end,p.comment&&(s.comment?s.comment+=`
69
+ `+p.comment:s.comment=p.comment);continue}(p.newlineAfterProp||xN.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==i.indent&&n(l,"BAD_INDENT",Cp);r.atKey=!0;let g=p.end,w=f?e(r,f,p,n):t(r,g,d,null,p,n);r.schema.compat&&xp.flowIndentCheck(i.indent,f,n),r.atKey=!1,CN.mapIncludes(r,s.items,w)&&n(g,"DUPLICATE_KEY","Map keys must be unique");let b=Ep.resolveProps(h??[],{indicator:"map-value-ind",next:m,offset:w.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(l=b.end,b.found){v&&(m?.type==="block-map"&&!b.hasNewline&&n(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&p.start<b.found.offset-1024&&n(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=m?e(r,m,b,n):t(r,l,h,null,b,n);r.schema.compat&&xp.flowIndentCheck(i.indent,m,n),l=k.range[2];let x=new Sp.Pair(w,k);r.options.keepSourceTokens&&(x.srcToken=u),s.items.push(x)}else{v&&n(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(w.comment?w.comment+=`
70
+ `+b.comment:w.comment=b.comment);let k=new Sp.Pair(w);r.options.keepSourceTokens&&(k.srcToken=u),s.items.push(k)}}return c&&c<l&&n(c,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,l,c??l],s}Pp.resolveBlockMap=PN});var Ap=y(_p=>{"use strict";var RN=Ht(),_N=Ki(),AN=Kc();function IN({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=a?.nodeClass??RN.YAMLSeq,s=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let l=i.offset,c=null;for(let{start:u,value:d}of i.items){let f=_N.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?n(f.end,"BAD_INDENT","All sequence items must start at the same column"):n(l,"MISSING_CHAR","Sequence item without - indicator");else{c=f.end,f.comment&&(s.comment=f.comment);continue}let h=d?e(r,d,f,n):t(r,f.end,u,null,f,n);r.schema.compat&&AN.flowIndentCheck(i.indent,d,n),l=h.range[2],s.items.push(h)}return s.range=[i.offset,l,c??l],s}_p.resolveBlockSeq=IN});var Br=y(Ip=>{"use strict";function TN(e,t,r,i){let n="";if(e){let a=!1,o="";for(let s of e){let{source:l,type:c}=s;switch(c){case"space":a=!0;break;case"comment":{r&&!a&&i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=l.substring(1)||" ";n?n+=o+u:n=u,o="";break}case"newline":n&&(o+=l),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:n,offset:t}}Ip.resolveEnd=TN});var Op=y(jp=>{"use strict";var $N=_(),jN=$t(),Tp=Ot(),ON=Ht(),HN=Br(),$p=Ki(),DN=Wa(),LN=Yc(),Xc="Block collections are not allowed within flow collections",Qc=e=>e&&(e.type==="block-map"||e.type==="block-seq");function BN({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",l=a?.nodeClass??(o?Tp.YAMLMap:ON.YAMLSeq),c=new l(r.schema);c.flow=!0;let u=r.atRoot;u&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let d=i.offset+i.start.source.length;for(let v=0;v<i.items.length;++v){let g=i.items[v],{start:w,key:b,sep:k,value:x}=g,E=$p.resolveProps(w,{flow:s,indicator:"explicit-key-ind",next:b??k?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!k&&!x){v===0&&E.comma?n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):v<i.items.length-1&&n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),E.comment&&(c.comment?c.comment+=`
71
+ `+E.comment:c.comment=E.comment),d=E.end;continue}!o&&r.options.strict&&DN.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(v===0)E.comma&&n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(E.comma||n(E.start,"MISSING_CHAR",`Missing , between ${s} items`),E.comment){let H="";e:for(let N of w)switch(N.type){case"comma":case"space":break;case"comment":H=N.source.substring(1);break e;default:break e}if(H){let N=c.items[c.items.length-1];$N.isPair(N)&&(N=N.value??N.key),N.comment?N.comment+=`
72
+ `+H:N.comment=H,E.comment=E.comment.substring(H.length+1)}}if(!o&&!k&&!E.found){let H=x?e(r,x,E,n):t(r,E.end,k,null,E,n);c.items.push(H),d=H.range[2],Qc(x)&&n(H.range,"BLOCK_IN_FLOW",Xc)}else{r.atKey=!0;let H=E.end,N=b?e(r,b,E,n):t(r,H,w,null,E,n);Qc(b)&&n(N.range,"BLOCK_IN_FLOW",Xc),r.atKey=!1;let z=$p.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:x,offset:N.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(z.found){if(!o&&!E.found&&r.options.strict){if(k)for(let G of k){if(G===z.found)break;if(G.type==="newline"){n(G,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<z.found.offset-1024&&n(z.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else x&&("source"in x&&x.source?.[0]===":"?n(x,"MISSING_CHAR",`Missing space after : in ${s}`):n(z.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let xt=x?e(r,x,z,n):z.found?t(r,z.end,k,null,z,n):null;xt?Qc(x)&&n(xt.range,"BLOCK_IN_FLOW",Xc):z.comment&&(N.comment?N.comment+=`
73
+ `+z.comment:N.comment=z.comment);let Er=new jN.Pair(N,xt);if(r.options.keepSourceTokens&&(Er.srcToken=g),o){let G=c;LN.mapIncludes(r,G.items,N)&&n(H,"DUPLICATE_KEY","Map keys must be unique"),G.items.push(Er)}else{let G=new Tp.YAMLMap(r.schema);G.flow=!0,G.items.push(Er);let yd=(xt??N).range;G.range=[N.range[0],yd[1],yd[2]],c.items.push(G)}d=xt?xt.range[2]:z.end}}let f=o?"}":"]",[h,...m]=i.end,p=d;if(h?.source===f)p=h.offset+h.source.length;else{let v=s[0].toUpperCase()+s.substring(1),g=u?`${v} must end with a ${f}`:`${v} in block collection must be sufficiently indented and end with a ${f}`;n(d,u?"MISSING_CHAR":"BAD_INDENT",g),h&&h.source.length!==1&&m.unshift(h)}if(m.length>0){let v=HN.resolveEnd(m,p,r.options.strict,n);v.comment&&(c.comment?c.comment+=`
74
+ `+v.comment:c.comment=v.comment),c.range=[i.offset,p,v.offset]}else c.range=[i.offset,p,p];return c}jp.resolveFlowCollection=BN});var Dp=y(Hp=>{"use strict";var MN=_(),FN=q(),qN=Ot(),VN=Ht(),WN=Rp(),zN=Ap(),GN=Op();function Zc(e,t,r,i,n,a){let o=r.type==="block-map"?WN.resolveBlockMap(e,t,r,i,a):r.type==="block-seq"?zN.resolveBlockSeq(e,t,r,i,a):GN.resolveFlowCollection(e,t,r,i,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function JN(e,t,r,i,n){let a=i.tag,o=a?t.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:h}=i,m=f&&a?f.offset>a.offset?f:a:f??a;m&&(!h||h.offset<m.offset)&&n(m,"MISSING_CHAR","Missing newline after block sequence props")}let s=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===qN.YAMLMap.tagName&&s==="map"||o===VN.YAMLSeq.tagName&&s==="seq")return Zc(e,t,r,n,o);let l=t.schema.tags.find(f=>f.tag===o&&f.collection===s);if(!l){let f=t.schema.knownTags[o];if(f?.collection===s)t.schema.tags.push(Object.assign({},f,{default:!1})),l=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),Zc(e,t,r,n,o)}let c=Zc(e,t,r,n,o,l),u=l.resolve?.(c,f=>n(a,"TAG_RESOLVE_FAILED",f),t.options)??c,d=MN.isNode(u)?u:new FN.Scalar(u);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}Hp.composeCollection=JN});var tl=y(Lp=>{"use strict";var el=q();function UN(e,t,r){let i=t.offset,n=KN(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?el.Scalar.BLOCK_FOLDED:el.Scalar.BLOCK_LITERAL,o=t.source?YN(t.source):[],s=o.length;for(let p=o.length-1;p>=0;--p){let v=o[p][1];if(v===""||v==="\r")s=p;else break}if(s===0){let p=n.chomp==="+"&&o.length>0?`
75
75
  `.repeat(Math.max(1,o.length-1)):"",v=i+n.length;return t.source&&(v+=t.source.length),{value:p,type:a,comment:n.comment,range:[i,v,v]}}let l=t.indent+n.indent,c=t.offset+n.length,u=0;for(let p=0;p<s;++p){let[v,g]=o[p];if(g===""||g==="\r")n.indent===0&&v.length>l&&(l=v.length);else{v.length<l&&r(c+v.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(l=v.length),u=p,l===0&&!e.atRoot&&r(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=v.length+g.length+1}for(let p=o.length-1;p>=s;--p)o[p][0].length>l&&(s=p+1);let d="",f="",h=!1;for(let p=0;p<u;++p)d+=o[p][0].slice(l)+`
76
- `;for(let p=u;p<s;++p){let[v,g]=o[p];c+=v.length+g.length+1;let w=g[g.length-1]==="\r";if(w&&(g=g.slice(0,-1)),g&&v.length<l){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(c-g.length-(w?2:1),"BAD_INDENT",k),v=""}a===dc.Scalar.BLOCK_LITERAL?(d+=f+v.slice(l)+g,f=`
76
+ `;for(let p=u;p<s;++p){let[v,g]=o[p];c+=v.length+g.length+1;let w=g[g.length-1]==="\r";if(w&&(g=g.slice(0,-1)),g&&v.length<l){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(c-g.length-(w?2:1),"BAD_INDENT",k),v=""}a===el.Scalar.BLOCK_LITERAL?(d+=f+v.slice(l)+g,f=`
77
77
  `):v.length>l||g[0]===" "?(f===" "?f=`
78
78
  `:!h&&f===`
79
79
  `&&(f=`
@@ -86,123 +86,208 @@ ${c}
86
86
  `+o[p][0].slice(l);d[d.length-1]!==`
87
87
  `&&(d+=`
88
88
  `);break;default:d+=`
89
- `}let m=i+n.length+t.source.length;return{value:d,type:a,comment:n.comment,range:[i,m,m]}}function tN({offset:e,props:t},r,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],a=n[0],o=0,s="",l=-1;for(let f=1;f<n.length;++f){let h=n[f];if(!s&&(h==="-"||h==="+"))s=h;else{let m=Number(h);!o&&m?o=m:l===-1&&(l=e+f)}}l!==-1&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let c=!1,u="",d=n.length;for(let f=1;f<t.length;++f){let h=t[f];switch(h.type){case"space":c=!0;case"newline":d+=h.source.length;break;case"comment":r&&!c&&i(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=h.source.length,u=h.source.substring(1);break;case"error":i(h,"UNEXPECTED_TOKEN",h.message),d+=h.source.length;break;default:{let m=`Unexpected token in block scalar header: ${h.type}`;i(h,"UNEXPECTED_TOKEN",m);let p=h.source;p&&typeof p=="string"&&(d+=p.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function rN(e){let t=e.split(/\n( *)/),r=t[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<t.length;o+=2)a.push([t[o],t[o+1]]);return a}Rf.resolveBlockScalar=eN});var hc=y(Af=>{"use strict";var pc=M(),iN=yr();function nN(e,t,r){let{offset:i,type:n,source:a,end:o}=e,s,l,c=(f,h,m)=>r(i+f,h,m);switch(n){case"scalar":s=pc.Scalar.PLAIN,l=aN(a,c);break;case"single-quoted-scalar":s=pc.Scalar.QUOTE_SINGLE,l=oN(a,c);break;case"double-quoted-scalar":s=pc.Scalar.QUOTE_DOUBLE,l=sN(a,c);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let u=i+a.length,d=iN.resolveEnd(o,u,t,r);return{value:l,type:s,comment:d.comment,range:[i,u,d.offset]}}function aN(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),_f(e)}function oN(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),_f(e.slice(1,-1)).replace(/''/g,"'")}function _f(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
89
+ `}let m=i+n.length+t.source.length;return{value:d,type:a,comment:n.comment,range:[i,m,m]}}function KN({offset:e,props:t},r,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],a=n[0],o=0,s="",l=-1;for(let f=1;f<n.length;++f){let h=n[f];if(!s&&(h==="-"||h==="+"))s=h;else{let m=Number(h);!o&&m?o=m:l===-1&&(l=e+f)}}l!==-1&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let c=!1,u="",d=n.length;for(let f=1;f<t.length;++f){let h=t[f];switch(h.type){case"space":c=!0;case"newline":d+=h.source.length;break;case"comment":r&&!c&&i(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=h.source.length,u=h.source.substring(1);break;case"error":i(h,"UNEXPECTED_TOKEN",h.message),d+=h.source.length;break;default:{let m=`Unexpected token in block scalar header: ${h.type}`;i(h,"UNEXPECTED_TOKEN",m);let p=h.source;p&&typeof p=="string"&&(d+=p.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function YN(e){let t=e.split(/\n( *)/),r=t[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<t.length;o+=2)a.push([t[o],t[o+1]]);return a}Lp.resolveBlockScalar=UN});var il=y(Mp=>{"use strict";var rl=q(),XN=Br();function QN(e,t,r){let{offset:i,type:n,source:a,end:o}=e,s,l,c=(f,h,m)=>r(i+f,h,m);switch(n){case"scalar":s=rl.Scalar.PLAIN,l=ZN(a,c);break;case"single-quoted-scalar":s=rl.Scalar.QUOTE_SINGLE,l=ek(a,c);break;case"double-quoted-scalar":s=rl.Scalar.QUOTE_DOUBLE,l=tk(a,c);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let u=i+a.length,d=XN.resolveEnd(o,u,t,r);return{value:l,type:s,comment:d.comment,range:[i,u,d.offset]}}function ZN(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),Bp(e)}function ek(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),Bp(e.slice(1,-1)).replace(/''/g,"'")}function Bp(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
90
90
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
91
91
  `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let n=i[1],a=" ",o=t.lastIndex;for(r.lastIndex=o;i=r.exec(e);)i[1]===""?a===`
92
92
  `?n+=a:a=`
93
- `:(n+=a+i[1],a=" "),o=r.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,i=s.exec(e),n+a+(i?.[1]??"")}function sN(e,t){let r="";for(let i=1;i<e.length-1;++i){let n=e[i];if(!(n==="\r"&&e[i+1]===`
93
+ `:(n+=a+i[1],a=" "),o=r.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,i=s.exec(e),n+a+(i?.[1]??"")}function tk(e,t){let r="";for(let i=1;i<e.length-1;++i){let n=e[i];if(!(n==="\r"&&e[i+1]===`
94
94
  `))if(n===`
95
- `){let{fold:a,offset:o}=cN(e,i);r+=a,i=o}else if(n==="\\"){let a=e[++i],o=lN[a];if(o)r+=o;else if(a===`
95
+ `){let{fold:a,offset:o}=rk(e,i);r+=a,i=o}else if(n==="\\"){let a=e[++i],o=ik[a];if(o)r+=o;else if(a===`
96
96
  `)for(a=e[i+1];a===" "||a===" ";)a=e[++i+1];else if(a==="\r"&&e[i+1]===`
97
- `)for(a=e[++i+1];a===" "||a===" ";)a=e[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=uN(e,i+1,s,t),i+=s}else{let s=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=e[i+1];for(;o===" "||o===" ";)o=e[++i+1];o!==`
97
+ `)for(a=e[++i+1];a===" "||a===" ";)a=e[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=nk(e,i+1,s,t),i+=s}else{let s=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=e[i+1];for(;o===" "||o===" ";)o=e[++i+1];o!==`
98
98
  `&&!(o==="\r"&&e[i+2]===`
99
- `)&&(r+=i>a?e.slice(a,i+1):n)}else r+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}function cN(e,t){let r="",i=e[t+1];for(;(i===" "||i===" "||i===`
99
+ `)&&(r+=i>a?e.slice(a,i+1):n)}else r+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}function rk(e,t){let r="",i=e[t+1];for(;(i===" "||i===" "||i===`
100
100
  `||i==="\r")&&!(i==="\r"&&e[t+2]!==`
101
101
  `);)i===`
102
102
  `&&(r+=`
103
- `),t+=1,i=e[t+1];return r||(r=" "),{fold:r,offset:t}}var lN={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
104
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function uN(e,t,r,i){let n=e.substr(t,r),o=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=e.substr(t-2,r+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Af.resolveFlowScalar=nN});var jf=y(Tf=>{"use strict";var Mt=R(),If=M(),dN=fc(),fN=hc();function pN(e,t,r,i){let{value:n,type:a,comment:o,range:s}=t.type==="block-scalar"?dN.resolveBlockScalar(e,t,i):fN.resolveFlowScalar(t,e.options.strict,i),l=r?e.directives.tagName(r.source,d=>i(r,"TAG_RESOLVE_FAILED",d)):null,c;e.options.stringKeys&&e.atKey?c=e.schema[Mt.SCALAR]:l?c=hN(e.schema,n,l,r,i):t.type==="scalar"?c=mN(e,n,t,i):c=e.schema[Mt.SCALAR];let u;try{let d=c.resolve(n,f=>i(r??t,"TAG_RESOLVE_FAILED",f),e.options);u=Mt.isScalar(d)?d:new If.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);i(r??t,"TAG_RESOLVE_FAILED",f),u=new If.Scalar(n)}return u.range=s,u.source=n,a&&(u.type=a),l&&(u.tag=l),c.format&&(u.format=c.format),o&&(u.comment=o),u}function hN(e,t,r,i,n){if(r==="!")return e[Mt.SCALAR];let a=[];for(let s of e.tags)if(!s.collection&&s.tag===r)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(t))return s;let o=e.knownTags[r];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[Mt.SCALAR])}function mN({atKey:e,directives:t,schema:r},i,n,a){let o=r.tags.find(s=>(s.default===!0||e&&s.default==="key")&&s.test?.test(i))||r[Mt.SCALAR];if(r.compat){let s=r.compat.find(l=>l.default&&l.test?.test(i))??r[Mt.SCALAR];if(o.tag!==s.tag){let l=t.tagString(o.tag),c=t.tagString(s.tag),u=`Value may be parsed as either ${l} or ${c}`;a(n,"TAG_RESOLVE_FAILED",u,!0)}}return o}Tf.composeScalar=pN});var Of=y($f=>{"use strict";function vN(e,t,r){if(t){r??(r=t.length);for(let i=r-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++i];n?.type==="space";)e+=n.source.length,n=t[++i];break}}return e}$f.emptyScalarPosition=vN});var Lf=y(vc=>{"use strict";var gN=ri(),wN=R(),yN=Pf(),Hf=jf(),NN=yr(),bN=Of(),kN={composeNode:Df,composeEmptyNode:mc};function Df(e,t,r,i){let n=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:l}=r,c,u=!0;switch(t.type){case"alias":c=SN(e,t,i),(s||l)&&i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Hf.composeScalar(e,t,l,i),s&&(c.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=yN.composeCollection(kN,e,t,r,i),s&&(c.anchor=s.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);i(t,"RESOURCE_EXHAUSTION",f)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",d),u=!1}}return c??(c=mc(e,t.offset,void 0,null,r,i)),s&&c.anchor===""&&i(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!wN.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(c.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?c.comment=o:c.commentBefore=o),e.options.keepSourceTokens&&u&&(c.srcToken=t),c}function mc(e,t,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:l},c){let u={type:"scalar",offset:bN.emptyScalarPosition(t,r,i),indent:-1,source:""},d=Hf.composeScalar(e,u,s,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),a&&(d.comment=a,d.range[2]=l),d}function SN({options:e},{offset:t,source:r,end:i},n){let a=new gN.Alias(r.substring(1));a.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+r.length,s=NN.resolveEnd(i,o,e.strict,n);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}vc.composeEmptyNode=mc;vc.composeNode=Df});var Ff=y(Mf=>{"use strict";var EN=wi(),Bf=Lf(),xN=yr(),CN=ki();function PN(e,t,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:t},e),l=new EN.Document(void 0,s),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=CN.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(l.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")),l.contents=n?Bf.composeNode(c,n,u,o):Bf.composeEmptyNode(c,u.end,i,null,u,o);let d=l.contents.range[2],f=xN.resolveEnd(a,d,!1,o);return f.comment&&(l.comment=f.comment),l.range=[r,d,f.offset],l}Mf.composeDoc=PN});var wc=y(Wf=>{"use strict";var RN=sn("process"),_N=is(),AN=wi(),Si=bi(),Vf=R(),IN=Ff(),TN=yr();function Ei(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r=="string"?r.length:1)]}function qf(e){let t="",r=!1,i=!1;for(let n=0;n<e.length;++n){let a=e[n];switch(a[0]){case"#":t+=(t===""?"":i?`
103
+ `),t+=1,i=e[t+1];return r||(r=" "),{fold:r,offset:t}}var ik={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
104
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function nk(e,t,r,i){let n=e.substr(t,r),o=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=e.substr(t-2,r+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Mp.resolveFlowScalar=QN});var Vp=y(qp=>{"use strict";var Qt=_(),Fp=q(),ak=tl(),ok=il();function sk(e,t,r,i){let{value:n,type:a,comment:o,range:s}=t.type==="block-scalar"?ak.resolveBlockScalar(e,t,i):ok.resolveFlowScalar(t,e.options.strict,i),l=r?e.directives.tagName(r.source,d=>i(r,"TAG_RESOLVE_FAILED",d)):null,c;e.options.stringKeys&&e.atKey?c=e.schema[Qt.SCALAR]:l?c=ck(e.schema,n,l,r,i):t.type==="scalar"?c=lk(e,n,t,i):c=e.schema[Qt.SCALAR];let u;try{let d=c.resolve(n,f=>i(r??t,"TAG_RESOLVE_FAILED",f),e.options);u=Qt.isScalar(d)?d:new Fp.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);i(r??t,"TAG_RESOLVE_FAILED",f),u=new Fp.Scalar(n)}return u.range=s,u.source=n,a&&(u.type=a),l&&(u.tag=l),c.format&&(u.format=c.format),o&&(u.comment=o),u}function ck(e,t,r,i,n){if(r==="!")return e[Qt.SCALAR];let a=[];for(let s of e.tags)if(!s.collection&&s.tag===r)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(t))return s;let o=e.knownTags[r];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[Qt.SCALAR])}function lk({atKey:e,directives:t,schema:r},i,n,a){let o=r.tags.find(s=>(s.default===!0||e&&s.default==="key")&&s.test?.test(i))||r[Qt.SCALAR];if(r.compat){let s=r.compat.find(l=>l.default&&l.test?.test(i))??r[Qt.SCALAR];if(o.tag!==s.tag){let l=t.tagString(o.tag),c=t.tagString(s.tag),u=`Value may be parsed as either ${l} or ${c}`;a(n,"TAG_RESOLVE_FAILED",u,!0)}}return o}qp.composeScalar=sk});var zp=y(Wp=>{"use strict";function uk(e,t,r){if(t){r??(r=t.length);for(let i=r-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++i];n?.type==="space";)e+=n.source.length,n=t[++i];break}}return e}Wp.emptyScalarPosition=uk});var Up=y(al=>{"use strict";var dk=_i(),fk=_(),pk=Dp(),Gp=Vp(),hk=Br(),mk=zp(),vk={composeNode:Jp,composeEmptyNode:nl};function Jp(e,t,r,i){let n=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:l}=r,c,u=!0;switch(t.type){case"alias":c=gk(e,t,i),(s||l)&&i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Gp.composeScalar(e,t,l,i),s&&(c.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=pk.composeCollection(vk,e,t,r,i),s&&(c.anchor=s.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);i(t,"RESOURCE_EXHAUSTION",f)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",d),u=!1}}return c??(c=nl(e,t.offset,void 0,null,r,i)),s&&c.anchor===""&&i(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!fk.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(c.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?c.comment=o:c.commentBefore=o),e.options.keepSourceTokens&&u&&(c.srcToken=t),c}function nl(e,t,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:l},c){let u={type:"scalar",offset:mk.emptyScalarPosition(t,r,i),indent:-1,source:""},d=Gp.composeScalar(e,u,s,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),a&&(d.comment=a,d.range[2]=l),d}function gk({options:e},{offset:t,source:r,end:i},n){let a=new dk.Alias(r.substring(1));a.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+r.length,s=hk.resolveEnd(i,o,e.strict,n);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}al.composeEmptyNode=nl;al.composeNode=Jp});var Xp=y(Yp=>{"use strict";var wk=zi(),Kp=Up(),yk=Br(),bk=Ki();function Nk(e,t,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:t},e),l=new wk.Document(void 0,s),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=bk.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(l.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")),l.contents=n?Kp.composeNode(c,n,u,o):Kp.composeEmptyNode(c,u.end,i,null,u,o);let d=l.contents.range[2],f=yk.resolveEnd(a,d,!1,o);return f.comment&&(l.comment=f.comment),l.range=[r,d,f.offset],l}Yp.composeDoc=Nk});var sl=y(eh=>{"use strict";var kk=Fn("process"),Sk=Gs(),Ek=zi(),Yi=Ui(),Qp=_(),xk=Xp(),Ck=Br();function Xi(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r=="string"?r.length:1)]}function Zp(e){let t="",r=!1,i=!1;for(let n=0;n<e.length;++n){let a=e[n];switch(a[0]){case"#":t+=(t===""?"":i?`
105
105
 
106
106
  `:`
107
- `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:t,afterEmptyLine:i}}var gc=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=Ei(r);a?this.warnings.push(new Si.YAMLWarning(o,i,n)):this.errors.push(new Si.YAMLParseError(o,i,n))},this.directives=new _N.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,r){let{comment:i,afterEmptyLine:n}=qf(this.prelude);if(i){let a=t.contents;if(r)t.comment=t.comment?`${t.comment}
108
- ${i}`:i;else if(n||t.directives.docStart||!a)t.commentBefore=i;else if(Vf.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Vf.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
107
+ `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:t,afterEmptyLine:i}}var ol=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=Xi(r);a?this.warnings.push(new Yi.YAMLWarning(o,i,n)):this.errors.push(new Yi.YAMLParseError(o,i,n))},this.directives=new Sk.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,r){let{comment:i,afterEmptyLine:n}=Zp(this.prelude);if(i){let a=t.contents;if(r)t.comment=t.comment?`${t.comment}
108
+ ${i}`:i;else if(n||t.directives.docStart||!a)t.commentBefore=i;else if(Qp.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Qp.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
109
109
  ${s}`:i}else{let o=a.commentBefore;a.commentBefore=o?`${i}
110
- ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)t.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)t.warnings.push(this.warnings[a])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:qf(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,r=!1,i=-1){for(let n of t)yield*this.next(n);yield*this.end(r,i)}*next(t){switch(RN.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(r,i,n)=>{let a=Ei(t);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let r=IN.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let r=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new Si.YAMLParseError(Ei(t),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new Si.YAMLParseError(Ei(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=TN.resolveEnd(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
111
- ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new Si.YAMLParseError(Ei(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let i=Object.assign({_directives:this.directives},this.options),n=new AN.Document(void 0,i);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,r,r],this.decorate(n,!1),yield n}}};Wf.Composer=gc});var Jf=y(sa=>{"use strict";var jN=fc(),$N=hc(),ON=bi(),zf=si();function HN(e,t=!0,r){if(e){let i=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(s,a,o);else throw new ON.YAMLParseError([s,s+1],a,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return $N.resolveFlowScalar(e,t,i);case"block-scalar":return jN.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function DN(e,t){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=t,s=zf.stringifyString({type:o,value:e},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:i,source:`
110
+ ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)t.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)t.warnings.push(this.warnings[a])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Zp(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,r=!1,i=-1){for(let n of t)yield*this.next(n);yield*this.end(r,i)}*next(t){switch(kk.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(r,i,n)=>{let a=Xi(t);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let r=xk.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let r=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new Yi.YAMLParseError(Xi(t),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new Yi.YAMLParseError(Xi(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=Ck.resolveEnd(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
111
+ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new Yi.YAMLParseError(Xi(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let i=Object.assign({_directives:this.directives},this.options),n=new Ek.Document(void 0,i);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,r,r],this.decorate(n,!1),yield n}}};eh.Composer=ol});var ih=y(za=>{"use strict";var Pk=tl(),Rk=il(),_k=Ui(),th=ji();function Ak(e,t=!0,r){if(e){let i=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(s,a,o);else throw new _k.YAMLParseError([s,s+1],a,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Rk.resolveFlowScalar(e,t,i);case"block-scalar":return Pk.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function Ik(e,t){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=t,s=th.stringifyString({type:o,value:e},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:i,source:`
112
112
  `}];switch(s[0]){case"|":case">":{let c=s.indexOf(`
113
113
  `),u=s.substring(0,c),d=s.substring(c+1)+`
114
- `,f=[{type:"block-scalar-header",offset:a,indent:i,source:u}];return Gf(f,l)||f.push({type:"newline",offset:-1,indent:i,source:`
115
- `}),{type:"block-scalar",offset:a,indent:i,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:i,source:s,end:l};case"'":return{type:"single-quoted-scalar",offset:a,indent:i,source:s,end:l};default:return{type:"scalar",offset:a,indent:i,source:s,end:l}}}function LN(e,t,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in e?e.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=zf.stringifyString({type:o,value:t},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":BN(e,l);break;case'"':yc(e,l,"double-quoted-scalar");break;case"'":yc(e,l,"single-quoted-scalar");break;default:yc(e,l,"scalar")}}function BN(e,t){let r=t.indexOf(`
114
+ `,f=[{type:"block-scalar-header",offset:a,indent:i,source:u}];return rh(f,l)||f.push({type:"newline",offset:-1,indent:i,source:`
115
+ `}),{type:"block-scalar",offset:a,indent:i,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:i,source:s,end:l};case"'":return{type:"single-quoted-scalar",offset:a,indent:i,source:s,end:l};default:return{type:"scalar",offset:a,indent:i,source:s,end:l}}}function Tk(e,t,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in e?e.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=th.stringifyString({type:o,value:t},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":$k(e,l);break;case'"':cl(e,l,"double-quoted-scalar");break;case"'":cl(e,l,"single-quoted-scalar");break;default:cl(e,l,"scalar")}}function $k(e,t){let r=t.indexOf(`
116
116
  `),i=t.substring(0,r),n=t.substring(r+1)+`
117
- `;if(e.type==="block-scalar"){let a=e.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,e.source=n}else{let{offset:a}=e,o="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];Gf(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
118
- `});for(let l of Object.keys(e))l!=="type"&&l!=="offset"&&delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:s,source:n})}}function Gf(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function yc(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let i=e.props.slice(1),n=t.length;e.props[0].type==="block-scalar-header"&&(n-=e.props[0].source.length);for(let a of i)a.offset+=n;delete e.props,Object.assign(e,{type:r,source:t,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
119
- `};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let i="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(e))a!=="type"&&a!=="offset"&&delete e[a];Object.assign(e,{type:r,indent:i,source:t,end:n})}}}sa.createScalarToken=DN;sa.resolveAsScalar=HN;sa.setScalarValue=LN});var Kf=y(Uf=>{"use strict";var MN=e=>"type"in e?la(e):ca(e);function la(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=la(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=ca(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=ca(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=ca(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function ca({start:e,key:t,sep:r,value:i}){let n="";for(let a of e)n+=a.source;if(t&&(n+=la(t)),r)for(let a of r)n+=a.source;return i&&(n+=la(i)),n}Uf.stringify=MN});var Zf=y(Qf=>{"use strict";var Nc=Symbol("break visit"),FN=Symbol("skip children"),Yf=Symbol("remove item");function Ft(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),Xf(Object.freeze([]),e,t)}Ft.BREAK=Nc;Ft.SKIP=FN;Ft.REMOVE=Yf;Ft.itemAtPath=(e,t)=>{let r=e;for(let[i,n]of t){let a=r?.[i];if(a&&"items"in a)r=a.items[n];else return}return r};Ft.parentCollection=(e,t)=>{let r=Ft.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Xf(e,t,r){let i=r(t,e);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=t[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=Xf(Object.freeze(e.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===Nc)return Nc;s===Yf&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}Qf.visit=Ft});var ua=y(ae=>{"use strict";var bc=Jf(),VN=Kf(),qN=Zf(),kc="\uFEFF",Sc="",Ec="",xc="",WN=e=>!!e&&"items"in e,zN=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function GN(e){switch(e){case kc:return"<BOM>";case Sc:return"<DOC>";case Ec:return"<FLOW_END>";case xc:return"<SCALAR>";default:return JSON.stringify(e)}}function JN(e){switch(e){case kc:return"byte-order-mark";case Sc:return"doc-mode";case Ec:return"flow-error-end";case xc:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
117
+ `;if(e.type==="block-scalar"){let a=e.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,e.source=n}else{let{offset:a}=e,o="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];rh(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
118
+ `});for(let l of Object.keys(e))l!=="type"&&l!=="offset"&&delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:s,source:n})}}function rh(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function cl(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let i=e.props.slice(1),n=t.length;e.props[0].type==="block-scalar-header"&&(n-=e.props[0].source.length);for(let a of i)a.offset+=n;delete e.props,Object.assign(e,{type:r,source:t,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
119
+ `};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let i="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(e))a!=="type"&&a!=="offset"&&delete e[a];Object.assign(e,{type:r,indent:i,source:t,end:n})}}}za.createScalarToken=Ik;za.resolveAsScalar=Ak;za.setScalarValue=Tk});var ah=y(nh=>{"use strict";var jk=e=>"type"in e?Ja(e):Ga(e);function Ja(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=Ja(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=Ga(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=Ga(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=Ga(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function Ga({start:e,key:t,sep:r,value:i}){let n="";for(let a of e)n+=a.source;if(t&&(n+=Ja(t)),r)for(let a of r)n+=a.source;return i&&(n+=Ja(i)),n}nh.stringify=jk});var lh=y(ch=>{"use strict";var ll=Symbol("break visit"),Ok=Symbol("skip children"),oh=Symbol("remove item");function Zt(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),sh(Object.freeze([]),e,t)}Zt.BREAK=ll;Zt.SKIP=Ok;Zt.REMOVE=oh;Zt.itemAtPath=(e,t)=>{let r=e;for(let[i,n]of t){let a=r?.[i];if(a&&"items"in a)r=a.items[n];else return}return r};Zt.parentCollection=(e,t)=>{let r=Zt.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function sh(e,t,r){let i=r(t,e);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=t[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=sh(Object.freeze(e.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===ll)return ll;s===oh&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}ch.visit=Zt});var Ua=y(ce=>{"use strict";var ul=ih(),Hk=ah(),Dk=lh(),dl="\uFEFF",fl="",pl="",hl="",Lk=e=>!!e&&"items"in e,Bk=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Mk(e){switch(e){case dl:return"<BOM>";case fl:return"<DOC>";case pl:return"<FLOW_END>";case hl:return"<SCALAR>";default:return JSON.stringify(e)}}function Fk(e){switch(e){case dl:return"byte-order-mark";case fl:return"doc-mode";case pl:return"flow-error-end";case hl:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
120
120
  `:case`\r
121
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}ae.createScalarToken=bc.createScalarToken;ae.resolveAsScalar=bc.resolveAsScalar;ae.setScalarValue=bc.setScalarValue;ae.stringify=VN.stringify;ae.visit=qN.visit;ae.BOM=kc;ae.DOCUMENT=Sc;ae.FLOW_END=Ec;ae.SCALAR=xc;ae.isCollection=WN;ae.isScalar=zN;ae.prettyToken=GN;ae.tokenType=JN});var Rc=y(tp=>{"use strict";var xi=ua();function Pe(e){switch(e){case void 0:case" ":case`
122
- `:case"\r":case" ":return!0;default:return!1}}var ep=new Set("0123456789ABCDEFabcdef"),UN=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),da=new Set(",[]{}"),KN=new Set(` ,[]{}
123
- \r `),Cc=e=>!e||KN.has(e),Pc=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,r=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let t=this.pos,r=this.buffer[t];for(;r===" "||r===" ";)r=this.buffer[++t];return!r||r==="#"||r===`
121
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}ce.createScalarToken=ul.createScalarToken;ce.resolveAsScalar=ul.resolveAsScalar;ce.setScalarValue=ul.setScalarValue;ce.stringify=Hk.stringify;ce.visit=Dk.visit;ce.BOM=dl;ce.DOCUMENT=fl;ce.FLOW_END=pl;ce.SCALAR=hl;ce.isCollection=Lk;ce.isScalar=Bk;ce.prettyToken=Mk;ce.tokenType=Fk});var gl=y(dh=>{"use strict";var Qi=Ua();function je(e){switch(e){case void 0:case" ":case`
122
+ `:case"\r":case" ":return!0;default:return!1}}var uh=new Set("0123456789ABCDEFabcdef"),qk=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ka=new Set(",[]{}"),Vk=new Set(` ,[]{}
123
+ \r `),ml=e=>!e||Vk.has(e),vl=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,r=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let t=this.pos,r=this.buffer[t];for(;r===" "||r===" ";)r=this.buffer[++t];return!r||r==="#"||r===`
124
124
  `?!0:r==="\r"?this.buffer[t+1]===`
125
125
  `:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let r=this.buffer[t];if(this.indentNext>0){let i=0;for(;r===" ";)r=this.buffer[++i+t];if(r==="\r"){let n=this.buffer[i+t+1];if(n===`
126
126
  `||!n&&!this.atEnd)return t+i+1}return r===`
127
- `||i>=this.indentNext||!r&&!this.atEnd?t+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&Pe(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
128
- `,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===xi.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let r=t.length,i=t.indexOf("#");for(;i!==-1;){let a=t[i-1];if(a===" "||a===" "){r=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let a=t[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-r),yield*this.pushNewline(),"stream"}return yield xi.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&Pe(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Pe(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&Pe(r)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(t[r]){case"#":yield*this.pushCount(t.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Cc),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,r,i=-1;do t=yield*this.pushNewline(),t>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(t+r>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&Pe(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield xi.FLOW_END,yield*this.parseLineStart();let a=0;for(;n[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Cc),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Pe(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),r=this.buffer.indexOf(t,this.pos+1);if(t==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
127
+ `||i>=this.indentNext||!r&&!this.atEnd?t+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&je(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
128
+ `,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===Qi.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let r=t.length,i=t.indexOf("#");for(;i!==-1;){let a=t[i-1];if(a===" "||a===" "){r=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let a=t[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-r),yield*this.pushNewline(),"stream"}return yield Qi.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&je(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!je(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&je(r)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(t[r]){case"#":yield*this.pushCount(t.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(ml),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,r,i=-1;do t=yield*this.pushNewline(),t>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(t+r>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&je(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Qi.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(ml),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||je(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),r=this.buffer.indexOf(t,this.pos+1);if(t==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
129
129
  `,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=i.indexOf(`
130
- `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let t=this.pos;for(;;){let r=this.buffer[++t];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>Pe(r)||r==="#")}*parseBlockScalar(){let t=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
130
+ `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let t=this.pos;for(;;){let r=this.buffer[++t];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>je(r)||r==="#")}*parseBlockScalar(){let t=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
131
131
  `:t=a,r=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
132
132
  `)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(t+1);if(a===-1)break;t=this.buffer.indexOf(`
133
133
  `,a)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let n=t+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
134
134
  `;)i=this.buffer[++n];t=n-1}else if(!this.blockScalarKeep)do{let a=t-1,o=this.buffer[a];o==="\r"&&(o=this.buffer[--a]);let s=a;for(;o===" ";)o=this.buffer[--a];if(o===`
135
- `&&a>=this.pos&&a+1+r>s)t=a;else break}while(!0);return yield xi.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(Pe(a)||t&&da.has(a))break;r=i}else if(Pe(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
135
+ `&&a>=this.pos&&a+1+r>s)t=a;else break}while(!0);return yield Qi.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(je(a)||t&&Ka.has(a))break;r=i}else if(je(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
136
136
  `?(i+=1,n=`
137
- `,a=this.buffer[i+1]):r=i),a==="#"||t&&da.has(a))break;if(n===`
138
- `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&da.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield xi.SCALAR,yield*this.pushToIndex(r+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,r){let i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(Cc),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(Pe(i)||r&&da.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,r=this.buffer[t];for(;!Pe(r)&&r!==">";)r=this.buffer[++t];return yield*this.pushToIndex(r===">"?t+1:t,!1)}else{let t=this.pos+1,r=this.buffer[t];for(;r;)if(UN.has(r))r=this.buffer[++t];else if(r==="%"&&ep.has(this.buffer[t+1])&&ep.has(this.buffer[t+2]))r=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`
137
+ `,a=this.buffer[i+1]):r=i),a==="#"||t&&Ka.has(a))break;if(n===`
138
+ `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&Ka.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Qi.SCALAR,yield*this.pushToIndex(r+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,r){let i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(ml),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(je(i)||r&&Ka.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,r=this.buffer[t];for(;!je(r)&&r!==">";)r=this.buffer[++t];return yield*this.pushToIndex(r===">"?t+1:t,!1)}else{let t=this.pos+1,r=this.buffer[t];for(;r;)if(qk.has(r))r=this.buffer[++t];else if(r==="%"&&uh.has(this.buffer[t+1])&&uh.has(this.buffer[t+2]))r=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`
139
139
  `?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===`
140
- `?yield*this.pushCount(2):0}*pushSpaces(t){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||t&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(t){let r=this.pos,i=this.buffer[r];for(;!t(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};tp.Lexer=Pc});var Ac=y(rp=>{"use strict";var _c=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<t?r=a+1:i=a}if(this.lineStarts[r]===t)return{line:r+1,col:1};if(r===0)return{line:0,col:t};let n=this.lineStarts[r-1];return{line:r,col:t-n+1}}}};rp.LineCounter=_c});var Tc=y(sp=>{"use strict";var YN=sn("process"),ip=ua(),XN=Rc();function Ct(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function np(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function op(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function fa(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Nr(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function pa(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function ap(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!Ct(t.start,"explicit-key-ind")&&!Ct(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,op(t.value)?t.value.end?pa(t.value.end,t.sep):t.value.end=t.sep:pa(t.start,t.sep),delete t.sep)}var Ic=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new XN.Lexer,this.onNewLine=t}*parse(t,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(t,r))yield*this.next(i);r||(yield*this.end())}*next(t){if(this.source=t,YN.env.LOG_TOKENS&&console.log("|",ip.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let r=ip.tokenType(t);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let i=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let r=t??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let i=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in i?i.indent:0:r.type==="flow-collection"&&i.type==="document"&&(r.indent=0),r.type==="flow-collection"&&ap(r),i.type){case"document":i.value=r;break;case"block-scalar":i.props.push(r);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=r;else{Object.assign(n,{key:r,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:r}):n.value=r;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:r,sep:[]}):n.sep?n.value=r:Object.assign(n,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let n=r.items[r.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&np(n.start)===-1&&(r.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<r.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{np(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let r=this.startBlockValue(t);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let r=fa(this.peek(2)),i=Nr(r),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:i,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
140
+ `?yield*this.pushCount(2):0}*pushSpaces(t){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||t&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(t){let r=this.pos,i=this.buffer[r];for(;!t(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};dh.Lexer=vl});var yl=y(fh=>{"use strict";var wl=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<t?r=a+1:i=a}if(this.lineStarts[r]===t)return{line:r+1,col:1};if(r===0)return{line:0,col:t};let n=this.lineStarts[r-1];return{line:r,col:t-n+1}}}};fh.LineCounter=wl});var Nl=y(gh=>{"use strict";var Wk=Fn("process"),ph=Ua(),zk=gl();function Dt(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function hh(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function vh(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Ya(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Mr(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function Xa(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function mh(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!Dt(t.start,"explicit-key-ind")&&!Dt(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,vh(t.value)?t.value.end?Xa(t.value.end,t.sep):t.value.end=t.sep:Xa(t.start,t.sep),delete t.sep)}var bl=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new zk.Lexer,this.onNewLine=t}*parse(t,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(t,r))yield*this.next(i);r||(yield*this.end())}*next(t){if(this.source=t,Wk.env.LOG_TOKENS&&console.log("|",ph.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let r=ph.tokenType(t);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let i=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let r=t??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let i=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in i?i.indent:0:r.type==="flow-collection"&&i.type==="document"&&(r.indent=0),r.type==="flow-collection"&&mh(r),i.type){case"document":i.value=r;break;case"block-scalar":i.props.push(r);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=r;else{Object.assign(n,{key:r,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:r}):n.value=r;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:r,sep:[]}):n.sep?n.value=r:Object.assign(n,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let n=r.items[r.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&hh(n.start)===-1&&(r.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<r.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{hh(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let r=this.startBlockValue(t);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let r=Ya(this.peek(2)),i=Mr(r),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:i,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
141
141
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
142
- `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){pa(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let i=!this.onKeyLine&&this.indent===t.indent,n=i&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&r.sep&&!r.value){let o=[];for(let s=0;s<r.sep.length;++s){let l=r.sep[s];switch(l.type){case"newline":o.push(s);break;case"space":break;case"comment":l.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||r.value?(a.push(this.sourceToken),t.items.push({start:a}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):n||r.value?(a.push(this.sourceToken),t.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ct(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(op(r.key)&&!Ct(r.sep,"newline")){let o=Nr(r.start),s=r.key,l=r.sep;l.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:l}]})}else a.length>0?r.sep=r.sep.concat(a,this.sourceToken):r.sep.push(this.sourceToken);else if(Ct(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Nr(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||n?t.items.push({start:a,key:null,sep:[this.sourceToken]}):Ct(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||r.value?(t.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(t);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!Ct(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){pa(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=t.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;r.value||Ct(r.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>t.indent){let i=this.startBlockValue(t);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let r=t.items[t.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?t.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!r||r.value?t.items.push({start:[],key:n,sep:[]}):r.sep?this.stack.push(n):Object.assign(r,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===t.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=fa(i),a=Nr(n);ap(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:a,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let r=this.source.indexOf(`
142
+ `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Xa(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let i=!this.onKeyLine&&this.indent===t.indent,n=i&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&r.sep&&!r.value){let o=[];for(let s=0;s<r.sep.length;++s){let l=r.sep[s];switch(l.type){case"newline":o.push(s);break;case"space":break;case"comment":l.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||r.value?(a.push(this.sourceToken),t.items.push({start:a}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):n||r.value?(a.push(this.sourceToken),t.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Dt(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(vh(r.key)&&!Dt(r.sep,"newline")){let o=Mr(r.start),s=r.key,l=r.sep;l.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:l}]})}else a.length>0?r.sep=r.sep.concat(a,this.sourceToken):r.sep.push(this.sourceToken);else if(Dt(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Mr(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||n?t.items.push({start:a,key:null,sep:[this.sourceToken]}):Dt(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||r.value?(t.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(t);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!Dt(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Xa(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=t.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;r.value||Dt(r.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>t.indent){let i=this.startBlockValue(t);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let r=t.items[t.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?t.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!r||r.value?t.items.push({start:[],key:n,sep:[]}):r.sep?this.stack.push(n):Object.assign(r,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===t.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=Ya(i),a=Mr(n);mh(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:a,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let r=this.source.indexOf(`
143
143
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
144
- `,r)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=fa(t),i=Nr(r);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=fa(t),i=Nr(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};sp.Parser=Ic});var fp=y(Pi=>{"use strict";var cp=wc(),QN=wi(),Ci=bi(),ZN=vs(),eb=R(),tb=Ac(),lp=Tc();function up(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new tb.LineCounter||null,prettyErrors:t}}function rb(e,t={}){let{lineCounter:r,prettyErrors:i}=up(t),n=new lp.Parser(r?.addNewLine),a=new cp.Composer(t),o=Array.from(a.compose(n.parse(e)));if(i&&r)for(let s of o)s.errors.forEach(Ci.prettifyError(e,r)),s.warnings.forEach(Ci.prettifyError(e,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function dp(e,t={}){let{lineCounter:r,prettyErrors:i}=up(t),n=new lp.Parser(r?.addNewLine),a=new cp.Composer(t),o=null;for(let s of a.compose(n.parse(e),!0,e.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new Ci.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(Ci.prettifyError(e,r)),o.warnings.forEach(Ci.prettifyError(e,r))),o}function ib(e,t,r){let i;typeof t=="function"?i=t:r===void 0&&t&&typeof t=="object"&&(r=t);let n=dp(e,r);if(!n)return null;if(n.warnings.forEach(a=>ZN.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},r))}function nb(e,t,r){let i=null;if(typeof t=="function"||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}return eb.isDocument(e)&&!i?e.toString(r):new QN.Document(e,i,r).toString(r)}Pi.parse=ib;Pi.parseAllDocuments=rb;Pi.parseDocument=dp;Pi.stringify=nb});var Ze=y(A=>{"use strict";var ab=wc(),ob=wi(),sb=Qs(),jc=bi(),cb=ri(),Pt=R(),lb=kt(),ub=M(),db=Et(),fb=xt(),pb=ua(),hb=Rc(),mb=Ac(),vb=Tc(),ha=fp(),pp=Qr();A.Composer=ab.Composer;A.Document=ob.Document;A.Schema=sb.Schema;A.YAMLError=jc.YAMLError;A.YAMLParseError=jc.YAMLParseError;A.YAMLWarning=jc.YAMLWarning;A.Alias=cb.Alias;A.isAlias=Pt.isAlias;A.isCollection=Pt.isCollection;A.isDocument=Pt.isDocument;A.isMap=Pt.isMap;A.isNode=Pt.isNode;A.isPair=Pt.isPair;A.isScalar=Pt.isScalar;A.isSeq=Pt.isSeq;A.Pair=lb.Pair;A.Scalar=ub.Scalar;A.YAMLMap=db.YAMLMap;A.YAMLSeq=fb.YAMLSeq;A.CST=pb;A.Lexer=hb.Lexer;A.LineCounter=mb.LineCounter;A.Parser=vb.Parser;A.parse=ha.parse;A.parseAllDocuments=ha.parseAllDocuments;A.parseDocument=ha.parseDocument;A.stringify=ha.stringify;A.visit=pp.visit;A.visitAsync=pp.visitAsync});function yb(e,t){return $c[e][t]}function ma(e){return mp.get(e.trim().toLocaleLowerCase("en-US"))??null}function va(e){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${yb(e,r)}
145
- `).join(`
146
- `)}var $c,gb,wb,mp,hp,Vt=S(()=>{"use strict";$c={en:{outcome:"Outcome",scope:"Scope",nonGoals:"Non-goals",acceptanceExamples:"Acceptance examples",constraints:"Constraints and invariants",decisions:"Decisions",openQuestions:"Open questions",verificationExpectations:"Verification expectations"},"zh-CN":{outcome:"目标",scope:"范围",nonGoals:"非目标",acceptanceExamples:"验收示例",constraints:"约束与不变量",decisions:"决策",openQuestions:"待解决问题",verificationExpectations:"验证预期"}},gb={en:{verification:"Verification",currentResult:"Current result",acceptance:"Acceptance",checks:"Checks",blockers:"Blockers",risks:"Risks and skipped work",previousIterations:"Previous iterations",conclusion:"Conclusion"},"zh-CN":{verification:"验证",currentResult:"当前结果",acceptance:"验收",checks:"检查",blockers:"阻塞项",risks:"风险与跳过的工作",previousIterations:"之前的迭代",conclusion:"结论"}},wb={en:{acceptanceEvidence:"Acceptance evidence",commandsAndResults:"Commands and results",skippedChecks:"Skipped checks",specConsistency:"Spec consistency",knownLimitationsAndRisks:"Known limitations and risks",conclusion:"Conclusion"},"zh-CN":{acceptanceEvidence:"验收证据",commandsAndResults:"命令与结果",skippedChecks:"跳过的检查",specConsistency:"规格一致性",knownLimitationsAndRisks:"已知限制与风险",conclusion:"结论"}},mp=new Map,hp=new Map;for(let e of Object.keys($c)){for(let[t,r]of Object.entries($c[e]))mp.set(r.toLocaleLowerCase("en-US"),t);for(let[t,r]of Object.entries(gb[e]))hp.set(r.toLocaleLowerCase("en-US"),t);for(let[t,r]of Object.entries(wb[e]))hp.set(r.toLocaleLowerCase("en-US"),t)}});import Rt from"path";function Eb(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim();if(r.length===0||Rt.posix.isAbsolute(r)||Rt.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${t} must be a project-relative path`);if(r===".")return[];let i=r.replaceAll("\\","/").split("/");if(i.some(n=>n===".."))throw new Error(`${t} must stay inside the project root`);if(i.some(n=>n===""||n==="."))throw new Error(`${t} must not contain empty or dot path segments`);return i}function qt(e){let t=Eb(e,"native.artifact_root");return t.length===0?".":t.join("/")}function Sp(e,t="docs"){let r=e??t;if(r!=="legacy"&&r!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return r}function Na(e,t,r=!1){if(typeof e!="string")throw new Error(`${t} must be a string`);let i=e.trim().replaceAll("\\","/");if(i.length===0||Rt.posix.isAbsolute(i)||Rt.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${t} must be relative to its declared path base`);let n=i.split("/");if(n.some(a=>a===".."))throw new Error(`${t} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${t} must not contain empty or dot path segments`);if(!r&&/[*?]/u.test(i))throw new Error(`${t} cannot contain wildcards`);return n.join("/")}function et(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Ep(e,t,r){let i=e??t;if(i!=="en"&&i!=="zh-CN")throw new Error(`${r} must be en or zh-CN`);return i}function Dc(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||e.startsWith("/")||e.split("/").includes(".."))throw new Error(`${t} contains an unsafe pattern`);if(e.length>wa)throw new Error(`${t} exceeds ${wa} characters`);let r=0;for(let i=0;i<e.length;i+=1)e[i]==="?"?r+=1:e[i]==="*"&&(r+=1,e[i+1]==="*"&&(i+=1));if(r>ya)throw new Error(`${t} contains more than ${ya} wildcard tokens`);return e}function Np(e,t,r){if(e===void 0)return[...r];if(!Array.isArray(e))throw new Error(`${t} contains an unsafe pattern`);return[...new Set(e.map(i=>Dc(i,t)))].sort((i,n)=>i.localeCompare(n,"en"))}function Ri(e,t,r){let i=e??t;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${r} must be a positive integer`);return i}function bp(e,t,r){let i=Ri(e,t,r);if(i>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${r} is too large to convert to bytes safely`);return i}function xb(e){if(e===void 0)return{...oe,include:[...oe.include],exclude:[...oe.exclude]};let t=et(e,"native.snapshot");return{include:Np(t.include,"native.snapshot.include",oe.include),exclude:Np(t.exclude,"native.snapshot.exclude",oe.exclude),max_files:Ri(t.max_files,oe.max_files,"native.snapshot.max_files"),max_total_bytes:Ri(t.max_total_bytes,oe.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Ri(t.max_duration_ms,oe.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:Ri(t.max_selection_records,oe.max_selection_records,"native.snapshot.max_selection_records")}}function Cb(e){if(e===void 0)return;let t=et(e,"native.pending_root_move"),r=t.id,i=t.from_artifact_root,n=t.to_artifact_root,a=t.stage;if(typeof r!="string"||!/^[a-f0-9-]{8,}$/u.test(r))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(t.cleanup!==void 0){let s=et(t.cleanup,"native.pending_root_move.cleanup"),l=s.kind,c=s.state,u=s.manifest_hash;if(l!=="forward-source"&&l!=="restart-staging"&&l!=="rollback-destination"&&l!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(c!=="prepared"&&c!=="quarantined"&&c!=="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:l,state:c,manifestHash:u}}return{id:r,fromArtifactRoot:qt(i),toArtifactRoot:qt(n),stage:a,...o?{cleanup:o}:{}}}function Pb(e){if(e===void 0)return;let t=et(e,"native.finish");if(t.pull_request===void 0)return{};let r=et(t.pull_request,"native.finish.pull_request");if(r.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(r.command)||r.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(r.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=r.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(Rt.posix.isAbsolute(i[0])||Rt.win32.isAbsolute(i[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=r.timeout_ms??Nb;if(!Number.isSafeInteger(n)||n<1||n>yp)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${yp}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function Rb(e,t={}){let r=et(e,"native"),i=r.artifact_root??(t.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let n=r.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=r.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=r.max_verify_failures??Hc;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=r.document_writes??"allow";if(s!=="allow"&&s!=="revert")throw new Error("native.document_writes must be allow or revert");let l=Cb(r.pending_root_move),c=Pb(r.finish);return{artifact_root:qt(i),language:Ep(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,...s==="revert"?{document_writes:s}:{},snapshot:xb(r.snapshot),...c?{finish:c}:{},...l?{pending_root_move:l}:{}}}function _b(e){let t=et(e,"classic"),r=t.context_compression??"off";if(r!=="off"&&r!=="beta")throw new Error("classic.context_compression must be off or beta");let i=t.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=t.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");let a=t.document_evidence??"neutral";if(a!=="neutral"&&a!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:Sp(t.artifact_layout),language:Ep(t.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n,...a==="strict"?{document_evidence:a}:{}}}function Ab(e){let r=et(e,"hook").allow_paths??[];if(!Array.isArray(r))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(r.map((i,n)=>Na(i,`hook.allow_paths[${n}]`)))]}}function Ib(e){if(e===void 0)return{...ga};let t=et(e,"memory"),r=t.learning??ga.learning,i=t.retrieval??ga.retrieval;if(typeof r!="boolean")throw new Error("memory.learning must be true or false");if(typeof i!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:r,retrieval:i}}function Lc(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Tb(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim();if(r.length===0||r.includes("\\")||r.includes("\0")||Rt.posix.isAbsolute(r)||Rt.win32.isAbsolute(r)||r.startsWith("~")||r.split("/").some(n=>n===""||n==="."||n===".."))throw new Error(`${t} must be a safe project-relative glob`);if(!r.toLowerCase().endsWith(".md"))throw new Error(`${t} must target a Markdown file ending in .md`);if(r.length>vp)throw new Error(`${t} exceeds ${vp} characters`);let i=0;for(let n=0;n<r.length;n+=1)r[n]==="?"?i+=1:r[n]==="*"&&(i+=1,r[n+1]==="*"&&(n+=1));if(i>gp)throw new Error(`${t} contains more than ${gp} wildcard tokens`);return r}function jb(e){let t=Lc(e,"knowledge.local"),r=t.include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");let i={include:[...new Set(r.map((n,a)=>Tb(n,`knowledge.local.include[${a}]`)))],max_file_mb:bp(t.max_file_mb,wp.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:bp(t.max_total_mb,wp.max_total_mb,"knowledge.local.max_total_mb")};if(i.max_file_mb>i.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return i}function $b(e){if(typeof e!="string"||e.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let t;try{t=new URL(e)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let r=t.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=r==="localhost"||r==="127.0.0.1"||r==="::1";if(t.protocol!=="https:"&&!(t.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return t.toString()}function Ob(e){let t=Lc(e,"knowledge.remote"),r=$b(t.endpoint),i=t.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let n=t.scope;if(n!==void 0&&(typeof n!="string"||n.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let a=t.timeout_ms??5e3;if(typeof a!="number"||!Number.isSafeInteger(a)||a<100||a>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:r,...i===void 0?{}:{token_env:i},...n===void 0?{}:{scope:n},timeout_ms:a}}function Hb(e){if(e===void 0)return{...kp};let t=Lc(e,"knowledge"),r=t.provider??"local";if(r!=="local"&&r!=="remote")throw new Error("knowledge.provider must be local or remote");let i=t.local===void 0?void 0:jb(t.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=t.remote===void 0?void 0:Ob(t.remote);if(n===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:r,...i?{local:i}:{},remote:n}}function Db(e){let t=e??!0;if(typeof t!="boolean")throw new Error("ambient_resume must be true or false");return t}function Lb(e,t,r,i,n,a,o,s){let l=e.schema!==void 0;if(!(l||e.default_workflow!==void 0||e.workflows!==void 0||!s.allowPartialProject&&e.native!==void 0)||s.allowPartialProject&&!l)return null;if(e.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(e.default_workflow!=="native"&&e.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let u=e.workflows??[e.default_workflow];if(!Array.isArray(u)||u.length===0||u.some(f=>f!=="native"&&f!=="classic"))throw new Error("workflows must contain native and/or classic");let d=[...new Set(u)];if(!d.includes(e.default_workflow))throw new Error("workflows must include default_workflow");if(d.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:e.default_workflow,workflows:d,ambient_resume:o,...t?{hook:t}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function Ai(e,t={}){let r=(0,Oc.parseDocument)(e,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${r.errors[0].message}`);let i=r.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=i,a=Db(n.ambient_resume),o=n.hook===void 0?void 0:Ab(n.hook),s=Ib(n.memory),l=Hb(n.knowledge),c=n.native===void 0?void 0:Rb(n.native,{allowMissingArtifactRoot:t.allowMissingNativeFields}),u=n.classic===void 0?void 0:_b(n.classic),d=Lb(n,o,s,l,c,u,a,{allowPartialProject:t.allowPartialProject??!1});return{value:n,config:d,ambient_resume:a,memory:s,knowledge:l,...o?{hook:o}:{},...c?{native:c}:{},...u?{classic:u}:{}}}function ba(e="docs",t="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...ga},knowledge:{...kp},native:{artifact_root:qt(e),language:t,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Hc,snapshot:{...oe,include:[...oe.include],exclude:[...oe.exclude]}}}}var Oc,_i,wa,ya,vp,gp,Hc,ga,wp,kp,Nb,yp,bb,kb,Sb,oe,_t=S(()=>{"use strict";Oc=mt(Ze(),1),_i=Number.MAX_SAFE_INTEGER,wa=1024,ya=64,vp=1024,gp=64,Hc=5,ga={learning:!0,retrieval:!0},wp={include:[],max_file_mb:1,max_total_mb:32},kp={provider:"local"},Nb=12e4,yp=6e5,bb=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".devin/skills/**",".dsh/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".omp/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],kb=["**/.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"],Sb=[...bb,...kb].sort((e,t)=>e.localeCompare(t,"en")),oe={include:["**/*"],exclude:[...Sb],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});import{constants as ka,promises as Wt}from"fs";function Bc(e){return"birthtimeNs"in e&&typeof e.birthtimeNs=="bigint"?e.birthtimeNs:e.birthtimeMs}function xp(e){return"ctimeNs"in e&&typeof e.ctimeNs=="bigint"?e.ctimeNs:e.ctimeMs}function Ii(e){return{dev:e.dev,ino:e.ino,birthtime:Bc(e)}}function Sa(e,t){let r=Ii(e),i=Ii(t);return Se(r,i)?j(r,i):j(r,i)&&Bc(e)===Bc(t)&&xp(e)===xp(t)&&e.size===t.size}async function br(e,t,r={}){if(!Number.isSafeInteger(t)||t<1)throw new Error("race-safe read byte limit must be a positive integer");let i=r.label??"file",n=r.bigint===!0,a=await Wt.lstat(e,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new Re("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(t))throw new Re("too-large",`${i} exceeds ${t} bytes`);let o=await Wt.realpath(e);await r.verify?.("pre-open",{realPath:o,identity:Ii(a)});let s=process.platform==="win32"?ka.O_RDONLY:ka.O_RDONLY|ka.O_NOFOLLOW|ka.O_NONBLOCK,l;try{l=await Wt.open(e,s)}catch(c){throw c.code==="ELOOP"?new Re("not-regular-file",`${i} must be a regular file`,{cause:c}):c}try{let[c,u,d]=await Promise.all([l.stat({bigint:n}),Wt.lstat(e,{bigint:n}),Wt.realpath(e)]);if(!c.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!Sa(a,c)||!Sa(a,u))throw new Re("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:d,identity:Ii(c)}),await r.hooks?.afterOpen?.();let f=[],h=0,m=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let w=t+1-h,{bytesRead:N}=await l.read(m,0,Math.min(m.length,w),null);if(N===0)break;if(h+=N,h>t)throw new Re("too-large",`${i} exceeds ${t} bytes`);f.push(Buffer.from(m.subarray(0,N)))}await r.hooks?.beforeFinalCheck?.();let[p,v,g]=await Promise.all([l.stat({bigint:n}),Wt.lstat(e,{bigint:n}),Wt.realpath(e)]);if(!v.isFile()||v.isSymbolicLink()||g!==o||!Sa(a,p)||!Sa(a,v))throw new Re("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:g,identity:Ii(p)}),{bytes:Buffer.concat(f,h),stat:p,realPath:g}}finally{await l.close()}}var Re,Ti=S(()=>{"use strict";Kr();Re=class extends Error{reason;constructor(t,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=t}}});import{promises as Ea}from"fs";import At from"path";function Bb(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function Mc(e,t){let r=At.relative(e,t);return r===""||!At.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${At.sep}`)}async function Cp(e,t){let r=At.resolve(e),i=await Ea.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${t} project root must be a real directory`);return Ea.realpath(r)}async function Pp(e,t,r,i){let n=e;for(let a=0;a<r.length;a++){n=At.join(n,r[a]);let o;try{o=await Ea.lstat(n)}catch(u){if(Bb(u))return{exists:!1,kind:"missing"};throw u}let s=At.relative(e,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${s}`);let l=a===r.length-1;if(!l&&!o.isDirectory())throw new Error(`${i.label} ancestor ${s} must be a real directory`);if(l&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let c=await Ea.realpath(n);if(!Mc(t,c))throw new Error(`${i.label} resolves outside the project root`);if(l)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function kr(e,t,r){let i=Na(t,r.label),n=At.resolve(e),a=await Cp(n,r.label),o=i.split("/"),s=At.resolve(n,...o);if(!Mc(n,s))throw new Error(`${r.label} must stay inside the project root`);let l=await Pp(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:l.exists,kind:l.kind}}async function tt(e,t,r,i){let n=await kr(e,t,{label:i.label,expected:"file"});if(!n.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let a=await Cp(n.projectRoot,i.label);return br(n.target,r,{...i,verify:async(o,s)=>{if(!Mc(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await Pp(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var It=S(()=>{"use strict";Ti();_t()});import{createHash as Mb}from"crypto";function Fb(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}async function xa(e,t={}){return(await Ca(e,t)).document}async function Vb(e){try{return(await tt(e,ji,_i,{label:ji})).bytes}catch(t){if(Fb(t))return null;throw t}}function qb(e){return e?{exists:!0,sha256:Mb("sha256").update(e).digest("hex")}:{exists:!1,sha256:null}}async function Ca(e,t={}){let r=await Vb(e);return{document:r?Ai(r.toString("utf8"),t):null,identity:qb(r)}}async function Fc(e){return(await xa(e))?.config??null}var ji,Sr=S(()=>{"use strict";_t();It();ji=".comet/config.yaml"});var Er=S(()=>{"use strict";Xo();Kr()});var D_,Vc=S(()=>{"use strict";Er();Sr();It();D_=16*1024});var zc=S(()=>{"use strict";Er();_t();Sr();It();Vc()});import{existsSync as _p,promises as zt}from"fs";import _ from"path";import Ub from"os";async function Gc(e){try{return await zt.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Yb(e){try{let t=await zt.readFile(e,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(t)}catch(t){if(t.code==="ENOENT")return!1;throw t}}function Cr(e,t){let r=_.relative(e,t);return r===""||!_.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${_.sep}`)}async function xr(e){let t=[],r=e;for(;!await Gc(r);){let n=_.dirname(r);if(n===r)break;t.push(_.basename(r)),r=n}let i=await zt.realpath(r);return _.resolve(i,...t.reverse())}async function Jc(e){try{return(await zt.lstat(e)).isSymbolicLink()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Ra(e){let t=_.resolve(e);try{(await zt.stat(t)).isDirectory()||(t=_.dirname(t))}catch(n){if(n.code!=="ENOENT")throw n}let r=t,i=_.resolve(Ub.homedir());for(;;){if(!(t===i&&r!==i)){let o=_.join(t,...Pa.split("/")),s=t===r||await Yb(o);if(await Gc(o)&&s)return t}if(await Gc(_.join(t,".git")))return t;let a=_.dirname(t);if(a===t)return r;t=a}}function _a(e){return qt(e)}async function Xb(e,t){let r=_a(t),i=_.resolve(e,...r.split("/")),n=await zt.realpath(e),a=await xr(i);if(!Cr(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Pr(e,t){let r=_a(t),i=await Xb(e,r),n=_.join(i,"comet");if(await Jc(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([xr(i),xr(n)]);if(!Cr(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=_.resolve(e),l=_.join(s,".comet","runtime","native");if(await Jc(l))throw new Error("The Native Runtime root must not be a symbolic link");let[c,u]=await Promise.all([zt.realpath(s),xr(l)]);if(!Cr(c,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:_.join(e,...Pa.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:_.join(n,"specs"),changesDir:_.join(n,"changes"),archiveDir:_.join(n,"archive"),runtimeDir:l,changesRuntimeDir:_.join(l,"changes"),locksDir:_.join(l,"locks"),transactionsDir:_.join(l,"transactions")}}function Ap(e){if(!Kb.test(e))throw new Error(`Invalid Native change name: ${e}`)}function _e(e,t){Ap(t);let r=_.join(e.changesRuntimeDir,t);if(!X(e.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function Uc(e,t){Ap(t);let r=_.join(e.changesDir,t,"runtime");if(!X(e.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Ae(e,t){let r=_e(e,t);if(_p(r))return r;let i=Uc(e,t);return _p(i)?i:r}function Kc(e,t){if(!t.startsWith("runtime/")||_.isAbsolute(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Native Runtime ref: ${t}`);let r=_.resolve(e,...t.slice(8).split("/"));if(!X(e,r))throw new Error(`Native Runtime ref escaped: ${t}`);return r}function ce(e,t){let r=_.resolve(t);if(X(e.runtimeDir,r))return e.runtimeDir;if(X(e.nativeRoot,r))return e.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${t}`)}function X(e,t){return Cr(_.resolve(e),_.resolve(t))}async function I(e,t){let r=_.resolve(e),i=_.resolve(t);if(!Cr(r,i))throw new Error(`Path is outside the Native root: ${t}`);if(await Jc(r))throw new Error(`Native root must not be a symbolic link: ${e}`);let[n,a]=await Promise.all([xr(r),xr(i)]);if(!Cr(n,a))throw new Error(`Path resolves outside the Native root: ${t}`);return i}var Pa,Kb,H=S(()=>{"use strict";_t();Pa=".comet/config.yaml",Kb=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});function Zb(e="docs",t="en"){return ba(e,t)}async function Ie(e){let t=(await xa(e))?.config??null;return t?.native?t:null}async function Aa(e){let t=await Ie(e);if(t?.native.pending_root_move)throw new Error(`Native root move ${t.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function Ip(e){let t=await Ra(e.startPath),r=await Ie(t);if(!r&&e.allowMissingConfig===!1)throw new Error(`${Pa} was not found`);if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let i=e.explicitArtifactRoot?_a(e.explicitArtifactRoot):void 0;if(r&&i&&i!==r.native.artifact_root)throw new Error(`Configured Native artifact root is ${r.native.artifact_root}; refusing conflicting root ${i}`);let n=r??Zb(i??"docs"),a=await Pr(t,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}var he=S(()=>{"use strict";_t();Sr();zc();L();H()});import{existsSync as ek}from"node:fs";import Oi from"node:path";function Tp(e,t){let r=t.toLowerCase();return Object.entries(e).find(([i,n])=>i.toLowerCase()===r&&n!==void 0)?.[1]}function rk(e){let t=(Tp(e,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").map(r=>r.trim().toLowerCase()).filter(Boolean);return[...new Set([...t,".ps1"])]}function ik(e,t,r){let n=Oi.win32.isAbsolute(e)||/[\\/]/u.test(e)?[""]:(Tp(t,"PATH")??"").split(Oi.delimiter).map(s=>s.trim().replace(/^"(.*)"$/u,"$1")).filter(Boolean),o=Oi.win32.extname(e)?[e]:rk(t).map(s=>`${e}${s}`);return n.flatMap(s=>o.map(l=>s?Oi.join(s,l):Oi.resolve(r,l)))}function Yc(e,t,r){return ik(e,t,r).find(i=>ek(i))??e}function Xc(e){if(e.some(t=>tk.test(t)))throw new Error("Windows batch check arguments must not contain shell syntax")}var tk,oA,Ia=S(()=>{"use strict";tk=/[&|<>()^%"!\r\n]/u,oA=["$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{execFileSync as nk}from"node:child_process";import jp from"node:path";function sk(e){return e instanceof Error&&(e.code==="ETIMEDOUT"||e.killed===!0&&e.signal==="SIGTERM")}function Ta(e,t,r={}){let i=r.timeoutMs??ak,n=r.maxBufferBytes??ok;if(!Number.isSafeInteger(i)||i<1)throw new Error("External command timeout must be a positive integer");if(!Number.isSafeInteger(n)||n<1)throw new Error("External command max buffer must be a positive integer");let a=jp.resolve(r.cwd??process.cwd()),o=r.env??process.env,s=process.platform==="win32"?Yc(e,o,a):e,l=jp.win32.extname(s).toLowerCase(),c=l===".bat"||l===".cmd";process.platform==="win32"&&c&&Xc(t);try{return nk(s,[...t],{cwd:a,env:o,...r.input!==void 0?{input:r.input}:{},encoding:"utf8",stdio:[r.input===void 0?"ignore":"pipe","pipe","pipe"],timeout:i,maxBuffer:n,windowsHide:!0,shell:process.platform==="win32"&&c})}catch(u){let d=typeof u.stderr=="string"?u.stderr.trim():Buffer.isBuffer(u.stderr)?u.stderr.toString("utf8").trim():"";throw new Qc(e,t,d,{cause:u,timedOut:sk(u)})}}var ak,ok,Qc,$p=S(()=>{"use strict";Ia();ak=6e4,ok=8*1024*1024,Qc=class extends Error{constructor(r,i,n,a){super(`${r} ${i.join(" ")} failed${n?`: ${n}`:""}`,a);this.command=r;this.args=i;this.stderr=n;this.name="ExternalCommandError",this.timedOut=a?.timedOut===!0}command;args;stderr;timedOut}});import{promises as Op}from"node:fs";import Hp from"node:path";function uk(e){let t=el.get(e);if(!t)return;let r=t.value===null?lk:ck;if(Date.now()-t.at>r){el.delete(e);return}return t.value}async function Hi(e){if(e===process.pid&&Zc!==null)return Zc;let t=uk(e);if(t!==void 0)return t;let r=await dk(e);return e===process.pid&&r!==null&&(Zc=r),e!==process.pid&&el.set(e,{value:r,at:Date.now()}),r}async function dk(e){if(!Number.isSafeInteger(e)||e<=0)return null;try{if(process.platform==="linux"){let[t,r]=await Promise.all([Op.readFile(`/proc/${e}/stat`,"utf8"),Op.readFile("/proc/sys/kernel/random/boot_id","utf8")]),i=t.slice(t.lastIndexOf(")")+2).trim().split(/\s+/u)[19];return/^\d+$/u.test(i??"")?`linux:${r.trim()}:${i}`:null}if(process.platform==="win32")return await pk(e);if(process.platform==="darwin"){let t=Ta("/bin/ps",["-p",String(e),"-o","lstart="],{timeoutMs:5e3,maxBufferBytes:4096,env:{...process.env,LC_ALL:"C",TZ:"UTC0"}}).trim();return t?`darwin:${t}`:null}}catch{}return null}function fk(e){let t=e.trim();return/^\d+$/u.test(t)?`win32-ps:${t}`:null}async function pk(e){try{let n=Ta(Hp.win32.join(process.env.SystemRoot??"C:\\Windows","System32","wbem","WMIC.exe"),["process","where",`processid=${e}`,"get","creationdate","/value"],{timeoutMs:5e3,maxBufferBytes:4096}),a=/^CreationDate=(\S+)/mu.exec(n);if(a)return`win32-wmic:${a[1]}`}catch{}let t=process.env.SystemRoot??"C:\\Windows",r=Hp.win32.join(t,"System32","WindowsPowerShell","v1.0","powershell.exe"),i=Ta(r,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`],{timeoutMs:8e3,maxBufferBytes:4096}).trim();return fk(i)}function ja(e){let t=e.indexOf(":");return t===-1?"":e.slice(0,t)}async function tl(e,t){if(!Number.isSafeInteger(e)||e<=0)return"alive";try{process.kill(e,0)}catch(i){if(i.code==="ESRCH")return"dead"}if(!t)return"unknown";let r=await Hi(e);return r===t?"alive":r===null||ja(r)!==ja(t)&&Dp.has(ja(r))&&Dp.has(ja(t))?"unknown":"dead"}var Zc,ck,lk,el,Dp,$a=S(()=>{"use strict";$p();Zc=null,ck=6e4,lk=1e4,el=new Map;Dp=new Set(["win32-wmic","win32-ps"])});import{AsyncLocalStorage as hk}from"async_hooks";import{randomUUID as Mp}from"crypto";import{promises as me}from"fs";import Fp from"os";import F from"path";function gk(e){if(!/^[a-z][a-z0-9-]*$/u.test(e))throw new Error(`Invalid Native lock name: ${e}`);return`${e}.lock`}function wk(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid Native lock metadata: ${t}`);let r=e;if(typeof r.id!="string"||r.id.length===0||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<1||typeof r.hostname!="string"||r.hostname.length===0||typeof r.createdAt!="string"||r.createdAt.length===0||typeof r.operation!="string"||r.operation.length===0||r.processIdentity!==void 0&&(typeof r.processIdentity!="string"||r.processIdentity.length===0))throw new Error(`Invalid Native lock metadata: ${t}`);return r}function Vp(e){return{device:e.dev.toString(),inode:e.ino.toString(),size:e.size.toString(),birthtimeNs:e.birthtimeNs.toString(),ctimeNs:e.ctimeNs.toString(),mtimeNs:e.mtimeNs.toString()}}function Ha(e,t){let r={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs},i={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs};return Se(r,i)?j(r,i):j(r,i)&&e.size===t.size}function Da(e,t){return Ha(e,t)&&e.size===t.size&&e.birthtimeNs===t.birthtimeNs&&e.ctimeNs===t.ctimeNs&&e.mtimeNs===t.mtimeNs}function yk(e,t){return e.status!==t.status?!1:!e.owner||!e.identity||!t.owner||!t.identity?e.owner===t.owner&&e.identity===t.identity:e.owner.id===t.owner.id&&Da(e.identity,t.identity)}async function Te(e){let t,r;try{let i=await br(e,Lp,{bigint:!0,label:"Native lock"});t=i.bytes,r=i.stat}catch(i){if(i.code==="ENOENT")return null;throw i instanceof Re?i.reason==="too-large"?new Error(`Native lock metadata exceeds ${Lp} bytes: ${e}`,{cause:i}):i.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${e}`,{cause:i}):new Error(`Native lock changed while reading: ${e}`,{cause:i}):i}return{file:e,owner:wk(JSON.parse(t.toString("utf8")),e),identity:Vp(r)}}async function Nk(e){return(await Te(e))?.owner??null}async function il(e){if(!e)return{status:"missing",owner:null,identity:null};if(e.owner.hostname!==Fp.hostname())return{status:"unknown",owner:e.owner,identity:e.identity};let t=await tl(e.owner.pid,e.owner.processIdentity);return{status:t==="alive"?"active":t==="dead"?"stale":"unknown",owner:e.owner,identity:e.identity}}async function bk(e,t){try{await me.lstat(t);return}catch(r){if(r.code!=="ENOENT")throw r}try{await me.rename(e,t)}catch(r){if(r.code!=="ENOENT")throw r}}async function La(e,t){let r=await Te(e.file);if(!r)return"missing";if(r.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!Da(r.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);await me.mkdir(t,{recursive:!0});let i=F.join(t,`${F.basename(e.file)}.${e.owner.id}.${Mp()}.removed`);try{await me.rename(e.file,i)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await Te(i);if(!n||n.owner.id!==e.owner.id||!Ha(n.identity,e.identity))throw await bk(i,e.file),new Error(`Native lock changed before quarantine: ${e.file}`);return await me.rm(i,{force:!0}),"removed"}async function qp(e){let t=await Hi(process.pid);return{id:Mp(),pid:process.pid,hostname:Fp.hostname(),createdAt:new Date().toISOString(),operation:e,...t===null?{}:{processIdentity:t}}}async function Wp(e,t){let r;try{r=await me.open(e,"wx")}catch(a){if(a.code==="EEXIST"){let o=await Nk(e);throw new Error(`Native lock is already held: ${e}${o?` by pid ${o.pid} for ${o.operation}`:""}`,{cause:a})}throw a}let i;try{await r.writeFile(JSON.stringify(t,null,2)+`
147
- `,"utf8"),await r.sync(),i=Vp(await r.stat({bigint:!0}))}finally{await r.close()}let n=await Te(e);if(!i||!n||n.owner.id!==t.id||!Ha(n.identity,i))throw new Error(`Native lock changed after write: ${e}`);return n.identity}async function kk(e,t){let r=await I(e.runtimeDir,e.locksDir);await me.mkdir(r,{recursive:!0});let i=await I(e.runtimeDir,F.join(r,rl));await me.mkdir(i,{recursive:!0});let n=await qp(t),a=F.join(i,`.${n.id}.tmp`),o=F.join(i,`${n.id}.claim`);try{let s=await Wp(a,n);await me.rename(a,o);let l=await Te(o);if(!l||!Ha(s,l.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:e.runtimeDir,locksDir:r,owner:n,identity:l.identity}}finally{await me.rm(a,{force:!0})}}async function Sk(e){let t=F.dirname(e.file),r=!1,i=F.basename(e.file);for(let n of await me.readdir(t,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=F.join(t,n.name);if(F.resolve(a)!==F.resolve(e.file))try{let o=await Te(a),s=await il(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await La(o,t);continue}n.name<i&&(r=!0)}catch{n.name<i&&(r=!0)}}return r}async function zp(e){let t=await Te(e.file);if(t){if(t.owner.id!==e.owner.id||!Da(t.identity,e.identity))throw new Error(`Native lock coordinator ownership changed: ${e.file}`);await La(t,F.dirname(e.file))}}async function Ek(e,t){let r=Date.now()+mk;for(;;){let i=await kk(e,t);if(!await Sk(i))return i;if(await zp(i),Date.now()>=r)throw new Error(`Native lock coordinator is busy: ${e.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function xk(e){let t=Oa.get(e)??Promise.resolve(),r,i=new Promise(a=>{r=a}),n=t.then(()=>i);return Oa.set(e,n),await t,()=>{r(),Oa.get(e)===n&&Oa.delete(e)}}async function nl(e,t,r){let i=F.resolve(e.locksDir),n=Bp.getStore();if(n?.has(i))return r();let a=await xk(i);try{let o=await Ek(e,t),s=new Map(n??[]);return s.set(i,o),await Bp.run(s,async()=>{try{return await r()}finally{await zp(o)}})}finally{a()}}async function Ba(e,t,r){return nl(e,`acquire ${t}`,async()=>{let i=await I(e.runtimeDir,e.locksDir);await me.mkdir(i,{recursive:!0});let n=await I(e.runtimeDir,F.join(i,gk(t))),a=await qp(r),o=await Wp(n,a);return{file:n,nativeRoot:e.runtimeDir,locksDir:i,owner:a,identity:o}})}async function Ma(e){await Te(e.file)&&await nl({runtimeDir:e.nativeRoot,locksDir:e.locksDir},`release ${F.basename(e.file)}`,async()=>{let t=await Te(e.file);if(!t)return;if(t.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!Da(t.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);let r=F.join(e.locksDir,rl);await La(t,r)})}function Ck(e,t=Date.now()){if(!e)return 0;let r=Date.parse(e.createdAt);return Number.isFinite(r)?Math.max(0,t-r):Number.POSITIVE_INFINITY}async function Gp(e){return il(await Te(e))}async function Jp(e,t,r,i={}){return nl(e,`take over ${F.basename(t)}`,async()=>{let n=await I(e.runtimeDir,e.locksDir),a=await I(e.runtimeDir,t);if(F.resolve(F.dirname(a))!==F.resolve(n))throw new Error(`Native lock takeover target is outside the lock directory: ${t}`);let o=await Te(a),s=await il(o);if(s.status==="missing")return{status:"missing"};if(r&&!yk(r,s))return{status:"changed",diagnosis:s};let l=i.allowAgedUnknown===!0&&s.status==="unknown"&&Ck(o?.owner??null)>=vk;if(s.status!=="stale"&&!l||!o)return{status:"changed",diagnosis:s};let c=F.join(n,rl);return await La(o,c)==="removed"?{status:"removed",owner:o.owner}:{status:"missing"}})}var Lp,rl,mk,vk,Bp,Oa,Di=S(()=>{"use strict";Ti();$a();H();Le();Lp=16*1024,rl=".coordinator",mk=5e3,vk=900*1e3,Bp=new hk,Oa=new Map});import{createHash as Pk}from"node:crypto";function Ut(e){return e.replaceAll(`\r
144
+ `,r)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Ya(t),i=Mr(r);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=Ya(t),i=Mr(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};gh.Parser=bl});var kh=y(en=>{"use strict";var wh=sl(),Gk=zi(),Zi=Ui(),Jk=ac(),Uk=_(),Kk=yl(),yh=Nl();function bh(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Kk.LineCounter||null,prettyErrors:t}}function Yk(e,t={}){let{lineCounter:r,prettyErrors:i}=bh(t),n=new yh.Parser(r?.addNewLine),a=new wh.Composer(t),o=Array.from(a.compose(n.parse(e)));if(i&&r)for(let s of o)s.errors.forEach(Zi.prettifyError(e,r)),s.warnings.forEach(Zi.prettifyError(e,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function Nh(e,t={}){let{lineCounter:r,prettyErrors:i}=bh(t),n=new yh.Parser(r?.addNewLine),a=new wh.Composer(t),o=null;for(let s of a.compose(n.parse(e),!0,e.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new Zi.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(Zi.prettifyError(e,r)),o.warnings.forEach(Zi.prettifyError(e,r))),o}function Xk(e,t,r){let i;typeof t=="function"?i=t:r===void 0&&t&&typeof t=="object"&&(r=t);let n=Nh(e,r);if(!n)return null;if(n.warnings.forEach(a=>Jk.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},r))}function Qk(e,t,r){let i=null;if(typeof t=="function"||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}return Uk.isDocument(e)&&!i?e.toString(r):new Gk.Document(e,i,r).toString(r)}en.parse=Xk;en.parseAllDocuments=Yk;en.parseDocument=Nh;en.stringify=Qk});var ut=y(I=>{"use strict";var Zk=sl(),eS=zi(),tS=Fc(),kl=Ui(),rS=_i(),Lt=_(),iS=$t(),nS=q(),aS=Ot(),oS=Ht(),sS=Ua(),cS=gl(),lS=yl(),uS=Nl(),Qa=kh(),Sh=xi();I.Composer=Zk.Composer;I.Document=eS.Document;I.Schema=tS.Schema;I.YAMLError=kl.YAMLError;I.YAMLParseError=kl.YAMLParseError;I.YAMLWarning=kl.YAMLWarning;I.Alias=rS.Alias;I.isAlias=Lt.isAlias;I.isCollection=Lt.isCollection;I.isDocument=Lt.isDocument;I.isMap=Lt.isMap;I.isNode=Lt.isNode;I.isPair=Lt.isPair;I.isScalar=Lt.isScalar;I.isSeq=Lt.isSeq;I.Pair=iS.Pair;I.Scalar=nS.Scalar;I.YAMLMap=aS.YAMLMap;I.YAMLSeq=oS.YAMLSeq;I.CST=sS;I.Lexer=cS.Lexer;I.LineCounter=lS.LineCounter;I.Parser=uS.Parser;I.parse=Qa.parse;I.parseAllDocuments=Qa.parseAllDocuments;I.parseDocument=Qa.parseDocument;I.stringify=Qa.stringify;I.visit=Sh.visit;I.visitAsync=Sh.visitAsync});function xh(e,t){return Sl[e][t]}function Za(e){return Ch.get(e.trim().toLocaleLowerCase("en-US"))??null}function pS(e){return er[e].section}function hS(e,t){return er[e].subsections[t]}function _h(e){return`${er.en.subsections[e]}/${er["zh-CN"].subsections[e]}`}function Ah(e){return Ph.has(e.trim().toLocaleLowerCase("en-US"))}function Ih(e){return Rh.get(e.trim().toLocaleLowerCase("en-US"))??null}function eo(e,t={}){let r=["outcome","scope","nonGoals","acceptanceExamples"];return t.compact||r.push("constraints","decisions","openQuestions","verificationExpectations"),r.map(i=>{if(i!=="scope")return`# ${xh(e,i)}
145
+ `;let n=[`# ${xh(e,i)}
146
+ `];n.push(`## ${pS(e)}
147
+ `);for(let a of El)n.push(`### ${hS(e,a)}
148
+ `);return n.join(`
149
+ `)}).join(`
150
+ `)}var El,Sl,dS,fS,Ch,Eh,Ph,Rh,er,tr=S(()=>{"use strict";El=["created","modified","deleted","notCreated"],Sl={en:{outcome:"Outcome",scope:"Scope",nonGoals:"Non-goals",acceptanceExamples:"Acceptance examples",constraints:"Constraints and invariants",decisions:"Decisions",openQuestions:"Open questions",verificationExpectations:"Verification expectations"},"zh-CN":{outcome:"目标",scope:"范围",nonGoals:"非目标",acceptanceExamples:"验收示例",constraints:"约束与不变量",decisions:"决策",openQuestions:"待解决问题",verificationExpectations:"验证预期"}},dS={en:{verification:"Verification",currentResult:"Current result",acceptance:"Acceptance",checks:"Checks",blockers:"Blockers",risks:"Risks and skipped work",previousIterations:"Previous iterations",conclusion:"Conclusion"},"zh-CN":{verification:"验证",currentResult:"当前结果",acceptance:"验收",checks:"检查",blockers:"阻塞项",risks:"风险与跳过的工作",previousIterations:"之前的迭代",conclusion:"结论"}},fS={en:{acceptanceEvidence:"Acceptance evidence",commandsAndResults:"Commands and results",skippedChecks:"Skipped checks",specConsistency:"Spec consistency",knownLimitationsAndRisks:"Known limitations and risks",conclusion:"Conclusion"},"zh-CN":{acceptanceEvidence:"验收证据",commandsAndResults:"命令与结果",skippedChecks:"跳过的检查",specConsistency:"规格一致性",knownLimitationsAndRisks:"已知限制与风险",conclusion:"结论"}},Ch=new Map,Eh=new Map,Ph=new Set,Rh=new Map,er={en:{section:"Directory structure",subsections:{created:"Created",modified:"Modified",deleted:"Deleted",notCreated:"Not created"}},"zh-CN":{section:"目录结构",subsections:{created:"新建",modified:"修改",deleted:"删除",notCreated:"明确不建"}}};for(let e of Object.keys(Sl)){for(let[t,r]of Object.entries(Sl[e]))Ch.set(r.toLocaleLowerCase("en-US"),t);for(let[t,r]of Object.entries(dS[e]))Eh.set(r.toLocaleLowerCase("en-US"),t);for(let[t,r]of Object.entries(fS[e]))Eh.set(r.toLocaleLowerCase("en-US"),t)}for(let e of Object.keys(er)){Ph.add(er[e].section.toLocaleLowerCase("en-US"));for(let[t,r]of Object.entries(er[e].subsections))Rh.set(r.toLocaleLowerCase("en-US"),t)}});import Bt from"path";function yS(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim();if(r.length===0||Bt.posix.isAbsolute(r)||Bt.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${t} must be a project-relative path`);if(r===".")return[];let i=r.replaceAll("\\","/").split("/");if(i.some(n=>n===".."))throw new Error(`${t} must stay inside the project root`);if(i.some(n=>n===""||n==="."))throw new Error(`${t} must not contain empty or dot path segments`);return i}function rr(e){let t=yS(e,"native.artifact_root");return t.length===0?".":t.join("/")}function Bh(e,t="docs"){let r=e??t;if(r!=="legacy"&&r!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return r}function no(e,t,r=!1){if(typeof e!="string")throw new Error(`${t} must be a string`);let i=e.trim().replaceAll("\\","/");if(i.length===0||Bt.posix.isAbsolute(i)||Bt.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${t} must be relative to its declared path base`);let n=i.split("/");if(n.some(a=>a===".."))throw new Error(`${t} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${t} must not contain empty or dot path segments`);if(!r&&/[*?]/u.test(i))throw new Error(`${t} cannot contain wildcards`);return n.join("/")}function dt(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Mh(e,t,r){let i=e??t;if(i!=="en"&&i!=="zh-CN")throw new Error(`${r} must be en or zh-CN`);return i}function Pl(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||e.startsWith("/")||e.split("/").includes(".."))throw new Error(`${t} contains an unsafe pattern`);if(e.length>ro)throw new Error(`${t} exceeds ${ro} characters`);let r=0;for(let i=0;i<e.length;i+=1)e[i]==="?"?r+=1:e[i]==="*"&&(r+=1,e[i+1]==="*"&&(i+=1));if(r>io)throw new Error(`${t} contains more than ${io} wildcard tokens`);return e}function Hh(e,t,r){if(e===void 0)return[...r];if(!Array.isArray(e))throw new Error(`${t} contains an unsafe pattern`);return[...new Set(e.map(i=>Pl(i,t)))].sort((i,n)=>i.localeCompare(n,"en"))}function tn(e,t,r){let i=e??t;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${r} must be a positive integer`);return i}function Dh(e,t,r){let i=tn(e,t,r);if(i>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${r} is too large to convert to bytes safely`);return i}function bS(e){if(e===void 0)return{...le,include:[...le.include],exclude:[...le.exclude]};let t=dt(e,"native.snapshot");return{include:Hh(t.include,"native.snapshot.include",le.include),exclude:Hh(t.exclude,"native.snapshot.exclude",le.exclude),max_files:tn(t.max_files,le.max_files,"native.snapshot.max_files"),max_total_bytes:tn(t.max_total_bytes,le.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:tn(t.max_duration_ms,le.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:tn(t.max_selection_records,le.max_selection_records,"native.snapshot.max_selection_records")}}function NS(e){if(e===void 0)return;let t=dt(e,"native.pending_root_move"),r=t.id,i=t.from_artifact_root,n=t.to_artifact_root,a=t.stage;if(typeof r!="string"||!/^[a-f0-9-]{8,}$/u.test(r))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(t.cleanup!==void 0){let s=dt(t.cleanup,"native.pending_root_move.cleanup"),l=s.kind,c=s.state,u=s.manifest_hash;if(l!=="forward-source"&&l!=="restart-staging"&&l!=="rollback-destination"&&l!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(c!=="prepared"&&c!=="quarantined"&&c!=="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:l,state:c,manifestHash:u}}return{id:r,fromArtifactRoot:rr(i),toArtifactRoot:rr(n),stage:a,...o?{cleanup:o}:{}}}function kS(e){if(e===void 0)return;let t=dt(e,"native.finish");if(t.pull_request===void 0)return{};let r=dt(t.pull_request,"native.finish.pull_request");if(r.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(r.command)||r.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(r.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=r.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(Bt.posix.isAbsolute(i[0])||Bt.win32.isAbsolute(i[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=r.timeout_ms??mS;if(!Number.isSafeInteger(n)||n<1||n>Oh)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Oh}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function SS(e,t={}){let r=dt(e,"native"),i=r.artifact_root??(t.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let n=r.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=r.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=r.max_verify_failures??Cl;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=r.document_writes??"allow";if(s!=="allow"&&s!=="revert")throw new Error("native.document_writes must be allow or revert");let l=NS(r.pending_root_move),c=kS(r.finish);return{artifact_root:rr(i),language:Mh(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,...s==="revert"?{document_writes:s}:{},snapshot:bS(r.snapshot),...c?{finish:c}:{},...l?{pending_root_move:l}:{}}}function ES(e){let t=dt(e,"classic"),r=t.context_compression??"off";if(r!=="off"&&r!=="beta")throw new Error("classic.context_compression must be off or beta");let i=t.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=t.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");let a=t.document_evidence??"neutral";if(a!=="neutral"&&a!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:Bh(t.artifact_layout),language:Mh(t.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n,...a==="strict"?{document_evidence:a}:{}}}function xS(e){let r=dt(e,"hook").allow_paths??[];if(!Array.isArray(r))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(r.map((i,n)=>no(i,`hook.allow_paths[${n}]`)))]}}function CS(e){if(e===void 0)return{...to};let t=dt(e,"memory"),r=t.learning??to.learning,i=t.retrieval??to.retrieval;if(typeof r!="boolean")throw new Error("memory.learning must be true or false");if(typeof i!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:r,retrieval:i}}function Rl(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function PS(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim();if(r.length===0||r.includes("\\")||r.includes("\0")||Bt.posix.isAbsolute(r)||Bt.win32.isAbsolute(r)||r.startsWith("~")||r.split("/").some(n=>n===""||n==="."||n===".."))throw new Error(`${t} must be a safe project-relative glob`);if(!r.toLowerCase().endsWith(".md"))throw new Error(`${t} must target a Markdown file ending in .md`);if(r.length>Th)throw new Error(`${t} exceeds ${Th} characters`);let i=0;for(let n=0;n<r.length;n+=1)r[n]==="?"?i+=1:r[n]==="*"&&(i+=1,r[n+1]==="*"&&(n+=1));if(i>$h)throw new Error(`${t} contains more than ${$h} wildcard tokens`);return r}function RS(e){let t=Rl(e,"knowledge.local"),r=t.include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");let i={include:[...new Set(r.map((n,a)=>PS(n,`knowledge.local.include[${a}]`)))],max_file_mb:Dh(t.max_file_mb,jh.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Dh(t.max_total_mb,jh.max_total_mb,"knowledge.local.max_total_mb")};if(i.max_file_mb>i.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return i}function _S(e){if(typeof e!="string"||e.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let t;try{t=new URL(e)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let r=t.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=r==="localhost"||r==="127.0.0.1"||r==="::1";if(t.protocol!=="https:"&&!(t.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return t.toString()}function AS(e){let t=Rl(e,"knowledge.remote"),r=_S(t.endpoint),i=t.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let n=t.scope;if(n!==void 0&&(typeof n!="string"||n.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let a=t.timeout_ms??5e3;if(typeof a!="number"||!Number.isSafeInteger(a)||a<100||a>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:r,...i===void 0?{}:{token_env:i},...n===void 0?{}:{scope:n},timeout_ms:a}}function IS(e){if(e===void 0)return{...Lh};let t=Rl(e,"knowledge"),r=t.provider??"local";if(r!=="local"&&r!=="remote")throw new Error("knowledge.provider must be local or remote");let i=t.local===void 0?void 0:RS(t.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=t.remote===void 0?void 0:AS(t.remote);if(n===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:r,...i?{local:i}:{},remote:n}}function TS(e){let t=e??!0;if(typeof t!="boolean")throw new Error("ambient_resume must be true or false");return t}function $S(e,t,r,i,n,a,o,s){let l=e.schema!==void 0;if(!(l||e.default_workflow!==void 0||e.workflows!==void 0||!s.allowPartialProject&&e.native!==void 0)||s.allowPartialProject&&!l)return null;if(e.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(e.default_workflow!=="native"&&e.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let u=e.workflows??[e.default_workflow];if(!Array.isArray(u)||u.length===0||u.some(f=>f!=="native"&&f!=="classic"))throw new Error("workflows must contain native and/or classic");let d=[...new Set(u)];if(!d.includes(e.default_workflow))throw new Error("workflows must include default_workflow");if(d.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:e.default_workflow,workflows:d,ambient_resume:o,...t?{hook:t}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function nn(e,t={}){let r=(0,xl.parseDocument)(e,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${r.errors[0].message}`);let i=r.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=i,a=TS(n.ambient_resume),o=n.hook===void 0?void 0:xS(n.hook),s=CS(n.memory),l=IS(n.knowledge),c=n.native===void 0?void 0:SS(n.native,{allowMissingArtifactRoot:t.allowMissingNativeFields}),u=n.classic===void 0?void 0:ES(n.classic),d=$S(n,o,s,l,c,u,a,{allowPartialProject:t.allowPartialProject??!1});return{value:n,config:d,ambient_resume:a,memory:s,knowledge:l,...o?{hook:o}:{},...c?{native:c}:{},...u?{classic:u}:{}}}function ao(e="docs",t="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...to},knowledge:{...Lh},native:{artifact_root:rr(e),language:t,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Cl,snapshot:{...le,include:[...le.include],exclude:[...le.exclude]}}}}var xl,rn,ro,io,Th,$h,Cl,to,jh,Lh,mS,Oh,vS,gS,wS,le,Mt=S(()=>{"use strict";xl=Ct(ut(),1),rn=Number.MAX_SAFE_INTEGER,ro=1024,io=64,Th=1024,$h=64,Cl=5,to={learning:!0,retrieval:!0},jh={include:[],max_file_mb:1,max_total_mb:32},Lh={provider:"local"},mS=12e4,Oh=6e5,vS=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".devin/skills/**",".dsh/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".omp/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],gS=["**/.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"],wS=[...vS,...gS].sort((e,t)=>e.localeCompare(t,"en")),le={include:["**/*"],exclude:[...wS],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});import{constants as oo,promises as ir}from"fs";function _l(e){return"birthtimeNs"in e&&typeof e.birthtimeNs=="bigint"?e.birthtimeNs:e.birthtimeMs}function Fh(e){return"ctimeNs"in e&&typeof e.ctimeNs=="bigint"?e.ctimeNs:e.ctimeMs}function an(e){return{dev:e.dev,ino:e.ino,birthtime:_l(e)}}function so(e,t){let r=an(e),i=an(t);return Ae(r,i)?j(r,i):j(r,i)&&_l(e)===_l(t)&&Fh(e)===Fh(t)&&e.size===t.size}async function Fr(e,t,r={}){if(!Number.isSafeInteger(t)||t<1)throw new Error("race-safe read byte limit must be a positive integer");let i=r.label??"file",n=r.bigint===!0,a=await ir.lstat(e,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new Oe("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(t))throw new Oe("too-large",`${i} exceeds ${t} bytes`);let o=await ir.realpath(e);await r.verify?.("pre-open",{realPath:o,identity:an(a)});let s=process.platform==="win32"?oo.O_RDONLY:oo.O_RDONLY|oo.O_NOFOLLOW|oo.O_NONBLOCK,l;try{l=await ir.open(e,s)}catch(c){throw c.code==="ELOOP"?new Oe("not-regular-file",`${i} must be a regular file`,{cause:c}):c}try{let[c,u,d]=await Promise.all([l.stat({bigint:n}),ir.lstat(e,{bigint:n}),ir.realpath(e)]);if(!c.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!so(a,c)||!so(a,u))throw new Oe("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:d,identity:an(c)}),await r.hooks?.afterOpen?.();let f=[],h=0,m=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let w=t+1-h,{bytesRead:b}=await l.read(m,0,Math.min(m.length,w),null);if(b===0)break;if(h+=b,h>t)throw new Oe("too-large",`${i} exceeds ${t} bytes`);f.push(Buffer.from(m.subarray(0,b)))}await r.hooks?.beforeFinalCheck?.();let[p,v,g]=await Promise.all([l.stat({bigint:n}),ir.lstat(e,{bigint:n}),ir.realpath(e)]);if(!v.isFile()||v.isSymbolicLink()||g!==o||!so(a,p)||!so(a,v))throw new Oe("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:g,identity:an(p)}),{bytes:Buffer.concat(f,h),stat:p,realPath:g}}finally{await l.close()}}var Oe,on=S(()=>{"use strict";ki();Oe=class extends Error{reason;constructor(t,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=t}}});import{promises as co}from"fs";import Ft from"path";function jS(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function Al(e,t){let r=Ft.relative(e,t);return r===""||!Ft.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ft.sep}`)}async function qh(e,t){let r=Ft.resolve(e),i=await co.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${t} project root must be a real directory`);return co.realpath(r)}async function Vh(e,t,r,i){let n=e;for(let a=0;a<r.length;a++){n=Ft.join(n,r[a]);let o;try{o=await co.lstat(n)}catch(u){if(jS(u))return{exists:!1,kind:"missing"};throw u}let s=Ft.relative(e,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${s}`);let l=a===r.length-1;if(!l&&!o.isDirectory())throw new Error(`${i.label} ancestor ${s} must be a real directory`);if(l&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let c=await co.realpath(n);if(!Al(t,c))throw new Error(`${i.label} resolves outside the project root`);if(l)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function qr(e,t,r){let i=no(t,r.label),n=Ft.resolve(e),a=await qh(n,r.label),o=i.split("/"),s=Ft.resolve(n,...o);if(!Al(n,s))throw new Error(`${r.label} must stay inside the project root`);let l=await Vh(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:l.exists,kind:l.kind}}async function Ke(e,t,r,i){let n=await qr(e,t,{label:i.label,expected:"file"});if(!n.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let a=await qh(n.projectRoot,i.label);return Fr(n.target,r,{...i,verify:async(o,s)=>{if(!Al(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await Vh(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var ft=S(()=>{"use strict";on();Mt()});import{createHash as OS}from"crypto";function HS(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}async function lo(e,t={}){return(await uo(e,t)).document}async function DS(e){try{return(await Ke(e,sn,rn,{label:sn})).bytes}catch(t){if(HS(t))return null;throw t}}function LS(e){return e?{exists:!0,sha256:OS("sha256").update(e).digest("hex")}:{exists:!1,sha256:null}}async function uo(e,t={}){let r=await DS(e);return{document:r?nn(r.toString("utf8"),t):null,identity:LS(r)}}async function Il(e){return(await lo(e))?.config??null}var sn,Vr=S(()=>{"use strict";Mt();ft();sn=".comet/config.yaml"});var Wr=S(()=>{"use strict";Ms();ki()});var JT,Tl=S(()=>{"use strict";Wr();Vr();ft();JT=16*1024});var Ol=S(()=>{"use strict";Wr();Mt();Vr();ft();Tl()});import{existsSync as zh,promises as nr}from"fs";import A from"path";import VS from"os";async function Hl(e){try{return await nr.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function zS(e){try{let t=await nr.readFile(e,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(t)}catch(t){if(t.code==="ENOENT")return!1;throw t}}function Gr(e,t){let r=A.relative(e,t);return r===""||!A.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${A.sep}`)}async function zr(e){let t=[],r=e;for(;!await Hl(r);){let n=A.dirname(r);if(n===r)break;t.push(A.basename(r)),r=n}let i=await nr.realpath(r);return A.resolve(i,...t.reverse())}async function Dl(e){try{return(await nr.lstat(e)).isSymbolicLink()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function po(e){let t=A.resolve(e);try{(await nr.stat(t)).isDirectory()||(t=A.dirname(t))}catch(n){if(n.code!=="ENOENT")throw n}let r=t,i=A.resolve(VS.homedir());for(;;){if(!(t===i&&r!==i)){let o=A.join(t,...fo.split("/")),s=t===r||await zS(o);if(await Hl(o)&&s)return t}if(await Hl(A.join(t,".git")))return t;let a=A.dirname(t);if(a===t)return r;t=a}}function ho(e){return rr(e)}async function GS(e,t){let r=ho(t),i=A.resolve(e,...r.split("/")),n=await nr.realpath(e),a=await zr(i);if(!Gr(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Jr(e,t){let r=ho(t),i=await GS(e,r),n=A.join(i,"comet");if(await Dl(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([zr(i),zr(n)]);if(!Gr(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=A.resolve(e),l=A.join(s,".comet","runtime","native");if(await Dl(l))throw new Error("The Native Runtime root must not be a symbolic link");let[c,u]=await Promise.all([nr.realpath(s),zr(l)]);if(!Gr(c,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:A.join(e,...fo.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:A.join(n,"specs"),changesDir:A.join(n,"changes"),archiveDir:A.join(n,"archive"),runtimeDir:l,changesRuntimeDir:A.join(l,"changes"),locksDir:A.join(l,"locks"),transactionsDir:A.join(l,"transactions")}}function Gh(e){if(!WS.test(e))throw new Error(`Invalid Native change name: ${e}`)}function He(e,t){Gh(t);let r=A.join(e.changesRuntimeDir,t);if(!te(e.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function Ll(e,t){Gh(t);let r=A.join(e.changesDir,t,"runtime");if(!te(e.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function De(e,t){let r=He(e,t);if(zh(r))return r;let i=Ll(e,t);return zh(i)?i:r}function Bl(e,t){if(!t.startsWith("runtime/")||A.isAbsolute(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Native Runtime ref: ${t}`);let r=A.resolve(e,...t.slice(8).split("/"));if(!te(e,r))throw new Error(`Native Runtime ref escaped: ${t}`);return r}function fe(e,t){let r=A.resolve(t);if(te(e.runtimeDir,r))return e.runtimeDir;if(te(e.nativeRoot,r))return e.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${t}`)}function te(e,t){return Gr(A.resolve(e),A.resolve(t))}async function T(e,t){let r=A.resolve(e),i=A.resolve(t);if(!Gr(r,i))throw new Error(`Path is outside the Native root: ${t}`);if(await Dl(r))throw new Error(`Native root must not be a symbolic link: ${e}`);let[n,a]=await Promise.all([zr(r),zr(i)]);if(!Gr(n,a))throw new Error(`Path resolves outside the Native root: ${t}`);return i}var fo,WS,L=S(()=>{"use strict";Mt();fo=".comet/config.yaml",WS=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});function US(e="docs",t="en"){return ao(e,t)}async function Le(e){let t=(await lo(e))?.config??null;return t?.native?t:null}async function mo(e){let t=await Le(e);if(t?.native.pending_root_move)throw new Error(`Native root move ${t.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}async function Jh(e){let t=await po(e.startPath),r=await Le(t);if(!r&&e.allowMissingConfig===!1)throw new Error(`${fo} was not found`);if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let i=e.explicitArtifactRoot?ho(e.explicitArtifactRoot):void 0;if(r&&i&&i!==r.native.artifact_root)throw new Error(`Configured Native artifact root is ${r.native.artifact_root}; refusing conflicting root ${i}`);let n=r??US(i??"docs"),a=await Jr(t,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}var be=S(()=>{"use strict";Mt();Vr();Ol();B();L()});import{createHash as Fl,randomUUID as KS}from"node:crypto";import{promises as pe}from"node:fs";import YS from"node:os";import ue from"node:path";async function Ml(e,t){let r=await pe.lstat(e,{bigint:!0});if(!r.isFile()||r.isSymbolicLink()||r.size>BigInt(t))throw new Error("Invalid process probe cache");let i=await pe.readFile(e),n=await pe.lstat(e,{bigint:!0});if(r.ino!==n.ino||r.ctimeNs!==n.ctimeNs||r.size!==n.size)throw new Error("Process probe cache changed");return i}async function Yh(e){try{let t=JSON.parse((await Ml(ue.join(e,"probe.json"),4096)).toString("utf8"));if(!/^probe-[a-f0-9-]+\.exe$/u.test(t.file??""))return null;let r=ue.join(e,t.file),i=await Ml(r,65536);return Fl("sha256").update(i).digest("hex")===t.hash?r:null}catch{return null}}async function ZS(e,t){let r,i=KS(),n=ue.join(e,`probe-${i}.cs`),a=ue.join(e,`probe-${i}.exe`),o=ue.join(e,`probe-${i}.json`);try{if(await pe.mkdir(e,{recursive:!0,mode:448}),(await pe.lstat(e)).isSymbolicLink())return null;r=await pe.open(ue.join(e,"prepare.lock"),"wx",384);let s=await Yh(e);if(s)return s;await pe.writeFile(n,Kh,{flag:"wx",mode:384});let l;for(let u of["Framework64","Framework"]){let d=ue.join(t,"Microsoft.NET",u,"v4.0.30319","csc.exe");try{await pe.access(d),l=d;break}catch{}}if(!l)return null;await Pt(l,["/nologo","/target:exe","/platform:anycpu",`/out:${a}`,n],{timeoutMs:1500,maxBufferBytes:4096});let c=Fl("sha256").update(await Ml(a,65536)).digest("hex");return await pe.writeFile(o,JSON.stringify({file:ue.basename(a),hash:c}),{flag:"wx",mode:384}),await pe.rename(o,ue.join(e,"probe.json")),a}catch{return null}finally{await pe.unlink(n).catch(()=>{}),await pe.unlink(o).catch(()=>{}),r&&(await r.close().catch(()=>{}),await pe.unlink(ue.join(e,"prepare.lock")).catch(()=>{}))}}async function Uh(e,t,r){try{let i=await Pt(ue.join(t,"System32","wbem","WMIC.exe"),["process","where",`processid=${e}`,"get","creationdate","/value"],{timeoutMs:300,maxBufferBytes:4096,signal:r}),n=/^CreationDate=(\S+)/mu.exec(i);if(n)return`win32-wmic:${n[1]}`}catch{}if(r.aborted)return null;try{let n=(await Pt(ue.join(t,"System32","WindowsPowerShell","v1.0","powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`],{timeoutMs:1e3,maxBufferBytes:4096,signal:r})).trim();return/^\d+$/u.test(n)?`win32-ps:${n}`:null}catch{return null}}function eE(e,t){let r=vo.get(e);if(r&&performance.now()<r.retryAfter)return r.promise;let i={promise:ZS(e,t),retryAfter:1/0};return vo.set(e,i),i.promise.then(n=>{vo.get(e)===i&&(n?vo.delete(e):i.retryAfter=performance.now()+QS)}),i.promise}async function Xh(e,t={}){if(!Number.isSafeInteger(e)||e<=0)return null;let r=t.systemRoot??process.env.SystemRoot??"C:\\Windows",i=ue.join(t.cacheRoot??ue.join(YS.tmpdir(),"comet-process-identity"),XS),n=async c=>{if(!c)return null;try{let d=(await Pt(c,[String(e)],{timeoutMs:1e3,maxBufferBytes:4096})).trim();return/^\d+$/u.test(d)?`win32-ps:${d}`:null}catch{return null}},a=await Yh(i);if(a){let c=await n(a);return c||Uh(e,r,new AbortController().signal)}let o=eE(i,r),s=new AbortController,l=c=>{if(!c)throw new Error("Probe unavailable");return c};try{return await Promise.any([o.then(n).then(l),Uh(e,r,s.signal).then(l)])}catch{return null}finally{s.abort()}}var Kh,XS,QS,vo,Qh=S(()=>{"use strict";Yn();Kh=`using System;
151
+ using System.Runtime.InteropServices;
152
+ class CometProcessIdentity {
153
+ [DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
154
+ [DllImport("kernel32.dll")] static extern bool GetProcessTimes(IntPtr process, out long creation, out long exit, out long kernel, out long user);
155
+ [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
156
+ static int Main(string[] args) {
157
+ int pid; if(args.Length != 1 || !int.TryParse(args[0], out pid) || pid <= 0) return 1;
158
+ IntPtr handle=OpenProcess(0x1000, false, pid); if(handle == IntPtr.Zero) return 1;
159
+ try { long creation, exit, kernel, user; if(!GetProcessTimes(handle,out creation,out exit,out kernel,out user)) return 1;
160
+ Console.WriteLine(DateTime.FromFileTimeUtc(creation).Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); return 0;
161
+ } finally { CloseHandle(handle); }
162
+ }
163
+ }`,XS=Fl("sha256").update(Kh).digest("hex"),QS=1e4,vo=new Map});import{promises as Zh}from"node:fs";function rE(e){let t=Vl.get(e);if(t){if(Date.now()-t.at>tE){Vl.delete(e);return}return t.value}}async function ln(e){if(e===process.pid&&ql!==null)return ql;let t=rE(e);if(t!==void 0)return t;let r=go.get(e);r||(r=iE(e),go.set(e,r));let i=await r;return go.get(e)===r&&go.delete(e),e===process.pid&&i!==null&&(ql=i),i===null&&Vl.set(e,{value:null,at:Date.now()}),i}async function iE(e){if(!Number.isSafeInteger(e)||e<=0)return null;try{if(process.platform==="linux"){let[t,r]=await Promise.all([Zh.readFile(`/proc/${e}/stat`,"utf8"),Zh.readFile("/proc/sys/kernel/random/boot_id","utf8")]),i=t.slice(t.lastIndexOf(")")+2).trim().split(/\s+/u)[19];return/^\d+$/u.test(i??"")?`linux:${r.trim()}:${i}`:null}if(process.platform==="win32")return await Xh(e);if(process.platform==="darwin"){let t=(await Pt("/bin/ps",["-p",String(e),"-o","lstart="],{timeoutMs:5e3,maxBufferBytes:4096,env:{...process.env,LC_ALL:"C",TZ:"UTC0"}})).trim();return t?`darwin:${t}`:null}}catch{}return null}function wo(e){let t=e.indexOf(":");return t===-1?"":e.slice(0,t)}async function Wl(e,t){if(!Number.isSafeInteger(e)||e<=0)return"alive";try{process.kill(e,0)}catch(i){if(i.code==="ESRCH")return"dead"}if(!t)return"unknown";let r=await ln(e);return r===t?"alive":r===null||wo(r)!==wo(t)&&em.has(wo(r))&&em.has(wo(t))?"unknown":"dead"}var ql,tE,Vl,go,em,yo=S(()=>{"use strict";Yn();Qh();ql=null,tE=1e4,Vl=new Map,go=new Map;em=new Set(["win32-wmic","win32-ps"])});import{AsyncLocalStorage as nE}from"async_hooks";import{randomUUID as im}from"crypto";import{promises as Ne}from"fs";import nm from"os";import V from"path";function sE(e){if(!/^[a-z][a-z0-9-]*$/u.test(e))throw new Error(`Invalid Native lock name: ${e}`);return`${e}.lock`}function cE(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid Native lock metadata: ${t}`);let r=e;if(typeof r.id!="string"||r.id.length===0||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<1||typeof r.hostname!="string"||r.hostname.length===0||typeof r.createdAt!="string"||r.createdAt.length===0||typeof r.operation!="string"||r.operation.length===0||r.processIdentity!==void 0&&(typeof r.processIdentity!="string"||r.processIdentity.length===0))throw new Error(`Invalid Native lock metadata: ${t}`);return r}function am(e){return{device:e.dev.toString(),inode:e.ino.toString(),size:e.size.toString(),birthtimeNs:e.birthtimeNs.toString(),ctimeNs:e.ctimeNs.toString(),mtimeNs:e.mtimeNs.toString()}}function No(e,t){let r={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs},i={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs};return Ae(r,i)?j(r,i):j(r,i)&&e.size===t.size}function un(e,t){return No(e,t)&&e.size===t.size&&e.birthtimeNs===t.birthtimeNs&&e.ctimeNs===t.ctimeNs&&e.mtimeNs===t.mtimeNs}function lE(e,t){return e.status!==t.status?!1:!e.owner||!e.identity||!t.owner||!t.identity?e.owner===t.owner&&e.identity===t.identity:e.owner.id===t.owner.id&&un(e.identity,t.identity)}async function ke(e){let t,r;try{let i=await Fr(e,tm,{bigint:!0,label:"Native lock"});t=i.bytes,r=i.stat}catch(i){if(i.code==="ENOENT")return null;throw i instanceof Oe?i.reason==="too-large"?new Error(`Native lock metadata exceeds ${tm} bytes: ${e}`,{cause:i}):i.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${e}`,{cause:i}):new Error(`Native lock changed while reading: ${e}`,{cause:i}):i}return{file:e,owner:cE(JSON.parse(t.toString("utf8")),e),identity:am(r)}}async function uE(e){return(await ke(e))?.owner??null}async function Gl(e){if(!e)return{status:"missing",owner:null,identity:null};if(e.owner.hostname!==nm.hostname())return{status:"unknown",owner:e.owner,identity:e.identity};let t=await Wl(e.owner.pid,e.owner.processIdentity);return{status:t==="alive"?"active":t==="dead"?"stale":"unknown",owner:e.owner,identity:e.identity}}async function dE(e,t){try{await Ne.lstat(t);return}catch(r){if(r.code!=="ENOENT")throw r}try{await Ne.rename(e,t)}catch(r){if(r.code!=="ENOENT")throw r}}async function ko(e,t){let r=await ke(e.file);if(!r)return"missing";if(r.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!un(r.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);await Ne.mkdir(t,{recursive:!0});let i=V.join(t,`${V.basename(e.file)}.${e.owner.id}.${im()}.removed`);try{await Ne.rename(e.file,i)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await ke(i);if(!n||n.owner.id!==e.owner.id||!No(n.identity,e.identity))throw await dE(i,e.file),new Error(`Native lock changed before quarantine: ${e.file}`);return await Ne.rm(i,{force:!0}),"removed"}async function om(e){let t=await ln(process.pid);return{id:im(),pid:process.pid,hostname:nm.hostname(),createdAt:new Date().toISOString(),operation:e,...t===null?{}:{processIdentity:t}}}async function sm(e,t){let r;try{r=await Ne.open(e,"wx")}catch(a){if(a.code==="EEXIST"){let o=await uE(e);throw new Error(`Native lock is already held: ${e}${o?` by pid ${o.pid} for ${o.operation}`:""}`,{cause:a})}throw a}let i;try{await r.writeFile(JSON.stringify(t,null,2)+`
164
+ `,"utf8"),await r.sync(),i=am(await r.stat({bigint:!0}))}finally{await r.close()}let n=await ke(e);if(!i||!n||n.owner.id!==t.id||!No(n.identity,i))throw new Error(`Native lock changed after write: ${e}`);return n.identity}async function fE(e,t){let r=await T(e.runtimeDir,e.locksDir);await Ne.mkdir(r,{recursive:!0});let i=await T(e.runtimeDir,V.join(r,zl));await Ne.mkdir(i,{recursive:!0});let n=await om(t),a=V.join(i,`.${n.id}.tmp`),o=V.join(i,`${n.id}.claim`);try{let s=await sm(a,n);await Ne.rename(a,o);let l=await ke(o);if(!l||!No(s,l.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:e.runtimeDir,locksDir:r,owner:n,identity:l.identity}}finally{await Ne.rm(a,{force:!0})}}async function pE(e){let t=V.dirname(e.file),r=!1,i=V.basename(e.file);for(let n of await Ne.readdir(t,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=V.join(t,n.name);if(V.resolve(a)!==V.resolve(e.file))try{let o=await ke(a),s=await Gl(o);if(s.status==="missing")continue;let l=await ke(a);if(!l)continue;if(!o||l.owner.id!==o.owner.id||!un(l.identity,o.identity)){n.name<i&&(r=!0);continue}if(s.status==="stale"&&o){await ko(o,t);continue}n.name<i&&(r=!0)}catch{n.name<i&&(r=!0)}}return r}async function cm(e){let t=await ke(e.file);if(t){if(t.owner.id!==e.owner.id||!un(t.identity,e.identity))throw new Error(`Native lock coordinator ownership changed: ${e.file}`);await ko(t,V.dirname(e.file))}}async function hE(e,t){let r=Date.now()+aE;for(;;){let i=await fE(e,t);if(!await pE(i))return i;if(await cm(i),Date.now()>=r)throw new Error(`Native lock coordinator is busy: ${e.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function mE(e){let t=bo.get(e)??Promise.resolve(),r,i=new Promise(a=>{r=a}),n=t.then(()=>i);return bo.set(e,n),await t,()=>{r(),bo.get(e)===n&&bo.delete(e)}}async function Jl(e,t,r){let i=V.resolve(e.locksDir),n=rm.getStore();if(n?.has(i))return r();let a=await mE(i);try{let o=await hE(e,t),s=new Map(n??[]);return s.set(i,o),await rm.run(s,async()=>{try{return await r()}finally{await cm(o)}})}finally{a()}}async function So(e,t,r){return Jl(e,`acquire ${t}`,async()=>{let i=await T(e.runtimeDir,e.locksDir);await Ne.mkdir(i,{recursive:!0});let n=await T(e.runtimeDir,V.join(i,sE(t))),a=await om(r),o=await sm(n,a);return{file:n,nativeRoot:e.runtimeDir,locksDir:i,owner:a,identity:o}})}async function Eo(e){await ke(e.file)&&await Jl({runtimeDir:e.nativeRoot,locksDir:e.locksDir},`release ${V.basename(e.file)}`,async()=>{let t=await ke(e.file);if(!t)return;if(t.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!un(t.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);let r=V.join(e.locksDir,zl);await ko(t,r)})}function vE(e,t=Date.now()){if(!e)return 0;let r=Date.parse(e.createdAt);return Number.isFinite(r)?Math.max(0,t-r):Number.POSITIVE_INFINITY}async function lm(e){return Gl(await ke(e))}async function um(e,t,r,i={}){return Jl(e,`take over ${V.basename(t)}`,async()=>{let n=await T(e.runtimeDir,e.locksDir),a=await T(e.runtimeDir,t);if(V.resolve(V.dirname(a))!==V.resolve(n))throw new Error(`Native lock takeover target is outside the lock directory: ${t}`);let o=await ke(a),s=await Gl(o);if(s.status==="missing")return{status:"missing"};if(r&&!lE(r,s))return{status:"changed",diagnosis:s};let l=i.allowAgedUnknown===!0&&s.status==="unknown"&&vE(o?.owner??null)>=oE;if(s.status!=="stale"&&!l||!o)return{status:"changed",diagnosis:s};let c=V.join(n,zl);return await ko(o,c)==="removed"?{status:"removed",owner:o.owner}:{status:"missing"}})}var tm,zl,aE,oE,rm,bo,dn=S(()=>{"use strict";on();yo();L();Ge();tm=16*1024,zl=".coordinator",aE=5e3,oE=900*1e3,rm=new nE,bo=new Map});import{createHash as gE}from"node:crypto";function sr(e){return e.replaceAll(`\r
148
165
  `,`
149
166
  `).replaceAll("\r",`
150
- `)}function Rr(e){return Pk("sha256").update(Ut(e)).digest("hex")}function ll(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new P(`${t} must be an object`);return e}function Zp(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new P(`${r} has unknown field(s): ${i.join(", ")}`)}function ul(e,t){if(typeof e!="string"||e.trim().length===0)throw new P(`${t} must be a non-empty string`);return e.trim()}function Kp(e,t){if(e!==void 0){if(typeof e!="string")throw new P(`${t} must be text`);return Ut(e).replace(/^\n+|\n+$/gu,"")}}function Fa(e,t){let r=ul(e,t).toLowerCase();if(!_k.test(r))throw new P(`${t} must be a SHA-256 hash`);return r}function Yp(e,t,r){let i=ll(e,t),n=Object.entries(i);if(n.length>Up)throw new P(`${t} must contain at most ${Up} entries`);let a={};for(let[o,s]of n){if(sl(o,`${t} ID`)!==o)throw new P(`${t} ID must be normalized: ${o}`);s===null&&r?a[o]=null:a[o]=Fa(s,`${t}.${o}`)}return a}function sl(e,t){let r=ul(e,t);if(!Qp.test(r))throw new P(`${t} is not a valid stable requirement ID`);return r}function Ak(e,t){let r=ul(e,t);if(!Rk.test(r))throw new P(`${t} is not a valid capability ID`);return r}function Ik(e,t){let r=`Native delta operations[${t}]`,i=ll(e,r);Zp(i,new Set(["id","operation","to_id","title","body","expected_hash"]),r);let n=sl(i.id,`${r}.id`),a=i.operation;if(!["add","modify","remove","rename"].includes(String(a)))throw new P(`${r}.operation is invalid`);let o=a,s=i.to_id===void 0?void 0:sl(i.to_id,`${r}.to_id`),l=Kp(i.title,`${r}.title`),c=Kp(i.body,`${r}.body`),u=i.expected_hash===void 0?void 0:Fa(i.expected_hash,`${r}.expected_hash`);if(o==="add"){if(s!==void 0||u!==void 0||!c?.trim())throw new P(`${r} add requires body and forbids to_id and expected_hash`)}else if(o==="modify"){if(s!==void 0||!u||!c?.trim())throw new P(`${r} modify requires body and expected_hash and forbids to_id`)}else if(o==="remove"){if(s!==void 0||l!==void 0||c!==void 0||!u)throw new P(`${r} remove requires expected_hash and forbids to_id, title, and body`)}else if(s===void 0||s===n||!u||c==="")throw new P(`${r} rename requires a different to_id and expected_hash`);return{id:n,operation:o,...s===void 0?{}:{to_id:s},...l===void 0?{}:{title:l},...c===void 0?{}:{body:c},...u===void 0?{}:{expected_hash:u}}}function Tk(e){let t=ll(e,"Native delta");if(Zp(t,new Set(["schema","capability","base_hash","base_version","legacy_hash","base_requirements","independent_requirements","operations"]),"Native delta"),t.schema!==al)throw new P(`Native delta schema must be ${al}`);let r=Ak(t.capability,"Native delta capability"),i=Fa(t.base_hash,"Native delta base_hash");if(!Number.isSafeInteger(t.base_version)||Number(t.base_version)<1)throw new P("Native delta base_version must be a positive integer");let n=t.legacy_hash===void 0?void 0:Fa(t.legacy_hash,"Native delta legacy_hash"),a;t.base_requirements!==void 0&&(a=Yp(t.base_requirements,"Native delta base_requirements",!1));let o=t.independent_requirements===void 0?void 0:Yp(t.independent_requirements,"Native delta independent_requirements",!0);if(!Array.isArray(t.operations))throw new P("Native delta operations must be an array");let s=t.operations.map(Ik),l=new Set;for(let[c,u]of s.entries()){let d=[u.id,...u.to_id===void 0?[]:[u.to_id]];for(let f of d){if(l.has(f))throw new P(`Native delta operations contain duplicate or overlapping requirement ID ${f} at ${c}`);l.add(f)}}if(o!==void 0){if(a===void 0)throw new P("Native delta independent_requirements requires base_requirements");for(let[c,u]of Object.entries(o)){if(l.has(c))throw new P(`Native delta requirement ${c} cannot be both addressed and independent`);let d=a[c];if(u===null?d!==void 0:d!==u)throw new P(`Native delta independent_requirements does not match baseline ${c}`)}}return{schema:al,capability:r,base_hash:i,base_version:Number(t.base_version),...n===void 0?{}:{legacy_hash:n},...a===void 0?{}:{base_requirements:a},...o===void 0?{}:{independent_requirements:o},operations:s}}function jk(e){let t=(0,cl.parseDocument)(e,{uniqueKeys:!0});if(t.errors.length>0)throw new P(`Native delta is invalid YAML: ${t.errors[0].message}`);return t.toJS({mapAsMap:!1})}function Li(e){return Tk(typeof e=="string"?jk(e):e)}function $k(e){let t=/^\s{0,3}(#{1,6})\s+/u.exec(e);return t?t[1].length:null}function Ok(e){let t=[],r=null;for(let[i,n]of e.entries()){let a=/^\s{0,3}(`{3,}|~{3,})(.*)$/u.exec(n.trimEnd());if(a){r?a[1][0]===r.marker&&a[1].length>=r.length&&a[2].trim().length===0&&(r=null):r={marker:a[1][0],length:a[1].length};continue}if(r)continue;let o=/^(\s{0,3})(#{2,6})\s+Requirement:\s*([^\s]+)(?:\s+(.*?))?\s*$/u.exec(n);if(!o)continue;let s=o[3];if(!Qp.test(s))throw new P(`Native total Spec requirement ID is invalid: ${s}`);t.push({line:i,level:o[2].length,id:s,title:o[4]?.trim()??""})}return t}function Jt(e){let t=Ut(e),r=t.split(`
151
- `),i=Ok(r),n=[],a=new Set;for(let c of i){if(a.has(c.id))throw new P(`Native total Spec contains duplicate requirement ID ${c.id}`);a.add(c.id);let u=r.length;for(let d=c.line+1;d<r.length;d+=1){if(i.some(h=>h.line===d)){u=d;break}let f=$k(r[d]);if(f!==null&&f<=c.level){u=d;break}}n.push({start:c.line,end:u,marker:c})}let o=new Map;for(let c of n){let u=`${r.slice(c.start,c.end).join(`
167
+ `)}function Ur(e){return gE("sha256").update(sr(e)).digest("hex")}function Ql(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new R(`${t} must be an object`);return e}function vm(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new R(`${r} has unknown field(s): ${i.join(", ")}`)}function Zl(e,t){if(typeof e!="string"||e.trim().length===0)throw new R(`${t} must be a non-empty string`);return e.trim()}function fm(e,t){if(e!==void 0){if(typeof e!="string")throw new R(`${t} must be text`);return sr(e).replace(/^\n+|\n+$/gu,"")}}function xo(e,t){let r=Zl(e,t).toLowerCase();if(!yE.test(r))throw new R(`${t} must be a SHA-256 hash`);return r}function pm(e,t,r){let i=Ql(e,t),n=Object.entries(i);if(n.length>dm)throw new R(`${t} must contain at most ${dm} entries`);let a={};for(let[o,s]of n){if(Yl(o,`${t} ID`)!==o)throw new R(`${t} ID must be normalized: ${o}`);s===null&&r?a[o]=null:a[o]=xo(s,`${t}.${o}`)}return a}function Yl(e,t){let r=Zl(e,t);if(!mm.test(r))throw new R(`${t} is not a valid stable requirement ID`);return r}function bE(e,t){let r=Zl(e,t);if(!wE.test(r))throw new R(`${t} is not a valid capability ID`);return r}function NE(e,t){let r=`Native delta operations[${t}]`,i=Ql(e,r);vm(i,new Set(["id","operation","to_id","title","body","expected_hash"]),r);let n=Yl(i.id,`${r}.id`),a=i.operation;if(!["add","modify","remove","rename"].includes(String(a)))throw new R(`${r}.operation is invalid`);let o=a,s=i.to_id===void 0?void 0:Yl(i.to_id,`${r}.to_id`),l=fm(i.title,`${r}.title`),c=fm(i.body,`${r}.body`),u=i.expected_hash===void 0?void 0:xo(i.expected_hash,`${r}.expected_hash`);if(o==="add"){if(s!==void 0||u!==void 0||!c?.trim())throw new R(`${r} add requires body and forbids to_id and expected_hash`)}else if(o==="modify"){if(s!==void 0||!u||!c?.trim())throw new R(`${r} modify requires body and expected_hash and forbids to_id`)}else if(o==="remove"){if(s!==void 0||l!==void 0||c!==void 0||!u)throw new R(`${r} remove requires expected_hash and forbids to_id, title, and body`)}else if(s===void 0||s===n||!u||c==="")throw new R(`${r} rename requires a different to_id and expected_hash`);return{id:n,operation:o,...s===void 0?{}:{to_id:s},...l===void 0?{}:{title:l},...c===void 0?{}:{body:c},...u===void 0?{}:{expected_hash:u}}}function kE(e){let t=Ql(e,"Native delta");if(vm(t,new Set(["schema","capability","base_hash","base_version","legacy_hash","base_requirements","independent_requirements","operations"]),"Native delta"),t.schema!==Ul)throw new R(`Native delta schema must be ${Ul}`);let r=bE(t.capability,"Native delta capability"),i=xo(t.base_hash,"Native delta base_hash");if(!Number.isSafeInteger(t.base_version)||Number(t.base_version)<1)throw new R("Native delta base_version must be a positive integer");let n=t.legacy_hash===void 0?void 0:xo(t.legacy_hash,"Native delta legacy_hash"),a;t.base_requirements!==void 0&&(a=pm(t.base_requirements,"Native delta base_requirements",!1));let o=t.independent_requirements===void 0?void 0:pm(t.independent_requirements,"Native delta independent_requirements",!0);if(!Array.isArray(t.operations))throw new R("Native delta operations must be an array");let s=t.operations.map(NE),l=new Set;for(let[c,u]of s.entries()){let d=[u.id,...u.to_id===void 0?[]:[u.to_id]];for(let f of d){if(l.has(f))throw new R(`Native delta operations contain duplicate or overlapping requirement ID ${f} at ${c}`);l.add(f)}}if(o!==void 0){if(a===void 0)throw new R("Native delta independent_requirements requires base_requirements");for(let[c,u]of Object.entries(o)){if(l.has(c))throw new R(`Native delta requirement ${c} cannot be both addressed and independent`);let d=a[c];if(u===null?d!==void 0:d!==u)throw new R(`Native delta independent_requirements does not match baseline ${c}`)}}return{schema:Ul,capability:r,base_hash:i,base_version:Number(t.base_version),...n===void 0?{}:{legacy_hash:n},...a===void 0?{}:{base_requirements:a},...o===void 0?{}:{independent_requirements:o},operations:s}}function SE(e){let t=(0,Xl.parseDocument)(e,{uniqueKeys:!0});if(t.errors.length>0)throw new R(`Native delta is invalid YAML: ${t.errors[0].message}`);return t.toJS({mapAsMap:!1})}function fn(e){return kE(typeof e=="string"?SE(e):e)}function EE(e){let t=/^\s{0,3}(#{1,6})\s+/u.exec(e);return t?t[1].length:null}function xE(e){let t=[],r=null;for(let[i,n]of e.entries()){let a=/^\s{0,3}(`{3,}|~{3,})(.*)$/u.exec(n.trimEnd());if(a){r?a[1][0]===r.marker&&a[1].length>=r.length&&a[2].trim().length===0&&(r=null):r={marker:a[1][0],length:a[1].length};continue}if(r)continue;let o=/^(\s{0,3})(#{2,6})\s+Requirement:\s*([^\s]+)(?:\s+(.*?))?\s*$/u.exec(n);if(!o)continue;let s=o[3];if(!mm.test(s))throw new R(`Native total Spec requirement ID is invalid: ${s}`);t.push({line:i,level:o[2].length,id:s,title:o[4]?.trim()??""})}return t}function or(e){let t=sr(e),r=t.split(`
168
+ `),i=xE(r),n=[],a=new Set;for(let c of i){if(a.has(c.id))throw new R(`Native total Spec contains duplicate requirement ID ${c.id}`);a.add(c.id);let u=r.length;for(let d=c.line+1;d<r.length;d+=1){if(i.some(h=>h.line===d)){u=d;break}let f=EE(r[d]);if(f!==null&&f<=c.level){u=d;break}}n.push({start:c.line,end:u,marker:c})}let o=new Map;for(let c of n){let u=`${r.slice(c.start,c.end).join(`
152
169
  `)}${c.end<r.length?`
153
170
  `:""}`,d=r.slice(c.start+1,c.end).join(`
154
171
  `).replace(/^\n/u,"").replace(/\n+$/u,"");o.set(c.marker.id,{id:c.marker.id,level:c.marker.level,title:c.marker.title,body:d,raw:u,startLine:c.start,endLine:c.end})}let s=[],l=0;for(let c of n)s.push(r.slice(l,c.start).join(`
155
172
  `)),l=c.end;return s.push(r.slice(l).join(`
156
173
  `)),{text:t,lines:r,requirements:o,legacyText:s.join(`
157
- `)}}function dl(e){return Rr(e)}function rt(e){return Rr(e)}function eh(e){let t=Jt(e).legacyText;return Rr(t.split(`
174
+ `)}}function eu(e){return Ur(e)}function pt(e){return Ur(e)}function gm(e){let t=or(e).legacyText;return Ur(t.split(`
158
175
  `).filter(r=>r.trim().length>0).join(`
159
- `).trim())}function th(e,t){let r=Jt(e),i=[];for(let n of t.operations){if(n.operation==="remove")continue;let a=n.operation==="rename"?n.to_id:n.id,o=r.requirements.get(a);if(!o)throw new P(`Native delta target Spec is missing requirement ${a} for ${n.operation}`);i.push(o.raw.trimEnd())}return i.length===0?"":`${i.join(`
176
+ `).trim())}function wm(e,t){let r=or(e),i=[];for(let n of t.operations){if(n.operation==="remove")continue;let a=n.operation==="rename"?n.to_id:n.id,o=r.requirements.get(a);if(!o)throw new R(`Native delta target Spec is missing requirement ${a} for ${n.operation}`);i.push(o.raw.trimEnd())}return i.length===0?"":`${i.join(`
160
177
 
161
178
  `)}
162
- `}function Va(e,t,r,i){let n=`${"#".repeat(e)} Requirement: ${t}${r?.trim()?` ${r.trim()}`:""}`,a=Ut(i).replace(/\n+$/u,"");return[n,"",...a.split(`
179
+ `}function Co(e,t,r,i){let n=`${"#".repeat(e)} Requirement: ${t}${r?.trim()?` ${r.trim()}`:""}`,a=sr(i).replace(/\n+$/u,"");return[n,"",...a.split(`
163
180
  `),"",""].join(`
164
- `)}function ol(e){return e.operation==="rename"?[e.id,e.to_id]:[e.id]}function qa(e,t){if(e.operation==="rename"){if(!t)throw new P(`Rename target does not exist: ${e.id}`);return{id:e.to_id,level:t.level,title:e.title??t.title,body:e.body??t.body}}return{id:e.id,level:t?.level??2,title:e.title??t?.title,body:e.body??t?.body??""}}function Hk(e,t,r){let i=Jt(e),n=[...i.lines],a=i.requirements.get(t.id);if(!a)throw new P(`Requirement target disappeared: ${t.id}`);return n.splice(a.startLine,a.endLine-a.startLine,...r.split(`
181
+ `)}function Kl(e){return e.operation==="rename"?[e.id,e.to_id]:[e.id]}function Po(e,t){if(e.operation==="rename"){if(!t)throw new R(`Rename target does not exist: ${e.id}`);return{id:e.to_id,level:t.level,title:e.title??t.title,body:e.body??t.body}}return{id:e.id,level:t?.level??2,title:e.title??t?.title,body:e.body??t?.body??""}}function CE(e,t,r){let i=or(e),n=[...i.lines],a=i.requirements.get(t.id);if(!a)throw new R(`Requirement target disappeared: ${t.id}`);return n.splice(a.startLine,a.endLine-a.startLine,...r.split(`
165
182
  `)),n.join(`
166
- `)}function Dk(e,t){let r=Ut(e),i=r.length===0||r.endsWith(`
183
+ `)}function PE(e,t){let r=sr(e),i=r.length===0||r.endsWith(`
167
184
 
168
185
  `)?"":`
169
186
  `,n=`${r}${i}`;return`${n.endsWith(`
170
187
  `)||n.length===0?n:`${n}
171
- `}${t}`}function rh(e,t){if(e.operation==="add"||e.operation==="modify"){let a=t.requirements.get(e.id);if(!a)return!1;let o=qa(e,e.operation==="modify"?a:void 0);return a.raw===Va(o.level,o.id,o.title,o.body)}if(e.operation==="remove")return!1;let r=t.requirements.get(e.to_id),i=t.requirements.get(e.id);if(!r||i)return!1;let n=qa(e,{id:e.id,level:r.level,title:r.title,body:r.body,raw:r.raw,startLine:r.startLine,endLine:r.endLine});return r.raw===Va(n.level,n.id,n.title,n.body)}function Lk(e,t){let r=t.requirements.get(e.id);if(e.operation==="add"){if(r)throw new P(`Add target already exists: ${e.id}`);return}if(!r)throw new P(`Native delta target does not exist: ${e.id}`);if(e.expected_hash!==dl(r.raw))throw new P(`Native delta ${e.operation} expected_hash does not match ${e.id}`);if(e.operation==="rename"&&t.requirements.has(e.to_id))throw new P(`Rename destination already exists: ${e.to_id}`)}function Bk(e,t){if(e.base_requirements===void 0)return;let r=e.base_requirements,i=t.requirements;if(Object.keys(r).length!==i.size)throw new P("Native delta base_requirements must describe the complete total Spec baseline");for(let[n,a]of i)if(r[n]!==dl(a.raw))throw new P(`Native delta base_requirements does not match requirement ${n}`)}function Mk(e,t){let r=eh(t.text);if(r!==Rr("")&&e.legacy_hash!==r)throw new P("Native delta modifying a legacy total Spec requires a matching legacy_hash")}function Fk(e){let t=Ut(e.baselineMarkdown),r=[],i=[];for(let a of e.delta.operations){let o=Jt(t),s=o.requirements.get(a.id);if(e.allowAlreadyApplied&&rh(a,o)){i.push({id:a.id,operation:a.operation,status:"already-applied",targetIds:ol(a)});continue}if(a.operation==="add"){if(s)throw new Gt([a.id],`Native delta add conflicts with existing requirement ${a.id}`);let l=qa(a,void 0);t=Dk(t,Va(l.level,l.id,l.title,l.body))}else{if(!s)throw new Gt([a.id],`Native delta ${a.operation} target does not exist: ${a.id}`);if(a.expected_hash!==dl(s.raw))throw new Gt([a.id],`Native delta ${a.operation} conflicts with concurrent requirement ${a.id}`);let l=qa(a,s);if(a.operation==="rename"&&Jt(t).requirements.has(a.to_id))throw new Gt([a.id,a.to_id],`Native delta rename destination already exists: ${a.to_id}`);if(a.operation==="remove"){let c=[...Jt(t).lines];c.splice(s.startLine,s.endLine-s.startLine),t=c.join(`
172
- `)}else t=Hk(t,s,Va(l.level,l.id,l.title,l.body))}r.push(...ol(a)),i.push({id:a.id,operation:a.operation,status:"changed",targetIds:ol(a)})}let n=Ut(t);return{markdown:n,base_hash:e.delta.base_hash,result_hash:Rr(n),rebased:e.rebased,changedRequirementIds:[...new Set(r)],operationResults:i}}function ih(e){let t=Jt(e.baselineMarkdown);if(Rr(t.text)!==e.delta.base_hash)throw new Gt([e.delta.capability],`Native delta base hash does not match the current total Spec for ${e.delta.capability}`);Mk(e.delta,t),Bk(e.delta,t);for(let r of e.delta.operations)e.allowAlreadyApplied&&rh(r,t)||Lk(r,t);return Fk({baselineMarkdown:t.text,delta:e.delta,allowAlreadyApplied:e.allowAlreadyApplied??!1,rebased:!1})}var cl,al,Xp,Rk,Qp,_k,Up,P,Gt,fl=S(()=>{"use strict";cl=mt(Ze(),1),al="comet.native.delta.v1",Xp="delta.yaml",Rk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Qp=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u,_k=/^[a-f0-9]{64}$/iu,Up=512,P=class extends Error{code="native-delta-invalid";constructor(t){super(t),this.name="NativeDeltaValidationError"}},Gt=class extends Error{code="native-delta-conflict";conflictIds;constructor(t,r){super(r),this.name="NativeDeltaConflictError",this.conflictIds=[...new Set(t)]}}});var Fe,Ve,qe,Bi=S(()=>{"use strict";Fe="comet.native.v3",Ve="comet.native.v2",qe="comet.native.v1"});import Vk from"node:path";function Vi(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function sh(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function qi(e){if(!oh.test(e))throw new Error(`Invalid Native change name: ${e}`)}function ch(e){if(!oh.test(e))throw new Error(`Invalid Native capability id: ${e}`)}function lh(e,t){if(e.length===0||Vk.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native change`)}function Yk(e,t){let r=Vi(e,`spec_changes[${t}]`);if(sh(r,zk,`spec_changes[${t}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(ch(r.capability),r.operation!=="create"&&r.operation!=="replace"&&r.operation!=="remove")throw new Error(`Invalid spec operation for ${r.capability}`);let i=r.source,n=r.base_hash;if(i!==void 0&&typeof i!="string")throw new Error(`Spec source for ${r.capability} must be a string`);if(typeof i=="string"&&lh(i,`Spec source for ${r.capability}`),r.operation==="create"){if(!i)throw new Error(`Create spec ${r.capability} requires source`);if(n!==null)throw new Error(`Create spec ${r.capability} requires null base_hash`)}else if(r.operation==="replace"){if(!i)throw new Error(`Replace spec ${r.capability} requires source`);if(typeof n!="string"||!hl.test(n))throw new Error(`Replace spec ${r.capability} requires a SHA-256 base_hash`)}else{if(i!==void 0)throw new Error(`Remove spec ${r.capability} forbids source`);if(typeof n!="string"||!hl.test(n))throw new Error(`Remove spec ${r.capability} requires a SHA-256 base_hash`)}return{capability:r.capability,operation:r.operation,...typeof i=="string"?{source:i}:{},base_hash:n}}function Xk(e){return/^\d{4}-\d{2}-\d{2}$/u.test(e)?new Date(`${e}T00:00:00.000Z`).toISOString().slice(0,10)===e:!1}function ml(e,t){if(sh(e,t,nt),typeof e.name!="string")throw new Error("Native change name is required");if(qi(e.name),e.language!=="en"&&e.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof e.phase!="string"||!Gk.has(e.phase))throw new Error("Native change phase is invalid");if(e.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(e.approval!==null&&!Jk.has(e.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native spec_changes must be an array");let r=e.spec_changes.map(Yk),i=r.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(i.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(i)].join(", ")}`);if(typeof e.verification_result!="string"||!Uk.has(e.verification_result))throw new Error("Native verification_result is invalid");if(e.verification_report!==null&&typeof e.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof e.verification_report=="string"&&lh(e.verification_report,"Native verification_report"),typeof e.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof e.created_at!="string"||!Xk(e.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(e.run_id!==null&&(typeof e.run_id!="string"||e.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:e.name,language:e.language,phase:e.phase,brief:"brief.md",approval:e.approval,spec_changes:r,verification_result:e.verification_result,verification_report:e.verification_report,archived:e.archived,created_at:e.created_at,run_id:e.run_id}}function _r(e){let t=Vi(e,nt);if(t.schema!==qe)throw new Error(`Expected ${qe}`);return{schema:qe,...ml(t,qk)}}function Fi(e,t){if(!Number.isSafeInteger(e)||e<1)throw new Error(`${t} must be a positive integer`);return e}function pl(e,t,r){if(e===null)return null;let i=typeof e=="string"?Kk.exec(e):null;if(!i||i[1]!==r)throw new Error(`${t} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return e}function Qk(e){if(e==null)return null;if(typeof e!="string"||!hl.test(e))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return e}function Zk(e){if(e===void 0)return"legacy-v1";if(e!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return e}function Ar(e){let t=Vi(e,nt);if(t.schema!==Ve)throw new Error(`Expected ${Ve}`);if(Fi(t.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Ve} minimum_runtime_version must be 2`);return{schema:Ve,minimum_runtime_version:2,revision:Fi(t.revision,"Native v2 revision"),...ml(t,ah)}}function Kt(e){let t=Vi(e,nt);if(t.schema!==Fe){if(t.schema===qe||t.schema===Ve){let o=t.schema===qe?_r(t):Ar(t);throw new Mi(o.name,o.schema)}throw new We(typeof t.schema=="string"?t.schema:"(missing)",typeof t.minimum_runtime_version=="number"?t.minimum_runtime_version:null)}let r=Fi(t.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new We(t.schema,r);if(r!==3)throw new Error(`Native ${t.schema} minimum_runtime_version must be ${3}`);let i=Fi(t.revision,"Native revision"),n=ml(t,Wk),a=Qk(t.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Fe,minimum_runtime_version:3,revision:i,verification_protocol:Zk(t.verification_protocol),...n,approved_contract_hash:a,implementation_scope:pl(t.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:pl(t.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:pl(t.partial_allowance,"Native partial_allowance","allowances")}}function vl(e){let t=Vi(e,nt);if(t.schema===qe){let n=_r(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Fe}`}}if(t.schema===Ve){let n=Ar(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Fe}`}}if(t.schema!==Fe){let n=typeof t.minimum_runtime_version=="number"&&Number.isSafeInteger(t.minimum_runtime_version)?t.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof t.schema=="string"?t.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new We(typeof t.schema=="string"?t.schema:"(missing)",n).message}}let r=Fi(t.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:t.schema,minimumRuntimeVersion:r,state:null,message:new We(t.schema,r).message};let i=Kt(t);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}var nh,qk,ah,Wk,zk,Gk,Jk,Uk,nt,hl,oh,Kk,Mi,We,Wa=S(()=>{"use strict";Bi();nh=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],qk=new Set(nh),ah=new Set([...nh,"minimum_runtime_version","revision"]),Wk=new Set([...ah,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),zk=new Set(["capability","operation","source","base_hash"]),Gk=new Set(["shape","build","verify","archive"]),Jk=new Set(["implicit","confirmed"]),Uk=new Set(["pending","pass","fail"]),nt="comet-state.yaml",hl=/^[a-f0-9]{64}$/u,oh=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Kk=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Mi=class extends Error{constructor(r,i){super(`Native change ${r} uses ${i}; run comet native doctor ${r} --repair before mutating it`);this.change=r;this.schema=i;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},We=class extends Error{constructor(r,i){super(r!==Fe||i===null?`Unsupported Native change schema ${r} for runtime protocol ${3}`:`Native change ${r} requires runtime protocol ${i}; current protocol is ${3}`);this.schema=r;this.minimumRuntimeVersion=i;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"}});function fh(e){let t=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(e);return t?{level:t[1].length,text:t[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function uh(e,t){let r=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(e);if(!r)return t;let i=r[1][0];return t===null?{marker:i,length:r[1].length}:i===t.marker&&r[1].length>=t.length&&r[2].trim().length===0?null:t}function dh(e){return e.includes("-->")||e.includes("--!>")}function*za(e){let t=null,r=!1,i=null,n=new Set(["code","pre","script","style","svg","template"]),a=e.replace(/\r\n?/gu,`
188
+ `}${t}`}function ym(e,t){if(e.operation==="add"||e.operation==="modify"){let a=t.requirements.get(e.id);if(!a)return!1;let o=Po(e,e.operation==="modify"?a:void 0);return a.raw===Co(o.level,o.id,o.title,o.body)}if(e.operation==="remove")return!1;let r=t.requirements.get(e.to_id),i=t.requirements.get(e.id);if(!r||i)return!1;let n=Po(e,{id:e.id,level:r.level,title:r.title,body:r.body,raw:r.raw,startLine:r.startLine,endLine:r.endLine});return r.raw===Co(n.level,n.id,n.title,n.body)}function RE(e,t){let r=t.requirements.get(e.id);if(e.operation==="add"){if(r)throw new R(`Add target already exists: ${e.id}`);return}if(!r)throw new R(`Native delta target does not exist: ${e.id}`);if(e.expected_hash!==eu(r.raw))throw new R(`Native delta ${e.operation} expected_hash does not match ${e.id}`);if(e.operation==="rename"&&t.requirements.has(e.to_id))throw new R(`Rename destination already exists: ${e.to_id}`)}function _E(e,t){if(e.base_requirements===void 0)return;let r=e.base_requirements,i=t.requirements;if(Object.keys(r).length!==i.size)throw new R("Native delta base_requirements must describe the complete total Spec baseline");for(let[n,a]of i)if(r[n]!==eu(a.raw))throw new R(`Native delta base_requirements does not match requirement ${n}`)}function AE(e,t){let r=gm(t.text);if(r!==Ur("")&&e.legacy_hash!==r)throw new R("Native delta modifying a legacy total Spec requires a matching legacy_hash")}function IE(e){let t=sr(e.baselineMarkdown),r=[],i=[];for(let a of e.delta.operations){let o=or(t),s=o.requirements.get(a.id);if(e.allowAlreadyApplied&&ym(a,o)){i.push({id:a.id,operation:a.operation,status:"already-applied",targetIds:Kl(a)});continue}if(a.operation==="add"){if(s)throw new ar([a.id],`Native delta add conflicts with existing requirement ${a.id}`);let l=Po(a,void 0);t=PE(t,Co(l.level,l.id,l.title,l.body))}else{if(!s)throw new ar([a.id],`Native delta ${a.operation} target does not exist: ${a.id}`);if(a.expected_hash!==eu(s.raw))throw new ar([a.id],`Native delta ${a.operation} conflicts with concurrent requirement ${a.id}`);let l=Po(a,s);if(a.operation==="rename"&&or(t).requirements.has(a.to_id))throw new ar([a.id,a.to_id],`Native delta rename destination already exists: ${a.to_id}`);if(a.operation==="remove"){let c=[...or(t).lines];c.splice(s.startLine,s.endLine-s.startLine),t=c.join(`
189
+ `)}else t=CE(t,s,Co(l.level,l.id,l.title,l.body))}r.push(...Kl(a)),i.push({id:a.id,operation:a.operation,status:"changed",targetIds:Kl(a)})}let n=sr(t);return{markdown:n,base_hash:e.delta.base_hash,result_hash:Ur(n),rebased:e.rebased,changedRequirementIds:[...new Set(r)],operationResults:i}}function bm(e){let t=or(e.baselineMarkdown);if(Ur(t.text)!==e.delta.base_hash)throw new ar([e.delta.capability],`Native delta base hash does not match the current total Spec for ${e.delta.capability}`);AE(e.delta,t),_E(e.delta,t);for(let r of e.delta.operations)e.allowAlreadyApplied&&ym(r,t)||RE(r,t);return IE({baselineMarkdown:t.text,delta:e.delta,allowAlreadyApplied:e.allowAlreadyApplied??!1,rebased:!1})}var Xl,Ul,hm,wE,mm,yE,dm,R,ar,tu=S(()=>{"use strict";Xl=Ct(ut(),1),Ul="comet.native.delta.v1",hm="delta.yaml",wE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,mm=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u,yE=/^[a-f0-9]{64}$/iu,dm=512,R=class extends Error{code="native-delta-invalid";constructor(t){super(t),this.name="NativeDeltaValidationError"}},ar=class extends Error{code="native-delta-conflict";conflictIds;constructor(t,r){super(r),this.name="NativeDeltaConflictError",this.conflictIds=[...new Set(t)]}}});var Ye,Xe,Qe,pn=S(()=>{"use strict";Ye="comet.native.v3",Xe="comet.native.v2",Qe="comet.native.v1"});import TE from"node:path";function vn(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Em(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function gn(e){if(!Sm.test(e))throw new Error(`Invalid Native change name: ${e}`)}function xm(e){if(!Sm.test(e))throw new Error(`Invalid Native capability id: ${e}`)}function Cm(e,t){if(e.length===0||TE.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native change`)}function ME(e,t){let r=vn(e,`spec_changes[${t}]`);if(Em(r,OE,`spec_changes[${t}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(xm(r.capability),r.operation!=="create"&&r.operation!=="replace"&&r.operation!=="remove")throw new Error(`Invalid spec operation for ${r.capability}`);let i=r.source,n=r.base_hash;if(i!==void 0&&typeof i!="string")throw new Error(`Spec source for ${r.capability} must be a string`);if(typeof i=="string"&&Cm(i,`Spec source for ${r.capability}`),r.operation==="create"){if(!i)throw new Error(`Create spec ${r.capability} requires source`);if(n!==null)throw new Error(`Create spec ${r.capability} requires null base_hash`)}else if(r.operation==="replace"){if(!i)throw new Error(`Replace spec ${r.capability} requires source`);if(typeof n!="string"||!iu.test(n))throw new Error(`Replace spec ${r.capability} requires a SHA-256 base_hash`)}else{if(i!==void 0)throw new Error(`Remove spec ${r.capability} forbids source`);if(typeof n!="string"||!iu.test(n))throw new Error(`Remove spec ${r.capability} requires a SHA-256 base_hash`)}return{capability:r.capability,operation:r.operation,...typeof i=="string"?{source:i}:{},base_hash:n}}function FE(e){return/^\d{4}-\d{2}-\d{2}$/u.test(e)?new Date(`${e}T00:00:00.000Z`).toISOString().slice(0,10)===e:!1}function nu(e,t){if(Em(e,t,mt),typeof e.name!="string")throw new Error("Native change name is required");if(gn(e.name),e.language!=="en"&&e.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof e.phase!="string"||!HE.has(e.phase))throw new Error("Native change phase is invalid");if(e.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(e.approval!==null&&!DE.has(e.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native spec_changes must be an array");let r=e.spec_changes.map(ME),i=r.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(i.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(i)].join(", ")}`);if(typeof e.verification_result!="string"||!LE.has(e.verification_result))throw new Error("Native verification_result is invalid");if(e.verification_report!==null&&typeof e.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof e.verification_report=="string"&&Cm(e.verification_report,"Native verification_report"),typeof e.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof e.created_at!="string"||!FE(e.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(e.run_id!==null&&(typeof e.run_id!="string"||e.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:e.name,language:e.language,phase:e.phase,brief:"brief.md",approval:e.approval,spec_changes:r,verification_result:e.verification_result,verification_report:e.verification_report,archived:e.archived,created_at:e.created_at,run_id:e.run_id}}function Kr(e){let t=vn(e,mt);if(t.schema!==Qe)throw new Error(`Expected ${Qe}`);return{schema:Qe,...nu(t,$E)}}function mn(e,t){if(!Number.isSafeInteger(e)||e<1)throw new Error(`${t} must be a positive integer`);return e}function ru(e,t,r){if(e===null)return null;let i=typeof e=="string"?BE.exec(e):null;if(!i||i[1]!==r)throw new Error(`${t} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return e}function qE(e){if(e==null)return null;if(typeof e!="string"||!iu.test(e))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return e}function VE(e){if(e===void 0)return"legacy-v1";if(e!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return e}function Yr(e){let t=vn(e,mt);if(t.schema!==Xe)throw new Error(`Expected ${Xe}`);if(mn(t.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Xe} minimum_runtime_version must be 2`);return{schema:Xe,minimum_runtime_version:2,revision:mn(t.revision,"Native v2 revision"),...nu(t,km)}}function cr(e){let t=vn(e,mt);if(t.schema!==Ye){if(t.schema===Qe||t.schema===Xe){let o=t.schema===Qe?Kr(t):Yr(t);throw new hn(o.name,o.schema)}throw new Ze(typeof t.schema=="string"?t.schema:"(missing)",typeof t.minimum_runtime_version=="number"?t.minimum_runtime_version:null)}let r=mn(t.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Ze(t.schema,r);if(r!==3)throw new Error(`Native ${t.schema} minimum_runtime_version must be ${3}`);let i=mn(t.revision,"Native revision"),n=nu(t,jE),a=qE(t.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Ye,minimum_runtime_version:3,revision:i,verification_protocol:VE(t.verification_protocol),...n,approved_contract_hash:a,implementation_scope:ru(t.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:ru(t.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:ru(t.partial_allowance,"Native partial_allowance","allowances")}}function au(e){let t=vn(e,mt);if(t.schema===Qe){let n=Kr(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Ye}`}}if(t.schema===Xe){let n=Yr(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Ye}`}}if(t.schema!==Ye){let n=typeof t.minimum_runtime_version=="number"&&Number.isSafeInteger(t.minimum_runtime_version)?t.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof t.schema=="string"?t.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new Ze(typeof t.schema=="string"?t.schema:"(missing)",n).message}}let r=mn(t.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:t.schema,minimumRuntimeVersion:r,state:null,message:new Ze(t.schema,r).message};let i=cr(t);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}var Nm,$E,km,jE,OE,HE,DE,LE,mt,iu,Sm,BE,hn,Ze,Ro=S(()=>{"use strict";pn();Nm=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],$E=new Set(Nm),km=new Set([...Nm,"minimum_runtime_version","revision"]),jE=new Set([...km,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),OE=new Set(["capability","operation","source","base_hash"]),HE=new Set(["shape","build","verify","archive"]),DE=new Set(["implicit","confirmed"]),LE=new Set(["pending","pass","fail"]),mt="comet-state.yaml",iu=/^[a-f0-9]{64}$/u,Sm=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,BE=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,hn=class extends Error{constructor(r,i){super(`Native change ${r} uses ${i}; run comet native doctor ${r} --repair before mutating it`);this.change=r;this.schema=i;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},Ze=class extends Error{constructor(r,i){super(r!==Ye||i===null?`Unsupported Native change schema ${r} for runtime protocol ${3}`:`Native change ${r} requires runtime protocol ${i}; current protocol is ${3}`);this.schema=r;this.minimumRuntimeVersion=i;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"}});function _m(e){let t=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(e);return t?{level:t[1].length,text:t[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function Pm(e,t){let r=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(e);if(!r)return t;let i=r[1][0];return t===null?{marker:i,length:r[1].length}:i===t.marker&&r[1].length>=t.length&&r[2].trim().length===0?null:t}function Rm(e){return e.includes("-->")||e.includes("--!>")}function*_o(e){let t=null,r=!1,i=null,n=new Set(["code","pre","script","style","svg","template"]),a=e.replace(/\r\n?/gu,`
173
190
  `),o=0,s=0;for(;o<=a.length;){let l=a.indexOf(`
174
- `,o),c=l===-1?a.slice(o):a.slice(o,l);if(yield{line:c,body:t===null&&!r&&i===null,index:s},s+=1,t!==null)t=uh(c,t);else if(r)dh(c)&&(r=!1);else if(i!==null)new RegExp(`</${i}\\s*>`,"iu").test(c)&&(i=null);else{let d=uh(c,null);if(d!==null)t=d;else{let f=c.trimStart();if(f.startsWith("<!--")&&!dh(f))r=!0;else{let h=/^<([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/u.exec(f);h&&n.has(h[1].toLowerCase())&&!f.startsWith("</")&&!f.endsWith("/>")&&!new RegExp(`</${h[1]}\\s*>`,"iu").test(f)&&(i=h[1])}}}if(l===-1)break;o=l+1}}function Wi(e){return e.normalize("NFC").replace(/\s+/gu," ").trim()}function ph(e,t,r,i=[],n="content-hash"){let a=Wi(r),o=t.replaceAll("\\","/").trim(),s=i.map(Wi);if(a.length===0)throw new Error(`${e} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${e} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${O(eS,{kind:e,source:o,context:s,text:a})}`:"",kind:e,source:o,context:s,text:a}}function hh(e,t,r="content-hash"){let i=new Set;for(let n of e){let a=r==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(i.has(a))throw new Error(`${t} contains duplicate acceptance criteria`);i.add(a)}return e}function tS(e){let t=null,r=null,i=0,n=0;for(let{line:a,body:o,index:s}of za(e)){n=s+1;let l=o?fh(a):null;l?.level===1&&(ma(l.text)==="acceptanceExamples"?(i+=1,i===1&&(t=s+1)):t!==null&&r===null&&(r=s))}if(i===0||t===null)return null;if(i!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:t,end:r??n}}function gl(e,t="brief.md",r=Ga.maxCriteria,i="content-hash"){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native brief acceptance budget is invalid");let n=tS(e);if(n===null)return[];let a=null;for(let{line:c,body:u,index:d}of za(e)){if(d<n.start||d>=n.end)continue;let f=u?/^( {0,3})[-*+][ \t]+/u.exec(c):null;if(f===null)continue;let h=f[1].length;a=a===null?h:Math.min(a,h)}let o=[],s=null,l=()=>{if(s!==null){if(o.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);o.push(s)}};for(let{line:c,body:u,index:d}of za(e)){if(d<n.start||d>=n.end)continue;let f=u?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(c):null;f&&f[1].length===a?(l(),s=[f[2]]):s!==null&&s.push(c)}return l(),hh(o.map(c=>ph("brief-example",t,c.join(`
175
- `),[],i)),"Brief",i)}function wl(e,t="spec.md",r=Ga.maxCriteria,i="content-hash"){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native specification acceptance budget is invalid");let n=[],a=[],o=null,s=()=>{if(o!==null){if(n.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);n.push(ph("spec-scenario",t,[o.title,...o.body].join(`
176
- `),o.context,i)),o=null}};for(let{line:l,body:c}of za(e)){let u=c?fh(l):null,d=u?/^Scenario\s*:\s*(.*)$/iu.exec(u.text):null;if(d){for(s();a.at(-1)&&a.at(-1).level>=u.level;)a.pop();let f=Wi(d[1]);if(f.length===0)throw new Error("Scenario title must not be empty");o={level:u.level,title:f,body:[],context:a.map(h=>h.text)}}else if(u){for(o!==null&&u.level<=o.level?s():o!==null&&o.body.push(l);a.at(-1)&&a.at(-1).level>=u.level;)a.pop();a.push(u)}else o!==null&&c&&o.body.push(l)}return s(),hh(n,"Specification",i)}var eS,$A,Ga,Ja=S(()=>{"use strict";Vt();J();eS="comet.native.acceptance.v1",$A=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Ga=Object.freeze({maxCriteria:1024})});import mh from"node:path";function vh(e,t){if(e.length===0||e!==e.trim()||e.includes("\\")||mh.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||mh.posix.normalize(e)!==e||e==="."||e.endsWith("/"))throw new Error(`${t} must be a normalized change-relative ref`);return e}function iS(e,t){return e.localeCompare(t,"en")}function Ua(e){let t=vh(e.briefSource??"brief.md","Native brief source"),r=[...e.specs??[]].sort((a,o)=>iS(a.capability,o.capability));if(new Set(r.map(a=>a.capability)).size!==r.length)throw new Error("Native acceptance sources contain duplicate capabilities");let i=gl(e.briefMarkdown,t,Number.MAX_SAFE_INTEGER,"none").map(({source:a,text:o})=>({source:a,text:o}));for(let a of r){let o=vh(a.source,`Native spec source for ${a.capability}`);i.push(...wl(a.markdown,o,Number.MAX_SAFE_INTEGER,"none").map(({text:s})=>({source:o,text:s})))}let n=new Set;for(let a of i){a.text=Wi(a.text);let o=a.text;if(n.has(o))throw new Error(`Native acceptance contains a duplicate criterion: ${a.text}`);n.add(o)}if(i.length===0)throw new Error("Native change must define at least one acceptance criterion");return i.map((a,o)=>({id:`A${o+1}`,source:a.source,text:a.text}))}function gh(e){let t=e.map(({id:r})=>r);if(new Set(t).size!==t.length)throw new Error("Native acceptance IDs must be unique");for(let r=0;r<t.length;r+=1)if(!rS.test(t[r])||t[r]!==`A${r+1}`)throw new Error("Native acceptance IDs must be the contiguous sequence A1..An")}function yl(e,t){return e.length===t.length&&e.every((r,i)=>r.source===t[i]?.source&&r.text===t[i]?.text)}var rS,Ka=S(()=>{"use strict";Ja();rS=/^A[1-9]\d*$/u});import{promises as nS}from"node:fs";function te(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function re(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function U(e,t,r){if(typeof e!="string"||!r?.empty&&e.length===0)throw new Error(`${t} must be ${r?.empty?"a string":"a non-empty string"}`);return e}function bl(e,t){return e===null?null:U(e,t)}function kl(e,t){let r=U(e,t);if(!cS.test(r))throw new Error(`${t} must be a SHA-256 hash`);return r}function Ir(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function D(e,t,r=0){if(!Number.isSafeInteger(e)||e<r)throw new Error(`${t} must be a safe integer greater than or equal to ${r}`);return e}function uS(e,t){return e===null?null:D(e,t,Number.MIN_SAFE_INTEGER)}function V(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} must be one of: ${t.join(", ")}`);return e}function ze(e,t,r){if(!Array.isArray(e))throw new Error(`${t} must be an array`);return e.map((i,n)=>r(i,n))}function eo(e,t){return ze(e,t,(r,i)=>U(r,`${t}[${i}]`))}function Yt(e,t){if(new Set(e).size!==e.length)throw new Error(`${t} must be unique`)}function Tr(e,t){let r=U(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO date or timestamp`);return r}function Qa(e,t,r=!1){let i=U(e,t);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${t} must be a portable relative path`);return i}function ve(e,t){let r=te(e,t);return re(r,new Set(["text","truncated"]),t),{text:U(r.text,`${t}.text`,{empty:!0}),truncated:Ir(r.truncated,`${t}.truncated`)}}function dS(e,t){let r=`Native spec_changes[${t}]`,i=te(e,r);re(i,new Set(["capability","operation","source","delta_source","base_hash"]),r);let n=U(i.capability,`${r}.capability`);if(!oS.test(n))throw new Error(`${r}.capability is invalid`);let a=V(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:Qa(i.source,`${r}.source`),s=i.delta_source===void 0?void 0:Qa(i.delta_source,`${r}.delta_source`),l=i.base_hash===void 0?void 0:i.base_hash===null?null:kl(i.base_hash,`${r}.base_hash`);if(a==="remove"&&o!==null)throw new Error(`${r} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${r} ${a} requires a source`);if(s!==void 0&&a==="remove")throw new Error(`${r} remove cannot contain delta_source`);if(s!==void 0&&l==null)throw new Error(`${r} delta_source requires a non-null base_hash`);if(l!==void 0&&s===void 0&&a!=="remove")throw new Error(`${r} base_hash requires delta_source for non-remove specs`);return{capability:n,operation:a,source:o,...s===void 0?{}:{delta_source:s},...l===void 0?{}:{base_hash:l}}}function fS(e){let t="Native workspace",r=te(e,t);re(r,new Set(["isolation","change_branch","target_branch","finish"]),t);let i=V(r.isolation,["current","branch","worktree"],`${t}.isolation`),n=bl(r.change_branch,`${t}.change_branch`),a=bl(r.target_branch,`${t}.target_branch`),o=r.finish===null?null:V(r.finish,["merge","push","pull-request","keep"],`${t}.finish`);if(i==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(i==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(i!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:i,change_branch:n,target_branch:a,finish:o}}function pS(e){let t="Native loop",r=te(e,t);re(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","stop_reason","execution_failure_count","previous_unresolved_ids","next_action"]),t);let i=eo(r.previous_unresolved_ids,`${t}.previous_unresolved_ids`);Yt(i,`${t}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:V(r.stop_reason,["budget","stalled"],`${t}.stop_reason`);return{stage:V(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${t}.stage`),goal_cycle:D(r.goal_cycle,`${t}.goal_cycle`,1),iteration:D(r.iteration,`${t}.iteration`),attempt:D(r.attempt,`${t}.attempt`),retry_epoch:D(r.retry_epoch,`${t}.retry_epoch`),failed_iteration_count:D(r.failed_iteration_count,`${t}.failed_iteration_count`),no_progress_count:D(r.no_progress_count,`${t}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:D(r.execution_failure_count,`${t}.execution_failure_count`),previous_unresolved_ids:i,next_action:bl(r.next_action,`${t}.next_action`)}}function hS(e,t){let r=`Native acceptance[${t}]`,i=te(e,r);re(i,new Set(["id","source","text","result","reason"]),r);let n=U(i.id,`${r}.id`);if(!sS.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:Qa(i.source,`${r}.source`),text:U(i.text,`${r}.text`),result:V(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:ve(i.reason,`${r}.reason`)}}function mS(e,t){let r=`Native builder_handoff.checks[${t}]`,i=te(e,r);return re(i,new Set(["name","result","note"]),r),{name:ve(i.name,`${r}.name`),result:V(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:ve(i.note,`${r}.note`)}}function vS(e){let t="Native builder_handoff",r=te(e,t);re(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),t);let i=eo(r.addressed_acceptance_ids,`${t}.addressed_acceptance_ids`);Yt(i,`${t}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:te(r.review,`${t}.review`);return n&&re(n,new Set(["status","summary","reviewer_execution_ref"]),`${t}.review`),{candidate_id:U(r.candidate_id,`${t}.candidate_id`),identity_provider:U(r.identity_provider,`${t}.identity_provider`),builder_execution_ref:U(r.builder_execution_ref,`${t}.builder_execution_ref`),iteration:D(r.iteration,`${t}.iteration`,1),summary:ve(r.summary,`${t}.summary`),addressed_acceptance_ids:i,checks:ze(r.checks,`${t}.checks`,mS),checks_truncated:Ir(r.checks_truncated,`${t}.checks_truncated`),known_limits:ze(r.known_limits,`${t}.known_limits`,(a,o)=>ve(a,`${t}.known_limits[${o}]`)),known_limits_truncated:Ir(r.known_limits_truncated,`${t}.known_limits_truncated`),review:n?{status:V(n.status,["passed"],`${t}.review.status`),summary:ve(n.summary,`${t}.review.summary`),reviewer_execution_ref:U(n.reviewer_execution_ref,`${t}.review.reviewer_execution_ref`)}:null,submitted_at:Tr(r.submitted_at,`${t}.submitted_at`)}}function gS(e,t){let r=`Native blockers[${t}]`,i=te(e,r);re(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=eo(i.acceptance_ids,`${r}.acceptance_ids`);return Yt(n,`${r}.acceptance_ids`),{owner:V(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:ve(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:V(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function wS(e,t){let r=`Native verification.checks[${t}]`,i=te(e,r);return re(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:U(i.id,`${r}.id`),name:ve(i.name,`${r}.name`),argv_display:ze(i.argv_display,`${r}.argv_display`,(n,a)=>ve(n,`${r}.argv_display[${a}]`)),argv_truncated:Ir(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:Qa(i.cwd_ref,`${r}.cwd_ref`,!0),status:V(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:uS(i.exit_code,`${r}.exit_code`),duration_ms:D(i.duration_ms,`${r}.duration_ms`)}}function yS(e){let t="Native verification",r=te(e,t);re(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),t);let i=ze(r.checks,`${t}.checks`,wS);Yt(i.map(a=>a.id),`${t}.checks IDs`);let n=U(r.identity_provider,`${t}.identity_provider`);return{candidate_id:U(r.candidate_id,`${t}.candidate_id`),identity_provider:n,verifier_execution_ref:U(r.verifier_execution_ref,`${t}.verifier_execution_ref`),iteration:D(r.iteration,`${t}.iteration`,1),attempt:D(r.attempt,`${t}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":V(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${t}.assurance`),verdict:V(r.verdict,["pass","fail","blocked"],`${t}.verdict`),checks:i,summary:ve(r.summary,`${t}.summary`),risks:ze(r.risks,`${t}.risks`,(a,o)=>ve(a,`${t}.risks[${o}]`)),risks_truncated:Ir(r.risks_truncated,`${t}.risks_truncated`),completed_at:Tr(r.completed_at,`${t}.completed_at`)}}function wh(e,t){let r=`Native history[${t}]`,i=te(e,r);re(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=eo(i.unresolved_ids,`${r}.unresolved_ids`);return Yt(n,`${r}.unresolved_ids`),{goal_cycle:D(i.goal_cycle,`${r}.goal_cycle`,1),iteration:D(i.iteration,`${r}.iteration`),attempt:D(i.attempt,`${r}.attempt`),outcome:V(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:ve(i.summary,`${r}.summary`),completed_at:Tr(i.completed_at,`${r}.completed_at`)}}function NS(e){let t="Native history_overflow.outcome_counts",r=te(e,t),i=["pass","fail","blocked","execution-error","recovery"];return re(r,new Set(i),t),{pass:D(r.pass,`${t}.pass`),fail:D(r.fail,`${t}.fail`),blocked:D(r.blocked,`${t}.blocked`),"execution-error":D(r["execution-error"],`${t}.execution-error`),recovery:D(r.recovery,`${t}.recovery`)}}function bS(e){let t="Native history_overflow",r=te(e,t);re(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),t);let i=D(r.dropped_entries,`${t}.dropped_entries`),n=r.first_dropped_at===null?null:Tr(r.first_dropped_at,`${t}.first_dropped_at`),a=r.last_dropped_at===null?null:Tr(r.last_dropped_at,`${t}.last_dropped_at`);if(i===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(i>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=NS(r.outcome_counts);if(Object.values(o).reduce((l,c)=>l+c,0)!==i)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:i,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function kS(e){let t=new Set(e.acceptance.map(r=>r.id));for(let r of e.loop.previous_unresolved_ids)if(!t.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of e.builder_handoff?.addressed_acceptance_ids??[])if(!t.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);for(let r of e.blockers)for(let i of r.acceptance_ids)if(!t.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(e.builder_handoff){if(!(e.builder_handoff.iteration===e.loop.iteration||e.phase==="build"&&e.loop.stage==="repairing"&&e.builder_handoff.iteration===e.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(e.builder_handoff.review?.reviewer_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(e.verification){if(!e.builder_handoff)throw new Error("Native verification requires a builder handoff");if(e.verification.candidate_id!==e.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(e.verification.identity_provider!==e.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(e.verification.assurance)!==(e.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(e.verification.assurance==="semantic-verification-unavailable"&&e.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(e.verification.assurance==="user-confirmed-degraded"&&e.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(e.verification.verifier_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=e.verification.iteration===e.loop.iteration&&e.verification.attempt===e.loop.attempt,n=e.phase==="build"&&e.loop.stage==="repairing"&&e.verification.iteration===e.loop.iteration-1&&e.verification.iteration===e.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function SS(e){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[e.phase].has(e.loop.stage))throw new Error(`Native loop stage ${e.loop.stage} is invalid for phase ${e.phase}`);let r=e.status==="await-user"?"await-user":e.status==="blocked"?"blocked":e.status==="done"?"done":null;if(r!==null&&e.loop.stage!==r)throw new Error(`Native status ${e.status} requires loop stage ${r}`);if(e.status==="active"&&["await-user","blocked","done"].includes(e.loop.stage))throw new Error(`Native active status cannot use loop stage ${e.loop.stage}`);if(e.archived!==(e.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(e.archived&&e.phase!=="archive")throw new Error("Native archived state must be in Archive");if(e.verification_result==="pass"){if(e.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(e.acceptance.some(i=>i.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(e.verification.checks.some(i=>i.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(e.verification?.assurance==="semantic-verification-unavailable"&&(e.phase!=="verify"||e.status!=="await-user"||e.verification_result!=="blocked"||e.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(e.verification_report!==null&&e.verification===null)throw new Error("Native verification report requires persisted verification")}function ge(e){let t=te(e,"Native portable state");if(re(t,lS,"Native portable state"),t.schema!==cr)throw new Error(`Native portable state schema must be ${cr}`);let r=U(t.name,"Native state name");if(!aS.test(r))throw new Error("Native state name is invalid");if(t.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let i=ze(t.spec_changes,"Native spec_changes",dS);Yt(i.map(s=>s.capability),"Native spec change capabilities");let n=ze(t.acceptance,"Native acceptance",hS);Yt(n.map(s=>s.id),"Native acceptance IDs");let a=ze(t.history,"Native history",wh);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:cr,name:r,language:V(t.language,["en","zh-CN"],"Native state language"),phase:V(t.phase,["shape","build","verify","archive"],"Native state phase"),status:V(t.status,["active","await-user","blocked","done"],"Native state status"),state_version:D(t.state_version,"Native state_version",1),brief:"brief.md",...t.document_constraints_version===void 0?{}:t.document_constraints_version===1?{document_constraints_version:1}:(()=>{throw new Error("Native document_constraints_version must be 1")})(),...t.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:kl(t.shape_confirmation_hash,"Native Shape confirmation hash")},...t.children_contract_hash===void 0?{}:{children_contract_hash:kl(t.children_contract_hash,"Native children contract hash")},...t.coordination_mode===void 0?{}:{coordination_mode:V(t.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:fS(t.workspace),loop:pS(t.loop),acceptance:n,builder_handoff:t.builder_handoff===null?null:vS(t.builder_handoff),blockers:ze(t.blockers,"Native blockers",gS),verification:t.verification===null?null:yS(t.verification),history:a,history_overflow:bS(t.history_overflow),verification_result:V(t.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:t.verification_report===null?null:V(t.verification_report,["verification.md"],"Native verification_report"),archived:Ir(t.archived,"Native archived"),created_at:Tr(t.created_at,"Native created_at")};return kS(o),SS(o),o}function Xt(e,t){let r=ge(e),i=wh(t,r.history.length),n=[...r.history,i],a={...r.history_overflow,outcome_counts:{...r.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return ge({...r,history:n,history_overflow:a})}function ES(e,t){let r=(0,Za.parseDocument)(e,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`${t} is invalid YAML: ${r.errors[0].message}`);return r.toJS({mapAsMap:!1})}async function at(e){let t=await nS.readFile(e,"utf8");return ge(ES(t,"Native portable state"))}async function to(e,t,r={}){let i=ge(t);await ue(e,(0,Za.stringify)(i),r)}async function xS(e,t){let r=Ya.get(e)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);Ya.set(e,a),await r;try{return await t()}finally{i(),Ya.get(e)===a&&Ya.delete(e)}}async function yh(e){return xS(e.file,async()=>{let t=D(e.expectedStateVersion,"Native expected state version",1),r=ge(e.next);if(r.state_version!==t+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await at(e.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==t)throw new Xa(t,i.state_version);return await to(e.file,r,{...e.containedRoot?{containedRoot:e.containedRoot}:{},beforeCommit:async()=>{let n=await at(e.file);if(n.state_version!==t)throw new Xa(t,n.state_version)}}),r})}var Za,aS,oS,sS,cS,lS,Xa,Ya,ot=S(()=>{"use strict";Za=mt(Ze(),1);L();Jr();aS=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,oS=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,sS=/^A[1-9][0-9]*$/u,cS=/^[a-f0-9]{64}$/u,lS=new Set(["schema","name","language","phase","status","state_version","brief","document_constraints_version","shape_confirmation_hash","children_contract_hash","coordination_mode","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),Xa=class extends Error{constructor(r,i){super(`Native state version conflict: expected ${r}, got ${i}`);this.expectedStateVersion=r;this.actualStateVersion=i;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};Ya=new Map});function CS(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function je(e,t=16384){if(typeof e!="string")throw new Error("Native portable text must be a string");if(CS(t),Buffer.byteLength(e,"utf8")<=t)return{text:e,truncated:!1};let r="",i=0;for(let n of e){let a=Buffer.byteLength(n,"utf8");if(i+a>t)break;r+=n,i+=a}return{text:r,truncated:!0}}var Qt=S(()=>{"use strict"});import PS from"node:path";function jS(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function $S(e,t){let r=e instanceof Date?new Date(e.valueOf()):new Date(e);if(Number.isNaN(r.valueOf()))throw new Error(`${t} must be a valid timestamp`);return r.toISOString()}function OS(e,t){if(typeof e!="string")throw new Error(`${t} must be an ISO timestamp`);let r=new Date(e);if(Number.isNaN(r.valueOf())||r.toISOString()!==e)throw new Error(`${t} must be a canonical ISO timestamp`);return e}function HS(e){return e.schema===qe?_r(e):e.schema===Ve?Ar(e):Kt(e)}function DS(e){return PS.posix.normalize(e.replaceAll("\\","/"))}function LS(e){return e.spec_changes.map(t=>t.operation==="remove"?{capability:t.capability,operation:"remove",source:null}:{capability:t.capability,operation:t.operation==="replace"?"modify":"create",source:DS(t.source)})}function BS(e){return e==="shape"?"shape":"build"}function MS(e,t){return e==="zh-CN"?t==="shape"?"继续澄清并确认验收项":"重新提交候选实现":t==="shape"?"Continue clarification and confirm acceptance":"Submit a fresh implementation candidate"}function FS(e,t,r){return e==="zh-CN"?`从旧版 ${t} ${r} 状态恢复;旧版 Loop、验证结论和运行记录未继承。`:`Recovered from legacy ${t} ${r} state; prior Loop, verification results, and execution records were not inherited.`}function Nh(e){let t=HS(e.state);gh(e.acceptance);let r=BS(t.phase),i=r==="shape"?0:1,n=$S(e.migratedAt??`${t.created_at}T00:00:00.000Z`,"Native portable migration time"),a=e.acceptance.map(o=>({id:o.id,source:o.source,text:o.text,result:"pending",reason:null}));return ge({schema:cr,name:t.name,language:t.language,phase:r,status:"active",state_version:1,brief:"brief.md",spec_changes:LS(t),workspace:e.workspace,loop:{stage:r==="shape"?"shape":"building",goal_cycle:1,iteration:i,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:MS(t.language,r)},acceptance:a,builder_handoff:null,blockers:[],verification:null,history:[{goal_cycle:1,iteration:i,attempt:0,outcome:"recovery",unresolved_ids:a.map(({id:o})=>o),summary:je(FS(t.language,t.schema,t.phase)),completed_at:n}],history_overflow:Bo(),verification_result:"pending",verification_report:null,archived:!1,created_at:`${t.created_at}T00:00:00.000Z`})}function Sl(e){let t=jS(e,"Native portable migration transaction"),r=Object.keys(t).filter(i=>!RS.has(i));if(r.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${r.join(", ")}`);if(t.schema!==ro)throw new Error("Unsupported Native portable migration transaction schema");if(typeof t.id!="string"||!AS.test(t.id))throw new Error("Native portable migration transaction id is invalid");if(typeof t.change!="string"||!_S.test(t.change))throw new Error("Native portable migration transaction change is invalid");if(typeof t.fromSchema!="string"||!TS.has(t.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof t.status!="string"||!IS.has(t.status))throw new Error("Native portable migration transaction status is invalid");return{schema:ro,id:t.id,change:t.change,fromSchema:t.fromSchema,status:t.status,createdAt:OS(t.createdAt,"Native portable migration transaction createdAt")}}function bh(e){switch(Sl(e).status){case"prepared":return{action:"commit-portable-yaml",fromStatus:"prepared",nextStatus:"yaml-committed"};case"yaml-committed":return{action:"cleanup-legacy-runtime",fromStatus:"yaml-committed",nextStatus:"legacy-cleanup"};case"legacy-cleanup":return{action:"commit-transaction",fromStatus:"legacy-cleanup",nextStatus:"committed"};case"committed":return{action:"done",fromStatus:"committed",nextStatus:null}}}var ro,RS,_S,AS,IS,TS,El=S(()=>{"use strict";Wa();Ka();ot();Qt();Jr();Bi();ro="comet.native.portable-migration.v1",RS=new Set(["schema","id","change","fromSchema","status","createdAt"]),_S=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,AS=/^[a-z0-9][a-z0-9-]{7,127}$/u,IS=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),TS=new Set([qe,Ve,Fe])});import Cl from"node:path";function Ch(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Ph(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function xl(e,t){if(e!==void 0){if(e===null)return null;if(typeof e!="string"||!/^[a-f0-9]{64}$/iu.test(e))throw new Error(`${t} must be a SHA-256 hash or null`);return e.toLowerCase()}}function Sh(e,t){if(e!==void 0){if(e!==null&&typeof e!="string")throw new Error(`${t} must be text or null`);return e}}function KS(e,t){let r=`Native portable Archive spec_changes[${t}]`,i=Ch(e,r);if(Ph(i,US,r),typeof i.capability!="string"||!xh.test(i.capability))throw new Error(`${r}.capability is invalid`);if(!["create","modify","remove"].includes(String(i.operation)))throw new Error(`${r}.operation is invalid`);let n=i.operation,a=i.delta_source;if(a!==void 0&&(typeof a!="string"||a.length===0||a.includes("\\")||a.startsWith("/")||/^[A-Za-z]:/u.test(a)||a.split("/").some(f=>f==="."||f==="..")))throw new Error(`${r}.delta_source is invalid`);let o=xl(i.base_hash,`${r}.base_hash`),s=Sh(i.delta_content,`${r}.delta_content`),l=Sh(i.source_content,`${r}.source_content`),c=xl(i.expected_target_hash,`${r}.expected_target_hash`),u=xl(i.result_hash,`${r}.result_hash`),d=a!==void 0;if(d&&o==null)throw new Error(`${r}.delta_source requires a non-null base_hash`);if(d&&(s==null||l===void 0||l===null||u===void 0||u===null))throw new Error(`${r}.delta_source requires delta_content, source_content, and result_hash`);if(!d&&(s!==void 0||l!==void 0))throw new Error(`${r} delta transaction fields require delta_source`);if(d){let f=Li(s);if(f.capability!==i.capability)throw new Error(`${r}.delta_content capability does not match capability`);if(f.base_hash!==o)throw new Error(`${r}.delta_content base_hash does not match base_hash`);if(rt(i.content)!==u)throw new Error(`${r}.content does not match result_hash`);if(rt(l)!==u)throw new Error(`${r}.source_content does not match result_hash`)}if(n==="remove"){if(i.source!==null||i.content!==null||a!==void 0||s!==void 0||l!==void 0||u!==void 0)throw new Error(`${r} remove requires source and content null`);return{capability:i.capability,operation:n,source:null,content:null,...o===void 0?{}:{base_hash:o},...c===void 0?{}:{expected_target_hash:c}}}if(typeof i.source!="string"||i.source.length===0||i.source.includes("\\")||i.source.startsWith("/")||/^[A-Za-z]:/u.test(i.source)||i.source.split("/").some(f=>f==="."||f===".."))throw new Error(`${r}.${n} source is invalid`);if(typeof i.content!="string")throw new Error(`${r}.${n} content is invalid`);if(u!==void 0&&(u===null||rt(i.content)!==u))throw new Error(`${r}.content does not match result_hash`);return{capability:i.capability,operation:n,source:i.source,content:i.content,...a===void 0?{}:{delta_source:a},...o===void 0?{}:{base_hash:o},...s===void 0?{}:{delta_content:s},...l===void 0?{}:{source_content:l},...c===void 0?{}:{expected_target_hash:c},...u===void 0?{}:{result_hash:u}}}function YS(e){let t=Ch(e,"Native portable Archive transaction");if(Ph(t,JS,"Native portable Archive transaction"),t.schema!==kh)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof t.id!="string"||!WS.test(t.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof t.change!="string"||!xh.test(t.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(t.start_state_version)||Number(t.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof t.archive_ref!="string"||!zS.test(t.archive_ref)||!t.archive_ref.endsWith(`-${t.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof t.status!="string"||!GS.has(t.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let r=t.spec_changes.map(KS);if(new Set(r.map(({capability:n})=>n)).size!==r.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(t.next_spec_index)||Number(t.next_spec_index)<0||Number(t.next_spec_index)>r.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof t.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let i=new Date(t.created_at);if(Number.isNaN(i.valueOf())||i.toISOString()!==t.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:kh,id:t.id,change:t.change,start_state_version:Number(t.start_state_version),archive_ref:t.archive_ref,status:t.status,next_spec_index:Number(t.next_spec_index),spec_changes:r,created_at:t.created_at}}function io(e){let t=VS.exec(e);if(t)return{kind:"archive",change:t[1]};let r=qS.exec(e);return r?{kind:"migration",change:r[1]}:null}function no(e,t){let r=`${t.kind==="archive"?"portable-archive":"portable-migration"}-${t.change}.json`,i=io(r);if(!i||i.kind!==t.kind||i.change!==t.change)throw new Error(`Invalid Native portable transaction change: ${t.change}`);return Cl.join(e.transactionsDir,r)}async function Pl(e,t){let r=io(t);if(!r)return null;let i=await T({root:e.transactionsDir,ref:t,maxBytes:null,includeHash:!1}),n=JSON.parse(i.text),a=Cl.join(e.transactionsDir,t);if(r.kind==="archive"){let s=YS(n);if(s.change!==r.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:r.change,file:a,journal:s}}let o=Sl(n);if(o.change!==r.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:r.change,file:a,journal:o}}async function Rl(e,t){let r=no(e,t);try{return await Pl(e,Cl.basename(r))}catch(i){if(i.code==="ENOENT")return null;throw i}}function Rh(e){return e.kind==="archive"||e.journal.status!=="committed"}var kh,Eh,VS,qS,WS,zS,GS,JS,US,xh,ao=S(()=>{"use strict";fe();fl();El();kh="comet.native.archive-transaction.v4",Eh="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",VS=new RegExp(`^portable-archive-(${Eh})\\.json$`,"u"),qS=new RegExp(`^portable-migration-(${Eh})\\.json$`,"u"),WS=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,zS=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,GS=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),JS=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),US=new Set(["capability","operation","source","content","delta_source","base_hash","delta_content","source_content","expected_target_hash","result_hash"]),xh=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});import{createHash as XS}from"node:crypto";import{constants as oo,promises as $e}from"node:fs";import Oe from"node:path";function co(e,t){let r=Oe.relative(e,t);return r===""||!Oe.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Oe.sep}`)}function QS(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native protected file byte limit must be a positive integer");return e}function ZS(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function eE(e){return{dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs,ctimeMs:e.ctimeMs,mtimeMs:e.mtimeMs,size:e.size}}function so(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function _l(e,t){let r=await $e.lstat(e);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t} parent must be a real directory: ${e}`);return{path:e,realPath:await $e.realpath(e),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function tE(e,t,r){let i=Oe.resolve(e),n=Oe.resolve(t);if(!co(i,n))throw new Error(`${r} is outside its managed root`);let a=[await _l(i,r)],o=i;for(let s of Oe.relative(i,n).split(Oe.sep).filter(Boolean)){await Zt(a,r),o=Oe.join(o,s);let l=await _l(o,r);if(!co(a[0].realPath,l.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(l)}return await Zt(a,r),a}async function Zt(e,t){for(let r of e){let i=await $e.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!ZS(r,i)||await $e.realpath(r.path)!==r.realPath)throw new Error(`${t} parent changed during I/O: ${r.path}`)}}async function rE(e,t,r){let i=[],n=0,a=Buffer.allocUnsafe(t===null?64*1024:Math.min(64*1024,t+1));for(;;){let o=t===null?a.length:t+1-n,{bytesRead:s}=await e.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,t!==null&&n>t)throw new Error(`${r} exceeds ${t} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function zi(e){let t=e.maxBytes===null?null:QS(e.maxBytes),r=Oe.resolve(e.file),i=await tE(e.root,Oe.dirname(r),e.label),n=await Promise.all((e.forbiddenRoots??[]).map(u=>_l(Oe.resolve(u),e.label)));await e.hooks?.afterParentChainCaptured?.(),await Zt(i,e.label);let a=await $e.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);if(t!==null&&a.size>t)throw new Error(`${e.label} exceeds ${t} bytes`);let o=eE(a),s=await $e.realpath(r);if(!co(i[0].realPath,s))throw new Error(`${e.label} resolves outside its managed root`);if(n.some(u=>co(u.realPath,s)))throw new Error(`${e.label} resolves inside an excluded root`);let l=process.platform==="win32"?oo.O_RDONLY:oo.O_RDONLY|oo.O_NOFOLLOW|oo.O_NONBLOCK,c=await $e.open(r,l);try{let u=await c.stat();await e.hooks?.afterOpen?.();let[d,f]=await Promise.all([$e.lstat(r),$e.realpath(r)]);if(await Zt(i,e.label),await Zt(n,e.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!so(o,u)||!so(o,d))throw new Error(`${e.label} changed while opening`);await e.hooks?.beforeRead?.();let h=await rE(c,t,e.label);await e.hooks?.beforeFinalCheck?.();let[m,p,v]=await Promise.all([c.stat(),$e.lstat(r),$e.realpath(r)]);if(await Zt(i,e.label),await Zt(n,e.label),!p.isFile()||p.isSymbolicLink()||v!==s||!so(o,m)||!so(o,p))throw new Error(`${e.label} changed while reading`);return{bytes:h,hash:XS("sha256").update(h).digest("hex"),size:h.length}}finally{await c.close()}}var Ge=S(()=>{"use strict";L();Le()});import st from"path";import{TextDecoder as nE}from"util";function uo(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function fo(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Th(e){if(typeof e!="string")return!1;let t=new Date(e);return!Number.isNaN(t.valueOf())&&t.toISOString()===e}function Al(e,t){if(typeof e!="string"||e.length===0||st.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native root`)}function lo(e,t){if(typeof e!="string"||!/^[a-f0-9]{64}$/u.test(e))throw new Error(`${t} must be a SHA-256 hash`)}function _h(e,t){if(Al(e,t),e.includes("\\")||e!==st.posix.normalize(e)||e.split("/").includes(".")||e.endsWith("/")||Buffer.byteLength(e,"utf8")>1024)throw new Error(`${t} must be a normalized Native-relative ref`)}function uE(e,t){let r=uo(e,`transaction operations[${t}]`);if(fo(r,oE,`transaction operations[${t}]`),typeof r.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(r.id))throw new Error(`transaction operations[${t}].id is invalid`);if(r.type!=="write"&&r.type!=="remove"&&r.type!=="move")throw new Error(`transaction operation ${r.id} has an invalid type`);Al(r.target,`transaction operation ${r.id} target`);for(let i of["source","staged","backup"])r[i]!==void 0&&Al(r[i],`transaction operation ${r.id} ${i}`);if(r.type==="write"){if(r.staged===void 0||r.source!==void 0)throw new Error(`write operation ${r.id} requires staged and forbids source`)}else if(r.type==="remove"){if(r.source!==void 0||r.staged!==void 0)throw new Error(`remove operation ${r.id} forbids source and staged`)}else if(r.source===void 0||r.staged!==void 0||r.backup!==void 0)throw new Error(`move operation ${r.id} requires source and forbids staged and backup`);return r}function jh(e){let t=uo(e,"Native Archive transaction journal");if(fo(t,sE,"Native Archive transaction journal"),t.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native Archive transaction id is invalid");if(t.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof t.status!="string"||!Ih.has(t.status))throw new Error("Native Archive transaction status is invalid");if(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change))throw new Error("Native Archive transaction change name is invalid");if(!Th(t.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(lo(t.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(t.operations)||t.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let r=t.operations.map((s,l)=>{let c=uo(s,`Archive transaction operations[${l}]`);if(fo(c,cE,`Archive transaction operations[${l}]`),typeof c.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(c.id))throw new Error(`Archive transaction operations[${l}].id is invalid`);if(c.type!=="write"&&c.type!=="remove"&&c.type!=="move")throw new Error(`Archive transaction operation ${c.id} has an invalid type`);_h(c.target,`Archive transaction operation ${c.id} target`);for(let u of["source","staged","backup"])c[u]!==void 0&&_h(c[u],`Archive transaction operation ${c.id} ${u}`);if(c.expectedTargetHash!==null&&lo(c.expectedTargetHash,`Archive transaction operation ${c.id} expectedTargetHash`),c.type==="write"){if(c.staged===void 0||c.source!==void 0||c.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${c.id} requires staged and forbids source`);if(lo(c.stagedHash,`Archive write operation ${c.id} stagedHash`),c.expectedTargetHash===null!=(c.backup===void 0))throw new Error(`Archive write operation ${c.id} backup must match target existence`)}else if(c.type==="remove"){if(c.source!==void 0||c.staged!==void 0||c.stagedHash!==void 0||c.expectedSourceHash!==void 0||c.backup===void 0||c.expectedTargetHash===null)throw new Error(`Archive remove operation ${c.id} requires a bound target and backup`)}else{if(c.source===void 0||c.staged!==void 0||c.stagedHash!==void 0||c.backup!==void 0||c.expectedTargetHash!==null)throw new Error(`Archive move operation ${c.id} requires source and an absent target`);lo(c.expectedSourceHash,`Archive move operation ${c.id} expectedSourceHash`)}return c}),i=r.map(s=>s.id);if(new Set(i).size!==i.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${t.id}`,a=r.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${t.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${t.change}$`,"u").test(a[0].target)||r.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of r.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:t.id,kind:"archive",status:t.status,change:t.change,createdAt:t.createdAt,preflightHash:t.preflightHash,operations:r}}function dE(e){let t=uo(e,"Native transaction journal");if(t.schema==="comet.native.transaction.v2")return jh(t);if(fo(t,aE,"Native transaction journal"),t.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native transaction id is invalid");if(t.kind!=="archive"&&t.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof t.status!="string"||!Ih.has(t.status))throw new Error("Native transaction status is invalid");if(typeof t.projectRoot!="string"||!st.isAbsolute(t.projectRoot)||typeof t.nativeRoot!="string"||!st.isAbsolute(t.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(t.change!==void 0&&(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change)))throw new Error("Native transaction change name is invalid");if(!Th(t.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(t.operations))throw new Error("Native transaction operations must be an array");let r=t.operations.map(uE),i=r.map(n=>n.id);if(new Set(i).size!==i.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:t.id,kind:t.kind,status:t.status,projectRoot:t.projectRoot,nativeRoot:t.nativeRoot,...typeof t.change=="string"?{change:t.change}:{},createdAt:t.createdAt,operations:r}}function fE(e,t){if(!/^[a-f0-9-]{8,}$/u.test(t))throw new Error(`Invalid Native transaction id: ${t}`);return st.join(e.transactionsDir,t)}function $h(e,t){let r=fE(e,t);return{directory:r,journal:st.join(r,"transaction.json"),events:st.join(r,"events.jsonl"),staged:st.join(r,"staged"),backups:st.join(r,"backups")}}async function Tl(e,t){let r=$h(e,t);return await Promise.all(Object.values(r).map(i=>I(e.runtimeDir,i))),r}async function jl(e,t,r={}){let i=await Tl(e,t),n=await zi({root:e.runtimeDir,file:i.journal,maxBytes:null,label:`Native transaction journal ${t}`,hooks:r.hooks}),a=JSON.parse(lE.decode(n.bytes)),o=dE(a);if(o.id!==t)throw new Error(`Invalid Native transaction journal: ${t}`);return o}var aE,oE,sE,cE,Ih,lE,po=S(()=>{"use strict";L();H();Ge();aE=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),oE=new Set(["id","type","source","target","staged","backup"]),sE=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),cE=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]),Ih=new Set(["prepared","applying","committed","rolling-back","rolled-back"]),lE=new nE("utf-8",{fatal:!0})});import{promises as pE}from"fs";import hE from"path";async function mE(e,t,r){let i;try{i=await pE.readdir(e.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await jl(e,n.name);if(a.id!==t&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of i)if(io(n.name))try{let a=await Pl(e,n.name);if(!a||r?.kind===a.kind&&r.change===a.change)continue;if(Rh(a))return!0}catch{return!0}return!1}async function vE(e,t){let r=Date.now()+5e3,i=hE.join(e.locksDir,"root-move.lock");for(;;)try{return await Ba(e,"root-move",t)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await Gp(i);if(o.status==="missing")continue;if(o.status==="stale"){let s=await Jp(e,i,o);if(s.status==="removed"||s.status==="missing")continue;throw n}if(o.status!=="active"||Date.now()>=r)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function B(e,t,r,i){let n=await vE(e,t);try{if(await Aa(e.projectRoot),await mE(e,i?.allowedTransactionId,i?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await r()}finally{try{await Ma(n)}catch(a){process.stderr.write(`[comet] warning: could not release Native mutation lock ${n.file} (${a.message}); run comet native doctor --repair if commands start failing
177
- `)}}}var K=S(()=>{"use strict";he();Di();ao();po()});import{createHash as gE}from"crypto";function we(e){return gE("sha256").update(e).digest("hex")}var Je=S(()=>{"use strict"});var DI,LI,BI,MI,FI,VI,Gi=S(()=>{"use strict";L();he();Je();Le();H();Ge();Xr();DI={maxFiles:1e4,maxFileBytes:1024*1024*1024,maxTotalBytes:1024*1024*1024,maxManifestBytes:1024*1024*1024},LI=64*1024,BI=64*1024,MI={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},FI={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024},VI=(1n<<256n)-1n});var qh=S(()=>{"use strict"});var y$,ct=S(()=>{"use strict";qh();y$=8*1024*1024});import{promises as ax}from"node:fs";import ox from"node:path";function bo(e,t,r=""){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object${r}`);return e}function No(e,t,r){let i=Object.keys(e).filter(a=>!t.has(a)),n=[...t].filter(a=>!(a in e));if(i.length>0||n.length>0){let a=[...n.length>0?[`missing ${n.join(", ")}`]:[],...i.length>0?[`unexpected ${i.join(", ")}`]:[],`expected ${[...t].join(", ")}`];throw new Error(`${r} fields are invalid: ${a.join("; ")}`)}}function em(e,t){if(!Array.isArray(e)||!e.every(r=>typeof r=="string"))throw new Error(`${t} must be an array of strings`);return[...new Set(e)].sort((r,i)=>r.localeCompare(i,"en"))}function fx(e){let t=new Map(e.map(a=>[a.name,a])),r=new Set,i=new Set,n=a=>{if(!i.has(a)){if(r.has(a))throw new Error(`Native children dependency cycle includes ${a}`);r.add(a);for(let o of t.get(a).depends_on)n(o);r.delete(a),i.add(a)}};for(let a of e)n(a.name)}function tm(e,t,r=t){let i=new Set(t);for(let o of e){let s=o.covers.filter(l=>!i.has(l));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(e.flatMap(o=>o.covers)),a=r.filter(o=>!n.has(o));if(a.length>0)throw new Error(`Native children do not cover parent acceptance: ${a.join(", ")}`)}function am(e,t,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(e.schema===ql&&e.acceptance_index){let n=r.requiredAcceptanceIds??t??[],a=r.allowedAcceptanceIds??n,o=Object.keys(e.acceptance_index);i.missing=n.filter(c=>!(c in e.acceptance_index)),i.extra=o.filter(c=>!a.includes(c));let s=new Map((r.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of o){let u=s.get(c),d=e.acceptance_index[c];u&&d&&(d.source!==u.source||d.text!==u.text)&&i.mismatched.push(c)}let l=new Set(o);for(let c of e.children)i.unknownCovers.push(...c.covers.filter(u=>!l.has(u)));return i.uncovered=o.filter(c=>!rm(e.children,c)),im(i)?i:null}if(e.schema===tr&&t){let n=new Set(t);for(let a of e.children)i.unknownCovers.push(...a.covers.filter(o=>!n.has(o)));return i.uncovered=t.filter(a=>!rm(e.children,a)),im(i)?i:null}return null}function rm(e,t){return e.some(r=>r.covers.includes(t))}function im(e){return e.missing.length>0||e.extra.length>0||e.mismatched.length>0||e.uncovered.length>0||e.unknownCovers.length>0}function ir(e){let t=new Set(e.acceptance.map(({id:n})=>n)),r=new Set(e.acceptance.filter(({source:n})=>n===e.brief).map(({id:n})=>n)),i=new Set(r);for(let n of e.history.filter(({outcome:a})=>a==="fail"))for(let a of n.unresolved_ids)t.has(a)&&i.add(a);if(e.loop.stage==="repairing"&&e.verification_result==="fail"){let n=[...e.history].reverse().find(({outcome:a})=>a==="fail");for(let a of n?.unresolved_ids??[])r.add(a)}return{acceptanceCatalog:e.acceptance,requiredAcceptanceIds:[...r],allowedAcceptanceIds:[...i]}}function px(e){let t=bo(e,"Native children acceptance_index",' keyed by acceptance ID, for example A1: { source: brief.md, text: "Full acceptance text" }'),r={};for(let[i,n]of Object.entries(t)){let a=bo(n,`Native children acceptance_index.${i}`);if(No(a,new Set(["source","text"]),`Native children acceptance_index.${i}`),typeof a.source!="string"||a.source.length===0)throw new Error(`Native children acceptance_index.${i}.source must be a non-empty string`);if(typeof a.text!="string"||a.text.length===0)throw new Error(`Native children acceptance_index.${i}.text must be a non-empty string`);r[i]={source:a.source,text:a.text}}return r}function hx(e,t,r){let i=r.requiredAcceptanceIds??t??[],n=r.allowedAcceptanceIds??i,a=Object.keys(e),o=i.filter(c=>!(c in e)),s=a.filter(c=>!n.includes(c));if(o.length>0||s.length>0)throw new Error(`Native children acceptance_index must match the required acceptance: missing ${o.join(", ")||"none"}; extra ${s.join(", ")||"none"}`);let l=new Map((r.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of a){let u=l.get(c);if(!u)continue;let d=e[c];if(d.source!==u.source||d.text!==u.text){let f=["source","text"].filter(h=>d[h]!==u[h]);throw new Error(`Native children acceptance_index.${c} does not match the acceptance catalog: copy ${f.join(", ")} exactly from the current acceptance catalog`)}}}function om(e,t,r={}){let i=(0,nm.parseDocument)(e,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=bo(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==tr&&a!==rr)throw No(n,Zh,"Native children contract"),new Error(`Native children schema must be ${tr} or ${rr}`);let o=a===tr?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(No(n,o==="indexed-v2"?cx:Zh,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let l=n.children.map((f,h)=>{let m=bo(f,`Native child ${h}`);if(No(m,o==="indexed-v2"?dx:o==="summary-v2"?ux:lx,`Native ${s} child fields (child ${h})`),typeof m.name!="string"||!sx.test(m.name))throw new Error(`Native child ${h} name is invalid`);let p=o==="summary-v2";if(p){if(typeof m.summary!="string"||m.summary.trim().length===0)throw new Error(`Native child ${m.name} summary must be a non-empty string`);if(m.summary.length>2e3)throw new Error(`Native child ${m.name} summary exceeds 2000 characters`)}return{name:m.name,summary:p?m.summary:null,depends_on:em(m.depends_on,`Native child ${m.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?em(m.covers,`Native child ${m.name} covers`):[]}}),c=l.map(({name:f})=>f);if(new Set(c).size!==c.length)throw new Error("Native child names must be unique");let u=new Set(c);for(let f of l){let h=f.depends_on.filter(m=>!u.has(m));if(h.length>0)throw new Error(`Native child ${f.name} depends on unknown child: ${h.join(", ")}`)}fx(l);let d=r.policy==="advisory";if(a===ql){if(o==="indexed-v2"){let f=px(n.acceptance_index);d||hx(f,t,r);let h=Object.keys(f);return d||tm(l,h,h),{schema:rr,acceptance_index:f,children:l}}return{schema:rr,children:l}}return t&&!d&&tm(l,t),{schema:tr,children:l}}async function nr(e){let t=ox.join(e.changeDir,Vl);try{await ax.lstat(t)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await T({root:e.changeDir,ref:Vl}),i=e.policy==="advisory",n=i?{...e.validation,policy:"advisory"}:e.validation??{},a=om(r.text,e.acceptanceIds,n);return{contract:a,hash:r.hash,size:r.size,drift:i?am(a,e.acceptanceIds,e.validation??{}):null}}var nm,Vl,tr,rr,ql,sx,Zh,cx,lx,ux,dx,ko=S(()=>{"use strict";nm=mt(Ze(),1);fe();Vl="children.yaml",tr="comet.native.children.v1",rr="comet.native.children.v2",ql=rr,sx=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Zh=new Set(["schema","children"]),cx=new Set(["schema","acceptance_index","children"]),lx=new Set(["name","depends_on","covers"]),ux=new Set(["name","summary","depends_on"]),dx=new Set(["name","depends_on","covers"])});var Tt=S(()=>{"use strict";L();J();ko();H();$t()});var Wl=S(()=>{"use strict"});var ar=S(()=>{"use strict"});var So=S(()=>{"use strict";Ia();Wl();ar()});var sm=S(()=>{"use strict";ct();So();J()});var zl=S(()=>{"use strict";ct();L()});var pm,Mr=S(()=>{"use strict";J();Gi();pm=1024*1024});var Co=S(()=>{"use strict";J();ar();Xr();Mr()});var mm,Bx,Mx,Fx,lH,Vx,uH,Jl=S(()=>{"use strict";J();mm="scoped-text-safety",Bx=1,Mx=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),Fx="comet.native.checker-policy.v1",lH=O(Fx,{policy:mm,version:Bx,limits:Mx,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),Vx=["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"],uH=new Set(Vx)});var Po=S(()=>{"use strict";J();Jl();ar()});import{createHash as wm}from"node:crypto";import{promises as se}from"node:fs";import Ye from"node:path";function Ul(e,t){let r=Ye.relative(e,t);return r===""||!Ye.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ye.sep}`)}function Wx(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function rn(e,t){let r={...e,birthtime:e.birthtimeMs},i={...t,birthtime:t.birthtimeMs};return Se(r,i)?j(r,i):j(r,i)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function vm(e){let t=await se.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native evidence parent must be a real directory: ${e}`);return{path:e,realPath:await se.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function zx(e,t){let r=Ye.resolve(e),i=Ye.resolve(t);if(!Ul(r,i))throw new Error("Native evidence path is outside its change");let n=[await vm(r)],a=r;for(let o of Ye.relative(r,i).split(Ye.sep).filter(Boolean)){a=Ye.join(a,o);let s=await vm(a);if(!Ul(n[0].realPath,s.realPath))throw new Error(`Native evidence parent resolves outside its change: ${a}`);n.push(s)}return n}async function gm(e){for(let t of e){let r=await se.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!Wx(t,r)||await se.realpath(t.path)!==t.realPath)throw new Error(`Native evidence parent changed while reading: ${t.path}`)}}async function Gx(e,t,r={}){let i=await zx(t,Ye.dirname(e));await r.afterParentChainCaptured?.();let n=await se.lstat(e);if(!n.isFile()||n.isSymbolicLink())throw new Error("Native evidence document must be a regular file");let a=await se.realpath(e);if(!Ul(i[0].realPath,a))throw new Error("Native evidence document resolves outside its change");let o=await se.open(e,"r");try{let[s,l,c]=await Promise.all([o.stat(),se.lstat(e),se.realpath(e)]);if(await gm(i),!s.isFile()||!l.isFile()||l.isSymbolicLink()||c!==a||!rn(s,n)||!rn(s,l))throw new Error("Native evidence document changed while opening");if(s.size>dt)throw new Error(`Native evidence document exceeds ${dt} bytes`);await r.afterOpen?.();let u=[],d=0,f=Buffer.allocUnsafe(64*1024);for(;;){let v=dt+1-d,g=await o.read(f,0,Math.min(f.length,v),null);if(g.bytesRead===0)break;if(d+=g.bytesRead,d>dt)throw new Error(`Native evidence document exceeds ${dt} bytes`);u.push(Buffer.from(f.subarray(0,g.bytesRead)))}await r.beforeFinalCheck?.();let[h,m,p]=await Promise.all([o.stat(),se.lstat(e),se.realpath(e)]);if(await gm(i),!m.isFile()||m.isSymbolicLink()||p!==a||!rn(s,h)||!rn(s,m))throw new Error("Native evidence document changed while reading");return JSON.parse(Buffer.concat(u,d).toString("utf8"))}finally{await o.close()}}function Ro(e,t){if(!ym.test(t))throw new Error("Native evidence hash is invalid");return`runtime/evidence/${e}/${t}.json`}async function Yl(e){let t=Buffer.from(e.text,"utf8");if(t.byteLength>dt||wm("sha256").update(t).digest("hex")!==e.hash)throw new Error("Native verification report snapshot hash or size is invalid");return Ux({paths:e.paths,name:e.name,kind:"reports",hash:e.hash,onCreated:e.onCreated,value:{schema:"comet.native.verification-report.v1",reportHash:e.hash,content:e.text}})}async function Nm(e){let t=Xl(e.paths,e.name,"reports",e.hash),r=ce(e.paths,t);await I(r,t);let i=await se.lstat(t);if(await Jx(e.paths,e.name,e.hash),await I(r,t),!rn(i,await se.lstat(t)))throw new Error("Native report evidence changed before rollback");await se.unlink(t)}async function Jx(e,t,r,i,n){if(!ym.test(r))throw new Error("Native report evidence hash is invalid");let a=await Kl({paths:e,name:t,kind:"reports",hash:r,hooks:i,changeDir:n});if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Native report evidence must be an object");let o=a;if(Object.keys(o).sort().join(",")!=="content,reportHash,schema"||o.schema!=="comet.native.verification-report.v1"||o.reportHash!==r||typeof o.content!="string"||wm("sha256").update(Buffer.from(o.content,"utf8")).digest("hex")!==r)throw new Error("Native report evidence does not match its hash");return o.content}function Xl(e,t,r,i,n){let a=Ro(r,i);return n?Ye.join(n,...a.split("/")):Kc(Ae(e,t),a)}async function Kl(e){let t=Xl(e.paths,e.name,e.kind,e.hash,e.changeDir),r=e.changeDir??ce(e.paths,t);return await I(r,t),Gx(t,r,e.hooks)}async function Ux(e){Kx(e.value);let t=Xl(e.paths,e.name,e.kind,e.hash),r=ce(e.paths,t);await I(r,t);try{let n=await Kl(e);if(JSON.stringify(n)!==JSON.stringify(e.value))throw new Error(`Native evidence hash collision for ${e.hash}`);return Ro(e.kind,e.hash)}catch(n){if(n.code!=="ENOENT")throw n}await Q(t,e.value,{containedRoot:r}),e.onCreated?.();let i=await Kl(e);if(JSON.stringify(i)!==JSON.stringify(e.value))throw new Error(`Native evidence changed during commit for ${e.hash}`);return Ro(e.kind,e.hash)}function Kx(e){if(Yx(e)>dt)throw new Error(`Native evidence document exceeds ${dt} bytes`)}function Yx(e){return Buffer.byteLength(JSON.stringify(e,null,2)+`
178
- `,"utf8")}var ym,dt,AH,Fr=S(()=>{"use strict";L();H();Le();Mr();Co();Po();ym=/^[a-f0-9]{64}$/u,dt=pm,AH=3*dt});Jr();$t();function Z(e,t,r){return e.language==="zh-CN"?r:t}function gv(e,t,r){let i=n=>({required:!1,message:null,suggestedReply:null,agentInstruction:n});if(e.phase==="shape"&&e.status==="await-user"&&e.loop.next_action==="confirm-shape")return e.language==="zh-CN"?{required:!0,message:"Shape 已整理完成。请确认目标、范围、关键决定、验收标准和非目标是否准确;明确确认后才会进入 Build。",suggestedReply:"确认进入 Build",agentInstruction:"先用自然语言简要展示目标、范围、关键决定、验收标准和非目标,再转述 message 并等待用户明确确认。只有用户明确同意当前完整 Shape 时,才执行 commandAlternatives 中的 confirm-shape;补充或修改要求不算确认。不要展示机器状态或提前运行 --confirmed。"}:{required:!0,message:"Shape is ready. Confirm that the target, scope, key decisions, acceptance criteria, and non-goals are accurate; Build starts only after explicit confirmation.",suggestedReply:"Confirm and enter Build",agentInstruction:"First present a concise natural-language summary of the target, scope, key decisions, acceptance criteria, and non-goals. Then relay message and wait for explicit user confirmation. Run confirm-shape from commandAlternatives only when the user explicitly accepts the complete current Shape; additions or corrections are not confirmation. Do not expose machine state or run --confirmed early."};if(t&&e.phase==="shape"&&e.status==="active")return{required:!0,message:Z(e,"This Supervisor Change has multiple independent children. Choose one coordination mode before confirming Shape: A) Multi-session coordination (recommended), or B) Single-session progression.","当前 Supervisor Change 包含多个可独立执行的 Child。确认 Shape 前请选择推进方式:A)多会话协作(推荐),或 B)单会话推进。"),suggestedReply:Z(e,"Reply A or B","回复 A 或 B"),agentInstruction:Z(e,"Relay the two coordination choices and wait for the user decision. After the user chooses, execute the prepare-shape-confirmation commandArgs with the selected --coordination-mode. Do not combine mode selection with final confirmation; confirmation of the complete Shape is a separate await-user step.","转述这两个推进方式并等待用户选择。用户选择后,使用对应的 --coordination-mode 执行 prepare-shape-confirmation 的完整 commandArgs;不要把推进方式选择和最终确认合并执行,完整 Shape 的确认是后续单独的 await-user 步骤。")};if(e.phase==="verify"&&e.status==="active"&&e.loop.stage==="verify-ready"&&e.loop.next_action!=="await-verifier-result")return i(Z(e,"The current candidate and completed checks are preserved. Continue with dispatch-verifier without asking the user to recover files, processes, or workflow state. If a brief status update is necessary, say only that verification is being retried and the code is unchanged.","当前候选和已经完成的检查都已保留。直接继续 dispatch-verifier,不要让用户恢复文件、进程或工作流状态。如果确实需要简短同步进度,只说明正在重新尝试验收且代码没有变化。"));if(e.phase==="verify"&&e.status==="active"&&e.loop.next_action==="await-verifier-result")return i(Z(e,"Keep the same dispatched Verifier while it is active. A wait-tool timeout is not an execution timeout: check task progress and continue waiting; do not cancel, interrupt, or spawn a replacement just because a wait returned without a result. Request progress without telling the Verifier to stop inspecting. Only after confirmed task failure, a host-reported execution timeout, loss, or termination without a usable result, immediately submit verifier-execution-error. Preserve completed evidence and explain the failure and changed recovery approach before retrying. Submit verifier-unavailable only when the current platform truly has no usable subagent capability. Forward the actual report, including risks and incomplete checks; never turn an uninspected candidate into pass. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","已派发的验收任务仍在运行时,继续使用同一个 Verifier。等待工具超时不等于执行超时:检查任务进度并继续等待,不得仅因一次等待没有结果就取消、中断或重新派发。询问进度时不要要求停止核查。仅在确认任务失败、宿主报告执行超时、任务丢失或结束后没有可用结果时,立即提交 verifier-execution-error;保留已完成证据,重试前说明失败原因及恢复方式的变化。只有当前平台确实没有可用的 subagent 能力时才提交 verifier-unavailable。忠实传递原始报告,包括风险和未完成检查;没有核查当前候选不能判定通过。不要让用户恢复文件或进程,也不要向用户展示 attempt、requestCheckRounds 等机器状态。"));if(e.status==="blocked"&&e.blockers.some(({resolution_action:n})=>n==="retry-verifier"))return e.loop.retry_epoch>=3?e.language==="zh-CN"?{required:!0,message:"自动重试验收已连续多轮未能取得结果,验证环境很可能不可用。请人工检查验证环境(subagent 配额、平台任务队列、网络),或使用 doctor --repair 评估该 change 状态。",suggestedReply:"人工检查验证环境",agentInstruction:"只向用户转述 message,等待用户完成人工检查后再继续。不要自动重试验收。"}:{required:!0,message:"Automatic verification retries have failed across multiple rounds; the verification environment is likely unavailable. Inspect the environment manually (subagent quota, platform task queue, network), or use doctor --repair to assess the change state.",suggestedReply:"Inspect the verification environment",agentInstruction:"Relay message to the user and wait for a manual environment check before continuing. Do not retry verification automatically."}:e.language==="zh-CN"?{required:!0,message:"由于独立验收任务连续几次没有正常返回结果,本次验收已暂停。你的代码和已经完成的检查都已安全保留。回复“继续”即可重新尝试,不需要处理文件或进程。",suggestedReply:"继续",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户回复。不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification paused because the independent verification task repeatedly ended without a result. Your code and completed checks are safely preserved. Reply “Continue” to retry; you do not need to manage files or processes.",suggestedReply:"Continue",agentInstruction:"Relay only message and suggestedReply to the user, then wait for that reply. Do not expose internal attempts, counters, paths, or recovery steps."};if(e.phase==="verify"&&e.status==="await-user"&&e.verification?.assurance==="semantic-verification-unavailable")return e.language==="zh-CN"?{required:!0,message:"独立验收当前不可用,但你的代码和已经完成的检查都已安全保留。你可以直接重新尝试独立验收,也可以明确接受只有自动检查的结果。",suggestedReply:"重新尝试独立验收",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户选择。用户要求重试时执行 commandAlternatives 中的 retry-verifier;只有用户明确接受降级结果时才执行 confirm-verifier-unavailable。不要把“继续”视为接受降级结果,也不要要求用户处理文件、进程、服务或回调。"}:{required:!0,message:"Independent verification is currently unavailable, but your code and completed checks are safely preserved. You can retry independent verification directly or explicitly accept the automatic-check-only result.",suggestedReply:"Retry independent verification",agentInstruction:"Relay only message and suggestedReply, then wait for the user choice. If the user asks to retry, run retry-verifier from commandAlternatives; run confirm-verifier-unavailable only when the user explicitly accepts the degraded result. Do not treat “Continue” as accepting the degraded result, and do not ask the user to manage files, processes, services, or callbacks."};if(e.phase==="verify"&&e.status==="await-user"&&e.loop.next_action==="resolve-verifier-blocker")return e.language==="zh-CN"?{required:!0,message:"验证暂时无法下结论,因为缺少只有你能提供的信息,例如外部系统的真实行为或某个业务决定。你的代码和已经完成的检查都已安全保留。补充所需信息后可继续验证,也可以选择修改实现或调整需求。",suggestedReply:null,agentInstruction:"向用户转述 message,请用户补充缺失的信息,或在继续验证(resolve-verifier-blocker)、修改实现、调整需求之间明确选择,再执行 commandAlternatives 中对应的完整命令。不要把“继续”当作默认选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification cannot reach a verdict yet because information only you can provide is missing, such as the real behavior of an external system or a business decision. Your code and completed checks are safely preserved. Supply the missing information to resume verification, or choose to revise the implementation or the requirements.",suggestedReply:null,agentInstruction:"Relay message and ask the user to supply the missing information or explicitly choose between resuming verification (resolve-verifier-blocker), revising the implementation, and revising the requirements; run the matching commandAlternative afterwards. Do not treat “Continue” as a default choice, and do not expose internal rounds, counters, paths, or recovery steps."};if(e.phase==="verify"&&e.status==="await-user"&&e.loop.next_action==="await-user"){let a=(e.loop.stop_reason??(e.loop.no_progress_count>=3?"stalled":"budget"))==="stalled",o=a?"验证已连续三轮失败且未通过的验收场景一直没有减少,本次修改已暂停,以避免在同一个问题上反复循环。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。":"本次修改的验证失败次数已用完配置的预算,因此暂停等待你的决定,而不是自动重试。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。注意:预算不会重置,选择继续修复后,下一次验收失败会再次暂停。",s=a?"Verification has failed three times in a row without the unresolved scenarios shrinking, so this change is paused to avoid looping on the same problem. Your code and completed checks are safely preserved. You can have the Builder try a different repair approach, or go back and adjust the requirements.":"Verification for this change has used its configured failure budget, so it is paused for your decision instead of retrying automatically. Your code and completed checks are safely preserved. You can have the Builder continue with a different repair approach, or go back and adjust the requirements.";return e.language==="zh-CN"?{required:!0,message:o,suggestedReply:"继续修复",agentInstruction:"向用户转述 message 和 suggestedReply,等待用户在“继续修复实现”(revise-implementation)与“调整需求”(revise-requirements)之间明确选择,再执行 commandAlternatives 中对应的完整命令。选择继续修复时,要求 Builder 更换修复思路。不要替用户选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:s,suggestedReply:"Continue repairing",agentInstruction:"Relay message and suggestedReply, then wait for the user to explicitly choose between continuing the implementation (revise-implementation) and adjusting the requirements (revise-requirements); run the matching commandAlternative afterwards. When continuing, ask the Builder to change its repair approach. Do not choose for the user, and do not expose internal rounds, counters, paths, or recovery steps."}}if(e.phase==="verify"&&e.status==="await-user"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass")return{required:!0,message:Z(e,"The reported verification passed, but this platform cannot confirm an independent Verifier execution. Review the result and choose whether to accept it for Archive, revise the implementation, or revise the requirements.","当前验收报告已通过,但当前平台无法确认验收是否独立执行。请检查结果,并选择接受结果进入归档、继续修改实现,或调整需求。"),suggestedReply:Z(e,"Accept the result","接受结果"),agentInstruction:Z(e,"Summarize the result and verification evidence, relay the message, and wait for an explicit user decision. Only then execute the matching commandAlternative. Do not accept the result on the user’s behalf.","简要说明交付结果和验收证据,转述 message,并等待用户明确选择后再执行对应的 commandAlternative。不要替用户接受结果。")};if(e.phase==="build"&&e.status==="active"){let n=r?.children.some(({status:l})=>l==="blocked")??!1,a=r?.children.some(({status:l})=>l==="needs-reverify")??!1,o=r?.children.some(({status:l})=>l==="ready"||l==="active")??!1,s=r?.children.some(({status:l,builderFailureCount:c})=>l==="blocked"&&(c??0)>=un)??!1;return n&&!a&&!o&&!s?e.language==="zh-CN"?{required:!0,message:"Supervisor 子任务暂时无法启动,已暂停自动重试以避免流程循环。请先根据子任务 blocker 修复工作区、分支或依赖;修复完成后重新运行最新的 next 继续流程。代码和已有证据已保留。",suggestedReply:"修复 blocker 后继续",agentInstruction:"向用户说明子任务 blocker 和需要先完成的外部修复;不要反复执行 next,也不要创建替代任务。用户确认工作区或依赖已修复后,再重新读取 status 并执行最新 continuation。"}:{required:!0,message:"Supervisor child dispatch is paused because every remaining child is blocked. Automatic retries are stopped to avoid a loop. Resolve the recorded child blocker (workspace, branch, or dependency) first, then read the latest status and continue; code and completed evidence are preserved.",suggestedReply:"Resolve the blocker and continue",agentInstruction:"Explain the child blocker and the required external repair to the user. Do not repeatedly run next or spawn replacement tasks. After the user confirms the workspace or dependency is fixed, read status again and execute the latest continuation."}:i(Z(e,"Implement the confirmed scope and run focused checks. A separate pre-review is optional, not a prerequisite for Builder handoff. If review is useful, retain the same Reviewer for focused repair follow-ups rather than starting repeated full reviews. Submit the stable candidate for one complete independent verification; release completed helper tasks.","实现已确认范围并运行相关检查。额外预审是可选项,不是 Builder 交接的前置条件。确有必要审查时,保留同一个 Reviewer 复核修复及受影响范围,避免反复启动完整审查。候选稳定后提交一次完整独立验收,及时释放已完成的辅助任务。"))}return i(Z(e,"Follow the continuation action. Unless required is true, continue without asking the user to handle internal workflow state, and do not present machine fields as a user-facing explanation.","按 continuation 执行下一步。除非 required 为 true,否则继续推进,不要让用户处理内部工作流状态,也不要把机器字段作为面向用户的说明。"))}function wv(e){let t=e.workspace.change_branch??"<change-branch>",r=e.workspace.target_branch??"<target-branch>";return e.language==="zh-CN"?{required:!0,message:`当前 change 位于 ${t},目标分支为 ${r}。请选择一次工作区收尾方式:A) 保留工作区;B) 本地合并;C) 推送分支;D) 推送并创建 PR;E) 暂不归档。选择 A-D 后 Runtime 会先执行完整 dry-run,再给出唯一的 confirmed 命令;选择 E 将保留当前 change 等待稍后继续。`,suggestedReply:"回复 A、B、C、D 或 E",agentInstruction:"只向用户展示五种收尾方式及实际影响,等待用户选择。选择 A-D 时执行对应 commandAlternatives 中包含 --dry-run --finish 的完整命令;选择 E 时停止,不运行任何 Archive 命令。不要直接运行 --confirmed,也不要自行猜测 finish。"}:{required:!0,message:`This change is on ${t} and targets ${r}. Choose one workspace finish: A) keep the workspace; B) merge locally; C) push the branch; D) push and create a PR; or E) defer Archive. For A-D, Runtime will run a complete dry-run first, then return one confirmed command; E keeps the current change for later.`,suggestedReply:"Reply A, B, C, D, or E",agentInstruction:"Show all five finish choices and their actual effects, then wait. For A-D, execute the matching complete commandAlternative containing --dry-run --finish; for E, stop without running an Archive command. Do not run --confirmed directly or guess a finish mode."}}function yv(e){return[...[{finish:"keep",name:"keep-workspace",description:["保留当前分支和目录;完成归档提交,不合并、不推送、不创建 PR。","Keep the current branch and directory; create the archive commit without merging, pushing, or creating a PR."]},{finish:"merge",name:"merge-locally",description:["完成归档提交,并把 change 分支本地合并到目标分支;不推送、不创建 PR。","Create the archive commit and merge the change branch locally into the target branch without pushing or creating a PR."]},{finish:"push",name:"push-branch",description:["完成归档提交并推送 change 分支;不合并到目标分支、不创建 PR。","Create the archive commit and push the change branch without merging into the target branch or creating a PR."]},{finish:"pull-request",name:"push-pull-request",description:["完成归档提交、推送 change 分支,并以目标分支为基础创建 PR。","Create the archive commit, push the change branch, and create a PR against the target branch."]}].map(({finish:i,name:n,description:a})=>({name:n,stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","archive",e.name,"--dry-run","--finish",i],requiredInputs:[],inputOptions:[],description:Z(e,a[1],a[0])})),{name:"defer-archive",stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:null,requiredInputs:[],inputOptions:[],description:Z(e,"Keep the current change and workspace without archiving; stop and resume later.","保留当前 change 和工作区,不执行归档;停止本次流程,稍后再继续。")}]}function yu(e){return["comet","native","next",e.change,"--summary","<summary>",e.flag,"--expected-state-version",String(e.stateVersion),"--expected-action",e.action]}function Ot(e,t){return{name:e,flag:t,valueKind:"text",required:!0,template:null}}function vu(){return{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}}function Nv(e,t){return{name:e,flag:t,valueKind:"confirmation",required:!0,template:null}}function gu(e,t,r){return{name:e,flag:t,valueKind:"choice",required:!0,template:null,choices:[...r]}}function bv(e){return e?.coordinationChoiceRequired===!0||e?.schema==="comet.native.children.v2"&&e.children.length>=2}function kv(e){return["comet","native","next",e.change,"--summary","<summary>",...e.coordinationRequired?["--coordination-mode","<coordination-mode>"]:[],"--expected-state-version",String(e.stateVersion),"--expected-action","prepare-shape-confirmation"]}function vt(e){return{name:e.name,stateVersion:e.stateVersion,expectedAction:e.expectedAction,commandArgs:yu({change:e.change,stateVersion:e.stateVersion,action:e.expectedAction,flag:e.flag}),requiredInputs:["summary",e.confirmationInput],inputOptions:[Ot("summary","--summary"),Nv(e.name,e.flag)]}}function wu(e,t){return t.some(i=>/^verification\.md is (?:missing|stale|invalid)$/u.test(i))?[{name:"repair-verification-report",stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","doctor",e.name,"--repair"],requiredInputs:[],inputOptions:[],description:Z(e,"Rebuild the Runtime-managed verification report, then rerun the Archive dry-run.","重建由 Runtime 管理的 verification.md,然后重新运行 Archive 预检。")}]:[]}function Sv(e){return/^verification\.md is (?:missing|stale|invalid)$/u.test(e)}function dn(e){return[vt({name:"revise-implementation",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),vt({name:"revise-requirements",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function Ev(e){let t={"request-checks":"Choose when the Verifier needs additional Runtime checks.","final-result":"Choose when the Verifier has a result for every current scope ID.","verifier-execution-error":"Choose when a dispatched Verifier failed, was lost, or ended without a result.","verifier-unavailable":"Choose only when the platform has no usable independent Verifier capability."};return e.flatMap(r=>Array.isArray(r.template)?r.template.map(i=>{let n=i.response?.kind??i.kind;return{...r,name:n,required:!1,exclusiveGroup:"runner-input",description:t[n],template:i}}):[r])}function fn(e,t,r={}){let i=bv(t)&&e.coordination_mode===void 0,n=gv(e,i,t),a={schema:"comet.native.continuation.v2",skill:"comet-native",change:e.name,phase:e.phase,status:e.status,stateVersion:e.state_version,inputOptions:[],requiresUserDecision:n.required,userCommunication:n},o=s=>({kind:s,candidateId:e.builder_handoff?.candidate_id??null,iteration:e.loop.iteration,attempt:e.loop.attempt});if(e.status==="done")return{...a,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:o("none")};if(e.status==="await-user")return e.phase==="shape"&&e.loop.next_action==="confirm-shape"?{...a,disposition:"await-user",action:"confirm-shape",commandArgs:null,requiredInputs:["summary","shared-understanding-confirmation"],inputOptions:[Ot("summary","--summary")],commandAlternatives:[vt({name:"confirm-shape",change:e.name,stateVersion:e.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"})],runnerAction:o("none")}:e.phase==="verify"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass"?{...a,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Ot("summary","--summary")],commandAlternatives:[vt({name:"accept-result",change:e.name,stateVersion:e.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...dn({change:e.name,stateVersion:e.state_version})],runnerAction:o("none")}:e.phase==="verify"&&e.verification?.assurance==="semantic-verification-unavailable"&&e.loop.next_action==="confirm-verifier-unavailable"?{...a,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Ot("summary","--summary")],commandAlternatives:[vt({name:"retry-verifier",change:e.name,stateVersion:e.state_version,expectedAction:"retry-verifier",flag:"--retry-verifier",confirmationInput:"user-decision"}),vt({name:"confirm-verifier-unavailable",change:e.name,stateVersion:e.state_version,expectedAction:"confirm-verifier-unavailable",flag:"--confirmed",confirmationInput:"user-decision"})],runnerAction:o("none")}:e.phase==="verify"&&e.loop.next_action==="resolve-verifier-blocker"?{...a,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Ot("summary","--summary")],commandAlternatives:[vt({name:"resolve-verifier-blocker",change:e.name,stateVersion:e.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...dn({change:e.name,stateVersion:e.state_version})],runnerAction:o("none")}:e.phase==="verify"&&e.loop.next_action==="await-user"?{...a,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Ot("summary","--summary")],commandAlternatives:dn({change:e.name,stateVersion:e.state_version}),runnerAction:o("none")}:{...a,disposition:"await-user",action:"none",commandArgs:null,commandAlternatives:dn({change:e.name,stateVersion:e.state_version}),userCommunication:{...a.userCommunication,required:!0,message:e.blockers.length>0?e.blockers.map(({reason:s})=>s).join("; "):a.userCommunication.message,suggestedReply:e.blockers.length>0?e.blockers[0]?.resolution_action??null:a.userCommunication.suggestedReply},requiredInputs:["resolve-blocker"],runnerAction:o("none")};if(e.status==="blocked"){let s=e.blockers.some(({resolution_action:l})=>l==="retry-verifier");return{...a,disposition:"blocked",action:s?"retry-verifier":"none",commandArgs:s?yu({change:e.name,stateVersion:e.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:s?["summary"]:["repair-runtime"],inputOptions:s?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:o(s?"retry-verifier":"none")}}if(e.phase==="shape")return{...a,disposition:i?"await-user":"continue",action:"prepare-shape-confirmation",commandArgs:kv({change:e.name,stateVersion:e.state_version,coordinationRequired:i}),requiredInputs:["summary",...i?["coordination-choice"]:[]],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},...i?[gu("coordination-mode","--coordination-mode",mu)]:[]],runnerAction:o("none")};if(e.phase==="build"){if(t){if(!t.confirmed)return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(e.loop.stage==="repairing"&&e.verification_result==="fail")return{...a,disposition:"continue",action:"repair",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["repair-child"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.allDone)return{...a,disposition:"continue",action:"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[vu()],known_limits:[]}}],runnerAction:o("builder-handoff")};let s=t.children.find(({status:m})=>m==="verified");if(s){let m=r.supervisorIntegrationRetryIds;return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["supervisor-integration-checks"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-integrate",child:s.name,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}],...m&&m.length>0?{retry_check_ids:[...m]}:{}}}],runnerAction:o("none")}}let l=t.children.some(({status:m})=>m==="blocked"||m==="needs-reverify"),c=t.children.some(({status:m})=>m==="needs-reverify"),u=t.children.some(({status:m})=>m==="ready"||m==="active"),d=t.supervisorStateVersion===void 0?null:t.children.find(m=>m.status==="blocked"&&(m.builderFailureCount??0)>=un)??null,f=d===null?null:{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-retry-builder",child:d.name,stateVersion:t.supervisorStateVersion},description:Z(e,"Explicitly authorize one fresh Builder attempt after the Builder failure budget was exhausted.","Builder 失败预算已耗尽;明确授权后才能重新开始一次 Builder 尝试。")},h=l&&!c&&!u&&f===null;return{...a,disposition:h?"blocked":"continue",action:"advance-children",commandArgs:h?null:f!==null?["comet","native","next",e.name,"--runner-input","<temporary-json-file>"]:["comet","native","next",e.name,"--summary","<summary>",...e.coordination_mode==="single-session"?["--max-parallel","1"]:[]],requiredInputs:h?[]:f!==null?["supervisor-builder-retry-json-file"]:["ready-children"],inputOptions:h?[]:f!==null?[f]:[Ot("summary","--summary")],runnerAction:o("none")}}return{...a,disposition:"continue",action:e.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[],known_limits:[]}}],runnerAction:o("builder-handoff")}}if(e.phase==="verify"){let s=e.loop.next_action==="await-verifier-result",l=!!e.children_contract_hash,c=vu();return!s&&r.retryCheckIds&&r.retryCheckIds.length>0?{...a,disposition:"continue",action:"retry-checks",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["retry-checks-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"retry-checks",check_ids:[...r.retryCheckIds]}}],runnerAction:o("retry-checks")}:{...a,userCommunication:!s&&l?{...a.userCommunication,agentInstruction:`${a.userCommunication.agentInstruction} ${Z(e,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:a.userCommunication,disposition:"continue",action:s?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:[s?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:Ev([{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:s?[{kind:"verifier-response",candidateId:e.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"request-checks",iteration:e.loop.iteration,attempt:e.loop.attempt,checks:[c]}},{kind:"verifier-response",candidateId:e.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"final-result",result:{iteration:e.loop.iteration,attempt:e.loop.attempt,verdict:"blocked",acceptance:[{id:"<acceptance-id>",result:"blocked",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:r.verificationCheckPlans?r.verificationCheckPlans.map(u=>({...u,argv:[...u.argv]})):l?[c]:[]}}]),runnerAction:o(s?"await-verifier":"dispatch-verifier")}}if(e.phase==="archive"&&e.status==="active"&&e.loop.stage==="archive-ready"&&!e.archived){let s=r.archiveMode??"archive-ready",c=e.workspace.isolation!=="current"&&e.workspace.finish===null;if(s==="blocked")return{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],runnerAction:o("none")};if(s==="preview"){if(r.archiveBlockers&&r.archiveBlockers.length>0){let u=wu(e,r.archiveBlockers)[0];return u&&r.archiveBlockers.every(d=>Sv(d))?{...a,disposition:"continue",action:"repair",commandArgs:u.commandArgs,requiredInputs:[],inputOptions:[],runnerAction:o("none")}:{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],commandAlternatives:wu(e,r.archiveBlockers),runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}return c?{...a,disposition:"await-user",action:"archive",commandArgs:null,requiredInputs:["workspace-finish"],inputOptions:[gu("finish","--finish",["keep","merge","push","pull-request"])],commandAlternatives:[...yv(e)],userCommunication:wv(e),runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--dry-run"],requiredInputs:[],commandAlternatives:[vt({name:"revise-requirements",change:e.name,stateVersion:e.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}import{promises as nv}from"node:fs";import uP from"node:path";import{randomUUID as fC}from"node:crypto";import{promises as nn}from"node:fs";import pC from"node:path";import{execFileSync as xv}from"child_process";import Cv from"fs";import qo from"path";function pn(e,t){return xv("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Wo(e,t){return Nu(e)===Nu(t)}function Nu(e){let t=qo.resolve(e);try{let r=Cv.realpathSync.native(t);return process.platform==="win32"?r.toLowerCase():r}catch{return process.platform==="win32"?t.toLowerCase():t}}function ke(e){try{let t=qo.resolve(pn(e,["rev-parse","--show-toplevel"])),i=pn(e,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?qo.resolve(i.slice(9)):t,a=null;try{a=pn(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Wo(t,n),currentWorktreeRoot:t,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function bu(e){try{return pn(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{return null}}L();fe();var Ol=mt(Ze(),1);import Ki from"path";fe();L();Vt();he();K();H();Ge();Gi();K();H();Er();_t();var EE=mt(Ze(),1);Er();_t();It();It();Sr();zc();Er();It();var nT=4*1024*1024;var xE=null;function CE(e,t){let r=e;for(let i of t)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function Oh(e,t){return(...r)=>{let i=xE;if(i===null)return t(...r);let n=CE(`async:${e}`,r),a=i.entries.get(n);if(a)return a.value;let o=t(...r).catch(s=>{throw i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}Sr();var lT=Oh("hookWritePolicy",async e=>(await Fc(e))?.hook??{allow_paths:[]});Ti();var PE=16*1024;Vc();Kr();var dj=Number.MAX_SAFE_INTEGER;L();Le();var Ej={runStateBytes:Number.MAX_SAFE_INTEGER,trajectoryBytes:Number.MAX_SAFE_INTEGER,trajectoryEvents:4096,trajectoryEventBytes:Number.MAX_SAFE_INTEGER,checkpointBytes:Number.MAX_SAFE_INTEGER,pendingActionBytes:Number.MAX_SAFE_INTEGER,contextBytes:Number.MAX_SAFE_INTEGER,artifactsBytes:Number.MAX_SAFE_INTEGER};import jr from"node:path";L();fe();K();H();var Ji=/^[a-f0-9]{64}$/u,Dh=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,$E=16*1024,Bj=process.platform;function OE(e,t){let r=jr.relative(e,t);return jr.isAbsolute(r)||r===".."||r.startsWith(`..${jr.sep}`)?null:r.replaceAll("\\","/")||"."}function Bh(e){return Array.from(e).some(t=>{let r=t.codePointAt(0)??0;return r<=31||r===127})}function Mh(e,t){if(e.length===0||Bh(e)||e.includes("\\")||jr.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes(".."))throw new Error(`${t} must be a portable project-relative path`);let r=jr.posix.normalize(e);if(r!==e||r===".."||r.startsWith("../"))throw new Error(`${t} must be a normalized project-relative path`);return r}function HE(e){if(typeof e!="string")throw new Error("Native workspace capturedAt is invalid");let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw new Error("Native workspace capturedAt is invalid");return e}function $l(e,t){if(e===null)return null;if(typeof e!="string"||e.length===0||e.trim()!==e||Bh(e))throw new Error(`${t} must be a non-empty branch name or null`);return e}function DE(e){if(!new Set(["current","branch","worktree"]).has(e.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if($l(e.changeBranch,"Native workspace change branch"),$l(e.targetBranch,"Native workspace target branch"),(e.isolation==="branch"||e.isolation==="worktree")&&(e.changeBranch===null||e.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function LE(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace Git provenance must be an object");let t=e,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(t).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(t.provider!=="git"||typeof t.baseCommit!="string"||!Dh.test(t.baseCommit)||typeof t.targetCommit!="string"||!Dh.test(t.targetCommit))throw new Error("Native workspace Git provenance is invalid");$l(t.targetBranch,"Native workspace Git target branch")}function BE(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace identity must be an object");let t=e,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(t).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(t.schema!=="comet.native.workspace.v2"&&t.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(t.capturedRevision)||t.capturedRevision<1||typeof t.nativeRootRef!="string"||!Ji.test(String(t.projectRootId))||!Ji.test(String(t.nativeRootId)))throw new Error("Native workspace identity is invalid");HE(t.capturedAt),Mh(t.nativeRootRef,"Native workspace root ref");let n=t.projectRootPathId!==void 0,a=t.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!Ji.test(String(t.projectRootPathId))||a&&!Ji.test(String(t.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(t.sessionHash!==void 0&&!Ji.test(String(t.sessionHash)))throw new Error("Native workspace session hash is invalid");if(t.git!==void 0&&LE(t.git),t.schema==="comet.native.workspace.v2"){if(t.isolation!==void 0||t.changeBranch!==void 0||t.targetBranch!==void 0||t.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof t.isolation!="string"||t.changeBranch===void 0||t.targetBranch===void 0||t.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(DE(t),t.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(t.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function ME(e,t){return jr.join(Ae(e,t),"workspace.json")}function FE(e,t){let r=ME(e,t),i=ce(e,r),n=OE(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:Mh(n,"Native workspace file ref")}}async function VE(e,t){try{let r=FE(e,t),i=await T({root:r.root,ref:r.ref,maxBytes:$E});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Ui(e,t){let r=await VE(e,t);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(BE(r),r)}Bi();Wa();Wa();var mo=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},Yi=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},vo=class extends Error{constructor(r,i,n,a,o,s=null,l=null){super(`Native change ${r} baseline is incomplete (${i} omitted entr${i===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=r;this.omittedCount=i;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=l;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},p$=va("en");function Ue(e,t){qi(t);let r=Ki.join(e.changesDir,t);if(!X(e.changesDir,r))throw new Error("Native change path escaped");return r}async function zE(e,t=Ki.dirname(e)){let r=Ki.relative(t,e).split(Ki.sep).join("/"),i=await T({root:t,ref:r,maxBytes:null,includeHash:!1}),n=(0,Ol.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${e}: ${n.errors[0].message}`);return n.toJS()}async function Vh(e,t){let r=Ki.join(Ue(e,t),nt);await I(e.nativeRoot,r);let i=vl(await zE(r,e.nativeRoot));if(i.state&&i.state.name!==t)throw new Error(`Native change directory/name mismatch: ${t}`);return i}K();El();ao();Ka();import{promises as Gh}from"node:fs";import wo from"node:path";ct();L();Jr();import{promises as GE}from"node:fs";import JE from"node:os";import Zi from"node:path";function Xi(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Qi(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function ie(e,t,r=!1){if(typeof e!="string"||!r&&e.length===0)throw new Error(`${t} must be ${r?"a string":"a non-empty string"}`);return e}function $r(e,t){return e===null?null:ie(e,t)}function Or(e,t,r=0){if(!Number.isSafeInteger(e)||e<r)throw new Error(`${t} must be a safe integer greater than or equal to ${r}`);return e}function UE(e,t){if(e===null)return null;if(!Number.isSafeInteger(e))throw new Error(`${t} must be null or a safe integer`);return e}function KE(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function Hr(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} must be one of: ${t.join(", ")}`);return e}function Hl(e,t){if(e===null)return null;let r=ie(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO timestamp`);return r}function YE(e,t){let r=ie(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO timestamp`);return r}function Dl(e,t){let r=ie(e,t);if(!Zi.isAbsolute(r))throw new Error(`${t} must be absolute`);return Zi.resolve(r)}function XE(e,t){let r=`Native local checks[${t}]`,i=Xi(e,r);if(Qi(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log","activeProcess","evidence","evidenceDigest"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((u,d)=>ie(u,`${r}.argv[${d}]`,!0)),a=Hr(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=Hl(i.startedAt,`${r}.startedAt`),s=Hl(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let l=Or(i.timeoutMs,`${r}.timeoutMs`);if(l<1)throw new Error(`${r}.timeoutMs must be positive`);let c;if(Object.hasOwn(i,"activeProcess"))if(i.activeProcess===null)c=null;else{let u=Xi(i.activeProcess,`${r}.activeProcess`),d=Hr(u.status,["starting","running"],`${r}.activeProcess.status`);if(Qi(u,new Set(["status","pid","identity"]),`${r}.activeProcess`),d==="starting"){if(Object.hasOwn(u,"pid")||Object.hasOwn(u,"identity"))throw new Error(`${r}.activeProcess starting state cannot contain process identity`);c={status:"starting"}}else c={status:"running",pid:Or(u.pid,`${r}.activeProcess.pid`,1),...Object.hasOwn(u,"identity")?{identity:ie(u.identity,`${r}.activeProcess.identity`)}:{}}}return{id:ie(i.id,`${r}.id`),name:ie(i.name,`${r}.name`),operationId:ie(i.operationId,`${r}.operationId`),status:a,repeatable:KE(i.repeatable,`${r}.repeatable`),timeoutMs:l,executionCount:Or(i.executionCount,`${r}.executionCount`),argv:n,cwd:Dl(i.cwd,`${r}.cwd`),exitCode:UE(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:ie(i.log,`${r}.log`),...Object.hasOwn(i,"activeProcess")?{activeProcess:c}:{},...Object.hasOwn(i,"evidence")?{evidence:Hr(i.evidence,["runtime"],`${r}.evidence`)}:{},...Object.hasOwn(i,"evidenceDigest")?{evidenceDigest:ie(i.evidenceDigest,`${r}.evidenceDigest`)}:{}}}function Wh(e){let t="Native local execution state",r=Xi(e,t);if(Qi(r,new Set(["schema","change","basedOnStateVersion","candidateId","inputFingerprint","inputFingerprintGate","candidateInputFingerprintGate","workspace","execution","checks"]),t),r.schema!==Gr)throw new Error(`Native local execution schema must be ${Gr}`);let i=Xi(r.workspace,"Native local workspace");Qi(i,new Set(["projectRoot","worktreeRoot","branch","machineId"]),"Native local workspace");let n=null;if(r.execution!==null){let o=Xi(r.execution,"Native local execution");Qi(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds","verifierStartedAt","ownerPid","ownerIdentity"]),"Native local execution");let s=Hl(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:ie(o.operationId,"Native local execution.operationId"),stage:Hr(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Hr(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:$r(o.executionId,"Native local execution.executionId"),status:Hr(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Or(o.requestCheckRounds,"Native local execution.requestCheckRounds"),...Object.hasOwn(o,"verifierStartedAt")?{verifierStartedAt:YE(o.verifierStartedAt,"Native local execution.verifierStartedAt")}:{},...Object.hasOwn(o,"ownerPid")?{ownerPid:Or(o.ownerPid,"Native local execution.ownerPid",1)}:{},...Object.hasOwn(o,"ownerIdentity")?{ownerIdentity:ie(o.ownerIdentity,"Native local execution.ownerIdentity")}:{}}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(XE);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:Gr,change:ie(r.change,"Native local change"),basedOnStateVersion:Or(r.basedOnStateVersion,"Native local basedOnStateVersion",1),...Object.hasOwn(r,"candidateId")?{candidateId:$r(r.candidateId,"Native local candidateId")}:{},...Object.hasOwn(r,"inputFingerprint")?{inputFingerprint:$r(r.inputFingerprint,"Native local inputFingerprint")}:{},...Object.hasOwn(r,"inputFingerprintGate")?{inputFingerprintGate:$r(r.inputFingerprintGate,"Native local inputFingerprintGate")}:{},...Object.hasOwn(r,"candidateInputFingerprintGate")?{candidateInputFingerprintGate:$r(r.candidateInputFingerprintGate,"Native local candidateInputFingerprintGate")}:{},workspace:{projectRoot:Dl(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Dl(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:$r(i.branch,"Native local workspace.branch"),...Object.hasOwn(i,"machineId")?{machineId:ie(i.machineId,"Native local workspace.machineId")}:{}},execution:n,checks:a}}function He(e){return Wh({schema:Gr,change:e.portableState.name,basedOnStateVersion:e.portableState.state_version,candidateId:e.portableState.builder_handoff?.candidate_id??null,inputFingerprint:null,inputFingerprintGate:null,candidateInputFingerprintGate:null,workspace:{projectRoot:Zi.resolve(e.projectRoot),worktreeRoot:Zi.resolve(e.worktreeRoot??e.projectRoot),branch:e.branch??null,machineId:JE.hostname()},execution:null,checks:[]})}async function De(e,t,r={}){let i=Wh(t);await GE.mkdir(Zi.dirname(e),{recursive:!0}),await Q(e,i,r)}ot();H();var en=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Jh="comet-state.yaml",Uh="state.json";function le(e,t){if(!en.test(t))throw new Error(`Invalid Native change name: ${t}`);let r=wo.join(e.changesDir,t);if(!X(e.changesDir,r))throw new Error("Native change path escaped");return r}function Ke(e,t){return wo.join(le(e,t),Jh)}function ye(e,t){return wo.join(_e(e,t),Uh)}async function er(e,t){try{let r=await Gh.readFile(Ke(e,t),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function lt(e){return bu(e)}async function Ne(e,t){return at(Ke(e,t))}async function ut(e){let t=await yh({file:Ke(e.paths,e.previous.name),expectedStateVersion:e.previous.state_version,next:e.next,containedRoot:e.paths.nativeRoot});if(t.verification===null&&t.verification_report===null){let r=wo.join(le(e.paths,t.name),"verification.md");await I(e.paths.nativeRoot,r),await Gh.rm(r,{force:!0})}return t}L();import{createHash as sC}from"node:crypto";import{promises as Vr}from"node:fs";import ft from"node:path";Vt();fe();Je();H();var Yh=["outcome","scope","nonGoals","acceptanceExamples"],Kh=[...Yh,"constraints","decisions","openQuestions","verificationExpectations"];var ex=new Set(["nonGoals","decisions","openQuestions"]),tx={maxFileBytes:Zo};function rx(e){let t=new Map,r=null,i=[],n=()=>{r!==null&&t.set(r,i.join(`
179
- `).trim())};for(let a of e.split(/\r?\n/u)){let o=/^# ([^#].*)$/u.exec(a);o?(n(),r=o[1].trim(),i=[]):r!==null&&i.push(a)}return n(),t}function Ll(e){return{valid:e.length===0,findings:e}}function Bl(e){let t=[],r=0;for(;r<e.length;){let i=e.indexOf("<!--",r);if(i<0){t.push(e.slice(r));break}t.push(e.slice(r,i));let n=e.indexOf("-->",i+4);if(n<0){t.push(e.slice(i));break}r=n+3}return t.join("")}function ix(e){return Bl(e).trim()}function yo(e){let t=ix(e).split(/\r?\n/u),r=[],i=!1;for(let n of t){if(/^\s*(?:```|~~~)/u.test(n)){i=!i;continue}!i&&/^\s*#{1,6}\s*$/u.test(n)||!i&&/^\s*#{1,6}\s+/u.test(n)||!i&&/^\s*(?:[-*+]\s*|\d+[.)]\s*)$/u.test(n)||r.push(n)}return r.join(`
180
- `).trim()}function nx(e){let t=yo(e).replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/gmu,"").replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim().toLocaleLowerCase("en-US");return/^(?:none|n\/a|not applicable|no(?:ne)?(?:\s+at\s+this\s+time)?|no\s+(?:additional\s+)?(?:non-goals?|decisions?|open\s+questions?|questions?)|无|无相关事项|没有(?:额外)?(?:非目标|决定|待解决问题)|不适用|暂无)[.!。;;::,,、 -]*$/iu.test(t)}function Xh(e){let t=yo(e).replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/gmu,"").replace(/\s+/gu," ").trim();if(t.length===0)return!1;let r=t.replace(/[*_`]/gu,"").replace(/^\s*>+\s?/gmu,"").replace(/\s+/gu," ").trim();if(/^(?:<[^>\r\n]+>|\{\{[^}\r\n]+\}\})[.!。;;::,,、 -]*$/iu.test(r))return!0;let i=t.replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim();return/^(?:(?:todo|tbd|fixme)(?:\s*[::-]\s*.+)?|fill(?:\s+this\s+in)?(?:\s*[::-]\s*.+)?|placeholder(?:\s*[::-]\s*.+)?|待填写\S*|待补充\S*|<[^>]+>|\{\{[^}]+\}\})[.!。;;::,,、 -]*$/iu.test(i)}function Qh(e,t){let r=[];return yo(e).length===0?r.push({code:"spec-document-empty",message:`Native target Spec is empty: ${t}. Add the complete target requirements or use an explicit no-product-behavior exemption in brief.md.`,path:t}):Xh(e)&&r.push({code:"spec-document-placeholder",message:`Native target Spec contains only template placeholder content: ${t}. Replace it with complete target requirements.`,path:t}),Ll(r)}function Ml(e){let t=new Set(["blocker","blocking","coverage","decision","open_question","question","requirement","requirements","source","source_coverage","state","status","决策","来源","覆盖","问题","状态","需求","阻塞"]),r=null;for(let i of e.split(/\r?\n/u)){let n=i.match(/^\s*(`{3,}|~{3,})/u);if(n){let s=n[1]?.[0];r===null?r=s:r===s&&(r=null);continue}if(r!==null)continue;let a=i.trim();if(/^(?:[-*+]\s+|\d+[.)]\s+)(?:\[[ xX]\]\s+)?\[blocking\](?=$|[\s::—-])/iu.test(a)||a.includes("|")&&a.split("|").some(s=>/^\s*\[blocking\](?=$|[\s::—-])/iu.test(s)))return!0;let o=a.match(/^([\p{L}\p{N}_./-]+)\s*[::]\s*\[blocking\](?=$|[\s::—-])/iu);if(o){let s=o[1]?.toLocaleLowerCase("en-US")??"";if(t.has(s)||/[./_-]/u.test(s))return!0}}return!1}async function Fl(e,t,r={}){let i=[],n;try{n=(await T({root:e,ref:t,maxBytes:tx.maxFileBytes})).text}catch(s){return Ll([{code:"brief-missing",message:s.message,path:t}])}let a=new Map;for(let[s,l]of rx(n))a.set(ma(s)??s,l);for(let s of Kh)a.has(s)||i.push({code:"brief-section-missing",message:`Missing brief section: ${s}`,path:t});let o=r.strict?Kh:Yh;for(let s of o){let l=a.get(s)??"";yo(l).length===0?i.push({code:"brief-section-empty",message:`Brief section is empty: ${s}`,path:t}):Xh(l)?i.push({code:"brief-section-placeholder",message:`Brief section contains only template placeholder content: ${s}`,path:t}):r.strict&&!ex.has(s)&&nx(l)&&i.push({code:"brief-section-empty",message:`Brief section must describe the confirmed work instead of declaring no items: ${s}`,path:t})}return Ml(n)&&i.push({code:"brief-blocking-question",message:"Brief has a blocking open question",path:t}),Ll(i)}fe();J();var jx=mt(Ze(),1);ct();fe();J();he();H();ot();ko();ko();$t();Tt();ct();$a();L();J();So();K();H();sm();$t();Tt();zl();ct();he();zl();Di();H();var Eo=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};ct();he();K();$t();Tt();function Gl(e){return O("comet.native.parent-contract.v1",{acceptance:e.acceptance.map(({id:t,source:r,text:i})=>({id:t,source:r,text:i})),children:e.children})}ot();Qt();Ur();ln();function fm(e){return e.state_version+1}function Ox(e){return e.map(t=>({...t,result:"pending",reason:null}))}function Hx(e){return{goal_cycle:e.state.loop.goal_cycle,iteration:e.state.loop.iteration,attempt:e.state.loop.attempt,outcome:e.outcome,unresolved_ids:e.unresolvedIds??[],summary:je(e.summary),completed_at:e.completedAt}}function xo(e){let t=ge(e.state);if(t.phase!=="verify"&&t.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let r=e.failureBudget,i=r?t.loop.failed_iteration_count+1:t.loop.failed_iteration_count,n=r!==void 0&&i>=r.maxVerifyFailures,a=(e.now??new Date).toISOString(),o=Xt(t,Hx({state:t,outcome:"recovery",summary:e.reason,completedAt:a})),s=new Set(t.loop.previous_unresolved_ids),l=s.size===0?Ox(t.acceptance):t.acceptance.map(c=>s.has(c.id)?{...c,result:"pending",reason:null}:c);return n?ge({...o,phase:"verify",status:"await-user",state_version:fm(t),verification_result:"fail",builder_handoff:t.builder_handoff,blockers:[{owner:"user",reason:je(`Native Runtime checks failed at Builder handoff and reached the configured failed iteration limit: ${e.reason}`),acceptance_ids:[...s],resolution_action:"await-user"}],loop:{...t.loop,stage:"await-user",failed_iteration_count:i,execution_failure_count:0,stop_reason:"budget",next_action:"resolve-loop-stop"}}):ge({...o,phase:"build",status:"active",state_version:fm(t),verification_result:"pending",verification_report:null,verification:null,builder_handoff:t.builder_handoff,blockers:[],acceptance:l,loop:{...t.loop,stage:"repairing",iteration:t.loop.iteration+1,attempt:0,execution_failure_count:0,failed_iteration_count:i,stop_reason:void 0,next_action:"submit-builder-candidate"}})}K();Ka();fl();ot();Qt();L();Vt();Ur();H();Vt();Fr();he();var Zl=mt(Ze(),1);It();var TH=new Set("a an and are as at be by for from in is it of on or that the this to with you your".split(" "));var bm=5,Xx=600,LH=256*1024,Qx=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Zx=/^[A-Za-z0-9][A-Za-z0-9._-]*$/u;var eC=/^[a-f0-9]{64}$/iu;function km(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function jt(e,t,r=4096){if(typeof e!="string"||e.trim().length===0||e.length>r)throw new Error(`${t} must be a non-empty string within the association limit`);return e}function Ql(e,t){let r=jt(e,t).replaceAll("\\","/");if(r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").some(i=>i===""||i==="."||i===".."))throw new Error(`${t} must be a project-relative path`);return r}function tC(e,t){let r=jt(e,t,64).toLowerCase();if(!eC.test(r))throw new Error(`${t} must be a SHA-256 hash`);return r}function rC(e,t){let r=`Capability association evidence[${t}]`,i=km(e,r),n=Object.keys(i).filter(a=>!new Set(["source","kind","title","snippet"]).has(a));if(n.length>0)throw new Error(`${r} has unknown field(s): ${n.join(", ")}`);return{source:Ql(i.source,`${r}.source`),kind:jt(i.kind,`${r}.kind`,128),...i.title===void 0?{}:{title:jt(i.title,`${r}.title`)},...i.snippet===void 0?{}:{snippet:jt(i.snippet,`${r}.snippet`,Xx)}}}function Sm(e){let t=typeof e=="string"?(()=>{if(e.length>65536)throw new Error("Capability association exceeds the size limit");let c=(0,Zl.parseDocument)(e,{uniqueKeys:!0});if(c.errors.length>0)throw new Error(c.errors[0].message);return c.toJS({mapAsMap:!1})})():e,r=km(t,"Capability association"),i=Object.keys(r).filter(c=>!new Set(["schema","status","workflow","capability","current_spec","current_hash","confidence","query","reason","historical_sources","evidence"]).has(c));if(i.length>0)throw new Error(`Capability association has unknown field(s): ${i.join(", ")}`);if(r.schema!=="comet.capability-association.v1")throw new Error("Unsupported capability association schema");let n=r.workflow;if(n!=="native"&&n!=="classic")throw new Error("Capability association workflow is invalid");let a=iC(jt(r.capability,"Capability association capability"),n);if(!Array.isArray(r.historical_sources))throw new Error("Capability association historical_sources must be an array");let o=r.historical_sources.map((c,u)=>Ql(c,`Capability association historical_sources[${u}]`));if(!Array.isArray(r.evidence)||r.evidence.length>bm)throw new Error(`Capability association evidence must contain at most ${bm} entries`);let s=r.status;if(s!=="suggested"&&s!=="explicit")throw new Error("Capability association status is invalid");let l=r.confidence;if(l!=="high"&&l!=="medium"&&l!=="low")throw new Error("Capability association confidence is invalid");return{schema:"comet.capability-association.v1",status:s,workflow:n,capability:a,current_spec:Ql(r.current_spec,"Capability association current_spec"),current_hash:tC(r.current_hash,"Capability association current_hash"),confidence:l,...r.query===void 0?{}:{query:jt(r.query,"Capability association query")},reason:jt(r.reason,"Capability association reason",2048),historical_sources:o,evidence:r.evidence.map(rC)}}function iC(e,t){let r=e.replaceAll("\\","/").replace(/^\/+|\/+$/gu,""),i=r.split("/"),n=t==="native"?Qx:Zx;if(!r||i.some(a=>!n.test(a)))throw new Error(`Invalid ${t} capability: ${e}`);return i.join("/")}ot();Qt();Tt();var cC=va("en"),eu="capability-association.yaml";function _o(e){let t=e.replace(/\r\n?/gu,`
191
+ `,o),c=l===-1?a.slice(o):a.slice(o,l);if(yield{line:c,body:t===null&&!r&&i===null,index:s},s+=1,t!==null)t=Pm(c,t);else if(r)Rm(c)&&(r=!1);else if(i!==null)new RegExp(`</${i}\\s*>`,"iu").test(c)&&(i=null);else{let d=Pm(c,null);if(d!==null)t=d;else{let f=c.trimStart();if(f.startsWith("<!--")&&!Rm(f))r=!0;else{let h=/^<([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/u.exec(f);h&&n.has(h[1].toLowerCase())&&!f.startsWith("</")&&!f.endsWith("/>")&&!new RegExp(`</${h[1]}\\s*>`,"iu").test(f)&&(i=h[1])}}}if(l===-1)break;o=l+1}}function wn(e){return e.normalize("NFC").replace(/\s+/gu," ").trim()}function Am(e,t,r,i=[],n="content-hash"){let a=wn(r),o=t.replaceAll("\\","/").trim(),s=i.map(wn);if(a.length===0)throw new Error(`${e} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${e} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${D(WE,{kind:e,source:o,context:s,text:a})}`:"",kind:e,source:o,context:s,text:a}}function Im(e,t,r="content-hash"){let i=new Set;for(let n of e){let a=r==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(i.has(a))throw new Error(`${t} contains duplicate acceptance criteria`);i.add(a)}return e}function zE(e){let t=null,r=null,i=0,n=0;for(let{line:a,body:o,index:s}of _o(e)){n=s+1;let l=o?_m(a):null;l?.level===1&&(Za(l.text)==="acceptanceExamples"?(i+=1,i===1&&(t=s+1)):t!==null&&r===null&&(r=s))}if(i===0||t===null)return null;if(i!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:t,end:r??n}}function ou(e,t="brief.md",r=Ao.maxCriteria,i="content-hash"){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native brief acceptance budget is invalid");let n=zE(e);if(n===null)return[];let a=null;for(let{line:c,body:u,index:d}of _o(e)){if(d<n.start||d>=n.end)continue;let f=u?/^( {0,3})[-*+][ \t]+/u.exec(c):null;if(f===null)continue;let h=f[1].length;a=a===null?h:Math.min(a,h)}let o=[],s=null,l=()=>{if(s!==null){if(o.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);o.push(s)}};for(let{line:c,body:u,index:d}of _o(e)){if(d<n.start||d>=n.end)continue;let f=u?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(c):null;f&&f[1].length===a?(l(),s=[f[2]]):s!==null&&s.push(c)}return l(),Im(o.map(c=>Am("brief-example",t,c.join(`
192
+ `),[],i)),"Brief",i)}function su(e,t="spec.md",r=Ao.maxCriteria,i="content-hash",n={}){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native specification acceptance budget is invalid");let a=[],o=[],s=null,l=()=>{if(s===null)return;if(a.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);let c=(n.resolveBriefReferences?s.body:[]).map(u=>/^\s*(?:Acceptance|验收)\s*[::]\s*(.*)$/iu.exec(u)?.[1]).filter(u=>u!==void 0);if(c.some(u=>!/^A[1-9]\d*$/u.test(u)))throw new Error("A Spec acceptance reference must be one brief ID such as A1");if(c.length>1)throw new Error("A Spec scenario may reference only one brief acceptance criterion");a.push({...Am("spec-scenario",t,[s.title,...s.body].join(`
193
+ `),s.context,i),...c[0]===void 0?{}:{briefAcceptanceRef:c[0]}}),s=null};for(let{line:c,body:u}of _o(e)){let d=u?_m(c):null,f=d?/^Scenario\s*:\s*(.*)$/iu.exec(d.text):null;if(f){for(l();o.at(-1)&&o.at(-1).level>=d.level;)o.pop();let h=wn(f[1]);if(h.length===0)throw new Error("Scenario title must not be empty");s={level:d.level,title:h,body:[],context:o.map(m=>m.text)}}else if(d){for(s!==null&&d.level<=s.level?l():s!==null&&s.body.push(c);o.at(-1)&&o.at(-1).level>=d.level;)o.pop();o.push(d)}else s!==null&&u&&s.body.push(c)}return l(),Im(a,"Specification",i)}var WE,q$,Ao,Io=S(()=>{"use strict";tr();K();WE="comet.native.acceptance.v1",q$=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Ao=Object.freeze({maxCriteria:1024})});import Tm from"node:path";function $m(e,t){if(e.length===0||e!==e.trim()||e.includes("\\")||Tm.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||Tm.posix.normalize(e)!==e||e==="."||e.endsWith("/"))throw new Error(`${t} must be a normalized change-relative ref`);return e}function JE(e,t){return e.localeCompare(t,"en")}function To(e){let t=$m(e.briefSource??"brief.md","Native brief source"),r=[...e.specs??[]].sort((o,s)=>JE(o.capability,s.capability));if(new Set(r.map(o=>o.capability)).size!==r.length)throw new Error("Native acceptance sources contain duplicate capabilities");let i=ou(e.briefMarkdown,t,Number.MAX_SAFE_INTEGER,"none").map(({source:o,text:s})=>({source:o,text:s})),n=i.length;for(let o of r){let s=$m(o.source,`Native spec source for ${o.capability}`);for(let l of su(o.markdown,s,Number.MAX_SAFE_INTEGER,"none",{resolveBriefReferences:e.resolveBriefReferences===!0})){if(l.briefAcceptanceRef!==void 0){let c=Number(l.briefAcceptanceRef.slice(1))-1;if(!Number.isSafeInteger(c)||c<0||c>=n)throw new Error(`Native Spec references unknown brief acceptance ${l.briefAcceptanceRef}: ${s}`);continue}i.push({source:s,text:l.text})}}let a=new Set;for(let o of i){o.text=wn(o.text);let s=o.text;if(a.has(s))throw new Error(`Native acceptance contains a duplicate criterion: ${o.text}`);a.add(s)}if(i.length===0)throw new Error("Native change must define at least one acceptance criterion");return i.map((o,s)=>({id:`A${s+1}`,source:o.source,text:o.text}))}function jm(e){let t=e.map(({id:r})=>r);if(new Set(t).size!==t.length)throw new Error("Native acceptance IDs must be unique");for(let r=0;r<t.length;r+=1)if(!GE.test(t[r])||t[r]!==`A${r+1}`)throw new Error("Native acceptance IDs must be the contiguous sequence A1..An")}function cu(e,t){return e.length===t.length&&e.every((r,i)=>r.source===t[i]?.source&&r.text===t[i]?.text)}var GE,$o=S(()=>{"use strict";Io();GE=/^A[1-9]\d*$/u});function lu(e,t){if(typeof e!="string"||!e.trim()||e.length>4e3||/^<[^>]+>$/u.test(e.trim()))throw new Error(`${t} must contain a concrete statement of at most 4000 characters`);return e.trim()}function uu(e){if(!Array.isArray(e))throw new Error("Native Builder acceptance_review must be an array");return e.map((t,r)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native Builder acceptance review entry must be an object");let i=t,n=`Native Builder acceptance_review[${r}]`;As(i,["id","status","evidence","note"],n,`/acceptance_review/${r}`);let a=i.status;if(!["implemented-with-evidence","implemented-no-evidence","not-implemented","known-fail"].includes(a))throw new Error(`${n}.status is invalid`);if(!Array.isArray(i.evidence))throw new Error(`${n}.evidence must be an array`);return{id:lu(i.id,`${n}.id`),status:a,evidence:i.evidence.map(o=>lu(o,`${n}.evidence`)),note:lu(i.note,`${n}.note`)}})}function du(e,t){if(!t)throw new Xr(e.map(({id:l})=>l),[]);let r=new Set(e.map(({id:l})=>l)),i=t.map(({id:l})=>l),n=new Set(i);if(n.size!==i.length)throw new Error("Native Builder acceptance_review contains duplicate IDs");let a=i.filter(l=>!r.has(l));if(a.length)throw new Error(`Native Builder acceptance_review contains unknown IDs: ${a.join(", ")}`);let o=e.filter(({id:l})=>!n.has(l)).map(({id:l})=>l),s=t.filter(l=>l.status!=="implemented-with-evidence"||l.evidence.length===0).map(({id:l})=>l);if(o.length||s.length)throw new Xr(o,s)}var Xr,jo=S(()=>{"use strict";qn();Xr=class extends Error{constructor(r,i){super(`Native Builder handoff is incomplete${r.length?`; missing: ${r.join(", ")}`:""}${i.length?`; not ready: ${i.join(", ")}`:""}. Complete acceptance_review for every requirement and its evidence before Verify`);this.missingIds=r;this.incompleteIds=i}missingIds;incompleteIds}});import{promises as UE}from"node:fs";function ne(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function ae(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function X(e,t,r){if(typeof e!="string"||!r?.empty&&e.length===0)throw new Error(`${t} must be ${r?.empty?"a string":"a non-empty string"}`);return e}function pu(e,t){return e===null?null:X(e,t)}function hu(e,t){let r=X(e,t);if(!QE.test(r))throw new Error(`${t} must be a SHA-256 hash`);return r}function Qr(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function M(e,t,r=0){if(!Number.isSafeInteger(e)||e<r)throw new Error(`${t} must be a safe integer greater than or equal to ${r}`);return e}function ex(e,t){return e===null?null:M(e,t,Number.MIN_SAFE_INTEGER)}function W(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} must be one of: ${t.join(", ")}`);return e}function et(e,t,r){if(!Array.isArray(e))throw new Error(`${t} must be an array`);return e.map((i,n)=>r(i,n))}function Bo(e,t){return et(e,t,(r,i)=>X(r,`${t}[${i}]`))}function lr(e,t){if(new Set(e).size!==e.length)throw new Error(`${t} must be unique`)}function Zr(e,t){let r=X(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO date or timestamp`);return r}function Do(e,t,r=!1){let i=X(e,t);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${t} must be a portable relative path`);return i}function Se(e,t){let r=ne(e,t);return ae(r,new Set(["text","truncated"]),t),{text:X(r.text,`${t}.text`,{empty:!0}),truncated:Qr(r.truncated,`${t}.truncated`)}}function tx(e,t){let r=`Native spec_changes[${t}]`,i=ne(e,r);ae(i,new Set(["capability","operation","source","delta_source","base_hash"]),r);let n=X(i.capability,`${r}.capability`);if(!YE.test(n))throw new Error(`${r}.capability is invalid`);let a=W(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:Do(i.source,`${r}.source`),s=i.delta_source===void 0?void 0:Do(i.delta_source,`${r}.delta_source`),l=i.base_hash===void 0?void 0:i.base_hash===null?null:hu(i.base_hash,`${r}.base_hash`);if(a==="remove"&&o!==null)throw new Error(`${r} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${r} ${a} requires a source`);if(s!==void 0&&a==="remove")throw new Error(`${r} remove cannot contain delta_source`);if(s!==void 0&&l==null)throw new Error(`${r} delta_source requires a non-null base_hash`);if(l!==void 0&&s===void 0&&a!=="remove")throw new Error(`${r} base_hash requires delta_source for non-remove specs`);return{capability:n,operation:a,source:o,...s===void 0?{}:{delta_source:s},...l===void 0?{}:{base_hash:l}}}function rx(e){let t="Native workspace",r=ne(e,t);ae(r,new Set(["isolation","change_branch","target_branch","finish"]),t);let i=W(r.isolation,["current","branch","worktree"],`${t}.isolation`),n=pu(r.change_branch,`${t}.change_branch`),a=pu(r.target_branch,`${t}.target_branch`),o=r.finish===null?null:W(r.finish,["merge","push","pull-request","keep"],`${t}.finish`);if(i==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(i==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(i!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:i,change_branch:n,target_branch:a,finish:o}}function ix(e){let t="Native loop",r=ne(e,t);ae(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","stop_reason","execution_failure_count","previous_unresolved_ids","next_action"]),t);let i=Bo(r.previous_unresolved_ids,`${t}.previous_unresolved_ids`);lr(i,`${t}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:W(r.stop_reason,["budget","stalled"],`${t}.stop_reason`);return{stage:W(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${t}.stage`),goal_cycle:M(r.goal_cycle,`${t}.goal_cycle`,1),iteration:M(r.iteration,`${t}.iteration`),attempt:M(r.attempt,`${t}.attempt`),retry_epoch:M(r.retry_epoch,`${t}.retry_epoch`),failed_iteration_count:M(r.failed_iteration_count,`${t}.failed_iteration_count`),no_progress_count:M(r.no_progress_count,`${t}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:M(r.execution_failure_count,`${t}.execution_failure_count`),previous_unresolved_ids:i,next_action:pu(r.next_action,`${t}.next_action`)}}function nx(e,t){let r=`Native acceptance[${t}]`,i=ne(e,r);ae(i,new Set(["id","source","text","result","reason"]),r);let n=X(i.id,`${r}.id`);if(!XE.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:Do(i.source,`${r}.source`),text:X(i.text,`${r}.text`),result:W(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:Se(i.reason,`${r}.reason`)}}function ax(e,t){let r=`Native builder_handoff.checks[${t}]`,i=ne(e,r);return ae(i,new Set(["name","result","note"]),r),{name:Se(i.name,`${r}.name`),result:W(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:Se(i.note,`${r}.note`)}}function ox(e){let t="Native builder_handoff",r=ne(e,t);ae(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","acceptance_review","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),t);let i=Bo(r.addressed_acceptance_ids,`${t}.addressed_acceptance_ids`);lr(i,`${t}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:ne(r.review,`${t}.review`);return n&&ae(n,new Set(["status","summary","reviewer_execution_ref"]),`${t}.review`),{candidate_id:X(r.candidate_id,`${t}.candidate_id`),identity_provider:X(r.identity_provider,`${t}.identity_provider`),builder_execution_ref:X(r.builder_execution_ref,`${t}.builder_execution_ref`),iteration:M(r.iteration,`${t}.iteration`,1),summary:Se(r.summary,`${t}.summary`),addressed_acceptance_ids:i,...r.acceptance_review===void 0?{}:{acceptance_review:uu(r.acceptance_review)},checks:et(r.checks,`${t}.checks`,ax),checks_truncated:Qr(r.checks_truncated,`${t}.checks_truncated`),known_limits:et(r.known_limits,`${t}.known_limits`,(a,o)=>Se(a,`${t}.known_limits[${o}]`)),known_limits_truncated:Qr(r.known_limits_truncated,`${t}.known_limits_truncated`),review:n?{status:W(n.status,["passed"],`${t}.review.status`),summary:Se(n.summary,`${t}.review.summary`),reviewer_execution_ref:X(n.reviewer_execution_ref,`${t}.review.reviewer_execution_ref`)}:null,submitted_at:Zr(r.submitted_at,`${t}.submitted_at`)}}function sx(e,t){let r=`Native blockers[${t}]`,i=ne(e,r);ae(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=Bo(i.acceptance_ids,`${r}.acceptance_ids`);return lr(n,`${r}.acceptance_ids`),{owner:W(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:Se(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:W(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function cx(e,t){let r=`Native verification.checks[${t}]`,i=ne(e,r);return ae(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:X(i.id,`${r}.id`),name:Se(i.name,`${r}.name`),argv_display:et(i.argv_display,`${r}.argv_display`,(n,a)=>Se(n,`${r}.argv_display[${a}]`)),argv_truncated:Qr(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:Do(i.cwd_ref,`${r}.cwd_ref`,!0),status:W(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:ex(i.exit_code,`${r}.exit_code`),duration_ms:M(i.duration_ms,`${r}.duration_ms`)}}function lx(e){let t="Native verification",r=ne(e,t);ae(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),t);let i=et(r.checks,`${t}.checks`,cx);lr(i.map(a=>a.id),`${t}.checks IDs`);let n=X(r.identity_provider,`${t}.identity_provider`);return{candidate_id:X(r.candidate_id,`${t}.candidate_id`),identity_provider:n,verifier_execution_ref:X(r.verifier_execution_ref,`${t}.verifier_execution_ref`),iteration:M(r.iteration,`${t}.iteration`,1),attempt:M(r.attempt,`${t}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":W(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${t}.assurance`),verdict:W(r.verdict,["pass","fail","blocked"],`${t}.verdict`),checks:i,summary:Se(r.summary,`${t}.summary`),risks:et(r.risks,`${t}.risks`,(a,o)=>Se(a,`${t}.risks[${o}]`)),risks_truncated:Qr(r.risks_truncated,`${t}.risks_truncated`),completed_at:Zr(r.completed_at,`${t}.completed_at`)}}function Om(e,t){let r=`Native history[${t}]`,i=ne(e,r);ae(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=Bo(i.unresolved_ids,`${r}.unresolved_ids`);return lr(n,`${r}.unresolved_ids`),{goal_cycle:M(i.goal_cycle,`${r}.goal_cycle`,1),iteration:M(i.iteration,`${r}.iteration`),attempt:M(i.attempt,`${r}.attempt`),outcome:W(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:Se(i.summary,`${r}.summary`),completed_at:Zr(i.completed_at,`${r}.completed_at`)}}function ux(e){let t="Native history_overflow.outcome_counts",r=ne(e,t),i=["pass","fail","blocked","execution-error","recovery"];return ae(r,new Set(i),t),{pass:M(r.pass,`${t}.pass`),fail:M(r.fail,`${t}.fail`),blocked:M(r.blocked,`${t}.blocked`),"execution-error":M(r["execution-error"],`${t}.execution-error`),recovery:M(r.recovery,`${t}.recovery`)}}function dx(e){let t="Native history_overflow",r=ne(e,t);ae(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),t);let i=M(r.dropped_entries,`${t}.dropped_entries`),n=r.first_dropped_at===null?null:Zr(r.first_dropped_at,`${t}.first_dropped_at`),a=r.last_dropped_at===null?null:Zr(r.last_dropped_at,`${t}.last_dropped_at`);if(i===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(i>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=ux(r.outcome_counts);if(Object.values(o).reduce((l,c)=>l+c,0)!==i)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:i,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function fx(e){let t=new Set(e.acceptance.map(r=>r.id));for(let r of e.loop.previous_unresolved_ids)if(!t.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of e.builder_handoff?.addressed_acceptance_ids??[])if(!t.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);e.builder_handoff?.acceptance_review&&du(e.acceptance,e.builder_handoff.acceptance_review);for(let r of e.blockers)for(let i of r.acceptance_ids)if(!t.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(e.builder_handoff){if(!(e.builder_handoff.iteration===e.loop.iteration||e.phase==="build"&&e.loop.stage==="repairing"&&e.builder_handoff.iteration===e.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(e.builder_handoff.review?.reviewer_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(e.verification){if(!e.builder_handoff)throw new Error("Native verification requires a builder handoff");if(e.verification.candidate_id!==e.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(e.verification.identity_provider!==e.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(e.verification.assurance)!==(e.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(e.verification.assurance==="semantic-verification-unavailable"&&e.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(e.verification.assurance==="user-confirmed-degraded"&&e.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(e.verification.verifier_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=e.verification.iteration===e.loop.iteration&&e.verification.attempt===e.loop.attempt,n=e.phase==="build"&&e.loop.stage==="repairing"&&e.verification.iteration===e.loop.iteration-1&&e.verification.iteration===e.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function px(e){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[e.phase].has(e.loop.stage))throw new Error(`Native loop stage ${e.loop.stage} is invalid for phase ${e.phase}`);let r=e.status==="await-user"?"await-user":e.status==="blocked"?"blocked":e.status==="done"?"done":null;if(r!==null&&e.loop.stage!==r)throw new Error(`Native status ${e.status} requires loop stage ${r}`);if(e.status==="active"&&["await-user","blocked","done"].includes(e.loop.stage))throw new Error(`Native active status cannot use loop stage ${e.loop.stage}`);if(e.archived!==(e.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(e.archived&&e.phase!=="archive")throw new Error("Native archived state must be in Archive");if(e.verification_result==="pass"){if(e.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(e.acceptance.some(i=>i.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(e.verification.checks.some(i=>i.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(e.verification?.assurance==="semantic-verification-unavailable"&&(e.phase!=="verify"||e.status!=="await-user"||e.verification_result!=="blocked"||e.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(e.verification_report!==null&&e.verification===null)throw new Error("Native verification report requires persisted verification")}function Ee(e){let t=ne(e,"Native portable state");if(ae(t,ZE,"Native portable state"),t.schema!==xr)throw new Error(`Native portable state schema must be ${xr}`);let r=X(t.name,"Native state name");if(!KE.test(r))throw new Error("Native state name is invalid");if(t.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let i=et(t.spec_changes,"Native spec_changes",tx);lr(i.map(s=>s.capability),"Native spec change capabilities");let n=et(t.acceptance,"Native acceptance",nx);lr(n.map(s=>s.id),"Native acceptance IDs");let a=et(t.history,"Native history",Om);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:xr,name:r,language:W(t.language,["en","zh-CN"],"Native state language"),phase:W(t.phase,["shape","build","verify","archive"],"Native state phase"),status:W(t.status,["active","await-user","blocked","done"],"Native state status"),state_version:M(t.state_version,"Native state_version",1),brief:"brief.md",...t.document_constraints_version===void 0?{}:t.document_constraints_version===1||t.document_constraints_version===2||t.document_constraints_version===3?{document_constraints_version:t.document_constraints_version}:(()=>{throw new Error("Native document_constraints_version must be 1, 2, or 3")})(),...t.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:hu(t.shape_confirmation_hash,"Native Shape confirmation hash")},...t.children_contract_hash===void 0?{}:{children_contract_hash:hu(t.children_contract_hash,"Native children contract hash")},...t.coordination_mode===void 0?{}:{coordination_mode:W(t.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:rx(t.workspace),loop:ix(t.loop),acceptance:n,builder_handoff:t.builder_handoff===null?null:ox(t.builder_handoff),blockers:et(t.blockers,"Native blockers",sx),verification:t.verification===null?null:lx(t.verification),history:a,history_overflow:dx(t.history_overflow),verification_result:W(t.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:t.verification_report===null?null:W(t.verification_report,["verification.md"],"Native verification_report"),archived:Qr(t.archived,"Native archived"),created_at:Zr(t.created_at,"Native created_at")};return fx(o),px(o),o}function ur(e,t){let r=Ee(e),i=Om(t,r.history.length),n=[...r.history,i],a={...r.history_overflow,outcome_counts:{...r.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return Ee({...r,history:n,history_overflow:a})}function hx(e,t){let r=(0,Lo.parseDocument)(e,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`${t} is invalid YAML: ${r.errors[0].message}`);return r.toJS({mapAsMap:!1})}async function vt(e){let t=await UE.readFile(e,"utf8");return Ee(hx(t,"Native portable state"))}async function Mo(e,t,r={}){let i=Ee(t);await ve(e,(0,Lo.stringify)(i),r)}async function mx(e,t){let r=Oo.get(e)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);Oo.set(e,a),await r;try{return await t()}finally{i(),Oo.get(e)===a&&Oo.delete(e)}}async function Hm(e){return mx(e.file,async()=>{let t=M(e.expectedStateVersion,"Native expected state version",1),r=Ee(e.next);if(r.state_version!==t+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await vt(e.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==t)throw new Ho(t,i.state_version);return await Mo(e.file,r,{...e.containedRoot?{containedRoot:e.containedRoot}:{},beforeCommit:async()=>{let n=await vt(e.file);if(n.state_version!==t)throw new Ho(t,n.state_version)}}),r})}var Lo,KE,YE,XE,QE,ZE,Ho,Oo,gt=S(()=>{"use strict";jo();Lo=Ct(ut(),1);B();mi();KE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,YE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,XE=/^A[1-9][0-9]*$/u,QE=/^[a-f0-9]{64}$/u,ZE=new Set(["schema","name","language","phase","status","state_version","brief","document_constraints_version","shape_confirmation_hash","children_contract_hash","coordination_mode","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),Ho=class extends Error{constructor(r,i){super(`Native state version conflict: expected ${r}, got ${i}`);this.expectedStateVersion=r;this.actualStateVersion=i;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};Oo=new Map});function vx(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function Be(e,t=16384){if(typeof e!="string")throw new Error("Native portable text must be a string");if(vx(t),Buffer.byteLength(e,"utf8")<=t)return{text:e,truncated:!1};let r="",i=0;for(let n of e){let a=Buffer.byteLength(n,"utf8");if(i+a>t)break;r+=n,i+=a}return{text:r,truncated:!0}}var dr=S(()=>{"use strict"});import gx from"node:path";function Sx(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Ex(e,t){let r=e instanceof Date?new Date(e.valueOf()):new Date(e);if(Number.isNaN(r.valueOf()))throw new Error(`${t} must be a valid timestamp`);return r.toISOString()}function xx(e,t){if(typeof e!="string")throw new Error(`${t} must be an ISO timestamp`);let r=new Date(e);if(Number.isNaN(r.valueOf())||r.toISOString()!==e)throw new Error(`${t} must be a canonical ISO timestamp`);return e}function Cx(e){return e.schema===Qe?Kr(e):e.schema===Xe?Yr(e):cr(e)}function Px(e){return gx.posix.normalize(e.replaceAll("\\","/"))}function Rx(e){return e.spec_changes.map(t=>t.operation==="remove"?{capability:t.capability,operation:"remove",source:null}:{capability:t.capability,operation:t.operation==="replace"?"modify":"create",source:Px(t.source)})}function _x(e){return e==="shape"?"shape":"build"}function Ax(e,t){return e==="zh-CN"?t==="shape"?"继续澄清并确认验收项":"重新提交候选实现":t==="shape"?"Continue clarification and confirm acceptance":"Submit a fresh implementation candidate"}function Ix(e,t,r){return e==="zh-CN"?`从旧版 ${t} ${r} 状态恢复;旧版 Loop、验证结论和运行记录未继承。`:`Recovered from legacy ${t} ${r} state; prior Loop, verification results, and execution records were not inherited.`}function Dm(e){let t=Cx(e.state);jm(e.acceptance);let r=_x(t.phase),i=r==="shape"?0:1,n=Ex(e.migratedAt??`${t.created_at}T00:00:00.000Z`,"Native portable migration time"),a=e.acceptance.map(o=>({id:o.id,source:o.source,text:o.text,result:"pending",reason:null}));return Ee({schema:xr,name:t.name,language:t.language,phase:r,status:"active",state_version:1,brief:"brief.md",spec_changes:Rx(t),workspace:e.workspace,loop:{stage:r==="shape"?"shape":"building",goal_cycle:1,iteration:i,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:Ax(t.language,r)},acceptance:a,builder_handoff:null,blockers:[],verification:null,history:[{goal_cycle:1,iteration:i,attempt:0,outcome:"recovery",unresolved_ids:a.map(({id:o})=>o),summary:Be(Ix(t.language,t.schema,t.phase)),completed_at:n}],history_overflow:Ps(),verification_result:"pending",verification_report:null,archived:!1,created_at:`${t.created_at}T00:00:00.000Z`})}function mu(e){let t=Sx(e,"Native portable migration transaction"),r=Object.keys(t).filter(i=>!wx.has(i));if(r.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${r.join(", ")}`);if(t.schema!==Fo)throw new Error("Unsupported Native portable migration transaction schema");if(typeof t.id!="string"||!bx.test(t.id))throw new Error("Native portable migration transaction id is invalid");if(typeof t.change!="string"||!yx.test(t.change))throw new Error("Native portable migration transaction change is invalid");if(typeof t.fromSchema!="string"||!kx.has(t.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof t.status!="string"||!Nx.has(t.status))throw new Error("Native portable migration transaction status is invalid");return{schema:Fo,id:t.id,change:t.change,fromSchema:t.fromSchema,status:t.status,createdAt:xx(t.createdAt,"Native portable migration transaction createdAt")}}function Lm(e){switch(mu(e).status){case"prepared":return{action:"commit-portable-yaml",fromStatus:"prepared",nextStatus:"yaml-committed"};case"yaml-committed":return{action:"cleanup-legacy-runtime",fromStatus:"yaml-committed",nextStatus:"legacy-cleanup"};case"legacy-cleanup":return{action:"commit-transaction",fromStatus:"legacy-cleanup",nextStatus:"committed"};case"committed":return{action:"done",fromStatus:"committed",nextStatus:null}}}var Fo,wx,yx,bx,Nx,kx,vu=S(()=>{"use strict";Ro();$o();gt();dr();mi();pn();Fo="comet.native.portable-migration.v1",wx=new Set(["schema","id","change","fromSchema","status","createdAt"]),yx=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,bx=/^[a-z0-9][a-z0-9-]{7,127}$/u,Nx=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),kx=new Set([Qe,Xe,Ye])});import wu from"node:path";function Vm(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Wm(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function gu(e,t){if(e!==void 0){if(e===null)return null;if(typeof e!="string"||!/^[a-f0-9]{64}$/iu.test(e))throw new Error(`${t} must be a SHA-256 hash or null`);return e.toLowerCase()}}function Mm(e,t){if(e!==void 0){if(e!==null&&typeof e!="string")throw new Error(`${t} must be text or null`);return e}}function Bx(e,t){let r=`Native portable Archive spec_changes[${t}]`,i=Vm(e,r);if(Wm(i,Lx,r),typeof i.capability!="string"||!qm.test(i.capability))throw new Error(`${r}.capability is invalid`);if(!["create","modify","remove"].includes(String(i.operation)))throw new Error(`${r}.operation is invalid`);let n=i.operation,a=i.delta_source;if(a!==void 0&&(typeof a!="string"||a.length===0||a.includes("\\")||a.startsWith("/")||/^[A-Za-z]:/u.test(a)||a.split("/").some(f=>f==="."||f==="..")))throw new Error(`${r}.delta_source is invalid`);let o=gu(i.base_hash,`${r}.base_hash`),s=Mm(i.delta_content,`${r}.delta_content`),l=Mm(i.source_content,`${r}.source_content`),c=gu(i.expected_target_hash,`${r}.expected_target_hash`),u=gu(i.result_hash,`${r}.result_hash`),d=a!==void 0;if(d&&o==null)throw new Error(`${r}.delta_source requires a non-null base_hash`);if(d&&(s==null||l===void 0||l===null||u===void 0||u===null))throw new Error(`${r}.delta_source requires delta_content, source_content, and result_hash`);if(!d&&(s!==void 0||l!==void 0))throw new Error(`${r} delta transaction fields require delta_source`);if(d){let f=fn(s);if(f.capability!==i.capability)throw new Error(`${r}.delta_content capability does not match capability`);if(f.base_hash!==o)throw new Error(`${r}.delta_content base_hash does not match base_hash`);if(pt(i.content)!==u)throw new Error(`${r}.content does not match result_hash`);if(pt(l)!==u)throw new Error(`${r}.source_content does not match result_hash`)}if(n==="remove"){if(i.source!==null||i.content!==null||a!==void 0||s!==void 0||l!==void 0||u!==void 0)throw new Error(`${r} remove requires source and content null`);return{capability:i.capability,operation:n,source:null,content:null,...o===void 0?{}:{base_hash:o},...c===void 0?{}:{expected_target_hash:c}}}if(typeof i.source!="string"||i.source.length===0||i.source.includes("\\")||i.source.startsWith("/")||/^[A-Za-z]:/u.test(i.source)||i.source.split("/").some(f=>f==="."||f===".."))throw new Error(`${r}.${n} source is invalid`);if(typeof i.content!="string")throw new Error(`${r}.${n} content is invalid`);if(u!==void 0&&(u===null||pt(i.content)!==u))throw new Error(`${r}.content does not match result_hash`);return{capability:i.capability,operation:n,source:i.source,content:i.content,...a===void 0?{}:{delta_source:a},...o===void 0?{}:{base_hash:o},...s===void 0?{}:{delta_content:s},...l===void 0?{}:{source_content:l},...c===void 0?{}:{expected_target_hash:c},...u===void 0?{}:{result_hash:u}}}function Mx(e){let t=Vm(e,"Native portable Archive transaction");if(Wm(t,Dx,"Native portable Archive transaction"),t.schema!==Bm)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof t.id!="string"||!jx.test(t.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof t.change!="string"||!qm.test(t.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(t.start_state_version)||Number(t.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof t.archive_ref!="string"||!Ox.test(t.archive_ref)||!t.archive_ref.endsWith(`-${t.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof t.status!="string"||!Hx.has(t.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let r=t.spec_changes.map(Bx);if(new Set(r.map(({capability:n})=>n)).size!==r.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(t.next_spec_index)||Number(t.next_spec_index)<0||Number(t.next_spec_index)>r.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof t.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let i=new Date(t.created_at);if(Number.isNaN(i.valueOf())||i.toISOString()!==t.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:Bm,id:t.id,change:t.change,start_state_version:Number(t.start_state_version),archive_ref:t.archive_ref,status:t.status,next_spec_index:Number(t.next_spec_index),spec_changes:r,created_at:t.created_at}}function qo(e){let t=Tx.exec(e);if(t)return{kind:"archive",change:t[1]};let r=$x.exec(e);return r?{kind:"migration",change:r[1]}:null}function Vo(e,t){let r=`${t.kind==="archive"?"portable-archive":"portable-migration"}-${t.change}.json`,i=qo(r);if(!i||i.kind!==t.kind||i.change!==t.change)throw new Error(`Invalid Native portable transaction change: ${t.change}`);return wu.join(e.transactionsDir,r)}async function yu(e,t){let r=qo(t);if(!r)return null;let i=await $({root:e.transactionsDir,ref:t,maxBytes:null,includeHash:!1}),n=JSON.parse(i.text),a=wu.join(e.transactionsDir,t);if(r.kind==="archive"){let s=Mx(n);if(s.change!==r.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:r.change,file:a,journal:s}}let o=mu(n);if(o.change!==r.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:r.change,file:a,journal:o}}async function bu(e,t){let r=Vo(e,t);try{return await yu(e,wu.basename(r))}catch(i){if(i.code==="ENOENT")return null;throw i}}function zm(e){return e.kind==="archive"||e.journal.status!=="committed"}var Bm,Fm,Tx,$x,jx,Ox,Hx,Dx,Lx,qm,Wo=S(()=>{"use strict";we();tu();vu();Bm="comet.native.archive-transaction.v4",Fm="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",Tx=new RegExp(`^portable-archive-(${Fm})\\.json$`,"u"),$x=new RegExp(`^portable-migration-(${Fm})\\.json$`,"u"),jx=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,Ox=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Hx=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),Dx=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),Lx=new Set(["capability","operation","source","content","delta_source","base_hash","delta_content","source_content","expected_target_hash","result_hash"]),qm=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});import{createHash as Fx}from"node:crypto";import{constants as zo,promises as Me}from"node:fs";import Fe from"node:path";function Jo(e,t){let r=Fe.relative(e,t);return r===""||!Fe.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Fe.sep}`)}function qx(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native protected file byte limit must be a positive integer");return e}function Vx(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Wx(e){return{dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs,ctimeMs:e.ctimeMs,mtimeMs:e.mtimeMs,size:e.size}}function Go(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Nu(e,t){let r=await Me.lstat(e);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t} parent must be a real directory: ${e}`);return{path:e,realPath:await Me.realpath(e),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function zx(e,t,r){let i=Fe.resolve(e),n=Fe.resolve(t);if(!Jo(i,n))throw new Error(`${r} is outside its managed root`);let a=[await Nu(i,r)],o=i;for(let s of Fe.relative(i,n).split(Fe.sep).filter(Boolean)){await fr(a,r),o=Fe.join(o,s);let l=await Nu(o,r);if(!Jo(a[0].realPath,l.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(l)}return await fr(a,r),a}async function fr(e,t){for(let r of e){let i=await Me.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!Vx(r,i)||await Me.realpath(r.path)!==r.realPath)throw new Error(`${t} parent changed during I/O: ${r.path}`)}}async function Gx(e,t,r){let i=[],n=0,a=Buffer.allocUnsafe(t===null?64*1024:Math.min(64*1024,t+1));for(;;){let o=t===null?a.length:t+1-n,{bytesRead:s}=await e.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,t!==null&&n>t)throw new Error(`${r} exceeds ${t} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function yn(e){let t=e.maxBytes===null?null:qx(e.maxBytes),r=Fe.resolve(e.file),i=await zx(e.root,Fe.dirname(r),e.label),n=await Promise.all((e.forbiddenRoots??[]).map(u=>Nu(Fe.resolve(u),e.label)));await e.hooks?.afterParentChainCaptured?.(),await fr(i,e.label);let a=await Me.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);if(t!==null&&a.size>t)throw new Error(`${e.label} exceeds ${t} bytes`);let o=Wx(a),s=await Me.realpath(r);if(!Jo(i[0].realPath,s))throw new Error(`${e.label} resolves outside its managed root`);if(n.some(u=>Jo(u.realPath,s)))throw new Error(`${e.label} resolves inside an excluded root`);let l=process.platform==="win32"?zo.O_RDONLY:zo.O_RDONLY|zo.O_NOFOLLOW|zo.O_NONBLOCK,c=await Me.open(r,l);try{let u=await c.stat();await e.hooks?.afterOpen?.();let[d,f]=await Promise.all([Me.lstat(r),Me.realpath(r)]);if(await fr(i,e.label),await fr(n,e.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!Go(o,u)||!Go(o,d))throw new Error(`${e.label} changed while opening`);await e.hooks?.beforeRead?.();let h=await Gx(c,t,e.label);await e.hooks?.beforeFinalCheck?.();let[m,p,v]=await Promise.all([c.stat(),Me.lstat(r),Me.realpath(r)]);if(await fr(i,e.label),await fr(n,e.label),!p.isFile()||p.isSymbolicLink()||v!==s||!Go(o,m)||!Go(o,p))throw new Error(`${e.label} changed while reading`);return{bytes:h,hash:Fx("sha256").update(h).digest("hex"),size:h.length}}finally{await c.close()}}var tt=S(()=>{"use strict";B();Ge()});import wt from"path";import{TextDecoder as Ux}from"util";function Ko(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Yo(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Km(e){if(typeof e!="string")return!1;let t=new Date(e);return!Number.isNaN(t.valueOf())&&t.toISOString()===e}function ku(e,t){if(typeof e!="string"||e.length===0||wt.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native root`)}function Uo(e,t){if(typeof e!="string"||!/^[a-f0-9]{64}$/u.test(e))throw new Error(`${t} must be a SHA-256 hash`)}function Gm(e,t){if(ku(e,t),e.includes("\\")||e!==wt.posix.normalize(e)||e.split("/").includes(".")||e.endsWith("/")||Buffer.byteLength(e,"utf8")>1024)throw new Error(`${t} must be a normalized Native-relative ref`)}function eC(e,t){let r=Ko(e,`transaction operations[${t}]`);if(Yo(r,Yx,`transaction operations[${t}]`),typeof r.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(r.id))throw new Error(`transaction operations[${t}].id is invalid`);if(r.type!=="write"&&r.type!=="remove"&&r.type!=="move")throw new Error(`transaction operation ${r.id} has an invalid type`);ku(r.target,`transaction operation ${r.id} target`);for(let i of["source","staged","backup"])r[i]!==void 0&&ku(r[i],`transaction operation ${r.id} ${i}`);if(r.type==="write"){if(r.staged===void 0||r.source!==void 0)throw new Error(`write operation ${r.id} requires staged and forbids source`)}else if(r.type==="remove"){if(r.source!==void 0||r.staged!==void 0)throw new Error(`remove operation ${r.id} forbids source and staged`)}else if(r.source===void 0||r.staged!==void 0||r.backup!==void 0)throw new Error(`move operation ${r.id} requires source and forbids staged and backup`);return r}function Ym(e){let t=Ko(e,"Native Archive transaction journal");if(Yo(t,Xx,"Native Archive transaction journal"),t.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native Archive transaction id is invalid");if(t.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof t.status!="string"||!Um.has(t.status))throw new Error("Native Archive transaction status is invalid");if(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change))throw new Error("Native Archive transaction change name is invalid");if(!Km(t.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Uo(t.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(t.operations)||t.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let r=t.operations.map((s,l)=>{let c=Ko(s,`Archive transaction operations[${l}]`);if(Yo(c,Qx,`Archive transaction operations[${l}]`),typeof c.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(c.id))throw new Error(`Archive transaction operations[${l}].id is invalid`);if(c.type!=="write"&&c.type!=="remove"&&c.type!=="move")throw new Error(`Archive transaction operation ${c.id} has an invalid type`);Gm(c.target,`Archive transaction operation ${c.id} target`);for(let u of["source","staged","backup"])c[u]!==void 0&&Gm(c[u],`Archive transaction operation ${c.id} ${u}`);if(c.expectedTargetHash!==null&&Uo(c.expectedTargetHash,`Archive transaction operation ${c.id} expectedTargetHash`),c.type==="write"){if(c.staged===void 0||c.source!==void 0||c.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${c.id} requires staged and forbids source`);if(Uo(c.stagedHash,`Archive write operation ${c.id} stagedHash`),c.expectedTargetHash===null!=(c.backup===void 0))throw new Error(`Archive write operation ${c.id} backup must match target existence`)}else if(c.type==="remove"){if(c.source!==void 0||c.staged!==void 0||c.stagedHash!==void 0||c.expectedSourceHash!==void 0||c.backup===void 0||c.expectedTargetHash===null)throw new Error(`Archive remove operation ${c.id} requires a bound target and backup`)}else{if(c.source===void 0||c.staged!==void 0||c.stagedHash!==void 0||c.backup!==void 0||c.expectedTargetHash!==null)throw new Error(`Archive move operation ${c.id} requires source and an absent target`);Uo(c.expectedSourceHash,`Archive move operation ${c.id} expectedSourceHash`)}return c}),i=r.map(s=>s.id);if(new Set(i).size!==i.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${t.id}`,a=r.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${t.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${t.change}$`,"u").test(a[0].target)||r.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of r.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:t.id,kind:"archive",status:t.status,change:t.change,createdAt:t.createdAt,preflightHash:t.preflightHash,operations:r}}function tC(e){let t=Ko(e,"Native transaction journal");if(t.schema==="comet.native.transaction.v2")return Ym(t);if(Yo(t,Kx,"Native transaction journal"),t.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native transaction id is invalid");if(t.kind!=="archive"&&t.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof t.status!="string"||!Um.has(t.status))throw new Error("Native transaction status is invalid");if(typeof t.projectRoot!="string"||!wt.isAbsolute(t.projectRoot)||typeof t.nativeRoot!="string"||!wt.isAbsolute(t.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(t.change!==void 0&&(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change)))throw new Error("Native transaction change name is invalid");if(!Km(t.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(t.operations))throw new Error("Native transaction operations must be an array");let r=t.operations.map(eC),i=r.map(n=>n.id);if(new Set(i).size!==i.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:t.id,kind:t.kind,status:t.status,projectRoot:t.projectRoot,nativeRoot:t.nativeRoot,...typeof t.change=="string"?{change:t.change}:{},createdAt:t.createdAt,operations:r}}function rC(e,t){if(!/^[a-f0-9-]{8,}$/u.test(t))throw new Error(`Invalid Native transaction id: ${t}`);return wt.join(e.transactionsDir,t)}function Xm(e,t){let r=rC(e,t);return{directory:r,journal:wt.join(r,"transaction.json"),events:wt.join(r,"events.jsonl"),staged:wt.join(r,"staged"),backups:wt.join(r,"backups")}}async function Eu(e,t){let r=Xm(e,t);return await Promise.all(Object.values(r).map(i=>T(e.runtimeDir,i))),r}async function xu(e,t,r={}){let i=await Eu(e,t),n=await yn({root:e.runtimeDir,file:i.journal,maxBytes:null,label:`Native transaction journal ${t}`,hooks:r.hooks}),a=JSON.parse(Zx.decode(n.bytes)),o=tC(a);if(o.id!==t)throw new Error(`Invalid Native transaction journal: ${t}`);return o}var Kx,Yx,Xx,Qx,Um,Zx,Xo=S(()=>{"use strict";B();L();tt();Kx=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),Yx=new Set(["id","type","source","target","staged","backup"]),Xx=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Qx=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]),Um=new Set(["prepared","applying","committed","rolling-back","rolled-back"]),Zx=new Ux("utf-8",{fatal:!0})});import{promises as iC}from"fs";import nC from"path";async function aC(e,t,r){let i;try{i=await iC.readdir(e.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await xu(e,n.name);if(a.id!==t&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of i)if(qo(n.name))try{let a=await yu(e,n.name);if(!a||r?.kind===a.kind&&r.change===a.change)continue;if(zm(a))return!0}catch{return!0}return!1}async function oC(e,t){let r=Date.now()+5e3,i=nC.join(e.locksDir,"root-move.lock");for(;;)try{return await So(e,"root-move",t)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await lm(i);if(o.status==="missing")continue;if(o.status==="stale"){let s=await um(e,i,o);if(s.status==="removed"||s.status==="missing")continue;throw n}if(o.status!=="active"||Date.now()>=r)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function F(e,t,r,i){let n=await oC(e,t);try{if(await mo(e.projectRoot),await aC(e,i?.allowedTransactionId,i?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await r()}finally{try{await Eo(n)}catch(a){process.stderr.write(`[comet] warning: could not release Native mutation lock ${n.file} (${a.message}); run comet native doctor --repair if commands start failing
194
+ `)}}}var Q=S(()=>{"use strict";be();dn();Wo();Xo()});import{createHash as sC}from"crypto";function xe(e){return sC("sha256").update(e).digest("hex")}var rt=S(()=>{"use strict"});var Kj,Yj,Xj,Qj,Zj,e0,bn=S(()=>{"use strict";Cr();B();be();rt();Ge();L();tt();Ei();Kj={maxFiles:1e4,maxFileBytes:1024*1024*1024,maxTotalBytes:1024*1024*1024,maxManifestBytes:1024*1024*1024},Yj=64*1024,Xj=64*1024,Qj={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},Zj={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024},e0=(1n<<256n)-1n});var AH,nt=S(()=>{"use strict";Cr();AH=8*1024*1024});import{promises as YP}from"node:fs";import XP from"node:path";function ls(e,t,r=""){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object${r}`);return e}function cs(e,t,r){let i=Object.keys(e).filter(a=>!t.has(a)),n=[...t].filter(a=>!(a in e));if(i.length>0||n.length>0){let a=[...n.length>0?[`missing ${n.join(", ")}`]:[],...i.length>0?[`unexpected ${i.join(", ")}`]:[],`expected ${[...t].join(", ")}`];throw new Error(`${r} fields are invalid: ${a.join("; ")}`)}}function Iv(e,t){if(!Array.isArray(e)||!e.every(r=>typeof r=="string"))throw new Error(`${t} must be an array of strings`);return[...new Set(e)].sort((r,i)=>r.localeCompare(i,"en"))}function iR(e){let t=new Map(e.map(a=>[a.name,a])),r=new Set,i=new Set,n=a=>{if(!i.has(a)){if(r.has(a))throw new Error(`Native children dependency cycle includes ${a}`);r.add(a);for(let o of t.get(a).depends_on)n(o);r.delete(a),i.add(a)}};for(let a of e)n(a.name)}function Tv(e,t,r=t){let i=new Set(t);for(let o of e){let s=o.covers.filter(l=>!i.has(l));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(e.flatMap(o=>o.covers)),a=r.filter(o=>!n.has(o));if(a.length>0)throw new Error(`Native children do not cover parent acceptance: ${a.join(", ")}`)}function Hv(e,t,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(e.schema===Ku&&e.acceptance_index){let n=r.requiredAcceptanceIds??t??[],a=r.allowedAcceptanceIds??n,o=Object.keys(e.acceptance_index);i.missing=n.filter(c=>!(c in e.acceptance_index)),i.extra=o.filter(c=>!a.includes(c));let s=new Map((r.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of o){let u=s.get(c),d=e.acceptance_index[c];u&&d&&(d.source!==u.source||d.text!==u.text)&&i.mismatched.push(c)}let l=new Set(o);for(let c of e.children)i.unknownCovers.push(...c.covers.filter(u=>!l.has(u)));return i.uncovered=o.filter(c=>!$v(e.children,c)),jv(i)?i:null}if(e.schema===gr&&t){let n=new Set(t);for(let a of e.children)i.unknownCovers.push(...a.covers.filter(o=>!n.has(o)));return i.uncovered=t.filter(a=>!$v(e.children,a)),jv(i)?i:null}return null}function $v(e,t){return e.some(r=>r.covers.includes(t))}function jv(e){return e.missing.length>0||e.extra.length>0||e.mismatched.length>0||e.uncovered.length>0||e.unknownCovers.length>0}function yr(e){let t=new Set(e.acceptance.map(({id:n})=>n)),r=new Set(e.acceptance.filter(({source:n})=>n===e.brief).map(({id:n})=>n)),i=new Set(r);for(let n of e.history.filter(({outcome:a})=>a==="fail"))for(let a of n.unresolved_ids)t.has(a)&&i.add(a);if(e.loop.stage==="repairing"&&e.verification_result==="fail"){let n=[...e.history].reverse().find(({outcome:a})=>a==="fail");for(let a of n?.unresolved_ids??[])r.add(a)}return{acceptanceCatalog:e.acceptance,requiredAcceptanceIds:[...r],allowedAcceptanceIds:[...i]}}function nR(e){let t=ls(e,"Native children acceptance_index",' keyed by acceptance ID, for example A1: { source: brief.md, text: "Full acceptance text" }'),r={};for(let[i,n]of Object.entries(t)){let a=ls(n,`Native children acceptance_index.${i}`);if(cs(a,new Set(["source","text"]),`Native children acceptance_index.${i}`),typeof a.source!="string"||a.source.length===0)throw new Error(`Native children acceptance_index.${i}.source must be a non-empty string`);if(typeof a.text!="string"||a.text.length===0)throw new Error(`Native children acceptance_index.${i}.text must be a non-empty string`);r[i]={source:a.source,text:a.text}}return r}function aR(e,t,r){let i=r.requiredAcceptanceIds??t??[],n=r.allowedAcceptanceIds??i,a=Object.keys(e),o=i.filter(c=>!(c in e)),s=a.filter(c=>!n.includes(c));if(o.length>0||s.length>0)throw new Error(`Native children acceptance_index must match the required acceptance: missing ${o.join(", ")||"none"}; extra ${s.join(", ")||"none"}`);let l=new Map((r.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of a){let u=l.get(c);if(!u)continue;let d=e[c];if(d.source!==u.source||d.text!==u.text){let f=["source","text"].filter(h=>d[h]!==u[h]);throw new Error(`Native children acceptance_index.${c} does not match the acceptance catalog: copy ${f.join(", ")} exactly from the current acceptance catalog`)}}}function Dv(e,t,r={}){let i=(0,Ov.parseDocument)(e,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=ls(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==gr&&a!==wr)throw cs(n,Av,"Native children contract"),new Error(`Native children schema must be ${gr} or ${wr}`);let o=a===gr?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(cs(n,o==="indexed-v2"?ZP:Av,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let l=n.children.map((f,h)=>{let m=ls(f,`Native child ${h}`);if(cs(m,o==="indexed-v2"?rR:o==="summary-v2"?tR:eR,`Native ${s} child fields (child ${h})`),typeof m.name!="string"||!QP.test(m.name))throw new Error(`Native child ${h} name is invalid`);let p=o==="summary-v2";if(p){if(typeof m.summary!="string"||m.summary.trim().length===0)throw new Error(`Native child ${m.name} summary must be a non-empty string`);if(m.summary.length>2e3)throw new Error(`Native child ${m.name} summary exceeds 2000 characters`)}return{name:m.name,summary:p?m.summary:null,depends_on:Iv(m.depends_on,`Native child ${m.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?Iv(m.covers,`Native child ${m.name} covers`):[]}}),c=l.map(({name:f})=>f);if(new Set(c).size!==c.length)throw new Error("Native child names must be unique");let u=new Set(c);for(let f of l){let h=f.depends_on.filter(m=>!u.has(m));if(h.length>0)throw new Error(`Native child ${f.name} depends on unknown child: ${h.join(", ")}`)}iR(l);let d=r.policy==="advisory";if(a===Ku){if(o==="indexed-v2"){let f=nR(n.acceptance_index);d||aR(f,t,r);let h=Object.keys(f);return d||Tv(l,h,h),{schema:wr,acceptance_index:f,children:l}}return{schema:wr,children:l}}return t&&!d&&Tv(l,t),{schema:gr,children:l}}async function br(e){let t=XP.join(e.changeDir,Uu);try{await YP.lstat(t)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await $({root:e.changeDir,ref:Uu}),i=e.policy==="advisory",n=i?{...e.validation,policy:"advisory"}:e.validation??{},a=Dv(r.text,e.acceptanceIds,n);return{contract:a,hash:r.hash,size:r.size,drift:i?Hv(a,e.acceptanceIds,e.validation??{}):null}}var Ov,Uu,gr,wr,Ku,QP,Av,ZP,eR,tR,rR,us=S(()=>{"use strict";Ov=Ct(ut(),1);we();Uu="children.yaml",gr="comet.native.children.v1",wr="comet.native.children.v2",Ku=wr,QP=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Av=new Set(["schema","children"]),ZP=new Set(["schema","acceptance_index","children"]),eR=new Set(["name","depends_on","covers"]),tR=new Set(["name","summary","depends_on"]),rR=new Set(["name","depends_on","covers"])});var Vt=S(()=>{"use strict";B();K();us();L();zt()});var Yu=S(()=>{"use strict"});var Nr=S(()=>{"use strict"});var ds=S(()=>{"use strict";yi();Yu();Nr()});var Lv=S(()=>{"use strict";nt();ds();K()});var Xu=S(()=>{"use strict";nt();B()});var Wv,ci=S(()=>{"use strict";K();bn();Wv=1024*1024});var hs=S(()=>{"use strict";K();Nr();Ei();ci()});var Gv,AR,IR,TR,$B,$R,jB,Zu=S(()=>{"use strict";K();Gv="scoped-text-safety",AR=1,IR=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),TR="comet.native.checker-policy.v1",$B=D(TR,{policy:Gv,version:AR,limits:IR,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),$R=["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"],jB=new Set($R)});var ms=S(()=>{"use strict";K();Zu();Nr()});import{createHash as Kv}from"node:crypto";import{promises as de}from"node:fs";import st from"node:path";function ed(e,t){let r=st.relative(e,t);return r===""||!st.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${st.sep}`)}function OR(e,t){return j({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Dn(e,t){let r={...e,birthtime:e.birthtimeMs},i={...t,birthtime:t.birthtimeMs};return Ae(r,i)?j(r,i):j(r,i)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function Jv(e){let t=await de.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native evidence parent must be a real directory: ${e}`);return{path:e,realPath:await de.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function HR(e,t){let r=st.resolve(e),i=st.resolve(t);if(!ed(r,i))throw new Error("Native evidence path is outside its change");let n=[await Jv(r)],a=r;for(let o of st.relative(r,i).split(st.sep).filter(Boolean)){a=st.join(a,o);let s=await Jv(a);if(!ed(n[0].realPath,s.realPath))throw new Error(`Native evidence parent resolves outside its change: ${a}`);n.push(s)}return n}async function Uv(e){for(let t of e){let r=await de.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!OR(t,r)||await de.realpath(t.path)!==t.realPath)throw new Error(`Native evidence parent changed while reading: ${t.path}`)}}async function DR(e,t,r={}){let i=await HR(t,st.dirname(e));await r.afterParentChainCaptured?.();let n=await de.lstat(e);if(!n.isFile()||n.isSymbolicLink())throw new Error("Native evidence document must be a regular file");let a=await de.realpath(e);if(!ed(i[0].realPath,a))throw new Error("Native evidence document resolves outside its change");let o=await de.open(e,"r");try{let[s,l,c]=await Promise.all([o.stat(),de.lstat(e),de.realpath(e)]);if(await Uv(i),!s.isFile()||!l.isFile()||l.isSymbolicLink()||c!==a||!Dn(s,n)||!Dn(s,l))throw new Error("Native evidence document changed while opening");if(s.size>kt)throw new Error(`Native evidence document exceeds ${kt} bytes`);await r.afterOpen?.();let u=[],d=0,f=Buffer.allocUnsafe(64*1024);for(;;){let v=kt+1-d,g=await o.read(f,0,Math.min(f.length,v),null);if(g.bytesRead===0)break;if(d+=g.bytesRead,d>kt)throw new Error(`Native evidence document exceeds ${kt} bytes`);u.push(Buffer.from(f.subarray(0,g.bytesRead)))}await r.beforeFinalCheck?.();let[h,m,p]=await Promise.all([o.stat(),de.lstat(e),de.realpath(e)]);if(await Uv(i),!m.isFile()||m.isSymbolicLink()||p!==a||!Dn(s,h)||!Dn(s,m))throw new Error("Native evidence document changed while reading");return JSON.parse(Buffer.concat(u,d).toString("utf8"))}finally{await o.close()}}function vs(e,t){if(!Yv.test(t))throw new Error("Native evidence hash is invalid");return`runtime/evidence/${e}/${t}.json`}async function rd(e){let t=Buffer.from(e.text,"utf8");if(t.byteLength>kt||Kv("sha256").update(t).digest("hex")!==e.hash)throw new Error("Native verification report snapshot hash or size is invalid");return BR({paths:e.paths,name:e.name,kind:"reports",hash:e.hash,onCreated:e.onCreated,value:{schema:"comet.native.verification-report.v1",reportHash:e.hash,content:e.text}})}async function Xv(e){let t=id(e.paths,e.name,"reports",e.hash),r=fe(e.paths,t);await T(r,t);let i=await de.lstat(t);if(await LR(e.paths,e.name,e.hash),await T(r,t),!Dn(i,await de.lstat(t)))throw new Error("Native report evidence changed before rollback");await de.unlink(t)}async function LR(e,t,r,i,n){if(!Yv.test(r))throw new Error("Native report evidence hash is invalid");let a=await td({paths:e,name:t,kind:"reports",hash:r,hooks:i,changeDir:n});if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Native report evidence must be an object");let o=a;if(Object.keys(o).sort().join(",")!=="content,reportHash,schema"||o.schema!=="comet.native.verification-report.v1"||o.reportHash!==r||typeof o.content!="string"||Kv("sha256").update(Buffer.from(o.content,"utf8")).digest("hex")!==r)throw new Error("Native report evidence does not match its hash");return o.content}function id(e,t,r,i,n){let a=vs(r,i);return n?st.join(n,...a.split("/")):Bl(De(e,t),a)}async function td(e){let t=id(e.paths,e.name,e.kind,e.hash,e.changeDir),r=e.changeDir??fe(e.paths,t);return await T(r,t),DR(t,r,e.hooks)}async function BR(e){MR(e.value);let t=id(e.paths,e.name,e.kind,e.hash),r=fe(e.paths,t);await T(r,t);try{let n=await td(e);if(JSON.stringify(n)!==JSON.stringify(e.value))throw new Error(`Native evidence hash collision for ${e.hash}`);return vs(e.kind,e.hash)}catch(n){if(n.code!=="ENOENT")throw n}await Z(t,e.value,{containedRoot:r}),e.onCreated?.();let i=await td(e);if(JSON.stringify(i)!==JSON.stringify(e.value))throw new Error(`Native evidence changed during commit for ${e.hash}`);return vs(e.kind,e.hash)}function MR(e){if(FR(e)>kt)throw new Error(`Native evidence document exceeds ${kt} bytes`)}function FR(e){return Buffer.byteLength(JSON.stringify(e,null,2)+`
195
+ `,"utf8")}var Yv,kt,e1,li=S(()=>{"use strict";B();L();Ge();ci();hs();ms();Yv=/^[a-f0-9]{64}$/u,kt=Wv,e1=3*kt});mi();zt();function Y(e,t,r){return e.language==="zh-CN"?r:t}function Kg(e,t,r,i){let n=a=>({required:!1,message:null,suggestedReply:null,agentInstruction:a});if(e.phase==="shape"&&e.status==="await-user"&&e.loop.next_action==="confirm-shape")return t?{required:!0,message:Y(e,"Shape is ready. Confirm the complete plan and choose A) Multi-session coordination (recommended), or B) Single-session progression in one reply.","Shape 已整理完成。请确认完整方案,并在同一次回复中选择 A)多会话协作(推荐),或 B)单会话推进。"),suggestedReply:Y(e,"Confirm the plan and use A","确认方案,按 A 开始"),agentInstruction:Y(e,"First present the target, scope, key decisions, acceptance criteria, non-goals, child responsibilities and dependencies, and both coordination choices. Execute the matching confirm-shape alternative only when the user explicitly accepts this complete Shape and chooses its mode. Choosing a mode alone, additions, or corrections are not full confirmation; retain that choice and ask only for the missing decision. Do not run --confirmed before full confirmation.","先展示目标、范围、关键决定、验收标准、非目标、各 Child 的职责与依赖,以及两种推进方式。只有用户明确同意当前完整 Shape 并选择推进方式后,才执行对应的 confirm-shape 选项。仅选择推进方式、补充或修改要求都不算完整确认;保留已选方式,只补问缺少的决定。完整确认前不要运行 --confirmed。")}:e.language==="zh-CN"?{required:!0,message:"Shape 已整理完成。请确认目标、范围、关键决定、验收标准和非目标是否准确;明确确认后才会进入 Build。",suggestedReply:"确认进入 Build",agentInstruction:"先用自然语言简要展示目标、范围、关键决定、验收标准和非目标,再转述 message 并等待用户明确确认。只有用户明确同意当前完整 Shape 时,才执行 commandAlternatives 中的 confirm-shape;补充或修改要求不算确认。不要展示机器状态或提前运行 --confirmed。"}:{required:!0,message:"Shape is ready. Confirm that the target, scope, key decisions, acceptance criteria, and non-goals are accurate; Build starts only after explicit confirmation.",suggestedReply:"Confirm and enter Build",agentInstruction:"First present a concise natural-language summary of the target, scope, key decisions, acceptance criteria, and non-goals. Then relay message and wait for explicit user confirmation. Run confirm-shape from commandAlternatives only when the user explicitly accepts the complete current Shape; additions or corrections are not confirmation. Do not expose machine state or run --confirmed early."};if(t&&e.phase==="shape"&&e.status==="active")return n(Y(e,"Complete the Shape documents and child plan, resolve blocking questions, then execute prepare-shape-confirmation. Its persisted response combines complete Shape confirmation and coordination choice in one user decision. If the user already chose only a mode, include that --coordination-mode when preparing and ask only for complete Shape confirmation afterward.","完成 Shape 文档和 Child 计划,解决阻塞问题后执行 prepare-shape-confirmation。持久化后的响应会让用户一次确认完整 Shape 并选择推进方式。如果用户已经仅选择了推进方式,准备时附上对应的 --coordination-mode,随后只确认完整 Shape。"));if(e.phase==="verify"&&e.status==="active"&&e.loop.stage==="verify-ready"&&e.loop.next_action!=="await-verifier-result")return n(Y(e,"The current candidate and completed checks are preserved. Continue with dispatch-verifier without asking the user to recover files, processes, or workflow state. If a brief status update is necessary, say only that verification is being retried and the code is unchanged.","当前候选和已经完成的检查都已保留。直接继续 dispatch-verifier,不要让用户恢复文件、进程或工作流状态。如果确实需要简短同步进度,只说明正在重新尝试验收且代码没有变化。"));if(e.phase==="verify"&&e.status==="active"&&e.loop.next_action==="await-verifier-result"){let a=i==="confirmed"?Y(e,"The Verifier has confirmed startup. Continue waiting on the same host task and use its actual progress.","Verifier 已确认启动。继续等待同一个宿主任务,并使用该任务的实际进度。"):Y(e,"Check whether the host accepted the startup call and locate the task for the current verifierExecutionRef. If the call has not been made, start the dispatched task once; if the host accepted it, check that same task and let the Verifier submit its startup receipt. A missing receipt alone does not prove failure. If local startup state is unavailable, recover the host task context before deciding whether startup is needed.","先核实宿主是否接受了启动调用,并找到当前 verifierExecutionRef 对应的任务。尚未调用时启动已派发的任务一次;宿主已接受时检查同一个任务,由 Verifier 提交启动回执。仅缺少回执不能证明执行失败。本地启动记录不可用时,先恢复宿主任务上下文,再判断是否需要启动。");return n(`${a} ${Y(e,"Keep the same dispatched Verifier while it is active. A wait-tool timeout is not an execution timeout: check task progress and continue waiting; do not cancel, interrupt, or spawn a replacement just because a wait returned without a result. Request progress without telling the Verifier to stop inspecting. Only after confirmed task failure, a host-reported execution timeout, loss, or termination without a usable result, immediately submit verifier-execution-error. Preserve completed evidence and explain the failure and changed recovery approach before retrying. Submit verifier-unavailable only when the current platform truly has no usable subagent capability. Forward the actual report, including risks and incomplete checks; never turn an uninspected candidate into pass. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","已派发的验收任务仍在运行时,继续使用同一个 Verifier。等待工具超时不等于执行超时:检查任务进度并继续等待,不得仅因一次等待没有结果就取消、中断或重新派发。询问进度时不要要求停止核查。仅在确认任务失败、宿主报告执行超时、任务丢失或结束后没有可用结果时,立即提交 verifier-execution-error;保留已完成证据,重试前说明失败原因及恢复方式的变化。只有当前平台确实没有可用的 subagent 能力时才提交 verifier-unavailable。忠实传递原始报告,包括风险和未完成检查;没有核查当前候选不能判定通过。不要让用户恢复文件或进程,也不要向用户展示 attempt、requestCheckRounds 等机器状态。")}`)}if(e.status==="blocked"&&e.blockers.some(({resolution_action:a})=>a==="retry-verifier"))return e.loop.retry_epoch>=3?e.language==="zh-CN"?{required:!0,message:"自动重试验收已连续多轮未能取得结果,验证环境很可能不可用。请人工检查验证环境(subagent 配额、平台任务队列、网络),或使用 doctor --repair 评估该 change 状态。",suggestedReply:"人工检查验证环境",agentInstruction:"只向用户转述 message,等待用户完成人工检查后再继续。不要自动重试验收。"}:{required:!0,message:"Automatic verification retries have failed across multiple rounds; the verification environment is likely unavailable. Inspect the environment manually (subagent quota, platform task queue, network), or use doctor --repair to assess the change state.",suggestedReply:"Inspect the verification environment",agentInstruction:"Relay message to the user and wait for a manual environment check before continuing. Do not retry verification automatically."}:e.language==="zh-CN"?{required:!0,message:"由于独立验收任务连续几次没有正常返回结果,本次验收已暂停。你的代码和已经完成的检查都已安全保留。回复“继续”即可重新尝试,不需要处理文件或进程。",suggestedReply:"继续",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户回复。不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification paused because the independent verification task repeatedly ended without a result. Your code and completed checks are safely preserved. Reply “Continue” to retry; you do not need to manage files or processes.",suggestedReply:"Continue",agentInstruction:"Relay only message and suggestedReply to the user, then wait for that reply. Do not expose internal attempts, counters, paths, or recovery steps."};if(e.phase==="verify"&&e.status==="await-user"&&e.verification?.assurance==="semantic-verification-unavailable")return e.language==="zh-CN"?{required:!0,message:"独立验收当前不可用,但你的代码和已经完成的检查都已安全保留。你可以直接重新尝试独立验收,也可以明确接受只有自动检查的结果。",suggestedReply:"重新尝试独立验收",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户选择。用户要求重试时执行 commandAlternatives 中的 retry-verifier;只有用户明确接受降级结果时才执行 confirm-verifier-unavailable。不要把“继续”视为接受降级结果,也不要要求用户处理文件、进程、服务或回调。"}:{required:!0,message:"Independent verification is currently unavailable, but your code and completed checks are safely preserved. You can retry independent verification directly or explicitly accept the automatic-check-only result.",suggestedReply:"Retry independent verification",agentInstruction:"Relay only message and suggestedReply, then wait for the user choice. If the user asks to retry, run retry-verifier from commandAlternatives; run confirm-verifier-unavailable only when the user explicitly accepts the degraded result. Do not treat “Continue” as accepting the degraded result, and do not ask the user to manage files, processes, services, or callbacks."};if(e.phase==="verify"&&e.status==="await-user"&&e.loop.next_action==="resolve-verifier-blocker")return e.language==="zh-CN"?{required:!0,message:"验证暂时无法下结论,因为缺少只有你能提供的信息,例如外部系统的真实行为或某个业务决定。你的代码和已经完成的检查都已安全保留。补充所需信息后可继续验证,也可以选择修改实现或调整需求。",suggestedReply:null,agentInstruction:"向用户转述 message,请用户补充缺失的信息,或在继续验证(resolve-verifier-blocker)、修改实现、调整需求之间明确选择,再执行 commandAlternatives 中对应的完整命令。不要把“继续”当作默认选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification cannot reach a verdict yet because information only you can provide is missing, such as the real behavior of an external system or a business decision. Your code and completed checks are safely preserved. Supply the missing information to resume verification, or choose to revise the implementation or the requirements.",suggestedReply:null,agentInstruction:"Relay message and ask the user to supply the missing information or explicitly choose between resuming verification (resolve-verifier-blocker), revising the implementation, and revising the requirements; run the matching commandAlternative afterwards. Do not treat “Continue” as a default choice, and do not expose internal rounds, counters, paths, or recovery steps."};if(e.phase==="verify"&&e.status==="await-user"&&e.loop.next_action==="await-user"){let o=(e.loop.stop_reason??(e.loop.no_progress_count>=3?"stalled":"budget"))==="stalled",s=o?"验证已连续三轮失败且未通过的验收场景一直没有减少,本次修改已暂停,以避免在同一个问题上反复循环。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。":"本次修改的验证失败次数已用完配置的预算,因此暂停等待你的决定,而不是自动重试。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。注意:预算不会重置,选择继续修复后,下一次验收失败会再次暂停。",l=o?"Verification has failed three times in a row without the unresolved scenarios shrinking, so this change is paused to avoid looping on the same problem. Your code and completed checks are safely preserved. You can have the Builder try a different repair approach, or go back and adjust the requirements.":"Verification for this change has used its configured failure budget, so it is paused for your decision instead of retrying automatically. Your code and completed checks are safely preserved. You can have the Builder continue with a different repair approach, or go back and adjust the requirements.";return e.language==="zh-CN"?{required:!0,message:s,suggestedReply:"继续修复",agentInstruction:"向用户转述 message 和 suggestedReply,等待用户在“继续修复实现”(revise-implementation)与“调整需求”(revise-requirements)之间明确选择,再执行 commandAlternatives 中对应的完整命令。选择继续修复时,要求 Builder 更换修复思路。不要替用户选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:l,suggestedReply:"Continue repairing",agentInstruction:"Relay message and suggestedReply, then wait for the user to explicitly choose between continuing the implementation (revise-implementation) and adjusting the requirements (revise-requirements); run the matching commandAlternative afterwards. When continuing, ask the Builder to change its repair approach. Do not choose for the user, and do not expose internal rounds, counters, paths, or recovery steps."}}if(e.phase==="verify"&&e.status==="await-user"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass")return{required:!0,message:Y(e,"The reported verification passed, but this platform cannot confirm an independent Verifier execution. Review the result and choose whether to accept it for Archive, revise the implementation, or revise the requirements."+(e.workspace.isolation!=="current"&&e.workspace.finish===null?" If accepting, also choose: keep the workspace, merge locally, push the branch, or push and create a PR. You may accept the result and defer the finish choice.":""),"当前验收报告已通过,但当前平台无法确认验收是否独立执行。请检查结果,并选择接受结果进入归档、继续修改实现,或调整需求。"+(e.workspace.isolation!=="current"&&e.workspace.finish===null?" 接受时可一起选择:保留工作区、本地合并、推送分支,或推送并创建 PR;也可以先接受结果,稍后再选择收尾方式。":"")),suggestedReply:Y(e,"Accept the result","接受结果"),agentInstruction:Y(e,"Summarize the result and verification evidence, relay the message, and wait for an explicit user decision. Only then execute the matching commandAlternative. Do not accept the result on the user’s behalf.","简要说明交付结果和验收证据,转述 message,并等待用户明确选择后再执行对应的 commandAlternative。不要替用户接受结果。")};if(e.phase==="build"&&e.status==="active"){let a=r?.children.some(({status:c})=>c==="blocked")??!1,o=r?.children.some(({status:c})=>c==="needs-reverify")??!1,s=r?.children.some(({status:c})=>c==="ready"||c==="active")??!1,l=r?.children.some(({status:c,builderFailureCount:u})=>c==="blocked"&&(u??0)>=Wn)??!1;return a&&!o&&!s&&!l?e.language==="zh-CN"?{required:!0,message:"Supervisor 子任务暂时无法启动,已暂停自动重试以避免流程循环。请先根据子任务 blocker 修复工作区、分支或依赖;修复完成后重新运行最新的 next 继续流程。代码和已有证据已保留。",suggestedReply:"修复 blocker 后继续",agentInstruction:"向用户说明子任务 blocker 和需要先完成的外部修复;不要反复执行 next,也不要创建替代任务。用户确认工作区或依赖已修复后,再重新读取 status 并执行最新 continuation。"}:{required:!0,message:"Supervisor child dispatch is paused because every remaining child is blocked. Automatic retries are stopped to avoid a loop. Resolve the recorded child blocker (workspace, branch, or dependency) first, then read the latest status and continue; code and completed evidence are preserved.",suggestedReply:"Resolve the blocker and continue",agentInstruction:"Explain the child blocker and the required external repair to the user. Do not repeatedly run next or spawn replacement tasks. After the user confirms the workspace or dependency is fixed, read status again and execute the latest continuation."}:n(Y(e,"Implement the complete confirmed brief and Spec scope, then review every acceptance ID with its implementation and evidence before handoff. Fill acceptance_review from this audit; derive remaining work from it. Do not submit a partial candidate just to obtain verification feedback. Run focused checks; a separate pre-review is optional. If review is useful, retain the same Reviewer for focused repair follow-ups. Submit the completed candidate for one complete independent verification and release completed helper tasks.","完成已确认的 brief 和 Spec 全部范围,交接前逐项核对所有验收 ID 的实现和证据,填写 acceptance_review,并由这份自查生成剩余工作。不得提交未完成的候选来试探验收反馈。开发期运行相关检查,额外预审为可选项;确需审查时,保留同一个 Reviewer 复核修复及受影响范围。全部完成后提交一次完整独立验收,及时释放已完成的辅助任务。"))}return n(Y(e,"Follow the continuation action. Unless required is true, continue without asking the user to handle internal workflow state, and do not present machine fields as a user-facing explanation.","按 continuation 执行下一步。除非 required 为 true,否则继续推进,不要让用户处理内部工作流状态,也不要把机器字段作为面向用户的说明。"))}function Yg(e){let t=e.workspace.change_branch??"<change-branch>",r=e.workspace.target_branch??"<target-branch>";return e.language==="zh-CN"?{required:!0,message:`当前 change 位于 ${t},目标分支为 ${r}。请选择一次工作区收尾方式:A) 保留工作区;B) 本地合并;C) 推送分支;D) 推送并创建 PR;E) 暂不归档。选择 A-D 后 Runtime 会完成预检,检查通过后按所选方式归档;选择 E 将保留当前 change 等待稍后继续。`,suggestedReply:"回复 A、B、C、D 或 E",agentInstruction:"向用户展示五种收尾方式及实际影响,等待用户选择。选择 A-D 时执行对应 commandAlternatives 的完整命令,Runtime 会在归档前检查状态和证据;选择 E 时停止,不运行 Archive 命令。按用户的明确选择执行 finish。"}:{required:!0,message:`This change is on ${t} and targets ${r}. Choose one workspace finish: A) keep the workspace; B) merge locally; C) push the branch; D) push and create a PR; or E) defer Archive. For A-D, Runtime will run preflight and archive with the selected finish when the checks pass; E keeps the current change for later.`,suggestedReply:"Reply A, B, C, D, or E",agentInstruction:"Show all five finish choices and their actual effects, then wait. For A-D, execute the matching complete commandAlternative; Runtime checks state and evidence before archiving. For E, stop without running an Archive command. Use the finish explicitly selected by the user."}}function Xg(e){return[...[{finish:"keep",name:"keep-workspace",description:["保留当前分支和目录;完成归档提交,不合并、不推送、不创建 PR。","Keep the current branch and directory; create the archive commit without merging, pushing, or creating a PR."]},{finish:"merge",name:"merge-locally",description:["完成归档提交,并把 change 分支本地合并到目标分支;不推送、不创建 PR。","Create the archive commit and merge the change branch locally into the target branch without pushing or creating a PR."]},{finish:"push",name:"push-branch",description:["完成归档提交并推送 change 分支;不合并到目标分支、不创建 PR。","Create the archive commit and push the change branch without merging into the target branch or creating a PR."]},{finish:"pull-request",name:"push-pull-request",description:["完成归档提交、推送 change 分支,并以目标分支为基础创建 PR。","Create the archive commit, push the change branch, and create a PR against the target branch."]}].map(({finish:i,name:n,description:a})=>({name:n,stateVersion:e.state_version,expectedAction:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed","--finish",i,"--expected-state-version",String(e.state_version)],requiredInputs:[],inputOptions:[],description:Y(e,a[1],a[0])})),{name:"defer-archive",stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:null,requiredInputs:[],inputOptions:[],description:Y(e,"Keep the current change and workspace without archiving; stop and resume later.","保留当前 change 和工作区,不执行归档;停止本次流程,稍后再继续。")}]}function xd(e){return["comet","native","next",e.change,"--summary","<summary>",e.flag,"--expected-state-version",String(e.stateVersion),"--expected-action",e.action]}function Gt(e,t){return{name:e,flag:t,valueKind:"text",required:!0,template:null}}function kd(){return{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}}function Qg(e,t){return{name:e,flag:t,valueKind:"confirmation",required:!0,template:null}}function Sd(e,t,r){return{name:e,flag:t,valueKind:"choice",required:!0,template:null,choices:[...r]}}function Zg(e){return e?.coordinationChoiceRequired===!0||e?.schema==="comet.native.children.v2"&&e.children.length>=2}function ew(e){return["comet","native","next",e.change,"--summary","<summary>","--expected-state-version",String(e.stateVersion),"--expected-action","prepare-shape-confirmation"]}function ze(e){return{name:e.name,stateVersion:e.stateVersion,expectedAction:e.expectedAction,commandArgs:xd({change:e.change,stateVersion:e.stateVersion,action:e.expectedAction,flag:e.flag}),requiredInputs:["summary",e.confirmationInput],inputOptions:[Gt("summary","--summary"),Qg(e.name,e.flag)]}}function Ed(e,t){return t.some(i=>/^verification\.md is (?:missing|stale|invalid)$/u.test(i))?[{name:"repair-verification-report",stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","doctor",e.name,"--repair"],requiredInputs:[],inputOptions:[],description:Y(e,"Rebuild the Runtime-managed verification report, then rerun the Archive dry-run.","重建由 Runtime 管理的 verification.md,然后重新运行 Archive 预检。")}]:[]}function tw(e){return/^verification\.md is (?:missing|stale|invalid)$/u.test(e)}function zn(e){return[ze({name:"revise-implementation",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),ze({name:"revise-requirements",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function rw(e){let t={"request-checks":"Choose when the Verifier needs additional Runtime checks.","final-result":"Choose when the Verifier has a result for every current scope ID.","verifier-execution-error":"Choose when a dispatched Verifier failed, was lost, or ended without a result.","verifier-unavailable":"Choose only when the platform has no usable independent Verifier capability."};return e.flatMap(r=>Array.isArray(r.template)?r.template.map(i=>{let n=i.response?.kind??i.kind;return{...r,name:n,required:!1,exclusiveGroup:"runner-input",description:t[n],template:i}}):[r])}function Gn(e,t,r={}){let i=Zg(t)&&e.coordination_mode===void 0,n=Kg(e,i,t,r.verifierStartup),a={schema:"comet.native.continuation.v2",skill:"comet-native",change:e.name,phase:e.phase,status:e.status,stateVersion:e.state_version,inputOptions:[],requiresUserDecision:n.required,userCommunication:n},o=s=>({kind:s,candidateId:e.builder_handoff?.candidate_id??null,iteration:e.loop.iteration,attempt:e.loop.attempt});if(e.status==="done")return{...a,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:o("none")};if(e.status==="await-user")return e.phase==="shape"&&e.loop.next_action==="confirm-shape"?{...a,disposition:"await-user",action:"confirm-shape",commandArgs:null,requiredInputs:["summary","shared-understanding-confirmation",...i?["coordination-choice"]:[]],inputOptions:[Gt("summary","--summary")],commandAlternatives:i?Nd.map(s=>{let l=ze({name:`confirm-shape-${s}`,change:e.name,stateVersion:e.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"});return{...l,commandArgs:[...l.commandArgs,"--coordination-mode",s],requiredInputs:[...l.requiredInputs,"coordination-choice"],inputOptions:[...l.inputOptions,Sd("coordination-mode","--coordination-mode",[s])]}}):[ze({name:"confirm-shape",change:e.name,stateVersion:e.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"})],runnerAction:o("none")}:e.phase==="verify"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass"?{...a,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Gt("summary","--summary")],commandAlternatives:[...e.workspace.isolation!=="current"&&e.workspace.finish===null?["keep","merge","push","pull-request"].map(s=>{let l=ze({name:`accept-result-${s}`,change:e.name,stateVersion:e.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"});return{...l,commandArgs:[...l.commandArgs,"--finish",s]}}):[],ze({name:"accept-result",change:e.name,stateVersion:e.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...zn({change:e.name,stateVersion:e.state_version})],runnerAction:o("none")}:e.phase==="verify"&&e.verification?.assurance==="semantic-verification-unavailable"&&e.loop.next_action==="confirm-verifier-unavailable"?{...a,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Gt("summary","--summary")],commandAlternatives:[ze({name:"retry-verifier",change:e.name,stateVersion:e.state_version,expectedAction:"retry-verifier",flag:"--retry-verifier",confirmationInput:"user-decision"}),ze({name:"confirm-verifier-unavailable",change:e.name,stateVersion:e.state_version,expectedAction:"confirm-verifier-unavailable",flag:"--confirmed",confirmationInput:"user-decision"})],runnerAction:o("none")}:e.phase==="verify"&&e.loop.next_action==="resolve-verifier-blocker"?{...a,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Gt("summary","--summary")],commandAlternatives:[ze({name:"resolve-verifier-blocker",change:e.name,stateVersion:e.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...zn({change:e.name,stateVersion:e.state_version})],runnerAction:o("none")}:e.phase==="verify"&&e.loop.next_action==="await-user"?{...a,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[Gt("summary","--summary")],commandAlternatives:zn({change:e.name,stateVersion:e.state_version}),runnerAction:o("none")}:{...a,disposition:"await-user",action:"none",commandArgs:null,commandAlternatives:zn({change:e.name,stateVersion:e.state_version}),userCommunication:{...a.userCommunication,required:!0,message:e.blockers.length>0?e.blockers.map(({reason:s})=>s).join("; "):a.userCommunication.message,suggestedReply:e.blockers.length>0?e.blockers[0]?.resolution_action??null:a.userCommunication.suggestedReply},requiredInputs:["resolve-blocker"],runnerAction:o("none")};if(e.status==="blocked"){let s=e.blockers.some(({resolution_action:l})=>l==="retry-verifier");return{...a,disposition:"blocked",action:s?"retry-verifier":"none",commandArgs:s?xd({change:e.name,stateVersion:e.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:s?["summary"]:["repair-runtime"],inputOptions:s?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:o(s?"retry-verifier":"none")}}if(e.phase==="shape")return{...a,disposition:"continue",action:"prepare-shape-confirmation",commandArgs:ew({change:e.name,stateVersion:e.state_version}),requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(e.phase==="build"){if(t){if(!t.confirmed)return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(e.loop.stage==="repairing"&&e.verification_result==="fail")return{...a,disposition:"continue",action:"repair",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["repair-child"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.allDone)return{...a,disposition:"continue",action:"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:e.acceptance.map(({id:m})=>m),acceptance_review:e.acceptance.map(({id:m})=>({id:m,status:"not-implemented",evidence:[],note:"<implementation and evidence summary>"})),checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[kd()],known_limits:[]}}],runnerAction:o("builder-handoff")};let s=t.children.find(({status:m})=>m==="verified");if(s){let m=r.supervisorIntegrationRetryIds;return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["supervisor-integration-checks"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-integrate",child:s.name,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}],...m&&m.length>0?{retry_check_ids:[...m]}:{}}}],runnerAction:o("none")}}let l=t.children.some(({status:m})=>m==="blocked"||m==="needs-reverify"),c=t.children.some(({status:m})=>m==="needs-reverify"),u=t.children.some(({status:m})=>m==="ready"||m==="active"),d=t.supervisorStateVersion===void 0?null:t.children.find(m=>m.status==="blocked"&&(m.builderFailureCount??0)>=Wn)??null,f=d===null?null:{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-retry-builder",child:d.name,stateVersion:t.supervisorStateVersion},description:Y(e,"Explicitly authorize one fresh Builder attempt after the Builder failure budget was exhausted.","Builder 失败预算已耗尽;明确授权后才能重新开始一次 Builder 尝试。")},h=l&&!c&&!u&&f===null;return{...a,disposition:h?"blocked":"continue",action:"advance-children",commandArgs:h?null:f!==null?["comet","native","next",e.name,"--runner-input","<temporary-json-file>"]:["comet","native","next",e.name,"--summary","<summary>",...e.coordination_mode==="single-session"?["--max-parallel","1"]:[]],requiredInputs:h?[]:f!==null?["supervisor-builder-retry-json-file"]:["ready-children"],inputOptions:h?[]:f!==null?[f]:[Gt("summary","--summary")],runnerAction:o("none")}}return{...a,disposition:"continue",action:e.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:e.acceptance.map(({id:s})=>s),acceptance_review:e.acceptance.map(({id:s})=>{let l=e.builder_handoff?.acceptance_review?.find(c=>c.id===s);return l?{...l,evidence:[...l.evidence],...e.loop.previous_unresolved_ids.includes(s)?{status:"implemented-no-evidence",evidence:[],note:"<current repair and evidence summary>"}:{}}:{id:s,status:"not-implemented",evidence:[],note:"<implementation and evidence summary>"}}),checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[],known_limits:[]}}],runnerAction:o("builder-handoff")}}if(e.phase==="verify"){let s=e.loop.next_action==="await-verifier-result",l=!!e.children_contract_hash,c=kd();return!s&&r.retryCheckIds&&r.retryCheckIds.length>0?{...a,disposition:"continue",action:"retry-checks",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["retry-checks-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"retry-checks",check_ids:[...r.retryCheckIds]}}],runnerAction:o("retry-checks")}:{...a,userCommunication:!s&&l?{...a.userCommunication,agentInstruction:`${a.userCommunication.agentInstruction} ${Y(e,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:a.userCommunication,disposition:"continue",action:s?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:[s?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:rw([{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:s?[{kind:"verifier-response",candidateId:e.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"request-checks",iteration:e.loop.iteration,attempt:e.loop.attempt,checks:[c]}},{kind:"verifier-response",candidateId:e.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"final-result",result:{iteration:e.loop.iteration,attempt:e.loop.attempt,verdict:"blocked",acceptance:[{id:"<acceptance-id>",result:"blocked",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:r.verificationCheckPlans?r.verificationCheckPlans.map(u=>({...u,argv:[...u.argv]})):l?[c]:[]}}]),runnerAction:o(s?"await-verifier":"dispatch-verifier")}}if(e.phase==="archive"&&e.status==="active"&&e.loop.stage==="archive-ready"&&!e.archived){let s=r.archiveMode??"archive-ready",c=e.workspace.isolation!=="current"&&e.workspace.finish===null;if(s==="blocked")return{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],runnerAction:o("none")};if(s==="preview"){if(r.archiveBlockers&&r.archiveBlockers.length>0){let u=Ed(e,r.archiveBlockers)[0];return u&&r.archiveBlockers.every(d=>tw(d))?{...a,disposition:"continue",action:"repair",commandArgs:u.commandArgs,requiredInputs:[],inputOptions:[],runnerAction:o("none")}:{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],commandAlternatives:Ed(e,r.archiveBlockers),runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}return c?{...a,disposition:"await-user",action:"archive",commandArgs:null,requiredInputs:["workspace-finish"],inputOptions:[Sd("finish","--finish",["keep","merge","push","pull-request"])],commandAlternatives:[...Xg(e)],userCommunication:Yg(e),runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--dry-run"],requiredInputs:[],commandAlternatives:[ze({name:"revise-requirements",change:e.name,stateVersion:e.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}import{promises as Hg}from"node:fs";import tA from"node:path";import{randomUUID as i_}from"node:crypto";import{promises as Ln}from"node:fs";import n_ from"node:path";Cr();Yn();import{execFileSync as mw}from"child_process";import vw from"fs";import Jt from"path";import{AsyncLocalStorage as _d}from"node:async_hooks";yi();var Pr=new _d,gw=new _d;function Ad(e){return Pr.getStore()?e():Pr.run(new Map,e)}function ww(e){let t=Pr.getStore();for(let r of e)t?.set(Rr(r.root),e);return e}function Xn(e,t){return Un(()=>mw("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim())}function Ni(e,t){return Rr(e)===Rr(t)}function Rr(e){let t=Jt.resolve(e);try{let r=vw.realpathSync.native(t);return process.platform==="win32"?r.toLowerCase():r}catch{return process.platform==="win32"?t.toLowerCase():t}}function _e(e){try{let t=gw.getStore()?.get(Rr(e)),r=Pr.getStore()?.get(t??Rr(e));if(r){let l=Rd(t??e,r);if(l)return l;if(r.length===0)return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}let i=Jt.resolve(Xn(e,["rev-parse","--show-toplevel"])),n=Pr.getStore()?.get(Rr(i))??yw(e),a=Rd(i,n);if(Pr.getStore()&&a)return a;let o=n[0]?.root??i,s=null;try{s=Xn(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Ni(i,o),currentWorktreeRoot:i,primaryWorktreeRoot:o,currentBranch:s}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function yw(e){let t=bw(Xn(e,["worktree","list","--porcelain","-z"]));return ww(t),t.map(r=>({...r}))}function bw(e){let t=e.split("\0"),r=[],i=null;for(let n of t)n.startsWith("worktree ")?(i&&r.push(i),i={root:Jt.resolve(n.slice(9)),branch:null,detached:!1}):i&&n.startsWith("branch refs/heads/")?i.branch=n.slice(18):i&&n==="detached"&&(i.detached=!0);return i&&r.push(i),r}function Rd(e,t){let r=t.find(a=>Ni(Jt.resolve(a.root),Jt.resolve(e)));if(!r)return null;let i=Jt.resolve(t[0].root),n=Jt.resolve(r.root);return{isGitWorktree:!0,isSecondaryWorktree:!Ni(i,n),currentWorktreeRoot:n,primaryWorktreeRoot:i,currentBranch:r.branch}}function Id(e){try{return Xn(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{return null}}B();we();var Pu=Ct(ut(),1);import Sn from"path";we();B();tr();be();Q();L();tt();bn();Q();L();Wr();Mt();var hC=Ct(ut(),1);Wr();Mt();ft();ft();Vr();Ol();Wr();ft();var v0=4*1024*1024;import{AsyncLocalStorage as mC}from"node:async_hooks";var vC=new mC;function gC(){let e=vC.getStore();return e?.active?e:null}function wC(e,t){let r=e;for(let i of t)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function Qm(e,t){return(...r)=>{let i=gC();if(i===null)return t(...r);let n=wC(`async:${e}`,r),a=i.entries.get(n);if(a)return a.value;let o=t(...r).catch(s=>{throw i.entries.get(n)?.value===o&&i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}Vr();var k0=Qm("hookWritePolicy",async e=>(await Il(e))?.hook??{allow_paths:[]});on();var yC=16*1024;Tl();ki();var EO=Number.MAX_SAFE_INTEGER;B();Ge();var DO={runStateBytes:Number.MAX_SAFE_INTEGER,trajectoryBytes:Number.MAX_SAFE_INTEGER,trajectoryEvents:4096,trajectoryEventBytes:Number.MAX_SAFE_INTEGER,checkpointBytes:Number.MAX_SAFE_INTEGER,pendingActionBytes:Number.MAX_SAFE_INTEGER,contextBytes:Number.MAX_SAFE_INTEGER,artifactsBytes:Number.MAX_SAFE_INTEGER};import ei from"node:path";B();we();Q();L();var Nn=/^[a-f0-9]{64}$/u,ev=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,CC=16*1024,QO=process.platform;function PC(e,t){let r=ei.relative(e,t);return ei.isAbsolute(r)||r===".."||r.startsWith(`..${ei.sep}`)?null:r.replaceAll("\\","/")||"."}function rv(e){return Array.from(e).some(t=>{let r=t.codePointAt(0)??0;return r<=31||r===127})}function iv(e,t){if(e.length===0||rv(e)||e.includes("\\")||ei.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes(".."))throw new Error(`${t} must be a portable project-relative path`);let r=ei.posix.normalize(e);if(r!==e||r===".."||r.startsWith("../"))throw new Error(`${t} must be a normalized project-relative path`);return r}function RC(e){if(typeof e!="string")throw new Error("Native workspace capturedAt is invalid");let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw new Error("Native workspace capturedAt is invalid");return e}function Cu(e,t){if(e===null)return null;if(typeof e!="string"||e.length===0||e.trim()!==e||rv(e))throw new Error(`${t} must be a non-empty branch name or null`);return e}function _C(e){if(!new Set(["current","branch","worktree"]).has(e.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Cu(e.changeBranch,"Native workspace change branch"),Cu(e.targetBranch,"Native workspace target branch"),(e.isolation==="branch"||e.isolation==="worktree")&&(e.changeBranch===null||e.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function AC(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace Git provenance must be an object");let t=e,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(t).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(t.provider!=="git"||typeof t.baseCommit!="string"||!ev.test(t.baseCommit)||typeof t.targetCommit!="string"||!ev.test(t.targetCommit))throw new Error("Native workspace Git provenance is invalid");Cu(t.targetBranch,"Native workspace Git target branch")}function IC(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace identity must be an object");let t=e,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(t).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(t.schema!=="comet.native.workspace.v2"&&t.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(t.capturedRevision)||t.capturedRevision<1||typeof t.nativeRootRef!="string"||!Nn.test(String(t.projectRootId))||!Nn.test(String(t.nativeRootId)))throw new Error("Native workspace identity is invalid");RC(t.capturedAt),iv(t.nativeRootRef,"Native workspace root ref");let n=t.projectRootPathId!==void 0,a=t.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!Nn.test(String(t.projectRootPathId))||a&&!Nn.test(String(t.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(t.sessionHash!==void 0&&!Nn.test(String(t.sessionHash)))throw new Error("Native workspace session hash is invalid");if(t.git!==void 0&&AC(t.git),t.schema==="comet.native.workspace.v2"){if(t.isolation!==void 0||t.changeBranch!==void 0||t.targetBranch!==void 0||t.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof t.isolation!="string"||t.changeBranch===void 0||t.targetBranch===void 0||t.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(_C(t),t.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(t.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function TC(e,t){return ei.join(De(e,t),"workspace.json")}function $C(e,t){let r=TC(e,t),i=fe(e,r),n=PC(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:iv(n,"Native workspace file ref")}}async function jC(e,t){try{let r=$C(e,t),i=await $({root:r.root,ref:r.ref,maxBytes:CC});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function kn(e,t){let r=await jC(e,t);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(IC(r),r)}pn();Ro();Ro();var Zo=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},En=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},es=class extends Error{constructor(r,i,n,a,o,s=null,l=null){super(`Native change ${r} baseline is incomplete (${i} omitted entr${i===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=r;this.omittedCount=i;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=l;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},CH=eo("en");function it(e,t){gn(t);let r=Sn.join(e.changesDir,t);if(!te(e.changesDir,r))throw new Error("Native change path escaped");return r}async function DC(e,t=Sn.dirname(e)){let r=Sn.relative(t,e).split(Sn.sep).join("/"),i=await $({root:t,ref:r,maxBytes:null,includeHash:!1}),n=(0,Pu.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${e}: ${n.errors[0].message}`);return n.toJS()}async function av(e,t){let r=Sn.join(it(e,t),mt);await T(e.nativeRoot,r);let i=au(await DC(r,e.nativeRoot));if(i.state&&i.state.name!==t)throw new Error(`Native change directory/name mismatch: ${t}`);return i}Q();vu();Wo();$o();import{promises as cv}from"node:fs";import rs from"node:path";nt();B();mi();import{promises as LC}from"node:fs";import BC from"node:os";import Pn from"node:path";function xn(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Cn(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function oe(e,t,r=!1){if(typeof e!="string"||!r&&e.length===0)throw new Error(`${t} must be ${r?"a string":"a non-empty string"}`);return e}function ti(e,t){return e===null?null:oe(e,t)}function ri(e,t,r=0){if(!Number.isSafeInteger(e)||e<r)throw new Error(`${t} must be a safe integer greater than or equal to ${r}`);return e}function MC(e,t){if(e===null)return null;if(!Number.isSafeInteger(e))throw new Error(`${t} must be null or a safe integer`);return e}function FC(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function ii(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} must be one of: ${t.join(", ")}`);return e}function Ru(e,t){if(e===null)return null;let r=oe(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO timestamp`);return r}function qC(e,t){let r=oe(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO timestamp`);return r}function _u(e,t){let r=oe(e,t);if(!Pn.isAbsolute(r))throw new Error(`${t} must be absolute`);return Pn.resolve(r)}function VC(e,t){let r=`Native local checks[${t}]`,i=xn(e,r);if(Cn(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log","activeProcess","evidence","evidenceDigest"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((u,d)=>oe(u,`${r}.argv[${d}]`,!0)),a=ii(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=Ru(i.startedAt,`${r}.startedAt`),s=Ru(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let l=ri(i.timeoutMs,`${r}.timeoutMs`);if(l<1)throw new Error(`${r}.timeoutMs must be positive`);let c;if(Object.hasOwn(i,"activeProcess"))if(i.activeProcess===null)c=null;else{let u=xn(i.activeProcess,`${r}.activeProcess`),d=ii(u.status,["starting","running"],`${r}.activeProcess.status`);if(Cn(u,new Set(["status","pid","identity"]),`${r}.activeProcess`),d==="starting"){if(Object.hasOwn(u,"pid")||Object.hasOwn(u,"identity"))throw new Error(`${r}.activeProcess starting state cannot contain process identity`);c={status:"starting"}}else c={status:"running",pid:ri(u.pid,`${r}.activeProcess.pid`,1),...Object.hasOwn(u,"identity")?{identity:oe(u.identity,`${r}.activeProcess.identity`)}:{}}}return{id:oe(i.id,`${r}.id`),name:oe(i.name,`${r}.name`),operationId:oe(i.operationId,`${r}.operationId`),status:a,repeatable:FC(i.repeatable,`${r}.repeatable`),timeoutMs:l,executionCount:ri(i.executionCount,`${r}.executionCount`),argv:n,cwd:_u(i.cwd,`${r}.cwd`),exitCode:MC(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:oe(i.log,`${r}.log`),...Object.hasOwn(i,"activeProcess")?{activeProcess:c}:{},...Object.hasOwn(i,"evidence")?{evidence:ii(i.evidence,["runtime"],`${r}.evidence`)}:{},...Object.hasOwn(i,"evidenceDigest")?{evidenceDigest:oe(i.evidenceDigest,`${r}.evidenceDigest`)}:{}}}function ov(e){let t="Native local execution state",r=xn(e,t);if(Cn(r,new Set(["schema","change","basedOnStateVersion","candidateId","inputFingerprint","inputFingerprintGate","candidateInputFingerprintGate","workspace","execution","checks"]),t),r.schema!==hi)throw new Error(`Native local execution schema must be ${hi}`);let i=xn(r.workspace,"Native local workspace");Cn(i,new Set(["projectRoot","worktreeRoot","branch","machineId"]),"Native local workspace");let n=null;if(r.execution!==null){let o=xn(r.execution,"Native local execution");Cn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds","verifierStartedAt","ownerPid","ownerIdentity"]),"Native local execution");let s=Ru(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:oe(o.operationId,"Native local execution.operationId"),stage:ii(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:ii(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:ti(o.executionId,"Native local execution.executionId"),status:ii(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:ri(o.requestCheckRounds,"Native local execution.requestCheckRounds"),...Object.hasOwn(o,"verifierStartedAt")?{verifierStartedAt:qC(o.verifierStartedAt,"Native local execution.verifierStartedAt")}:{},...Object.hasOwn(o,"ownerPid")?{ownerPid:ri(o.ownerPid,"Native local execution.ownerPid",1)}:{},...Object.hasOwn(o,"ownerIdentity")?{ownerIdentity:oe(o.ownerIdentity,"Native local execution.ownerIdentity")}:{}}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(VC);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:hi,change:oe(r.change,"Native local change"),basedOnStateVersion:ri(r.basedOnStateVersion,"Native local basedOnStateVersion",1),...Object.hasOwn(r,"candidateId")?{candidateId:ti(r.candidateId,"Native local candidateId")}:{},...Object.hasOwn(r,"inputFingerprint")?{inputFingerprint:ti(r.inputFingerprint,"Native local inputFingerprint")}:{},...Object.hasOwn(r,"inputFingerprintGate")?{inputFingerprintGate:ti(r.inputFingerprintGate,"Native local inputFingerprintGate")}:{},...Object.hasOwn(r,"candidateInputFingerprintGate")?{candidateInputFingerprintGate:ti(r.candidateInputFingerprintGate,"Native local candidateInputFingerprintGate")}:{},workspace:{projectRoot:_u(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:_u(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:ti(i.branch,"Native local workspace.branch"),...Object.hasOwn(i,"machineId")?{machineId:oe(i.machineId,"Native local workspace.machineId")}:{}},execution:n,checks:a}}function qe(e){return ov({schema:hi,change:e.portableState.name,basedOnStateVersion:e.portableState.state_version,candidateId:e.portableState.builder_handoff?.candidate_id??null,inputFingerprint:null,inputFingerprintGate:null,candidateInputFingerprintGate:null,workspace:{projectRoot:Pn.resolve(e.projectRoot),worktreeRoot:Pn.resolve(e.worktreeRoot??e.projectRoot),branch:e.branch??null,machineId:BC.hostname()},execution:null,checks:[]})}async function Ve(e,t,r={}){let i=ov(t);await LC.mkdir(Pn.dirname(e),{recursive:!0}),await Z(e,i,r)}gt();L();var Rn=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,lv="comet-state.yaml",uv="state.json";function he(e,t){if(!Rn.test(t))throw new Error(`Invalid Native change name: ${t}`);let r=rs.join(e.changesDir,t);if(!te(e.changesDir,r))throw new Error("Native change path escaped");return r}function at(e,t){return rs.join(he(e,t),lv)}function Ce(e,t){return rs.join(He(e,t),uv)}async function pr(e,t){try{let r=await cv.readFile(at(e,t),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function yt(e){return Id(e)}async function Pe(e,t){return vt(at(e,t))}async function bt(e){let t=await Hm({file:at(e.paths,e.previous.name),expectedStateVersion:e.previous.state_version,next:e.next,containedRoot:e.paths.nativeRoot});if(t.verification===null&&t.verification_report===null){let r=rs.join(he(e.paths,t.name),"verification.md");await T(e.paths.nativeRoot,r),await cv.rm(r,{force:!0})}return t}import{createHash as QR}from"node:crypto";import{promises as ui}from"node:fs";import St from"node:path";function $u(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var vr=$u();function wv(e){vr=e}var hr={exec:()=>null};function ni(e){let t=[];return r=>{let i=Math.max(0,Math.min(3,r-1)),n=t[i];return n||(n=e(i),t[i]=n),n}}function P(e,t=""){let r=typeof e=="string"?e:e.source,i={replace:(n,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(re.caret,"$1"),r=r.replace(n,o),i},getRegex:()=>new RegExp(r,t)};return i}var zC=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),re={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:ni(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ni(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:ni(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:ni(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:ni(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:ni(e=>new RegExp(`^ {0,${e}}>`))},GC=/^(?:[ \t]*(?:\n|$))+/,JC=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,UC=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,In=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,KC=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ju=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,yv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,bv=P(yv).replace(/bull/g,ju).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),YC=P(yv).replace(/bull/g,ju).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ou=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,XC=/^[^\n]+/,Hu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,QC=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Hu).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ZC=P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ju).getRegex(),ss="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Du=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,eP=P("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Du).replace("tag",ss).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Nv=e=>P(Ou).replace("hr",In).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ss).getRegex(),tP=Nv(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),rP=Nv(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),iP=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",rP).getRegex(),Lu={blockquote:iP,code:JC,def:QC,fences:UC,heading:KC,hr:In,html:eP,lheading:bv,list:ZC,newline:GC,paragraph:tP,table:hr,text:XC},dv=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",In).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ss).getRegex(),nP={...Lu,lheading:YC,table:dv,paragraph:P(Ou).replace("hr",In).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",dv).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ss).getRegex()},aP={...Lu,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Du).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:hr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(Ou).replace("hr",In).replace("heading",` *#{1,6} *[^
196
+ ]`).replace("lheading",bv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},oP=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,sP=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,kv=/^( {2,}|\\)\n(?!\s*$)/,cP=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Nt=/[\p{P}\p{S}]/u,ai=/[\s\p{P}\p{S}]/u,Tn=/[^\s\p{P}\p{S}]/u,lP=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ai).getRegex(),uP=/[\p{Pi}\p{Ps}"']/u,Sv=/(?!~)[\p{P}\p{S}]/u,dP=/(?!~)[\s\p{P}\p{S}]/u,fP=/(?:[^\s\p{P}\p{S}]|~)/u,pP=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zC?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ev=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,hP=P(Ev,"u").replace(/punct/g,Nt).getRegex(),mP=P(Ev,"u").replace(/punct/g,Sv).getRegex(),vP=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,gP=P(vP,"u").replace(/openQuote/g,uP).replace(/punct/g,Nt).getRegex(),xv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wP=P(xv,"gu").replace(/notPunctSpace/g,Tn).replace(/punctSpace/g,ai).replace(/punct/g,Nt).getRegex(),yP=P(xv,"gu").replace(/notPunctSpace/g,fP).replace(/punctSpace/g,dP).replace(/punct/g,Sv).getRegex(),bP="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",NP=P(bP,"gu").replace(/notPunctSpace/g,Tn).replace(/punctSpace/g,ai).replace(/punct/g,Nt).getRegex(),kP=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Tn).replace(/punctSpace/g,ai).replace(/punct/g,Nt).getRegex(),SP="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",EP=P(SP,"gu").replace(/notPunctSpace/g,Tn).replace(/punctSpace/g,ai).replace(/punct/g,Nt).getRegex(),xP=P(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Nt).getRegex(),CP="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",PP=P(CP,"gu").replace(/notPunctSpace/g,Tn).replace(/punctSpace/g,ai).replace(/punct/g,Nt).getRegex(),RP=P(/\\(punct)/,"gu").replace(/punct/g,Nt).getRegex(),_P=P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),AP=P(Du).replace("(?:-->|$)","-->").getRegex(),IP=P("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",AP).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ns=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,TP=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ns).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Cv=P(/^!?\[(label)\]\[(ref)\]/).replace("label",ns).replace("ref",Hu).getRegex(),Pv=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",Hu).getRegex(),$P=P("reflink|nolink(?!\\()","g").replace("reflink",Cv).replace("nolink",Pv).getRegex(),fv=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Bu={_backpedal:hr,anyPunctuation:RP,autolink:_P,blockSkip:pP,br:kv,code:sP,del:hr,delLDelim:hr,delRDelim:hr,emStrongLDelim:hP,emStrongRDelimAst:wP,emStrongRDelimUnd:kP,escape:oP,link:TP,nolink:Pv,punctuation:lP,reflink:Cv,reflinkSearch:$P,tag:IP,text:cP,url:hr},jP={...Bu,emStrongLDelim:gP,emStrongRDelimAst:NP,emStrongRDelimUnd:EP,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",ns).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ns).getRegex()},Au={...Bu,emStrongRDelimAst:yP,emStrongLDelim:mP,delLDelim:xP,delRDelim:PP,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",fv).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",fv).getRegex()},OP={...Au,br:P(kv).replace("{2,}","*").getRegex(),text:P(Au.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},is={normal:Lu,gfm:nP,pedantic:aP},_n={normal:Bu,gfm:Au,breaks:OP,pedantic:jP},HP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},pv=e=>HP[e];function ot(e,t){if(t){if(re.escapeTest.test(e))return e.replace(re.escapeReplace,pv)}else if(re.escapeTestNoEncode.test(e))return e.replace(re.escapeReplaceNoEncode,pv);return e}function hv(e){try{e=encodeURI(e).replace(re.percentDecode,"%")}catch{return null}return e}function mv(e,t){let r=e.replace(re.findPipe,(a,o,s)=>{let l=!1,c=o;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),i=r.split(re.splitPipe),n=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(re.slashPipe,"|");return i}function qt(e,t,r){let i=e.length;if(i===0)return"";let n=0;for(;n<i;){let a=e.charAt(i-n-1);if(a===t&&!r)n++;else if(a!==t&&r)n++;else break}return e.slice(0,i-n)}function vv(e){let t=e.split(`
197
+ `),r=t.length-1;for(;r>=0&&re.blankLine.test(t[r]);)r--;return t.length-r<=2?e:t.slice(0,r+1).join(`
198
+ `)}function DP(e,t){if(e.indexOf(t[1])===-1)return-1;let r=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])r++;else if(e[i]===t[1]&&(r--,r<0))return i;return r>0?-2:-1}function LP(e,t=0){let r=t,i="";for(let n of e)if(n===" "){let a=4-r%4;i+=" ".repeat(a),r+=a}else i+=n,r++;return i}function gv(e,t,r,i,n){let a=t.href,o=t.title||null,s=e[1].replace(n.other.outputLinkReplace,"$1"),l=e[0].charAt(0)==="!";i.state.inLink=!0;let c=i.state.linkEmitted,u=i.state.inRawBlock;i.state.linkEmitted=!1;let d=i.inlineTokens(s),f=i.state.linkEmitted;if(i.state.linkEmitted=c,i.state.inLink=!1,!l){if(f){i.state.inRawBlock=u;return}i.state.linkEmitted=!0}return{type:l?"image":"link",raw:r,href:a,title:o,text:s,tokens:d}}function BP(e,t,r){let i=e.match(r.other.indentCodeCompensation);if(i===null)return t;let n=i[1];return t.split(`
199
+ `).map(a=>{let o=a.match(r.other.beginningSpace);if(o===null)return a;let[s]=o;return s.length>=n.length?a.slice(n.length):a}).join(`
200
+ `)}var as=class{options;rules;lexer;constructor(e){this.options=e||vr}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let r=this.options.pedantic?t[0]:vv(t[0]),i=r.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:r,codeBlockStyle:"indented",text:i}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let r=t[0],i=BP(r,t[3]||"",this.rules);return{type:"code",raw:r,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let r=t[2].trim();if(this.rules.other.endingHash.test(r)){let i=qt(r,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(r=i.trim())}return{type:"heading",raw:qt(t[0],`
201
+ `),depth:t[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:qt(t[0],`
202
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let r=qt(t[0],`
181
203
  `).split(`
182
- `);for(;t.length>0&&t.at(-1)?.trim().length===0;)t.pop();return`${t.map(r=>r.replace(/[\t ]+$/gu,"")).join(`
204
+ `),i="",n="",a=[];for(;r.length>0;){let o=!1,s=[],l;for(l=0;l<r.length;l++)if(this.rules.other.blockquoteStart.test(r[l]))s.push(r[l]),o=!0;else if(!o)s.push(r[l]);else break;r=r.slice(l);let c=s.join(`
205
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
206
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
207
+ ${c}`:c,n=n?`${n}
208
+ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,a,!0),this.lexer.state.top=d,r.length===0)break;let f=a.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let h=f,m=r.join(`
209
+ `),p=h.raw+`
210
+ `+m.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(p);a[a.length-1]=v,i=`${i}
211
+ ${m}`,n=n.substring(0,n.length-h.text.length)+v.text;break}else if(f?.type==="list"){let h=f,m=h.raw+`
212
+ `+r.join(`
213
+ `),p=this.list(m);a[a.length-1]=p,i=i.substring(0,i.length-f.raw.length)+p.raw,n=n.substring(0,n.length-h.raw.length)+p.raw,r=m.substring(a.at(-1).raw.length).split(`
214
+ `);continue}}return{type:"blockquote",raw:i,tokens:a,text:n}}}list(e){let t=this.rules.block.list.exec(e);if(t){let r=t[1].trim(),i=r.length>1,n={type:"list",raw:"",ordered:i,start:i?+r.slice(0,-1):"",loose:!1,items:[]};r=i?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=i?r:"[*+-]");let a=this.rules.other.listItemRegex(r),o=!1;for(;e;){let l=!1,c="",u="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let d=LP(t[2].split(`
215
+ `,1)[0],t[1].length),f=e.split(`
216
+ `,1)[0],h=!d.trim(),m=0;if(this.options.pedantic?(m=2,u=d.trimStart()):h?m=t[1].length+1:(m=d.search(this.rules.other.nonSpaceChar),m=m>4?1:m,u=d.slice(m),m+=t[1].length),h&&this.rules.other.blankLine.test(f)&&(c+=f+`
217
+ `,e=e.substring(f.length+1),l=!0),!l){let p=this.rules.other.nextBulletRegex(m),v=this.rules.other.hrRegex(m),g=this.rules.other.fencesBeginRegex(m),w=this.rules.other.headingBeginRegex(m),b=this.rules.other.htmlBeginRegex(m),k=this.rules.other.blockquoteBeginRegex(m);for(;e;){let x=e.split(`
218
+ `,1)[0],E;if(f=x,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),E=f):E=f.replace(this.rules.other.tabCharGlobal," "),g.test(f)||w.test(f)||b.test(f)||k.test(f)||p.test(f)||v.test(f))break;if(E.search(this.rules.other.nonSpaceChar)>=m||!f.trim())u+=`
219
+ `+E.slice(m);else{if(h||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||g.test(d)||w.test(d)||v.test(d))break;u+=`
220
+ `+f}h=!f.trim(),c+=x+`
221
+ `,e=e.substring(x.length+1),d=E.slice(m)}}n.loose||(o?n.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),n.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),n.raw+=c}let s=n.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let l of n.items)if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),!n.loose){let c=l.tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));n.loose=u}for(let l of n.items){let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let d={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=d.checked,n.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=d.raw+l.tokens[0].raw,l.tokens[0].text=d.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(d)):l.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):l.tokens.unshift(d)}}else l.task&&(l.task=!1)}if(n.loose)for(let l of n.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return n}}html(e){let t=this.rules.block.html.exec(e);if(t){let r=vv(t[0]);return{type:"html",block:!0,raw:r,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:r}}}def(e){let t=this.rules.block.def.exec(e);if(t){let r=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:r,raw:qt(t[0],`
222
+ `),href:i,title:n}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let r=mv(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
223
+ `):[],a={type:"table",raw:qt(t[0],`
224
+ `),header:[],align:[],rows:[]};if(r.length===i.length){for(let o of i)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<r.length;o++)a.header.push({text:r[o],tokens:this.lexer.inline(r[o]),header:!0,align:a.align[o]});for(let o of n)a.rows.push(mv(o,a.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:a.align[l]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let r=t[1].trim();return{type:"heading",raw:qt(t[0],`
225
+ `),depth:t[2].charAt(0)==="="?1:2,text:r,tokens:this.lexer.inline(r)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let r=t[1].charAt(t[1].length-1)===`
226
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:r,tokens:this.lexer.inline(r)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let a=qt(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{let a=DP(t[2],"()");if(a===-2)return;if(a>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let i=t[2],n="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(i);a&&(i=a[1],n=a[3])}else n=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i=i.slice(1):i=i.slice(1,-1)),gv(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=t[i.toLowerCase()];if(!n){let a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return gv(r,n,r[0],this.lexer,this.rules)}}emStrong(e,t,r=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!r||this.rules.inline.punctuation.exec(r))){let n=[...i[0]].length-1,a,o,s=n,l=0,c=i[0][0],u=r===c,d=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+n);(i=d.exec(t))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(o=[...a].length,i[3]||i[4]){s+=o;continue}else if(i[5]||i[6]){if(n%3&&!((n+o)%3)){l+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+l);let f=[...i[0]][0].length,h=e.slice(0,n+i.index+f+o);if(Math.min(n,o)%2){let p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}let m=h.slice(2,-2);return{type:"strong",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let r=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(r),n=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return i&&n&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:t[0],text:r}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,r=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!r||this.rules.inline.punctuation.exec(r))){let n=[...i[0]].length-1,a,o,s=n,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+n);(i=l.exec(t))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a||(o=[...a].length,o!==n))continue;if(i[3]||i[4]){s+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s);let c=[...i[0]][0].length,u=e.slice(0,n+i.index+c+o),d=u.slice(n,-n);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let r,i;return t[2]==="@"?(r=t[1],i="mailto:"+r):(r=t[1],i=r),{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;else{let n;do n=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(n!==t[0]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let r=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:r}}}},me=class Iu{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||vr,this.options.tokenizer=this.options.tokenizer||new as,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let r={other:re,block:is.normal,inline:_n.normal};this.options.pedantic?(r.block=is.pedantic,r.inline=_n.pedantic):this.options.gfm&&(r.block=is.gfm,this.options.breaks?r.inline=_n.breaks:r.inline=_n.gfm),this.tokenizer.rules=r}static get rules(){return{block:is,inline:_n}}static lex(t,r){return new Iu(r).lex(t)}static lexInline(t,r){return new Iu(r).inlineTokens(t)}lex(t){t=t.replace(re.carriageReturn,`
227
+ `),this.blockTokens(t,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let i=this.inlineQueue[r];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,r=[],i=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(re.tabCharGlobal," ").replace(re.spaceLine,""));let n=1/0;for(;t;){if(t.length<n)n=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let a;if(this.options.extensions?.block?.some(s=>(a=s.call({lexer:this},t,r))?(t=t.substring(a.raw.length),r.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let s=r.at(-1);a.raw.length===1&&s!==void 0?s.raw+=`
228
+ `:r.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let s=r.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
229
+ `)?"":`
230
+ `)+a.raw,s.text+=`
231
+ `+a.text,this.inlineQueue.at(-1).src=s.text):r.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let s=r.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
232
+ `)?"":`
233
+ `)+a.raw,s.text+=`
234
+ `+a.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},r.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),r.push(a);continue}let o=t;if(this.options.extensions?.startBlock){let s=1/0,l=t.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},l),typeof c=="number"&&c>=0&&(s=Math.min(s,c))}),s<1/0&&s>=0&&(o=t.substring(0,s+1))}if(this.state.top&&(a=this.tokenizer.paragraph(o))){let s=r.at(-1);i&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
235
+ `)?"":`
236
+ `)+a.raw,s.text+=`
237
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(a),i=o.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let s=r.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
238
+ `)?"":`
239
+ `)+a.raw,s.text+=`
240
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(a);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,r}inline(t,r=[]){return this.inlineQueue.push({src:t,tokens:r}),r}linkInText(t){if(!t.includes("["))return!1;let r=this.tokenizer.rules.inline.link;for(let i of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(r.test(i[0])&&t.charAt(i.index-1)!=="!")return!0;for(let i of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let n=i[0],a=n.lastIndexOf("[");if(!(n.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,n.slice(a+1,-1)))&&!(a>1&&this.linkInText(n.slice(1,a-1))))return!0}return!1}inlineTokens(t,r=[]){this.tokenizer.lexer=this;let i=t;if(this.tokens.links&&t.includes("[")){let s=this.tokenizer.rules.inline.reflinkSearch,l=c=>{let u=c.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,c.slice(u+1,-1)))return c;if(u>1&&c.charAt(0)!=="!"){let d=c.slice(1,u-1);if(this.linkInText(d))return"["+d.replace(s,l)+"]["+"a".repeat(c.length-u-2)+"]"}return"["+"a".repeat(c.length-2)+"]"};i=i.replace(s,l)}i=i.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),i=i.replace(this.tokenizer.rules.inline.blockSkip,(s,l,c)=>{let u=c?c.length:0;return s.slice(0,u)+"["+"a".repeat(s.length-u-2)+"]"}),i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let n=!1,a="",o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}n||(a=""),n=!1;let s;if(this.options.extensions?.inline?.some(c=>(s=c.call({lexer:this},t,r))?(t=t.substring(s.raw.length),r.push(s),!0):!1))continue;if(s=this.tokenizer.escape(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.tag(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.link(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(s.raw.length);let c=r.at(-1);s.type==="text"&&c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):r.push(s);continue}if(s=this.tokenizer.emStrong(t,i,a)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.codespan(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.br(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.del(t,i,a)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.autolink(t)){t=t.substring(s.raw.length),r.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(t))){t=t.substring(s.raw.length),r.push(s);continue}let l=t;if(this.options.extensions?.startInline){let c=1/0,u=t.slice(1),d;this.options.extensions.startInline.forEach(f=>{d=f.call({lexer:this},u),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(l=t.substring(0,c+1))}if(s=this.tokenizer.inlineText(l)){t=t.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(a=s.raw.slice(-1)),n=!0;let c=r.at(-1);c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):r.push(s);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return r}infiniteLoopError(t){let r="Infinite loop on byte: "+t;if(this.options.silent)console.error(r);else throw new Error(r)}},os=class{options;parser;constructor(e){this.options=e||vr}space(e){return""}code({text:e,lang:t,escaped:r}){let i=(t||"").match(re.notSpaceStart)?.[0],n=e.replace(re.endingNewline,"")+`
241
+ `;return i?'<pre><code class="language-'+ot(i)+'">'+(r?n:ot(n,!0))+`</code></pre>
242
+ `:"<pre><code>"+(r?n:ot(n,!0))+`</code></pre>
243
+ `}blockquote({tokens:e}){return`<blockquote>
244
+ ${this.parser.parse(e)}</blockquote>
245
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
246
+ `}hr(e){return`<hr>
247
+ `}list(e){let t=e.ordered,r=e.start,i="";for(let o=0;o<e.items.length;o++){let s=e.items[o];i+=this.listitem(s)}let n=t?"ol":"ul",a=t&&r!==1?' start="'+r+'"':"";return"<"+n+a+`>
248
+ `+i+"</"+n+`>
249
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
250
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
251
+ `}table(e){let t="",r="";for(let n=0;n<e.header.length;n++)r+=this.tablecell(e.header[n]);t+=this.tablerow({text:r});let i="";for(let n=0;n<e.rows.length;n++){let a=e.rows[n];r="";for(let o=0;o<a.length;o++)r+=this.tablecell(a[o]);i+=this.tablerow({text:r})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
252
+ <thead>
253
+ `+t+`</thead>
254
+ `+i+`</table>
255
+ `}tablerow({text:e}){return`<tr>
256
+ ${e}</tr>
257
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+t+`</${r}>
258
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ot(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:r}){let i=this.parser.parseInline(r),n=hv(e);if(n===null)return i;e=n;let a='<a href="'+e+'"';return t&&(a+=' title="'+ot(t)+'"'),a+=">"+i+"</a>",a}image({href:e,title:t,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let n=hv(e);if(n===null)return ot(r);e=n;let a=`<img src="${e}" alt="${ot(r)}"`;return t&&(a+=` title="${ot(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ot(e.text)}},Mu=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},We=class Tu{options;renderer;textRenderer;constructor(t){this.options=t||vr,this.options.renderer=this.options.renderer||new os,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Mu}static parse(t,r){return new Tu(r).parse(t)}static parseInline(t,r){return new Tu(r).parseInline(t)}parse(t){this.renderer.parser=this;let r="";for(let i=0;i<t.length;i++){let n=t[i];if(this.options.extensions?.renderers?.[n.type]){let o=n,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){r+=s||"";continue}}let a=n;switch(a.type){case"space":{r+=this.renderer.space(a);break}case"hr":{r+=this.renderer.hr(a);break}case"heading":{r+=this.renderer.heading(a);break}case"code":{r+=this.renderer.code(a);break}case"table":{r+=this.renderer.table(a);break}case"blockquote":{r+=this.renderer.blockquote(a);break}case"list":{r+=this.renderer.list(a);break}case"checkbox":{r+=this.renderer.checkbox(a);break}case"html":{r+=this.renderer.html(a);break}case"def":{r+=this.renderer.def(a);break}case"paragraph":{r+=this.renderer.paragraph(a);break}case"text":{r+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(t,r=this.renderer){this.renderer.parser=this;let i="";for(let n=0;n<t.length;n++){let a=t[n];if(this.options.extensions?.renderers?.[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(a.type)){i+=s||"";continue}}let o=a;switch(o.type){case"escape":{i+=r.text(o);break}case"html":{i+=r.html(o);break}case"link":{i+=r.link(o);break}case"image":{i+=r.image(o);break}case"checkbox":{i+=r.checkbox(o);break}case"strong":{i+=r.strong(o);break}case"em":{i+=r.em(o);break}case"codespan":{i+=r.codespan(o);break}case"br":{i+=r.br(o);break}case"del":{i+=r.del(o);break}case"text":{i+=r.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return i}},An=class{options;block;constructor(e){this.options=e||vr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?me.lex:me.lexInline}provideParser(e=this.block){return e?We.parse:We.parseInline}},MP=class{defaults=$u();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=We;Renderer=os;TextRenderer=Mu;Lexer=me;Tokenizer=as;Hooks=An;constructor(...e){this.use(...e)}walkTokens(e,t){let r=[];for(let i of e)switch(r=r.concat(t.call(this,i)),i.type){case"table":{let n=i;for(let a of n.header)r=r.concat(this.walkTokens(a.tokens,t));for(let a of n.rows)for(let o of a)r=r.concat(this.walkTokens(o.tokens,t));break}case"list":{let n=i;r=r.concat(this.walkTokens(n.items,t));break}default:{let n=i;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(a=>{let o=n[a].flat(1/0);r=r.concat(this.walkTokens(o,t))}):n.tokens&&(r=r.concat(this.walkTokens(n.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{let i={...r};if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let a=t.renderers[n.name];a?t.renderers[n.name]=function(...o){let s=n.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:t.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[n.level];a?a.unshift(n.tokenizer):t[n.level]=[n.tokenizer],n.start&&(n.level==="block"?t.startBlock?t.startBlock.push(n.start):t.startBlock=[n.start]:n.level==="inline"&&(t.startInline?t.startInline.push(n.start):t.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(t.childTokens[n.name]=n.childTokens)}),i.extensions=t),r.renderer){let n=this.defaults.renderer||new os(this.defaults);for(let a in r.renderer){if(!(a in n))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=r.renderer[o],l=n[o];n[o]=(...c)=>{let u=s.apply(n,c);return u===!1&&(u=l.apply(n,c)),u||""}}i.renderer=n}if(r.tokenizer){let n=this.defaults.tokenizer||new as(this.defaults);for(let a in r.tokenizer){if(!(a in n))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=r.tokenizer[o],l=n[o];n[o]=(...c)=>{let u=s.apply(n,c);return u===!1&&(u=l.apply(n,c)),u}}i.tokenizer=n}if(r.hooks){let n=this.defaults.hooks||new An;for(let a in r.hooks){if(!(a in n))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=r.hooks[o],l=n[o];An.passThroughHooks.has(a)?n[o]=c=>{if(this.defaults.async&&An.passThroughHooksRespectAsync.has(a))return(async()=>{let d=await s.call(n,c);return l.call(n,d)})();let u=s.call(n,c);return l.call(n,u)}:n[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await s.apply(n,c);return d===!1&&(d=await l.apply(n,c)),d})();let u=s.apply(n,c);return u===!1&&(u=l.apply(n,c)),u}}i.hooks=n}if(r.walkTokens){let n=this.defaults.walkTokens,a=r.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),n&&(s=s.concat(n.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return me.lex(e,t??this.defaults)}parser(e,t){return We.parse(e,t??this.defaults)}parseMarkdown(e){return(t,r)=>{let i={...r},n={...this.defaults,...i},a=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=e),n.async)return(async()=>{let o=n.hooks?await n.hooks.preprocess(t):t,s=await(n.hooks?await n.hooks.provideLexer(e):e?me.lex:me.lexInline)(o,n),l=n.hooks?await n.hooks.processAllTokens(s):s;n.walkTokens&&await Promise.all(this.walkTokens(l,n.walkTokens));let c=await(n.hooks?await n.hooks.provideParser(e):e?We.parse:We.parseInline)(l,n);return n.hooks?await n.hooks.postprocess(c):c})().catch(a);try{n.hooks&&(t=n.hooks.preprocess(t));let o=(n.hooks?n.hooks.provideLexer(e):e?me.lex:me.lexInline)(t,n);n.hooks&&(o=n.hooks.processAllTokens(o)),n.walkTokens&&this.walkTokens(o,n.walkTokens);let s=(n.hooks?n.hooks.provideParser(e):e?We.parse:We.parseInline)(o,n);return n.hooks&&(s=n.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(e,t){return r=>{if(r.message+=`
259
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+ot(r.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(r);throw r}}},mr=new MP;function O(e,t){return mr.parse(e,t)}O.options=O.setOptions=function(e){return mr.setOptions(e),O.defaults=mr.defaults,wv(O.defaults),O};O.getDefaults=$u;O.defaults=vr;function FP(...e){return mr.use(...e),O.defaults=mr.defaults,wv(O.defaults),O}O.use=FP;O.walkTokens=function(e,t){return mr.walkTokens(e,t)};O.parseInline=mr.parseInline;O.Parser=We;O.parser=We.parse;O.Renderer=os;O.TextRenderer=Mu;O.Lexer=me;O.lexer=me.lex;O.Tokenizer=as;O.Hooks=An;O.parse=O;var GH=O.options,JH=O.setOptions,UH=O.walkTokens,KH=O.parseInline;var YH=We.parse,XH=me.lex;B();tr();we();rt();L();var Fu=["outcome","scope","nonGoals","acceptanceExamples"],Rv=[...Fu,"constraints","decisions","openQuestions","verificationExpectations"];var VP=new Set(["nonGoals","decisions","openQuestions"]),$n=class extends Error{constructor(r,i,n){super(r);this.findings=i;this.change=n;this.name="NativeDocumentConstraintError"}findings;change},WP={maxFileBytes:qs};function zP(e){let t=new Map,r=null,i=[],n={marker:null,length:0},a=()=>{r!==null&&t.set(r,i.join(`
260
+ `).trim())};for(let o of e.split(/\r?\n/u)){let l=On(o,n)===null&&n.marker===null?/^# ([^#].*)$/u.exec(o):null;l?(a(),r=l[1].trim(),i=[]):r!==null&&i.push(o)}return a(),t}function qu(e){return{valid:e.length===0,findings:e}}function Vu(e){let t=[],r=0;for(;r<e.length;){let i=e.indexOf("<!--",r);if(i<0){t.push(e.slice(r));break}t.push(e.slice(r,i));let n=e.indexOf("-->",i+4);if(n<0){t.push(e.slice(i));break}r=n+3}return t.join("")}function Wu(e){return Vu(e).trim()}function jn(e){let t=Wu(e).split(/\r?\n/u),r=[],i={marker:null,length:0};for(let n of t)On(n,i)===null&&(i.marker===null&&/^\s*#{1,6}\s*$/u.test(n)||i.marker===null&&/^\s*#{1,6}\s+/u.test(n)||i.marker===null&&/^\s*(?:[-*+]\s*|\d+[.)]\s*)$/u.test(n)||r.push(n));return r.join(`
261
+ `).trim()}function GP(e){let t=jn(e).replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/gmu,"").replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim().toLocaleLowerCase("en-US");return/^(?:none|n\/a|not applicable|no(?:ne)?(?:\s+at\s+this\s+time)?|no\s+(?:additional\s+)?(?:non-goals?|decisions?|open\s+questions?|questions?)|无|无相关事项|没有(?:额外)?(?:非目标|决定|待解决问题)|不适用|暂无)[.!。;;::,,、 -]*$/iu.test(t)}function zu(e){let t=jn(e).replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/gmu,"").replace(/\s+/gu," ").trim();if(t.length===0)return!1;let r=t.replace(/[*_`]/gu,"").replace(/^\s*>+\s?/gmu,"").replace(/\s+/gu," ").trim();if(/^(?:<[^>\r\n]+>|\{\{[^}\r\n]+\}\})[.!。;;::,,、 -]*$/iu.test(r))return!0;let i=t.replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim();return/^(?:(?:todo|tbd|fixme)(?:\s*[::-]\s*.+)?|fill(?:\s+this\s+in)?(?:\s*[::-]\s*.+)?|placeholder(?:\s*[::-]\s*.+)?|待填写\S*|待补充\S*|<[^>]+>|\{\{[^}]+\}\})[.!。;;::,,、 -]*$/iu.test(i)}function _v(e,t){let r=[];return jn(e).length===0?r.push({code:"spec-document-empty",message:`Native target Spec is empty: ${t}. Add the complete target requirements or use an explicit no-product-behavior exemption in brief.md.`,path:t}):zu(e)&&r.push({code:"spec-document-placeholder",message:`Native target Spec contains only template placeholder content: ${t}. Replace it with complete target requirements.`,path:t}),qu(r)}function Gu(e){let t=new Set(["blocker","blocking","coverage","decision","open_question","question","requirement","requirements","source","source_coverage","state","status","决策","来源","覆盖","问题","状态","需求","阻塞"]),r={marker:null,length:0};for(let i of e.split(/\r?\n/u)){if(On(i,r)!==null||r.marker!==null)continue;let n=i.trim();if(/^(?:[-*+]\s+|\d+[.)]\s+)(?:\[[ xX]\]\s+)?\[blocking\](?=$|[\s::—-])/iu.test(n)||n.includes("|")&&n.split("|").some(o=>/^\s*\[blocking\](?=$|[\s::—-])/iu.test(o)))return!0;let a=n.match(/^([\p{L}\p{N}_./-]+)\s*[::]\s*\[blocking\](?=$|[\s::—-])/iu);if(a){let o=a[1]?.toLocaleLowerCase("en-US")??"";if(t.has(o)||/[./_-]/u.test(o))return!0}}return!1}function On(e,t){let r=/^ {0,3}(`{3,}|~{3,})/u.exec(e);if(r===null)return null;let i=r[1]??"",n=i[0];return t.marker===null?(t.marker=n,t.length=i.length,"opened"):n===t.marker&&i.length>=t.length&&e.trim()===i?(t.marker=null,t.length=0,"closed"):null}function JP(e){let t=Wu(e).split(/\r?\n/u),r={marker:null,length:0},i=-1;for(let n=0;n<t.length;n+=1){let a=t[n]??"";if(On(a,r)!==null||r.marker!==null)continue;let o=/^##\s+(.+)$/u.exec(a);if(o!==null){if(i===-1){Ah(o[1]??"")&&(i=n+1);continue}return t.slice(i,n).join(`
262
+ `)}}return i===-1?null:t.slice(i).join(`
263
+ `)}function UP(e){let t=new Map,r=null,i=[],n={marker:null,length:0},a=()=>{r!==null&&t.set(r,i.join(`
264
+ `).trim())};for(let o of Wu(e).split(/\r?\n/u)){if(On(o,n)!==null){r!==null&&i.push(o);continue}let s=n.marker===null?/^###\s+(.+)$/u.exec(o):null;s!==null?(a(),r=Ih(s[1]??""),i=[]):r!==null&&i.push(o)}return a(),t}function KP(e,t){let r=[],i=JP(e);if(i===null)return r.push({code:"brief-structure-missing",message:'Brief scope must include a "## Directory structure"/「## 目录结构」 section with the subsections Created/新建, Modified/修改, Deleted/删除, and Not created/明确不建',path:t}),r;let n=UP(i),a=[];for(let o of El){let s=n.get(o);(s===void 0||jn(s).length===0||zu(s))&&a.push(_h(o))}return a.length>0&&r.push({code:"brief-structure-subsection-missing",message:`Brief directory structure subsections are missing or empty: ${a.join(", ")}. Keep every heading and write "None"/「无」 when there is no content`,path:t}),r}async function Ju(e,t,r={}){let i=[],n;try{n=(await $({root:e,ref:t,maxBytes:WP.maxFileBytes})).text}catch(s){return qu([{code:"brief-missing",message:s.message,path:t}])}let a=new Map;for(let[s,l]of zP(n))a.set(Za(s)??s,l);for(let s of r.compact?Fu:Rv)a.has(s)||i.push({code:"brief-section-missing",message:`Missing brief section: ${s}`,path:t});let o=r.strict?Rv.filter(s=>!r.compact||a.has(s)):Fu;for(let s of o){let l=a.get(s)??"";jn(l).length===0?i.push({code:"brief-section-empty",message:`Brief section is empty: ${s}`,path:t}):zu(l)?i.push({code:"brief-section-placeholder",message:`Brief section contains only template placeholder content: ${s}`,path:t}):r.strict&&!VP.has(s)&&GP(l)&&i.push({code:"brief-section-empty",message:`Brief section must describe the confirmed work instead of declaring no items: ${s}`,path:t})}return r.strict&&r.structure&&i.push(...KP(a.get("scope")??"",t)),Gu(n)&&i.push({code:"brief-blocking-question",message:"Brief has a blocking open question",path:t}),qu(i)}we();K();var ER=Ct(ut(),1);nt();we();K();be();L();gt();us();us();zt();Vt();nt();yo();B();K();ds();Q();L();Lv();zt();Vt();Xu();nt();be();Xu();dn();L();var fs=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};nt();be();Q();zt();Vt();function Qu(e){return D("comet.native.parent-contract.v1",{acceptance:e.acceptance.map(({id:t,source:r,text:i})=>({id:t,source:r,text:i})),children:e.children})}jo();gt();dr();gi();Vn();function Vv(e){return e.state_version+1}function CR(e){return e.map(t=>({...t,result:"pending",reason:null}))}function PR(e){return{goal_cycle:e.state.loop.goal_cycle,iteration:e.state.loop.iteration,attempt:e.state.loop.attempt,outcome:e.outcome,unresolved_ids:e.unresolvedIds??[],summary:Be(e.summary),completed_at:e.completedAt}}function ps(e){let t=Ee(e.state);if(t.phase!=="verify"&&t.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let r=e.failureBudget,i=r?t.loop.failed_iteration_count+1:t.loop.failed_iteration_count,n=r!==void 0&&i>=r.maxVerifyFailures,a=(e.now??new Date).toISOString(),o=ur(t,PR({state:t,outcome:"recovery",summary:e.reason,completedAt:a})),s=new Set(t.loop.previous_unresolved_ids),l=s.size===0?CR(t.acceptance):t.acceptance.map(c=>s.has(c.id)?{...c,result:"pending",reason:null}:c);return n?Ee({...o,phase:"verify",status:"await-user",state_version:Vv(t),verification_result:"fail",builder_handoff:t.builder_handoff,blockers:[{owner:"user",reason:Be(`Native Runtime checks failed at Builder handoff and reached the configured failed iteration limit: ${e.reason}`),acceptance_ids:[...s],resolution_action:"await-user"}],loop:{...t.loop,stage:"await-user",failed_iteration_count:i,execution_failure_count:0,stop_reason:"budget",next_action:"resolve-loop-stop"}}):Ee({...o,phase:"build",status:"active",state_version:Vv(t),verification_result:"pending",verification_report:null,verification:null,builder_handoff:t.builder_handoff,blockers:[],acceptance:l,loop:{...t.loop,stage:"repairing",iteration:t.loop.iteration+1,attempt:0,execution_failure_count:0,failed_iteration_count:i,stop_reason:void 0,next_action:"submit-builder-candidate"}})}Q();$o();tu();gt();dr();B();tr();gi();L();tr();li();be();var ad=Ct(ut(),1);ft();var r1=new Set("a an and are as at be by for from in is it of on or that the this to with you your".split(" "));var Qv=5,qR=600,c1=256*1024,VR=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,WR=/^[A-Za-z0-9][A-Za-z0-9._-]*$/u;var zR=/^[a-f0-9]{64}$/iu;function Zv(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Wt(e,t,r=4096){if(typeof e!="string"||e.trim().length===0||e.length>r)throw new Error(`${t} must be a non-empty string within the association limit`);return e}function nd(e,t){let r=Wt(e,t).replaceAll("\\","/");if(r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").some(i=>i===""||i==="."||i===".."))throw new Error(`${t} must be a project-relative path`);return r}function GR(e,t){let r=Wt(e,t,64).toLowerCase();if(!zR.test(r))throw new Error(`${t} must be a SHA-256 hash`);return r}function JR(e,t){let r=`Capability association evidence[${t}]`,i=Zv(e,r),n=Object.keys(i).filter(a=>!new Set(["source","kind","title","snippet"]).has(a));if(n.length>0)throw new Error(`${r} has unknown field(s): ${n.join(", ")}`);return{source:nd(i.source,`${r}.source`),kind:Wt(i.kind,`${r}.kind`,128),...i.title===void 0?{}:{title:Wt(i.title,`${r}.title`)},...i.snippet===void 0?{}:{snippet:Wt(i.snippet,`${r}.snippet`,qR)}}}function eg(e){let t=typeof e=="string"?(()=>{if(e.length>65536)throw new Error("Capability association exceeds the size limit");let c=(0,ad.parseDocument)(e,{uniqueKeys:!0});if(c.errors.length>0)throw new Error(c.errors[0].message);return c.toJS({mapAsMap:!1})})():e,r=Zv(t,"Capability association"),i=Object.keys(r).filter(c=>!new Set(["schema","status","workflow","capability","current_spec","current_hash","confidence","query","reason","historical_sources","evidence"]).has(c));if(i.length>0)throw new Error(`Capability association has unknown field(s): ${i.join(", ")}`);if(r.schema!=="comet.capability-association.v1")throw new Error("Unsupported capability association schema");let n=r.workflow;if(n!=="native"&&n!=="classic")throw new Error("Capability association workflow is invalid");let a=UR(Wt(r.capability,"Capability association capability"),n);if(!Array.isArray(r.historical_sources))throw new Error("Capability association historical_sources must be an array");let o=r.historical_sources.map((c,u)=>nd(c,`Capability association historical_sources[${u}]`));if(!Array.isArray(r.evidence)||r.evidence.length>Qv)throw new Error(`Capability association evidence must contain at most ${Qv} entries`);let s=r.status;if(s!=="suggested"&&s!=="explicit")throw new Error("Capability association status is invalid");let l=r.confidence;if(l!=="high"&&l!=="medium"&&l!=="low")throw new Error("Capability association confidence is invalid");return{schema:"comet.capability-association.v1",status:s,workflow:n,capability:a,current_spec:nd(r.current_spec,"Capability association current_spec"),current_hash:GR(r.current_hash,"Capability association current_hash"),confidence:l,...r.query===void 0?{}:{query:Wt(r.query,"Capability association query")},reason:Wt(r.reason,"Capability association reason",2048),historical_sources:o,evidence:r.evidence.map(JR)}}function UR(e,t){let r=e.replaceAll("\\","/").replace(/^\/+|\/+$/gu,""),i=r.split("/"),n=t==="native"?VR:WR;if(!r||i.some(a=>!n.test(a)))throw new Error(`Invalid ${t} capability: ${e}`);return i.join("/")}gt();dr();Vt();var ZR=eo("en",{compact:!0}),od="capability-association.yaml";function gs(e,t=!1){if(t){let i=n=>{if(Array.isArray(n))return n.filter(a=>a?.type!=="space").map(i);if(n&&typeof n=="object"){let a=n;return Object.fromEntries(Object.entries(a).filter(([o])=>o!=="raw"&&!(o==="text"&&Array.isArray(a.tokens))).map(([o,s])=>[o,o==="text"&&a.type==="text"&&typeof s=="string"?s.replace(/[\t ]*\n[\t ]*/gu," "):i(s)]))}return n};return JSON.stringify(i(me.lex(e.replace(/\r\n?/gu,`
265
+ `))))}let r=e.replace(/\r\n?/gu,`
266
+ `).split(`
267
+ `);for(;r.length>0&&r.at(-1)?.trim().length===0;)r.pop();return`${r.map(i=>i.replace(/[\t ]+$/gu,"")).join(`
183
268
  `)}
184
- `}function lC(e){let t=e.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/u,"").replace(/\s+/gu," ").trim();if(t.length===0||/^(?:<[^>\r\n]+>|\{\{[^}\r\n]+\}\})[.!:: -]*$/iu.test(t))return!0;let r=t.replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim();return/^(?:todo|tbd|fixme)(?:\s*[::-]|\s*$)/iu.test(r)||/^(?:fill(?:\s+this\s+in)?|placeholder)\b/iu.test(r)||/^(?:待填写|待补充)/u.test(r)?!0:/^(?:(?:todo|tbd|fixme)\b|fill(?:\s+this\s+in)?\b|placeholder\b|documentation[- ]only\b|no\s+product\s+behavior\s+change\b|待填写|待补充|仅文档|不改变产品行为|不涉及产品行为)[.!。;;::,,、 -]*$/iu.test(r)}function uC(e){let t=[],r=!1;for(let i of Bl(e).split(/\r?\n/u)){if(/^\s*(?:```|~~~)/u.test(i)){r=!r;continue}!r&&!/^\s*#{1,6}\s+/u.test(i)&&t.push(i)}return t.some(i=>{let n=/(?:no\s+product\s+behavior\s+change|documentation[- ]only|不改变产品行为|不涉及产品行为|仅文档)\s*[::]\s*(.*)$/iu.exec(i);return n!==null&&!lC(n[1]??"")})}async function xm(e){let t=le(e.paths,e.state.name),r=[...(await Fl(t,e.state.brief,{strict:!0})).findings],i="";try{i=(await T({root:t,ref:e.state.brief,maxBytes:null,includeHash:!1})).text}catch{}let n=e.specChanges??e.state.spec_changes,a=n.filter(({operation:c})=>c!=="remove"),o=e.state.spec_changes.filter(({operation:c})=>c!=="remove"),s=new Set(a.map(({capability:c})=>c));if(e.specChanges!==void 0)for(let c of o)s.has(c.capability)||r.push({code:"spec-document-missing",message:`Previously declared target Spec is missing: specs/${c.capability}/spec.md. Restore the complete file or record the intended capability deletion as a formal remove entry.`,path:`specs/${c.capability}/spec.md`});let l=n.length>0&&n.every(({operation:c})=>c==="remove");a.length===0&&o.length===0&&!l&&!uC(i)&&r.push({code:"spec-exemption-missing",message:"This change declares no target Spec. Add a complete target Spec, or record a concrete reason such as “No product behavior change: documentation-only wording.” in brief.md.",path:e.state.brief});for(let c of a){let u=`specs/${c.capability}/spec.md`;if(c.source!==u){r.push({code:"spec-source-path-invalid",message:`Target Spec must be staged at ${u}.`,path:c.source??u});continue}try{let d=(await T({root:t,ref:u,maxBytes:null,includeHash:!1})).text;r.push(...Qh(d,u).findings)}catch(d){r.push({code:"spec-document-missing",message:`Target Spec cannot be read: ${d.message}. Restore the complete file at ${u}.`,path:u})}}return{valid:r.length===0,findings:r}}function Ao(e){let t=e.expected;if(t){if(e.state.state_version!==t.stateVersion)throw new Error(`Native continuation is stale: the change moved on since the referenced response (current phase ${e.state.phase}, next action ${e.state.loop.next_action}, state version ${e.state.state_version}). Run comet native status ${e.state.name} --json and execute its commandAlternatives with --expected-state-version ${e.state.state_version} --expected-action ${e.state.loop.next_action}.`);if(t.action!==e.action)throw new Error(`Native continuation expected ${t.action} cannot be used for ${e.action}`)}}async function Cm(e){let t=le(e.paths,e.state.name),r=ft.join(t,"specs"),i=new Map(e.state.spec_changes.filter(({operation:o})=>o==="remove").map(o=>[o.capability,o])),n;try{n=await Vr.readdir(r,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")n=[];else throw o}let a=[];for(let o of n.sort((s,l)=>s.name.localeCompare(l.name,"en"))){if(o.isSymbolicLink())throw new Error(`Native spec capability is unsafe: ${o.name}`);if(!o.isDirectory())continue;if(!en.test(o.name))throw new Error(`Invalid Native capability: ${o.name}`);if(i.has(o.name))throw new Error(`Capability ${o.name} cannot be proposed and removed together`);let s=`specs/${o.name}/spec.md`,l=ft.join(t,...s.split("/")),c=await Vr.lstat(l);if(!c.isFile()||c.isSymbolicLink())throw new Error(`Native proposed spec must be a regular file: ${s}`);let u=ft.join(e.paths.specsDir,o.name,"spec.md"),d="create",f=null;try{let v=await Vr.lstat(u);if(!v.isFile()||v.isSymbolicLink())throw new Error(`Canonical Native spec is unsafe: ${o.name}`);d="modify",f=rt((await T({root:e.paths.specsDir,ref:`${o.name}/spec.md`,maxBytes:null,includeHash:!1})).text)}catch(v){if(v.code!=="ENOENT")throw v}let h=`specs/${o.name}/${Xp}`,m=ft.join(t,...h.split("/")),p={};try{let v=await Vr.lstat(m);if(!v.isFile()||v.isSymbolicLink())throw new Error(`Native delta manifest must be a regular file: ${h}`);let g=await T({root:t,ref:h,maxBytes:null,includeHash:!1}),w=Li(g.text);if(w.capability!==o.name)throw new Error(`Native delta capability ${w.capability} does not match directory ${o.name}`);let N=f??rt(""),k=e.state.spec_changes.find(E=>E.capability===o.name);if(k?.delta_source!==void 0){if(k.base_hash!==w.base_hash)throw new Error(`Native delta base changed for ${o.name}; explicit conversion is required`)}else if(w.base_hash!==N)throw new Error(`Native delta base_hash does not match the current total Spec for ${o.name}`);p={delta_source:h,base_hash:w.base_hash}}catch(v){if(v.code!=="ENOENT")throw v}a.push({capability:o.name,operation:d,source:s,...p})}return a.push(...i.values()),a.sort((o,s)=>o.capability.localeCompare(s.capability,"en"))}async function ru(e){let t=le(e.paths,e.state.name),r=await T({root:t,ref:"brief.md",maxBytes:null,includeHash:!1});if(Ml(r.text))throw new Error("Brief has a blocking open question");let i=[],n=[];for(let o of e.specChanges){if(o.source===null){n.push({...o,contentHash:null});continue}let s=await T({root:t,ref:o.source,maxBytes:null,includeHash:!1}),l=s.text,c=null;if(o.delta_source){let u=await T({root:t,ref:o.delta_source,maxBytes:null,includeHash:!1}),d=Li(u.text);l=th(s.text,d);let f="";try{f=(await T({root:e.paths.specsDir,ref:`${o.capability}/spec.md`,maxBytes:null,includeHash:!1})).text}catch(h){if(h.code!=="ENOENT")throw h}if(rt(f)===d.base_hash){let h=ih({baselineMarkdown:f,delta:d,allowAlreadyApplied:!0});if(rt(s.text)!==h.result_hash)throw new Error(`Native full target Spec does not match delta result for ${o.capability}; update the complete target before confirming Shape`)}c=O("comet.native.shape-artifact-content.v1",_o(u.text))}i.push({capability:o.capability,source:s.ref,markdown:l}),n.push({...o,contentHash:O("comet.native.shape-artifact-content.v1",_o(s.text)),...c===null?{}:{deltaContentHash:c}})}let a=null;try{let o=await T({root:t,ref:eu,maxBytes:65536,includeHash:!1}),s=Sm(o.text);if(s.workflow!=="native")throw new Error("Native capability association must use the native workflow");if(!e.specChanges.some(({capability:u})=>u===s.capability))throw new Error(`Native capability association ${s.capability} is not declared by this change`);let c=ft.relative(e.paths.projectRoot,ft.join(e.paths.specsDir,s.capability,"spec.md")).replaceAll(ft.sep,"/");if(s.current_spec!==c)throw new Error(`Native capability association points to ${s.current_spec}, expected ${c}`);a=O("comet.native.shape-artifact-content.v1",_o(o.text))}catch(o){if(o.code!=="ENOENT")throw o}return{acceptance:Ua({briefMarkdown:r.text,specs:i}),formalHash:O("comet.native.shape-formal-artifacts.v1",{brief:{source:r.ref,contentHash:O("comet.native.shape-artifact-content.v1",_o(r.text))},specs:n,association:{source:eu,contentHash:a}})}}function iu(e){return O("comet.native.shape-confirmation.v1",{formalHash:e.formalHash,childrenHash:e.childrenHash,coordinationMode:e.coordinationMode??null})}async function Pm(e){if(e.state.document_constraints_version===1){let c=await xm(e);if(!c.valid){let u=c.findings[0];return{drifted:!0,reason:u?`Native formal documents are invalid (${u.code}${u.path?`: ${u.path}`:""})`:"Native formal documents are invalid"}}}let t=await Cm(e),r=e.ignoreSpecOperationFor??(e.state.children_contract_hash?new Set(e.state.spec_changes.map(({capability:c})=>c)):void 0);if(!(t.length===e.state.spec_changes.length&&t.every((c,u)=>{let d=e.state.spec_changes[u];return d!==void 0&&c.capability===d.capability&&c.source===d.source&&c.delta_source===d.delta_source&&c.base_hash===d.base_hash&&(c.operation===d.operation||r?.has(c.capability)===!0)})))return{drifted:!0,reason:"Native target specification declarations changed"};let n;try{n=await ru({...e,specChanges:t})}catch{return{drifted:!0,reason:"Native Shape artifacts changed or became invalid"}}let{acceptance:a}=n,o=e.state.acceptance.map(({source:c,text:u})=>({source:c,text:u}));if(!yl(o,a))return{drifted:!0,reason:"Native confirmed acceptance criteria changed"};let s;try{s=await nr({changeDir:le(e.paths,e.state.name),acceptanceIds:a.map(({id:c})=>c),validation:ir({...e.state,acceptance:a})})}catch{return{drifted:!0,reason:"Native child declarations changed"}}return e.state.phase==="shape"&&e.state.status==="await-user"&&e.state.loop.next_action==="confirm-shape"&&e.state.shape_confirmation_hash===void 0?{drifted:!0,reason:"Native Shape confirmation fingerprint is missing"}:e.state.shape_confirmation_hash!==void 0&&iu({formalHash:n.formalHash,childrenHash:s?.hash??null,coordinationMode:e.state.coordination_mode})!==e.state.shape_confirmation_hash?{drifted:!0,reason:"Native Shape artifacts changed"}:(s?Gl({acceptance:a,children:s.contract}):null)===(e.state.children_contract_hash??null)?{drifted:!1,reason:null}:{drifted:!0,reason:"Native child declarations changed"}}async function qr(e){let t=await Pm(e);if(!t.drifted)return;let r=t.reason??"Native confirmed requirements changed";throw await Io({paths:e.paths,state:e.state,reason:r,keepFailureBudget:!0}),new Error(`${r}; Native change returned to Shape and requires confirmation`)}async function nu(e){return B(e.paths,`sync spec references ${e.name}`,async()=>{let t=await Ne(e.paths,e.name);if(t.state_version!==e.expectedStateVersion)throw new Error("Native spec sync state version is stale");if(t.archived||!["build","verify","archive"].includes(t.phase)||t.children_contract_hash)throw new Error("Native spec sync requires a confirmed ordinary active change; revise requirements in Shape otherwise");if(!en.test(e.capability)||!e.reason.trim()||!e.actor.trim())throw new Error("Native spec sync requires capability, actor and reason");await qr({paths:e.paths,state:t});let r=t.spec_changes.find(({capability:m,operation:p})=>m===e.capability&&p!=="remove");if(!r?.source)throw new Error("Stage this capability in the current change and confirm Shape before syncing references");let i=new Set(e.affectedAcceptanceIds);if(i.size===0||[...i].some(m=>!t.acceptance.some(p=>p.id===m))||t.acceptance.some(({source:m,id:p})=>m===r.source&&!i.has(p)))throw new Error("Native spec sync must cover the affected spec acceptance IDs");if(e.replacements.length===0||e.replacements.some(({from:m,to:p})=>!/^[A-Za-z0-9_./#%-]+$/u.test(m)||!/^[A-Za-z0-9_./#%-]+$/u.test(p)||m===p)||new Set(e.replacements.map(({from:m})=>m)).size!==e.replacements.length)throw new Error("Native spec sync only accepts unique local Markdown reference replacements");let n=le(e.paths,t.name),a=await T({root:n,ref:r.source,maxBytes:null,includeHash:!1}),o=new Map(e.replacements.map(({from:m,to:p})=>[m,p])),s=new Set,l=null,c=!1,u=a.text.split(/(?<=\n)/u).map(m=>{let p=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(m.trimEnd());return p?(l?p[1][0]===l.marker&&p[1].length>=l.length&&!p[2].trim()&&(l=null):l={marker:p[1][0],length:p[1].length},m):/^(?:\s|>|[-+*]\s|\d+[.)]\s)/u.test(m)?m:(m.includes("<!--")&&(c=!0),c?(m.includes("-->")&&(c=!1),m):l||/^(?: {4}|\t)/u.test(m)||m.includes("`")?m:m.replace(/(?<!!)\[([^\]\n]+)\]\(([^()\s]+)\)/gu,(v,g,w)=>{let N=o.get(w);return N?(s.add(w),`[${g}](${N})`):v}))}).join("");if(s.size!==o.size)throw new Error("Native spec sync replacement is not an existing prose Markdown reference; use revise-requirements for semantic changes");let d=ft.join(n,r.source);await ue(d,u,{containedRoot:e.paths.nativeRoot});let f=!1,h=null;try{let m=await ru({paths:e.paths,state:t,specChanges:t.spec_changes});if(!yl(t.acceptance,m.acceptance))throw new Error("Reference change affects acceptance; revise requirements in Shape");let p=x=>sC("sha256").update(x).digest("hex"),v=JSON.stringify({schema:"comet.native.spec-sync.v1",change:t.name,actor:e.actor,reason:e.reason,source:r.source,beforeHash:p(a.text),afterHash:p(u),replacements:e.replacements,affectedAcceptanceIds:[...i],requiresConfirmation:!1,at:new Date().toISOString()}),g=p(v),w=await Yl({paths:e.paths,name:t.name,hash:g,text:v,onCreated:()=>{h=g}}),N={...t,loop:{...t.loop,previous_unresolved_ids:[...new Set([...t.loop.previous_unresolved_ids,...i])]}},k=t.phase==="build"?{...N,state_version:t.state_version+1,acceptance:t.acceptance.map(x=>i.has(x.id)?{...x,result:"pending",reason:null}:x)}:xo({state:N,reason:`Spec reference sync: ${e.reason}`});k=Xt(k,{goal_cycle:t.loop.goal_cycle,iteration:t.loop.iteration,attempt:t.loop.attempt,outcome:"recovery",unresolved_ids:[...i],summary:je(`Spec reference sync by ${e.actor}: ${e.reason}; ${w}`),completed_at:new Date().toISOString()}),k.shape_confirmation_hash=iu({formalHash:m.formalHash,childrenHash:null,coordinationMode:t.coordination_mode});let E=await ut({paths:e.paths,previous:t,next:k});return f=!0,await De(ye(e.paths,t.name),He({portableState:E,projectRoot:e.paths.projectRoot,branch:lt(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),E}catch(m){if(!f)try{(await Ne(e.paths,t.name)).state_version===t.state_version&&(await ue(d,a.text,{containedRoot:e.paths.nativeRoot}),h&&await Nm({paths:e.paths,name:t.name,hash:h}))}catch{}throw m}})}async function au(e){if(!en.test(e.capability))throw new Error(`Invalid Native capability: ${e.capability}`);return B(e.paths,`remove portable spec ${e.capability}`,async()=>{let t=await Ne(e.paths,e.name);if(t.archived)throw new Error(`Native change ${t.name} is already archived`);let r=t.spec_changes.filter(({capability:a})=>a!==e.capability),i={...t,phase:"shape",status:"active",state_version:t.state_version+1,spec_changes:[...r,{capability:e.capability,operation:"remove",source:null}].sort((a,o)=>a.capability.localeCompare(o.capability,"en")),acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,history:[],history_overflow:{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}},loop:{stage:"shape",goal_cycle:t.loop.goal_cycle+(t.phase==="shape"?0:1),iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"prepare-shape-confirmation"}};delete i.shape_confirmation_hash,delete i.children_contract_hash;let n=await ut({paths:e.paths,previous:t,next:i});return await De(ye(e.paths,t.name),He({portableState:n,projectRoot:e.paths.projectRoot,branch:lt(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),n})}async function ou(e){return B(e.paths,`disassociate portable capability ${e.name}`,async()=>{let t=await Ne(e.paths,e.name);if(Ao({state:t,expected:e.expectedContinuation,action:"disassociate-capability"}),t.archived)throw new Error(`Native change ${t.name} is already archived`);let r=ft.join(le(e.paths,e.name),eu),i;try{i=await Vr.lstat(r)}catch(n){if(n.code==="ENOENT")return t;throw n}if(!i.isFile()||i.isSymbolicLink())throw new Error("Native capability association must be a regular file");return await Vr.rm(r),Io({paths:e.paths,state:t,reason:"Capability association revoked through comet native spec disassociate"})})}async function Io(e){let{state:t}=e;if(t.archived)throw new Error(`Native change ${t.name} is already archived`);let i={...Xt(t,{goal_cycle:t.loop.goal_cycle,iteration:t.loop.iteration,attempt:t.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:je(e.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:t.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:t.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:e.keepFailureBudget?t.loop.failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"prepare-shape-confirmation"}};delete i.shape_confirmation_hash,delete i.children_contract_hash;let n=await ut({paths:e.paths,previous:t,next:i});return await De(ye(e.paths,t.name),He({portableState:n,projectRoot:e.paths.projectRoot,branch:lt(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),n}he();K();$t();Tt();ot();Qt();ct();$a();J();So();K();Qt();H();var oL=1024*1024*1024;K();ln();Ur();Tt();K();Tt();K();ao();ot();H();var _m=["evidence.md","repair.md","archive.md","checkpoint.md"],hC="verification.md";async function mC(e,t){let r=await Rl(e,{kind:"migration",change:t});return r?.kind==="migration"?r.journal:null}async function Am(e,t){await nn.mkdir(e.transactionsDir,{recursive:!0}),await Q(no(e,{kind:"migration",change:t.change}),t,{containedRoot:e.runtimeDir})}async function Im(e,t,r={}){let i=r.removeVerificationReport===!1?_m:[..._m,hC];await Promise.all([nn.rm(_e(e,t),{recursive:!0,force:!0}),nn.rm(Uc(e,t),{recursive:!0,force:!0}),...i.map(n=>nn.rm(pC.join(Ue(e,t),n),{force:!0}))])}async function Tm(e,t){await De(ye(e,t.name),He({portableState:t,projectRoot:e.projectRoot}),{containedRoot:e.runtimeDir})}async function jm(e,t){try{let r=await Ui(e,t);if(r?.schema==="comet.native.workspace.v3")return{isolation:r.isolation,change_branch:r.changeBranch,target_branch:r.targetBranch,finish:r.finish}}catch{}return{isolation:"current",change_branch:null,target_branch:null,finish:null}}function $m(e,t){if(t.isolation==="current"&&t.change_branch===null)return;let r=ke(e.projectRoot);if(!r.isGitWorktree)throw new Error("Native legacy migration requires its bound Git branch or worktree");if(r.currentBranch!==t.change_branch)throw new Error(`Native legacy migration expected branch ${t.change_branch??"(missing)"}, current branch is ${r.currentBranch??"(detached)"}`);if(t.isolation==="worktree"&&!r.isSecondaryWorktree)throw new Error("Native legacy migration requires its bound linked worktree")}async function vC(e){let t=Ue(e.paths,e.state.name),r=await T({root:t,ref:e.state.brief,maxBytes:null,includeHash:!1}),i=[];for(let n of e.state.spec_changes){if(n.operation==="remove"||!n.source)continue;let a=await T({root:t,ref:n.source,maxBytes:null,includeHash:!1});i.push({capability:n.capability,source:a.ref,markdown:a.text})}try{return Ua({briefMarkdown:r.text,specs:i})}catch(n){if(e.state.phase==="shape"&&n.message.includes("at least one acceptance"))return[];throw n}}async function Om(e,t){let r=await Vh(e,t);if(r.status==="runtime-incompatible")throw new We(r.schema,r.minimumRuntimeVersion);if(!r.state)throw new Error(`Native legacy change ${t} is unreadable`);return r.state}async function Hm(e){return B(e.paths,`migrate ${e.name} to portable Native`,async()=>{let t=await mC(e.paths,e.name),r=await er(e.paths,e.name)?await at(Ke(e.paths,e.name)):null;if(!t&&r)return await Im(e.paths,e.name,{removeVerificationReport:!1}),await Tm(e.paths,r),r;let i=null,n=null;for(t||(i=await Om(e.paths,e.name),n=await jm(e.paths,e.name),$m(e.paths,n),t={schema:ro,id:fC(),change:i.name,fromSchema:i.schema,status:"prepared",createdAt:(e.now??new Date).toISOString()},await Am(e.paths,t));;){let a=bh(t);if(a.action==="done")break;a.action==="commit-portable-yaml"?r||(i??=await Om(e.paths,e.name),n??=await jm(e.paths,e.name),$m(e.paths,n),r=Nh({state:i,acceptance:await vC({paths:e.paths,state:i}),workspace:n,migratedAt:e.now}),await to(Ke(e.paths,e.name),r,{containedRoot:e.paths.nativeRoot})):a.action==="cleanup-legacy-runtime"?await Im(e.paths,e.name):a.action==="commit-transaction"&&(r??=await at(Ke(e.paths,e.name)),await Tm(e.paths,r)),t={...t,status:a.nextStatus},await Am(e.paths,t)}return await nn.rm(no(e.paths,{kind:"migration",change:e.name}),{force:!0}),r??at(Ke(e.paths,e.name))},{allowedPortableTransaction:{kind:"migration",change:e.name}})}Ti();import on from"path";import{realpathSync as aP}from"fs";function Dm(e,t){let r=u=>u!==null&&typeof u=="object"&&!Array.isArray(u)?u:{},i=r(e),n=r(i.entry),a=r(i.state??n.state??i),o=r(i.preparation??i.workspace??n.workspace),s=r(i.continuation??n.continuation),l=typeof o.projectRoot=="string"&&o.projectRoot!=="."?o.projectRoot:t??null,c=a.stateVersion??a.state_version;return{phase:typeof a.phase=="string"?a.phase:null,status:typeof a.status=="string"?a.status:null,stateVersion:typeof c=="number"?c:null,workspace:{cwd:l},continuation:Object.keys(s).length?{...s,cwd:l}:null}}var pt={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Lm(e){return e?e.command?`${pt.next} ${e.command}`:e.ask_user?`${pt.next} ${e.ask_user}`:null:null}function Bm(e,t){let r=[e.summary],i=Lm(e.next);return i&&r.push(i),e.user_message&&r.push("",pt.relay,e.user_message),t!==void 0&&r.push("",pt.details,JSON.stringify(t,null,2)),`${r.join(`
269
+ `}function e_(e){let t=e.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/u,"").replace(/\s+/gu," ").trim();if(t.length===0||/^(?:<[^>\r\n]+>|\{\{[^}\r\n]+\}\})[.!:: -]*$/iu.test(t))return!0;let r=t.replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim();return/^(?:todo|tbd|fixme)(?:\s*[::-]|\s*$)/iu.test(r)||/^(?:fill(?:\s+this\s+in)?|placeholder)\b/iu.test(r)||/^(?:待填写|待补充)/u.test(r)?!0:/^(?:(?:todo|tbd|fixme)\b|fill(?:\s+this\s+in)?\b|placeholder\b|documentation[- ]only\b|no\s+product\s+behavior\s+change\b|待填写|待补充|仅文档|不改变产品行为|不涉及产品行为)[.!。;;::,,、 -]*$/iu.test(r)}function t_(e){let t=[],r=!1;for(let i of Vu(e).split(/\r?\n/u)){if(/^\s*(?:```|~~~)/u.test(i)){r=!r;continue}!r&&!/^\s*#{1,6}\s+/u.test(i)&&t.push(i)}return t.some(i=>{let n=/(?:no\s+product\s+behavior\s+change|documentation[- ]only|不改变产品行为|不涉及产品行为|仅文档)\s*[::]\s*(.*)$/iu.exec(i);return n!==null&&!e_(n[1]??"")})}async function rg(e){let t=he(e.paths,e.state.name),r=e.state.document_constraints_version,i=r===2||r===3,n=r===3,a=[...(await Ju(t,e.state.brief,{strict:!0,compact:i,structure:n})).findings],o="";try{o=(await $({root:t,ref:e.state.brief,maxBytes:null,includeHash:!1})).text}catch{}let s=e.specChanges??e.state.spec_changes,l=s.filter(({operation:f})=>f!=="remove"),c=e.state.spec_changes.filter(({operation:f})=>f!=="remove"),u=new Set(l.map(({capability:f})=>f));if(e.specChanges!==void 0)for(let f of c)u.has(f.capability)||a.push({code:"spec-document-missing",message:`Previously declared target Spec is missing: specs/${f.capability}/spec.md. Restore the complete file or record the intended capability deletion as a formal remove entry.`,path:`specs/${f.capability}/spec.md`});let d=s.length>0&&s.every(({operation:f})=>f==="remove");l.length===0&&c.length===0&&!d&&!t_(o)&&a.push({code:"spec-exemption-missing",message:"This change declares no target Spec. Add a complete target Spec, or record a concrete reason such as “No product behavior change: documentation-only wording.” in brief.md.",path:e.state.brief});for(let f of l){let h=`specs/${f.capability}/spec.md`;if(f.source!==h){a.push({code:"spec-source-path-invalid",message:`Target Spec must be staged at ${h}.`,path:f.source??h});continue}try{let m=(await $({root:t,ref:h,maxBytes:null,includeHash:!1})).text;a.push(..._v(m,h).findings)}catch(m){a.push({code:"spec-document-missing",message:`Target Spec cannot be read: ${m.message}. Restore the complete file at ${h}.`,path:h})}}return{valid:a.length===0,findings:a}}function ws(e){let t=e.expected;if(t){if(e.state.state_version!==t.stateVersion)throw new Error(`Native continuation is stale: the change moved on since the referenced response (current phase ${e.state.phase}, next action ${e.state.loop.next_action}, state version ${e.state.state_version}). Run comet native status ${e.state.name} --json and execute its commandAlternatives with --expected-state-version ${e.state.state_version} --expected-action ${e.state.loop.next_action}.`);if(t.action!==e.action)throw new Error(`Native continuation expected ${t.action} cannot be used for ${e.action}`)}}async function ig(e){let t=he(e.paths,e.state.name),r=St.join(t,"specs"),i=new Map(e.state.spec_changes.filter(({operation:o})=>o==="remove").map(o=>[o.capability,o])),n;try{n=await ui.readdir(r,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")n=[];else throw o}let a=[];for(let o of n.sort((s,l)=>s.name.localeCompare(l.name,"en"))){if(o.isSymbolicLink())throw new Error(`Native spec capability is unsafe: ${o.name}`);if(!o.isDirectory())continue;if(!Rn.test(o.name))throw new Error(`Invalid Native capability: ${o.name}`);if(i.has(o.name))throw new Error(`Capability ${o.name} cannot be proposed and removed together`);let s=`specs/${o.name}/spec.md`,l=St.join(t,...s.split("/")),c=await ui.lstat(l);if(!c.isFile()||c.isSymbolicLink())throw new Error(`Native proposed spec must be a regular file: ${s}`);let u=St.join(e.paths.specsDir,o.name,"spec.md"),d="create",f=null;try{let v=await ui.lstat(u);if(!v.isFile()||v.isSymbolicLink())throw new Error(`Canonical Native spec is unsafe: ${o.name}`);d="modify",f=pt((await $({root:e.paths.specsDir,ref:`${o.name}/spec.md`,maxBytes:null,includeHash:!1})).text)}catch(v){if(v.code!=="ENOENT")throw v}let h=`specs/${o.name}/${hm}`,m=St.join(t,...h.split("/")),p={};try{let v=await ui.lstat(m);if(!v.isFile()||v.isSymbolicLink())throw new Error(`Native delta manifest must be a regular file: ${h}`);let g=await $({root:t,ref:h,maxBytes:null,includeHash:!1}),w=fn(g.text);if(w.capability!==o.name)throw new Error(`Native delta capability ${w.capability} does not match directory ${o.name}`);let b=f??pt(""),k=e.state.spec_changes.find(x=>x.capability===o.name);if(k?.delta_source!==void 0){if(k.base_hash!==w.base_hash)throw new Error(`Native delta base changed for ${o.name}; explicit conversion is required`)}else if(w.base_hash!==b)throw new Error(`Native delta base_hash does not match the current total Spec for ${o.name}`);p={delta_source:h,base_hash:w.base_hash}}catch(v){if(v.code!=="ENOENT")throw v}a.push({capability:o.name,operation:d,source:s,...p})}return a.push(...i.values()),a.sort((o,s)=>o.capability.localeCompare(s.capability,"en"))}async function cd(e){let t=he(e.paths,e.state.name),r=await $({root:t,ref:"brief.md",maxBytes:null,includeHash:!1});if(Gu(r.text))throw new Error("Brief has a blocking open question");let i=[],n=[];for(let o of e.specChanges){if(o.source===null){n.push({...o,contentHash:null});continue}let s=await $({root:t,ref:o.source,maxBytes:null,includeHash:!1}),l=s.text,c=null;if(o.delta_source){let u=await $({root:t,ref:o.delta_source,maxBytes:null,includeHash:!1}),d=fn(u.text);l=wm(s.text,d);let f="";try{f=(await $({root:e.paths.specsDir,ref:`${o.capability}/spec.md`,maxBytes:null,includeHash:!1})).text}catch(h){if(h.code!=="ENOENT")throw h}if(pt(f)===d.base_hash){let h=bm({baselineMarkdown:f,delta:d,allowAlreadyApplied:!0});if(pt(s.text)!==h.result_hash)throw new Error(`Native full target Spec does not match delta result for ${o.capability}; update the complete target before confirming Shape`)}c=D("comet.native.shape-artifact-content.v1",gs(u.text))}i.push({capability:o.capability,source:s.ref,markdown:l}),n.push({...o,contentHash:D("comet.native.shape-artifact-content.v1",gs(s.text,e.state.document_constraints_version!==void 0&&e.state.document_constraints_version!==1)),...c===null?{}:{deltaContentHash:c}})}let a=null;try{let o=await $({root:t,ref:od,maxBytes:65536,includeHash:!1}),s=eg(o.text);if(s.workflow!=="native")throw new Error("Native capability association must use the native workflow");if(!e.specChanges.some(({capability:u})=>u===s.capability))throw new Error(`Native capability association ${s.capability} is not declared by this change`);let c=St.relative(e.paths.projectRoot,St.join(e.paths.specsDir,s.capability,"spec.md")).replaceAll(St.sep,"/");if(s.current_spec!==c)throw new Error(`Native capability association points to ${s.current_spec}, expected ${c}`);a=D("comet.native.shape-artifact-content.v1",gs(o.text))}catch(o){if(o.code!=="ENOENT")throw o}return{acceptance:To({briefMarkdown:r.text,specs:i,resolveBriefReferences:e.state.document_constraints_version!==void 0&&e.state.document_constraints_version!==1}),formalHash:D("comet.native.shape-formal-artifacts.v1",{brief:{source:r.ref,contentHash:D("comet.native.shape-artifact-content.v1",gs(r.text,e.state.document_constraints_version!==void 0&&e.state.document_constraints_version!==1))},specs:n,association:{source:od,contentHash:a}})}}function ld(e){return D("comet.native.shape-confirmation.v1",{formalHash:e.formalHash,childrenHash:e.childrenHash,coordinationMode:e.coordinationMode??null})}async function ng(e){if(e.state.document_constraints_version!==void 0){let c=await rg(e);if(!c.valid){let u=c.findings[0];return{drifted:!0,reason:u?`Native formal documents are invalid (${u.code}${u.path?`: ${u.path}`:""})`:"Native formal documents are invalid"}}}let t=await ig(e),r=e.ignoreSpecOperationFor??(e.state.children_contract_hash?new Set(e.state.spec_changes.map(({capability:c})=>c)):void 0);if(!(t.length===e.state.spec_changes.length&&t.every((c,u)=>{let d=e.state.spec_changes[u];return d!==void 0&&c.capability===d.capability&&c.source===d.source&&c.delta_source===d.delta_source&&c.base_hash===d.base_hash&&(c.operation===d.operation||r?.has(c.capability)===!0)})))return{drifted:!0,reason:"Native target specification declarations changed"};let n;try{n=await cd({...e,specChanges:t})}catch{return{drifted:!0,reason:"Native Shape artifacts changed or became invalid"}}let{acceptance:a}=n,o=e.state.acceptance.map(({source:c,text:u})=>({source:c,text:u}));if(!cu(o,a))return{drifted:!0,reason:"Native confirmed acceptance criteria changed"};let s;try{s=await br({changeDir:he(e.paths,e.state.name),acceptanceIds:a.map(({id:c})=>c),validation:yr({...e.state,acceptance:a})})}catch{return{drifted:!0,reason:"Native child declarations changed"}}return e.state.phase==="shape"&&e.state.status==="await-user"&&e.state.loop.next_action==="confirm-shape"&&e.state.shape_confirmation_hash===void 0?{drifted:!0,reason:"Native Shape confirmation fingerprint is missing"}:e.state.shape_confirmation_hash!==void 0&&ld({formalHash:n.formalHash,childrenHash:s?.hash??null,coordinationMode:e.state.coordination_mode})!==e.state.shape_confirmation_hash?{drifted:!0,reason:"Native Shape artifacts changed"}:(s?Qu({acceptance:a,children:s.contract}):null)===(e.state.children_contract_hash??null)?{drifted:!1,reason:null}:{drifted:!0,reason:"Native child declarations changed"}}async function di(e){let t=await ng(e);if(!t.drifted)return;let r=t.reason??"Native confirmed requirements changed";throw await ys({paths:e.paths,state:e.state,reason:r,keepFailureBudget:!0}),new Error(`${r}; Native change returned to Shape and requires confirmation`)}async function ud(e){return F(e.paths,`sync spec references ${e.name}`,async()=>{let t=await Pe(e.paths,e.name);if(t.state_version!==e.expectedStateVersion)throw new Error("Native spec sync state version is stale");if(t.archived||!["build","verify","archive"].includes(t.phase)||t.children_contract_hash)throw new Error("Native spec sync requires a confirmed ordinary active change; revise requirements in Shape otherwise");if(!Rn.test(e.capability)||!e.reason.trim()||!e.actor.trim())throw new Error("Native spec sync requires capability, actor and reason");await di({paths:e.paths,state:t});let r=t.spec_changes.find(({capability:m,operation:p})=>m===e.capability&&p!=="remove");if(!r?.source)throw new Error("Stage this capability in the current change and confirm Shape before syncing references");let i=new Set(e.affectedAcceptanceIds);if(i.size===0||[...i].some(m=>!t.acceptance.some(p=>p.id===m))||t.acceptance.some(({source:m,id:p})=>m===r.source&&!i.has(p)))throw new Error("Native spec sync must cover the affected spec acceptance IDs");if(e.replacements.length===0||e.replacements.some(({from:m,to:p})=>!/^[A-Za-z0-9_./#%-]+$/u.test(m)||!/^[A-Za-z0-9_./#%-]+$/u.test(p)||m===p)||new Set(e.replacements.map(({from:m})=>m)).size!==e.replacements.length)throw new Error("Native spec sync only accepts unique local Markdown reference replacements");let n=he(e.paths,t.name),a=await $({root:n,ref:r.source,maxBytes:null,includeHash:!1}),o=new Map(e.replacements.map(({from:m,to:p})=>[m,p])),s=new Set,l=null,c=!1,u=a.text.split(/(?<=\n)/u).map(m=>{let p=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(m.trimEnd());return p?(l?p[1][0]===l.marker&&p[1].length>=l.length&&!p[2].trim()&&(l=null):l={marker:p[1][0],length:p[1].length},m):/^(?:\s|>|[-+*]\s|\d+[.)]\s)/u.test(m)?m:(m.includes("<!--")&&(c=!0),c?(m.includes("-->")&&(c=!1),m):l||/^(?: {4}|\t)/u.test(m)||m.includes("`")?m:m.replace(/(?<!!)\[([^\]\n]+)\]\(([^()\s]+)\)/gu,(v,g,w)=>{let b=o.get(w);return b?(s.add(w),`[${g}](${b})`):v}))}).join("");if(s.size!==o.size)throw new Error("Native spec sync replacement is not an existing prose Markdown reference; use revise-requirements for semantic changes");let d=St.join(n,r.source);await ve(d,u,{containedRoot:e.paths.nativeRoot});let f=!1,h=null;try{let m=await cd({paths:e.paths,state:t,specChanges:t.spec_changes});if(!cu(t.acceptance,m.acceptance))throw new Error("Reference change affects acceptance; revise requirements in Shape");let p=E=>QR("sha256").update(E).digest("hex"),v=JSON.stringify({schema:"comet.native.spec-sync.v1",change:t.name,actor:e.actor,reason:e.reason,source:r.source,beforeHash:p(a.text),afterHash:p(u),replacements:e.replacements,affectedAcceptanceIds:[...i],requiresConfirmation:!1,at:new Date().toISOString()}),g=p(v),w=await rd({paths:e.paths,name:t.name,hash:g,text:v,onCreated:()=>{h=g}}),b={...t,loop:{...t.loop,previous_unresolved_ids:[...new Set([...t.loop.previous_unresolved_ids,...i])]}},k=t.phase==="build"?{...b,state_version:t.state_version+1,acceptance:t.acceptance.map(E=>i.has(E.id)?{...E,result:"pending",reason:null}:E)}:ps({state:b,reason:`Spec reference sync: ${e.reason}`});k=ur(k,{goal_cycle:t.loop.goal_cycle,iteration:t.loop.iteration,attempt:t.loop.attempt,outcome:"recovery",unresolved_ids:[...i],summary:Be(`Spec reference sync by ${e.actor}: ${e.reason}; ${w}`),completed_at:new Date().toISOString()}),k.shape_confirmation_hash=ld({formalHash:m.formalHash,childrenHash:null,coordinationMode:t.coordination_mode});let x=await bt({paths:e.paths,previous:t,next:k});return f=!0,await Ve(Ce(e.paths,t.name),qe({portableState:x,projectRoot:e.paths.projectRoot,branch:yt(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),x}catch(m){if(!f)try{(await Pe(e.paths,t.name)).state_version===t.state_version&&(await ve(d,a.text,{containedRoot:e.paths.nativeRoot}),h&&await Xv({paths:e.paths,name:t.name,hash:h}))}catch{}throw m}})}async function dd(e){if(!Rn.test(e.capability))throw new Error(`Invalid Native capability: ${e.capability}`);return F(e.paths,`remove portable spec ${e.capability}`,async()=>{let t=await Pe(e.paths,e.name);if(t.archived)throw new Error(`Native change ${t.name} is already archived`);let r=t.spec_changes.filter(({capability:a})=>a!==e.capability),i={...t,phase:"shape",status:"active",state_version:t.state_version+1,spec_changes:[...r,{capability:e.capability,operation:"remove",source:null}].sort((a,o)=>a.capability.localeCompare(o.capability,"en")),acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,history:[],history_overflow:{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}},loop:{stage:"shape",goal_cycle:t.loop.goal_cycle+(t.phase==="shape"?0:1),iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"prepare-shape-confirmation"}};delete i.shape_confirmation_hash,delete i.children_contract_hash;let n=await bt({paths:e.paths,previous:t,next:i});return await Ve(Ce(e.paths,t.name),qe({portableState:n,projectRoot:e.paths.projectRoot,branch:yt(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),n})}async function fd(e){return F(e.paths,`disassociate portable capability ${e.name}`,async()=>{let t=await Pe(e.paths,e.name);if(ws({state:t,expected:e.expectedContinuation,action:"disassociate-capability"}),t.archived)throw new Error(`Native change ${t.name} is already archived`);let r=St.join(he(e.paths,e.name),od),i;try{i=await ui.lstat(r)}catch(n){if(n.code==="ENOENT")return t;throw n}if(!i.isFile()||i.isSymbolicLink())throw new Error("Native capability association must be a regular file");return await ui.rm(r),ys({paths:e.paths,state:t,reason:"Capability association revoked through comet native spec disassociate"})})}async function ys(e){let{state:t}=e;if(t.archived)throw new Error(`Native change ${t.name} is already archived`);let i={...ur(t,{goal_cycle:t.loop.goal_cycle,iteration:t.loop.iteration,attempt:t.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:Be(e.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:t.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:t.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:e.keepFailureBudget?t.loop.failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"prepare-shape-confirmation"}};delete i.shape_confirmation_hash,delete i.children_contract_hash;let n=await bt({paths:e.paths,previous:t,next:i});return await Ve(Ce(e.paths,t.name),qe({portableState:n,projectRoot:e.paths.projectRoot,branch:yt(e.paths.projectRoot)}),{containedRoot:e.paths.runtimeDir}),n}be();Q();zt();Vt();gt();dr();nt();yo();K();nt();ft();B();var mM=8*1024*1024;ds();Q();dr();L();var LM=1024*1024*1024;Q();Vn();gi();Vt();Q();Vt();Q();Wo();gt();L();var og=["evidence.md","repair.md","archive.md","checkpoint.md"],a_="verification.md";async function o_(e,t){let r=await bu(e,{kind:"migration",change:t});return r?.kind==="migration"?r.journal:null}async function sg(e,t){await Ln.mkdir(e.transactionsDir,{recursive:!0}),await Z(Vo(e,{kind:"migration",change:t.change}),t,{containedRoot:e.runtimeDir})}async function cg(e,t,r={}){let i=r.removeVerificationReport===!1?og:[...og,a_];await Promise.all([Ln.rm(He(e,t),{recursive:!0,force:!0}),Ln.rm(Ll(e,t),{recursive:!0,force:!0}),...i.map(n=>Ln.rm(n_.join(it(e,t),n),{force:!0}))])}async function lg(e,t){await Ve(Ce(e,t.name),qe({portableState:t,projectRoot:e.projectRoot}),{containedRoot:e.runtimeDir})}async function ug(e,t){try{let r=await kn(e,t);if(r?.schema==="comet.native.workspace.v3")return{isolation:r.isolation,change_branch:r.changeBranch,target_branch:r.targetBranch,finish:r.finish}}catch{}return{isolation:"current",change_branch:null,target_branch:null,finish:null}}function dg(e,t){if(t.isolation==="current"&&t.change_branch===null)return;let r=_e(e.projectRoot);if(!r.isGitWorktree)throw new Error("Native legacy migration requires its bound Git branch or worktree");if(r.currentBranch!==t.change_branch)throw new Error(`Native legacy migration expected branch ${t.change_branch??"(missing)"}, current branch is ${r.currentBranch??"(detached)"}`);if(t.isolation==="worktree"&&!r.isSecondaryWorktree)throw new Error("Native legacy migration requires its bound linked worktree")}async function s_(e){let t=it(e.paths,e.state.name),r=await $({root:t,ref:e.state.brief,maxBytes:null,includeHash:!1}),i=[];for(let n of e.state.spec_changes){if(n.operation==="remove"||!n.source)continue;let a=await $({root:t,ref:n.source,maxBytes:null,includeHash:!1});i.push({capability:n.capability,source:a.ref,markdown:a.text})}try{return To({briefMarkdown:r.text,specs:i})}catch(n){if(e.state.phase==="shape"&&n.message.includes("at least one acceptance"))return[];throw n}}async function fg(e,t){let r=await av(e,t);if(r.status==="runtime-incompatible")throw new Ze(r.schema,r.minimumRuntimeVersion);if(!r.state)throw new Error(`Native legacy change ${t} is unreadable`);return r.state}async function pg(e){return F(e.paths,`migrate ${e.name} to portable Native`,async()=>{let t=await o_(e.paths,e.name),r=await pr(e.paths,e.name)?await vt(at(e.paths,e.name)):null;if(!t&&r)return await cg(e.paths,e.name,{removeVerificationReport:!1}),await lg(e.paths,r),r;let i=null,n=null;for(t||(i=await fg(e.paths,e.name),n=await ug(e.paths,e.name),dg(e.paths,n),t={schema:Fo,id:i_(),change:i.name,fromSchema:i.schema,status:"prepared",createdAt:(e.now??new Date).toISOString()},await sg(e.paths,t));;){let a=Lm(t);if(a.action==="done")break;a.action==="commit-portable-yaml"?r||(i??=await fg(e.paths,e.name),n??=await ug(e.paths,e.name),dg(e.paths,n),r=Dm({state:i,acceptance:await s_({paths:e.paths,state:i}),workspace:n,migratedAt:e.now}),await Mo(at(e.paths,e.name),r,{containedRoot:e.paths.nativeRoot})):a.action==="cleanup-legacy-runtime"?await cg(e.paths,e.name):a.action==="commit-transaction"&&(r??=await vt(at(e.paths,e.name)),await lg(e.paths,r)),t={...t,status:a.nextStatus},await sg(e.paths,t)}return await Ln.rm(Vo(e.paths,{kind:"migration",change:e.name}),{force:!0}),r??vt(at(e.paths,e.name))},{allowedPortableTransaction:{kind:"migration",change:e.name}})}on();import Mn from"path";import{realpathSync as Y_}from"fs";function hg(e,t){let r=u=>u!==null&&typeof u=="object"&&!Array.isArray(u)?u:{},i=r(e),n=r(i.entry),a=r(i.state??n.state??i),o=r(i.preparation??i.workspace??n.workspace),s=r(i.continuation??n.continuation),l=typeof o.projectRoot=="string"&&o.projectRoot!=="."?o.projectRoot:t??null,c=a.stateVersion??a.state_version;return{phase:typeof a.phase=="string"?a.phase:null,status:typeof a.status=="string"?a.status:null,stateVersion:typeof c=="number"?c:null,workspace:{cwd:l},continuation:Object.keys(s).length?{...s,cwd:l}:null}}var Et={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function mg(e){return e?e.command?`${Et.next} ${e.command}`:e.ask_user?`${Et.next} ${e.ask_user}`:null:null}function vg(e,t){let r=[e.summary],i=mg(e.next);return i&&r.push(i),e.user_message&&r.push("",Et.relay,e.user_message),t!==void 0&&r.push("",Et.details,JSON.stringify(t,null,2)),`${r.join(`
185
270
  `)}
186
- `}function Mm(e,t,r){let i=[e.summary],n=Lm(e.next);return n&&i.push(n),e.user_message&&i.push("",pt.relay,e.user_message),i.push("",`${pt.detail} ${t}`),r!==void 0&&i.push("",pt.details,JSON.stringify(r,null,2)),i.join(`
187
- `)}J();fe();J();var gC=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});Fr();Ge();he();H();L();Je();Di();K();H();Ge();ar();J();J();Co();Mr();Je();var Fm={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:[]},yC=we("comet-native-runtime:v3:scope-reopen"),qM=[{skillVersion:"3",skillHash:we("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:we("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:we("comet-native-runtime:v1")}];Je();Je();Bi();var qm=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],SF=new Set(qm),CC=new Set([...qm,"minimum_runtime_version","revision"]),EF=new Set([...CC,"operation"]),PC=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),xF=new Set([...PC,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Ja();fe();fe();Ja();J();var AF={maxAcceptanceCriteria:Ga.maxCriteria};Fr();Gi();Mr();Co();import{execFile as DC}from"node:child_process";Ia();Wl();import{promisify as LC}from"node:util";L();Je();H();Ge();Xr();ar();K();L();Jl();H();Le();Fr();K();ar();var an=class extends Error{recovery;constructor(t,r){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=r}};Gi();Po();Mr();var TV=64*1024;var jV=3600*1e3;var $V=LC(DC);Po();var To=class extends Error{details;constructor(t){let r=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=t}};Je();Ge();L();Le();H();Ge();po();L();Vt();Fr();var Iq=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});Je();Di();K();H();Ge();he();K();var Lq=16*1024;po();var jo=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},$o=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};H();he();function C(e,t,r){return e==="zh-CN"?r:t}var su={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Gm(e,t){return typeof e=="string"&&su[e]?C(t,su[e].en,su[e].zh):typeof e=="string"?e:""}function cu(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&typeof t.passed=="number"&&typeof t.failed=="number"&&typeof t.blocked=="number"&&typeof t.pending=="number"}function WC(e){let t={total:e.length,passed:0,failed:0,blocked:0,pending:0};for(let r of e){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;t[i]+=1}return t}function Jm(e,t){let r=[];e.failed>0&&r.push(C(t,`${e.failed} failed`,`${e.failed} 项失败`)),e.blocked>0&&r.push(C(t,`${e.blocked} blocked`,`${e.blocked} 项受阻`)),e.pending>0&&r.push(C(t,`${e.pending} pending`,`${e.pending} 项待验`));let i=C(t,`acceptance ${e.passed}/${e.total} passed`,`验收 ${e.passed}/${e.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Um(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;if(typeof t.change!="string"||t.disposition!=="continue"&&t.disposition!=="await-user"&&t.disposition!=="blocked"&&t.disposition!=="done"||t.commandArgs!==null&&t.commandArgs!==void 0&&!Array.isArray(t.commandArgs))return!1;let r=t.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function lu(e){return/[\u4e00-\u9fff]/u.test(e.userCommunication.agentInstruction)?"zh-CN":"en"}function zC(e,t,r){return e==="done"?C(r,"complete","已完成"):e==="await-user"?C(r,"waiting for a user decision","等待用户决定"):e==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):t?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function GC(e,t,r){let i=lu(e),n=[];r&&n.push(r);let a=C(i,`Change ${e.change}`,`需求 ${e.change}`),o=Gm(e.phase,i),s=zC(e.disposition,e.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),t&&t.total>0&&n.push(Jm(t,i));let l=e.userCommunication,c=Km(e,i);return{summary:n.join("; "),...c?{next:c}:{},...l.required&&l.message?{user_message:l.message}:{}}}function Km(e,t){let r=e.userCommunication;if(e.disposition==="await-user"&&r.required)return{ask_user:C(t,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(e.commandArgs&&e.commandArgs.length>0)return{command:e.commandArgs.join(" ")};if(e.disposition==="done")return{ask_user:C(t,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(e.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:C(t,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function JC(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&Array.isArray(t.items)}function UC(e,t){let r=typeof e.name=="string"?e.name:"(unnamed)",i=Gm(e.phase,t),n=e.status==="await-user"?C(t,"waiting for a user decision","等待用户决定"):e.status==="blocked"?C(t,"paused","已暂停"):e.status==="done"?C(t,"complete","已完成"):C(t,"in progress","进行中"),a=cu(e.acceptance)?`${C(t,", ",",")}${Jm(e.acceptance,t)}`:"";return` ${r} · ${i||String(e.phase??"?")} · ${n}${a}`}function KC(e){for(let t of e){let r=t.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function YC(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.healthy!="boolean"?!1:t.findings===void 0||Array.isArray(t.findings)}function XC(e){if(e.healthy){let i=e.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=QC(e.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(e.findings)?e.findings.length:0;return{summary:C("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:C("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function QC(e){return Um(e)?Km(e,lu(e)):void 0}function Ym(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;if(YC(t))return XC(t);if(JC(t)){let i=KC(t.items);return{summary:[t.total===t.items.length?C(i,`Native changes (${t.total})`,`Native 需求列表(共 ${t.total} 条)`):C(i,`Native changes (showing ${t.items.length} of ${t.total})`,`Native 需求列表(显示 ${t.items.length}/${t.total} 条)`),...t.items.map(a=>UC(a,i))].join(`
188
- `)}}let r=t.continuation;if(Um(r)){let i=lu(r),n=GC(r,ZC(t),tP(t,i));return eP(t)==="unconfirmed"?{...n,summary:`${n.summary}${C(i,"; the dispatched Verifier has not confirmed startup yet — verify the subagent actually launched before waiting on it",";已派发的 Verifier 尚未确认启动——先核实子代理确实启动,再继续等待")}`}:n}if(typeof t.artifactRoot=="string"&&typeof t.nativeRoot=="string"){let i=t.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in t;return{summary:C(i,n?`Comet Native artifacts live under ${t.artifactRoot} (state root: ${t.nativeRoot}).`:`Initialized Comet Native at ${t.nativeRoot} (artifacts: ${t.artifactRoot}).`,n?`Comet Native 产物位于 ${t.artifactRoot}(状态根目录:${t.nativeRoot})。`:`Comet Native 已初始化于 ${t.nativeRoot}(产物目录:${t.artifactRoot})。`)}}}function ZC(e){if(cu(e.acceptance))return e.acceptance;let t=e.state;if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;if(cu(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return WC(r.acceptance)}return null}function eP(e){let t=e.localExecution;if(!t||typeof t!="object"||Array.isArray(t))return;let r=t.verifierStartup;if(!(!r||typeof r!="object"||Array.isArray(r)))return r.confirmation}function tP(e,t){if(e.selected!==void 0&&typeof e.selected=="string")return C(t,`Selected ${e.selected}.`,`已选择需求 ${e.selected}。`);let r=e.migration;return r&&typeof r=="object"&&r.completed===!0?C(t,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function Xm(e){let r=e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};switch(e.code){case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}Vo();var Qm=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--verbose Append the raw machine projection after the human/agent text.","--help Show help without requiring an initialized project."],uu=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",agentQuickStart:["Run `comet native status --json` to discover active changes.","Select an existing change with `select`, or create one with `new`.","In `agent.workspace.cwd`, execute the exact `agent.continuation.commandArgs` returned by Runtime.","Use `agent.continuation.inputOptions` templates for JSON input; do not reconstruct fields from memory."],subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec disassociate Revoke a capability association through Runtime.","spec remove Record a complete capability removal intent.","spec sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:Qm,output:"A human summary plus a NEXT step by default (RELAY TO USER blocks carry user decisions); use --json for the structured envelope, --verbose to append the raw machine projection.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--task <text>] [--capability <id>] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--task <text> Search Project Knowledge for an existing capability and save a revocable association draft.","--capability <id> Directly validate and associate an existing capability without retrieval.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, canonical artifact paths, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN",'comet native new add-sms-login --task "add SMS login to authentication"',"comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:`comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability
271
+ `}function gg(e,t,r){let i=[e.summary],n=mg(e.next);return n&&i.push(n),e.user_message&&i.push("",Et.relay,e.user_message),i.push("",`${Et.detail} ${t}`),r!==void 0&&i.push("",Et.details,JSON.stringify(r,null,2)),i.join(`
272
+ `)}K();we();K();var c_=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});li();tt();be();L();B();rt();dn();Q();L();tt();Nr();K();K();hs();ci();rt();var wg={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:[]},u_=xe("comet-native-runtime:v3:scope-reopen"),kV=[{skillVersion:"3",skillHash:xe("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:xe("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:xe("comet-native-runtime:v1")}];rt();rt();pn();var bg=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],rW=new Set(bg),g_=new Set([...bg,"minimum_runtime_version","revision"]),iW=new Set([...g_,"operation"]),w_=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),nW=new Set([...w_,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Io();we();we();Io();K();var lW={maxAcceptanceCriteria:Ao.maxCriteria};li();bn();ci();hs();import{execFile as R_}from"node:child_process";Cr();yi();Yu();import{promisify as __}from"node:util";B();rt();L();tt();Ei();Nr();Q();B();Zu();L();Ge();li();Q();Nr();var Bn=class extends Error{recovery;constructor(t,r){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=r}};bn();ms();ci();var fz=64*1024;var pz=3600*1e3;var hz=__(R_);ms();var bs=class extends Error{details;constructor(t){let r=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=t}};rt();tt();B();Ge();L();tt();Xo();B();tr();li();var d2=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});rt();dn();Q();L();tt();be();Q();var w2=16*1024;Xo();var Ns=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},ks=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};L();be();function C(e,t,r){return e==="zh-CN"?r:t}var pd={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Sg(e,t){return typeof e=="string"&&pd[e]?C(t,pd[e].en,pd[e].zh):typeof e=="string"?e:""}function hd(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&typeof t.passed=="number"&&typeof t.failed=="number"&&typeof t.blocked=="number"&&typeof t.pending=="number"}function O_(e){let t={total:e.length,passed:0,failed:0,blocked:0,pending:0};for(let r of e){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;t[i]+=1}return t}function Eg(e,t){let r=[];e.failed>0&&r.push(C(t,`${e.failed} failed`,`${e.failed} 项失败`)),e.blocked>0&&r.push(C(t,`${e.blocked} blocked`,`${e.blocked} 项受阻`)),e.pending>0&&r.push(C(t,`${e.pending} pending`,`${e.pending} 项待验`));let i=C(t,`acceptance ${e.passed}/${e.total} passed`,`验收 ${e.passed}/${e.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function xg(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;if(typeof t.change!="string"||t.disposition!=="continue"&&t.disposition!=="await-user"&&t.disposition!=="blocked"&&t.disposition!=="done"||t.commandArgs!==null&&t.commandArgs!==void 0&&!Array.isArray(t.commandArgs))return!1;let r=t.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function md(e){return/[\u4e00-\u9fff]/u.test(e.userCommunication.agentInstruction)?"zh-CN":"en"}function H_(e,t,r){return e==="done"?C(r,"complete","已完成"):e==="await-user"?C(r,"waiting for a user decision","等待用户决定"):e==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):t?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function D_(e,t,r){let i=md(e),n=[];r&&n.push(r);let a=C(i,`Change ${e.change}`,`需求 ${e.change}`),o=Sg(e.phase,i),s=H_(e.disposition,e.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),t&&t.total>0&&n.push(Eg(t,i));let l=e.userCommunication,c=Cg(e,i);return{summary:n.join("; "),...c?{next:c}:{},...l.required&&l.message?{user_message:l.message}:{}}}function Cg(e,t){let r=e.userCommunication;if(e.disposition==="await-user"&&r.required)return{ask_user:C(t,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(e.commandArgs&&e.commandArgs.length>0)return{command:e.commandArgs.join(" ")};if(e.disposition==="done")return{ask_user:C(t,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(e.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:C(t,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function L_(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&Array.isArray(t.items)}function B_(e,t){let r=typeof e.name=="string"?e.name:"(unnamed)",i=Sg(e.phase,t),n=e.status==="await-user"?C(t,"waiting for a user decision","等待用户决定"):e.status==="blocked"?C(t,"paused","已暂停"):e.status==="done"?C(t,"complete","已完成"):C(t,"in progress","进行中"),a=hd(e.acceptance)?`${C(t,", ",",")}${Eg(e.acceptance,t)}`:"";return` ${r} · ${i||String(e.phase??"?")} · ${n}${a}`}function M_(e){for(let t of e){let r=t.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function F_(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.healthy!="boolean"?!1:t.findings===void 0||Array.isArray(t.findings)}function q_(e){if(e.healthy){let i=e.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=V_(e.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(e.findings)?e.findings.length:0;return{summary:C("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:C("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function V_(e){return xg(e)?Cg(e,md(e)):void 0}function Pg(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;if(F_(t))return q_(t);if(L_(t)){let i=M_(t.items);return{summary:[t.total===t.items.length?C(i,`Native changes (${t.total})`,`Native 需求列表(共 ${t.total} 条)`):C(i,`Native changes (showing ${t.items.length} of ${t.total})`,`Native 需求列表(显示 ${t.items.length}/${t.total} 条)`),...t.items.map(a=>B_(a,i))].join(`
273
+ `)}}let r=t.continuation;if(xg(r)){let i=md(r),n=D_(r,W_(t),G_(t,i));return z_(t)==="unconfirmed"?{...n,summary:`${n.summary}${C(i,"; the dispatched Verifier has not confirmed startup yet — verify the subagent actually launched before waiting on it",";已派发的 Verifier 尚未确认启动——先核实子代理确实启动,再继续等待")}`}:n}if(typeof t.artifactRoot=="string"&&typeof t.nativeRoot=="string"){let i=t.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in t;return{summary:C(i,n?`Comet Native artifacts live under ${t.artifactRoot} (state root: ${t.nativeRoot}).`:`Initialized Comet Native at ${t.nativeRoot} (artifacts: ${t.artifactRoot}).`,n?`Comet Native 产物位于 ${t.artifactRoot}(状态根目录:${t.nativeRoot})。`:`Comet Native 已初始化于 ${t.nativeRoot}(产物目录:${t.artifactRoot})。`)}}}function W_(e){if(hd(e.acceptance))return e.acceptance;let t=e.state;if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;if(hd(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return O_(r.acceptance)}return null}function z_(e){let t=e.localExecution;if(!t||typeof t!="object"||Array.isArray(t))return;let r=t.verifierStartup;if(!(!r||typeof r!="object"||Array.isArray(r)))return r.confirmation}function G_(e,t){if(e.selected!==void 0&&typeof e.selected=="string")return C(t,`Selected ${e.selected}.`,`已选择需求 ${e.selected}。`);let r=e.migration;return r&&typeof r=="object"&&r.completed===!0?C(t,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function Rg(e){let r=e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};switch(e.code){case"document-invalid":return{summary:e.message,...typeof r.change=="string"?{next:{command:`comet native next ${r.change} --summary <summary>`}}:{}};case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}qn();jo();var _g=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--verbose Append the raw machine projection after the human/agent text.","--help Show help without requiring an initialized project."],vd=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",agentQuickStart:["Run `comet native status --json` to discover active changes.","Select an existing change with `select`, or create one with `new`.","In `agent.workspace.cwd`, execute the exact `agent.continuation.commandArgs` returned by Runtime.","Use `agent.continuation.inputOptions` templates for JSON input; do not reconstruct fields from memory."],subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec disassociate Revoke a capability association through Runtime.","spec remove Record a complete capability removal intent.","spec sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:_g,output:"A human summary plus a NEXT step by default (RELAY TO USER blocks carry user decisions); use --json for the structured envelope, --verbose to append the raw machine projection.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--task <text>] [--capability <id>] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--task <text> Search Project Knowledge for an existing capability and save a revocable association draft.","--capability <id> Directly validate and associate an existing capability without retrieval.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, canonical artifact paths, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN",'comet native new add-sms-login --task "add SMS login to authentication"',"comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:`comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability
189
274
  comet native spec remove <change-name> <capability>
190
275
  comet native spec sync <change-name> <capability> --input <json-file>`,purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["disassociate <change-name> Revoke a capability association and return to Shape.","remove <change-name> <capability> Record a capability removal.","sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections without changing prose or acceptance."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},"spec disassociate":{usage:"comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability",purpose:"Revoke a capability association through Runtime without hand-editing artifacts.",options:["--expected-state-version <n> State version returned by the latest status response.","--expected-action <action> Must be disassociate-capability."],output:"The updated portable state and continuation with the next Runner action."},"spec sync":{usage:"comet native spec sync <change-name> <capability> --input <json-file>",purpose:"Sync local Markdown link destinations in an already confirmed target spec; semantic edits require Shape.",options:["--input <json-file> Fields: expectedStateVersion, actor, reason, affectedAcceptanceIds, replacements [{from,to}]. Include all acceptance IDs from the affected spec."],output:"The audited portable state, preserved unaffected acceptance results and Build continuation for re-verification."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"A compact summary and NEXT action by default. Use --json to read canonical artifact paths, the portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required. Fill command-template placeholders before executing NEXT commands."},check:{usage:"comet native check <change-name>",purpose:"Legacy-only verification command; not supported for current portable changes.",output:"For current changes, run comet native status <change-name> --json and follow the continuation to dispatch verification through comet native next."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page, or a named details/history page.","--details Include one fixed-size page of acceptance, Spec, handoff, verification, history, workspace, and report details."],output:"A compact v2 status page or one compact Loop projection with canonical artifact paths and local execution availability. Use --details and --cursor to read fixed-size detail pages; parent changes expose childSummary and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--coordination-mode multi-session|single-session] [--max-parallel <n>] [--expected-state-version <n>] [--expected-action <action>]
191
276
  comet native next <change-name> --summary <text> [--confirmed|--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker] [--expected-state-version <n>] [--expected-action <action>]
192
- comet native next <change-name> --runner-input <json-file> [--validate-only]`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm the persisted Shape boundary with both expected guards, or confirm an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Select how a multi-child Supervisor proceeds while preparing its Shape confirmation; final Shape confirmation is a later, separate step.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, retry-checks, verifier-response, verifier-started, verifier-execution-error, or verifier-unavailable. Builder/dispatch identity fields are rejected; verifier responses must echo the current candidateId and verifierExecutionRef from the Verifier dispatch.","--validate-only Validate the Runner JSON shape and current boundary without writing state or starting a process; requires --runner-input."," Choose one object template from an inputOptions exclusiveGroup and save it as UTF-8 JSON (BOM accepted). Field errors return issues with JSON pointer, missingFields and unknownFields. Execute agent.continuation in agent.workspace.cwd; Supervisor results use task.returnAction."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, verification_checks, known_limits, optional review. checks summarize development feedback. verification_checks is an optional Runtime plan executed after the candidate is frozen; a passing plan is reused without executing the same plan twice when dispatch-verifier receives the unchanged plan. If review is supplied, its fields are status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," retry-checks fields: kind, check_ids for repeatable interrupted Runtime checks from the current candidate; each check can be retried at most three times."," verifier-response fields: kind, candidateId, verifierExecutionRef, response (request-checks or final-result); copy the two binding fields from the current continuation."," verifier-started fields: kind, candidateId, verifierExecutionRef copied from verifierDispatch; the dispatched Verifier submits it as its first Runtime action so status can distinguish a registered dispatch from a Verifier that actually started. Repeating it is accepted without side effects."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," Supervisor task fields: supervisor-builder-result (child, runId, candidateCommit), supervisor-builder-failure (child, runId, reason), supervisor-verifier-result (child, runId, verdict, verification data), supervisor-reconnect (child, runId), supervisor-cancel (child, runId, reason), or supervisor-integrate (child, checks)."," supervisor-checks fields: kind, child, runId, checks (non-empty repeatable Runtime check plans), materials [{name,content}], and optional retry_check_ids for interrupted checks from the same candidate, machine and workspace. Returns per-check execution state plus operationId, status and receiptRef. Repeated running plans return the same handle."," supervisor-verifier-result evidence fields: summary, checks (informal notes), acceptance [{id,result,reason}], receiptRef. verdict is pass, fail or blocked; every task acceptance ID must appear exactly once. Runtime receipts determine formal check status; receiptRef may be null for fail or blocked."," supervisor-integrate checks are non-empty Runtime check plans executed after the merge in the integration worktree, not declared statuses."],output:'A compact portable state summary, explicit skill-coordinated label, Runtime-owned check results, scoped verifierDispatch, bounded request-check response, continuation.runnerAction, machine-readable continuation.inputOptions, and continuation.userCommunication with a user-ready message and Agent relay guidance. Read acceptance text and other long fields from paged status --details output. Human-readable verification statuses include "Host independently verified", "Checks completed, but your confirmation is required", "Full verification was unavailable; only automatic checks completed", and "You accepted the incomplete verification result". This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.',examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed --expected-state-version <n> --expected-action confirm-shape','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep]
193
- comet native archive <change-name> [--confirmed] [--serial-first <current-change>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Run the complete read-only Archive and workspace-finish readiness check; it persists only an explicit --finish choice.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness, every blocker, and the exact next continuation, or the completed Archive transaction and workspace finish result. Execute the returned confirmed command only after ready is true; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function Oo(e,t){return`${e}:
277
+ comet native next <change-name> --runner-input <json-file> [--validate-only]`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm the persisted Shape boundary with both expected guards, or confirm an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Choose how a multi-child Supervisor proceeds. Supply it with --confirmed at the persisted Shape boundary to confirm the full plan and mode together, or select it during preparation and confirm the plan afterward.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--finish keep|merge|push|pull-request With --accept-result, record the explicitly chosen isolated-workspace finish in the same guarded decision.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, retry-checks, verifier-response, verifier-started, verifier-execution-error, or verifier-unavailable. Builder/dispatch identity fields are rejected; verifier responses must echo the current candidateId and verifierExecutionRef from the Verifier dispatch.","--validate-only Validate the Runner JSON shape and current boundary without writing state or starting a process; requires --runner-input."," Choose one object template from an inputOptions exclusiveGroup and save it as UTF-8 JSON (BOM accepted). Field errors return issues with JSON pointer, missingFields and unknownFields. Execute agent.continuation in agent.workspace.cwd; Supervisor results use task.returnAction."," builder-handoff fields: kind, summary, addressed_acceptance_ids, acceptance_review, checks, verification_checks, known_limits, optional review. acceptance_review must cover every confirmed ID exactly once with id, status, evidence (concrete references or observations), and note. Only implemented-with-evidence with nonempty evidence is ready for handoff; implemented-no-evidence, not-implemented, and known-fail remain in Build. This Builder declaration does not replace independent verification. checks summarize development feedback. verification_checks is an optional Runtime plan executed after the candidate is frozen; a passing plan returns the Verifier dispatch immediately. Completed Runtime checks can carry to a new candidate only when the implementation, confirmed documents, plan, workspace, environment, and saved evidence still match. If review is supplied, its fields are status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," retry-checks fields: kind, check_ids for repeatable interrupted Runtime checks from the current candidate; each check can be retried at most three times."," verifier-response fields: kind, candidateId, verifierExecutionRef, response (request-checks or final-result); copy the two binding fields from the current continuation."," verifier-started fields: kind, candidateId, verifierExecutionRef copied from verifierDispatch; the dispatched Verifier submits it as its first Runtime action so status can distinguish a registered dispatch from a Verifier that actually started. Repeating it is accepted without side effects."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," Supervisor task fields: supervisor-builder-result (child, runId, candidateCommit), supervisor-builder-failure (child, runId, reason), supervisor-verifier-result (child, runId, verdict, verification data), supervisor-reconnect (child, runId), supervisor-cancel (child, runId, reason), or supervisor-integrate (child, checks)."," supervisor-checks fields: kind, child, runId, checks (non-empty repeatable Runtime check plans), materials [{name,content}], and optional retry_check_ids for interrupted checks from the same candidate, machine and workspace. Returns per-check execution state plus operationId, status and receiptRef. Repeated running plans return the same handle."," supervisor-verifier-result evidence fields: summary, checks (informal notes), acceptance [{id,result,reason}], receiptRef. verdict is pass, fail or blocked; every task acceptance ID must appear exactly once. Runtime receipts determine formal check status; receiptRef may be null for fail or blocked."," supervisor-integrate checks are non-empty Runtime check plans executed after the merge in the integration worktree, not declared statuses."],output:'A compact portable state summary, explicit skill-coordinated label, Runtime-owned check results, scoped verifierDispatch, bounded request-check response, continuation.runnerAction, machine-readable continuation.inputOptions, and continuation.userCommunication with a user-ready message and Agent relay guidance. Read acceptance text and other long fields from paged status --details output. Human-readable verification statuses include "Host independently verified", "Checks completed, but your confirmation is required", "Full verification was unavailable; only automatic checks completed", and "You accepted the incomplete verification result". This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.',examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed --expected-state-version <n> --expected-action confirm-shape','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep] [--commit-message <text>] [--merge-message <text>]
278
+ comet native archive <change-name> [--confirmed] [--serial-first <current-change>] [--commit-message <text>] [--merge-message <text>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Run the complete read-only Archive and workspace-finish readiness check; it persists only an explicit --finish choice.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--expected-state-version <n> Preserve this continuation-issued guard when confirming a new finish choice; stale choices are rejected before it is recorded.","--commit-message <text> Set the archive commit message; Unicode and multiline text are supported. Git hooks still run.","--merge-message <text> Set the local merge commit message; requires merge finish. Omit it to use Git defaults.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness, every blocker, actual prepared commitMessages (mergeMessage is null when no merge is planned), and the exact next continuation, or the completed Archive transaction and workspace finish result. Messages are retained for retries. After a Git hook rejects a message, provide a corrected message with --confirmed for the unfinished step; completed commits are never rewritten. Execute the returned confirmed command only after ready is true; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function Ss(e,t){return`${e}:
194
279
  ${t.map(r=>` ${r}`).join(`
195
- `)}`}function rP(e){let t=e.filter(i=>i!=="--help");if(t.length===0)return"";let r=t.slice(0,2).join(" ");return uu[r]||t.length>1&&uu[t[0]]?.subcommands?r:t[0]}function iP(e=[]){let t=rP(e),r=uu[t];if(!r)throw new Error(`Unknown Native help topic: ${t}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.agentQuickStart&&i.push("",Oo("Agent Quick Start",r.agentQuickStart)),r.subcommands&&i.push("",Oo("Commands",r.subcommands));let n=t===""?r.options:[...r.options??[],...Qm];return n&&n.length>0&&i.push("",Oo("Options",n)),i.push("",`Output:
196
- ${r.output}`),r.examples&&i.push("",Oo("Examples",r.examples)),t===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:t,usage:`${i.join(`
280
+ `)}`}function J_(e){let t=e.filter(i=>i!=="--help");if(t.length===0)return"";let r=t.slice(0,2).join(" ");return vd[r]||t.length>1&&vd[t[0]]?.subcommands?r:t[0]}function U_(e=[]){let t=J_(e),r=vd[t];if(!r)throw new Error(`Unknown Native help topic: ${t}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.agentQuickStart&&i.push("",Ss("Agent Quick Start",r.agentQuickStart)),r.subcommands&&i.push("",Ss("Commands",r.subcommands));let n=t===""?r.options:[...r.options??[],..._g];return n&&n.length>0&&i.push("",Ss("Options",n)),i.push("",`Output:
281
+ ${r.output}`),r.examples&&i.push("",Ss("Examples",r.examples)),t===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:t,usage:`${i.join(`
197
282
  `)}
198
- `}}var nP=iP().usage;var G1=10*1024*1024,G=class extends Error{};function fu(e,t){let r=e.flatMap((i,n)=>i===t?[n]:[]);if(r.length>1)throw new G(`${t} may only be provided once`);return r.length===0?!1:(e.splice(r[0],1),!0)}function zr(e,t){let r=e.flatMap((a,o)=>a===t?[o]:[]);if(r.length>1)throw new G(`${t} may only be provided once`);if(r.length===0)return;let i=r[0],n=e[i+1];if(n===void 0||n.startsWith("--"))throw new G(`${t} requires a value`);return e.splice(i,2),n}function Ho(e){if(e.length>0)throw new G(`Unexpected argument: ${e[0]}`)}function or(e,t){let r=e.shift();if(!r||r.startsWith("--"))throw new G(`${t} is required`);return r}function du(e,t){let r=on.normalize(Zm(e)),i=on.normalize(Zm(t));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Zm(e){let t=on.resolve(e);try{return aP.native(t)}catch{return t}}function oP(e){let t=on.resolve(e),r=ke(process.cwd());if(!r.isSecondaryWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null)return t;let i=ke(t);return!i.isGitWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null||!du(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||du(r.currentWorktreeRoot,i.currentWorktreeRoot)?t:du(process.cwd(),r.currentWorktreeRoot)?on.resolve(process.cwd()):r.currentWorktreeRoot}async function ev(e){return e?oP(e):Ra(process.cwd())}async function Do(e){let t=await Ip({startPath:e,allowMissingConfig:!1});return{config:t.config,paths:t.paths}}function tv(e){return JSON.stringify(e,null,2)+`
199
- `}function Lo(e,t,r){return{command:e,exitCode:0,data:t,text:r??tv(t)}}function sP(e,t){if(t instanceof cn)return{command:e,exitCode:65,error:{code:"invalid-data",message:t.message,issues:t.issues}};if(t instanceof G)return{command:e,exitCode:64,error:{code:"usage",message:t.message}};if(t instanceof jo)return{command:e,exitCode:73,data:{capability:t.capability,expectedHash:t.expectedHash,actualHash:t.actualHash,canonicalPath:t.canonicalPath},error:{code:"conflict",message:t.message}};if(t instanceof $o)return{command:e,exitCode:73,data:t.preflight,error:{code:"conflict",message:t.message}};if(t instanceof mo)return{command:e,exitCode:73,data:{change:t.change,expectedRevision:t.expectedRevision,actualRevision:t.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:t.message}};if(t instanceof Yi)return{command:e,exitCode:73,data:{requestedIsolation:t.requestedIsolation,activeChanges:t.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:t.message}};if(t instanceof Eo)return{command:e,exitCode:73,data:{preparation:t.preparation},error:{code:"workspace-preparation-incomplete",message:t.message}};if(t instanceof vo)return{command:e,exitCode:65,data:{change:t.change,complete:!1,omittedCount:t.omittedCount,omittedByReason:t.omittedByReason,samplePaths:t.samplePaths,sampleTruncated:t.sampleTruncated,effectiveLimits:t.effectiveLimits,policyHash:t.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:t.message}};if(t instanceof To)return{command:e,exitCode:65,data:{receiptBindingFailures:t.details},error:{code:"invalid-data",message:t.message}};if(t instanceof an)return{command:e,exitCode:65,data:t.recovery,error:{code:"implementation-scope-stale",message:t.message}};if(t instanceof Error){let r=t.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:e,exitCode:70,error:{code:"internal",message:t.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(t.message);return{command:e,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:t.message}}}return{command:e,exitCode:70,error:{code:"internal",message:String(t)}}}function rv(e,t){let r=sP(e,t),i=r.error;if(!i)return r;let n=Xm({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function cP(e,t,r=!1){let i=e.envelope??Ym(e.data);return t?{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,agent:Dm(e.data,e.executionCwd),...i===void 0?{}:{summary:i.summary,...i.next===void 0?{}:{next:i.next},...i.user_message===void 0?{}:{user_message:i.user_message}},...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
200
- `}:e.error?{exitCode:e.exitCode,stderr:i?Mm(i,e.error.message,r?e.data:void 0):e.error.message}:i?{exitCode:e.exitCode,stdout:Bm(i,r?e.data:void 0)}:r&&e.text!==void 0&&e.data!==void 0&&e.text!==tv(e.data)?{exitCode:e.exitCode,stdout:`${e.text}
201
- ${pt.details}
283
+ `}}var K_=U_().usage;var RG=10*1024*1024,U=class extends Error{};function wd(e,t){let r=e.flatMap((i,n)=>i===t?[n]:[]);if(r.length>1)throw new U(`${t} may only be provided once`);return r.length===0?!1:(e.splice(r[0],1),!0)}function pi(e,t){let r=e.flatMap((a,o)=>a===t?[o]:[]);if(r.length>1)throw new U(`${t} may only be provided once`);if(r.length===0)return;let i=r[0],n=e[i+1];if(n===void 0||n.startsWith("--"))throw new U(`${t} requires a value`);return e.splice(i,2),n}function Es(e){if(e.length>0)throw new U(`Unexpected argument: ${e[0]}`)}function Sr(e,t){let r=e.shift();if(!r||r.startsWith("--"))throw new U(`${t} is required`);return r}function gd(e,t){let r=Mn.normalize(Ag(e)),i=Mn.normalize(Ag(t));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Ag(e){let t=Mn.resolve(e);try{return Y_.native(t)}catch{return t}}function X_(e,t){let r=Mn.resolve(t,e),i=_e(t);if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return r;let n=_e(r);return!n.isGitWorktree||n.currentWorktreeRoot===null||n.primaryWorktreeRoot===null||!gd(i.primaryWorktreeRoot,n.primaryWorktreeRoot)||gd(i.currentWorktreeRoot,n.currentWorktreeRoot)?r:gd(t,i.currentWorktreeRoot)?Mn.resolve(t):i.currentWorktreeRoot}async function Ig(e,t=process.cwd()){return e?X_(e,t):po(t)}function Tg(e,t){return e==="status"||e==="show"||e==="root"&&t[0]==="show"}async function xs(e){let t=await Jh({startPath:e,allowMissingConfig:!1});return{config:t.config,paths:t.paths}}function $g(e){return JSON.stringify(e,null,2)+`
284
+ `}function Cs(e,t,r){return{command:e,exitCode:0,data:t,text:r??$g(t)}}function Q_(e,t){if(t instanceof $n)return{command:e,exitCode:65,data:{change:t.change,findings:t.findings},error:{code:"document-invalid",message:t.message}};if(t instanceof Xr)return{command:e,exitCode:65,data:{builderReadiness:{ready:!1,missingIds:t.missingIds,incompleteIds:t.incompleteIds}},error:{code:"invalid-data",message:t.message}};if(t instanceof vi)return{command:e,exitCode:65,error:{code:"invalid-data",message:t.message,issues:t.issues}};if(t instanceof U)return{command:e,exitCode:64,error:{code:"usage",message:t.message}};if(t instanceof Ns)return{command:e,exitCode:73,data:{capability:t.capability,expectedHash:t.expectedHash,actualHash:t.actualHash,canonicalPath:t.canonicalPath},error:{code:"conflict",message:t.message}};if(t instanceof ks)return{command:e,exitCode:73,data:t.preflight,error:{code:"conflict",message:t.message}};if(t instanceof Zo)return{command:e,exitCode:73,data:{change:t.change,expectedRevision:t.expectedRevision,actualRevision:t.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:t.message}};if(t instanceof En)return{command:e,exitCode:73,data:{requestedIsolation:t.requestedIsolation,activeChanges:t.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:t.message}};if(t instanceof fs)return{command:e,exitCode:73,data:{preparation:t.preparation},error:{code:"workspace-preparation-incomplete",message:t.message}};if(t instanceof es)return{command:e,exitCode:65,data:{change:t.change,complete:!1,omittedCount:t.omittedCount,omittedByReason:t.omittedByReason,samplePaths:t.samplePaths,sampleTruncated:t.sampleTruncated,effectiveLimits:t.effectiveLimits,policyHash:t.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:t.message}};if(t instanceof bs)return{command:e,exitCode:65,data:{receiptBindingFailures:t.details},error:{code:"invalid-data",message:t.message}};if(t instanceof Bn)return{command:e,exitCode:65,data:t.recovery,error:{code:"implementation-scope-stale",message:t.message}};if(t instanceof Error){let r=t.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:e,exitCode:70,error:{code:"internal",message:t.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(t.message);return{command:e,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:t.message}}}return{command:e,exitCode:70,error:{code:"internal",message:String(t)}}}function jg(e,t){let r=Q_(e,t),i=r.error;if(!i)return r;let n=Rg({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function Z_(e,t,r=!1){let i=e.envelope??Pg(e.data);return t?{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,agent:hg(e.data,e.executionCwd),...i===void 0?{}:{summary:i.summary,...i.next===void 0?{}:{next:i.next},...i.user_message===void 0?{}:{user_message:i.user_message}},...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
285
+ `}:e.error?{exitCode:e.exitCode,stderr:i?gg(i,e.error.message,r?e.data:void 0):e.error.message}:i?{exitCode:e.exitCode,stdout:vg(i,r?e.data:void 0)}:r&&e.text!==void 0&&e.data!==void 0&&e.text!==$g(e.data)?{exitCode:e.exitCode,stdout:`${e.text}
286
+ ${Et.details}
202
287
  ${JSON.stringify(e.data,null,2)}
203
- `}:{exitCode:e.exitCode,stdout:e.text}}function lP(e,t,r=!1){let i=cP(e,t,r),n=!1;if(i.stdout?.trim())try{let a=JSON.parse(i.stdout);n=!!a&&typeof a=="object"&&!Array.isArray(a)}catch{n=!1}return{output:i,structuredDataVisible:n}}function iv(e,t,r=!1){return lP(e,t,r).output}async function av(e,t){let r=or(e,"spec subcommand");if(r==="sync"){let s=zr(e,"--input"),l=or(e,"change name"),c=or(e,"capability");if(Ho(e),!s)throw new G("spec sync requires --input <json-file>");let u=uP.resolve(t,s),d=await nv.lstat(u).catch(()=>{throw new G(`Spec sync input file is unreadable: ${s}`)});if(!d.isFile()||d.isSymbolicLink()||d.size>1024*1024)throw new G("Spec sync input must be a bounded regular JSON file");let f;try{f=JSON.parse(await nv.readFile(u,"utf8"))}catch{throw new G("Spec sync input must contain readable valid JSON")}if(!f||typeof f!="object"||Object.keys(f).sort().join(",")!=="actor,affectedAcceptanceIds,expectedStateVersion,reason,replacements"||typeof f.actor!="string"||typeof f.reason!="string"||!Number.isSafeInteger(f.expectedStateVersion)||!Array.isArray(f.affectedAcceptanceIds)||!f.affectedAcceptanceIds.every(p=>typeof p=="string")||!Array.isArray(f.replacements)||!f.replacements.every(p=>p&&typeof p=="object"&&Object.keys(p).sort().join(",")==="from,to"&&typeof p.from=="string"&&typeof p.to=="string"))throw new G("Spec sync input fields are invalid");let{paths:h}=await Do(t),m=await nu({...f,paths:h,name:l,capability:c});return Lo("spec sync",{...m,continuation:fn(m)},`Synced Native spec references in ${l}
204
- `)}if(r==="disassociate"){let s=or(e,"change name"),l=zr(e,"--expected-state-version"),c=zr(e,"--expected-action");if(l===void 0||c===void 0)throw new G("--expected-state-version and --expected-action are required for spec disassociate");if(!/^[1-9]\d*$/u.test(l)||!Number.isSafeInteger(Number(l)))throw new G("--expected-state-version must be a positive integer");if(c!=="disassociate-capability")throw new G("--expected-action for spec disassociate must be disassociate-capability");Ho(e);let{paths:u}=await Do(t);if(!await er(u,s))throw new G("spec disassociate requires a current portable Native change");let d=await ou({paths:u,name:s,expectedContinuation:{stateVersion:Number(l),action:"disassociate-capability"}});return Lo("spec disassociate",{...d,continuation:fn(d)},`Revoked Native capability association in ${s}
205
- `)}if(r!=="remove")throw new G(`Unknown spec command: ${r}`);let i=or(e,"change name"),n=or(e,"capability");Ho(e);let{paths:a}=await Do(t);await er(a,i)||await Hm({paths:a,name:i});let o=await au({paths:a,name:i,capability:n});return Lo("spec remove",{...o,continuation:fn(o)},`Marked Native capability ${n} for removal in ${i}
206
- `)}async function ov(e,t,r=process.argv.slice(2)){let i=r.indexOf("--"),n=i<0?[...r]:r.slice(0,i),a=i<0?[]:r.slice(i),o=n.includes("--json"),s=n.includes("--verbose"),l,c;try{fu(n,"--json"),fu(n,"--verbose"),l=zr(n,"--project-root");let d=[...n,...a],f=await ev(l);c={executionCwd:f,...await t(d,f)}}catch(d){c=rv(e,d)}let u=iv(c,o,s);return u.stdout&&process.stdout.write(u.stdout),u.stderr&&process.stderr.write(u.stderr+(u.stderr.endsWith(`
288
+ `}:{exitCode:e.exitCode,stdout:e.text}}function eA(e,t,r=!1){let i=Z_(e,t,r),n=!1;if(i.stdout?.trim())try{let a=JSON.parse(i.stdout);n=!!a&&typeof a=="object"&&!Array.isArray(a)}catch{n=!1}return{output:i,structuredDataVisible:n}}function Og(e,t,r=!1){return eA(e,t,r).output}async function Dg(e,t){let r=Sr(e,"spec subcommand");if(r==="sync"){let s=pi(e,"--input"),l=Sr(e,"change name"),c=Sr(e,"capability");if(Es(e),!s)throw new U("spec sync requires --input <json-file>");let u=tA.resolve(t,s),d=await Hg.lstat(u).catch(()=>{throw new U(`Spec sync input file is unreadable: ${s}`)});if(!d.isFile()||d.isSymbolicLink()||d.size>1024*1024)throw new U("Spec sync input must be a bounded regular JSON file");let f;try{f=JSON.parse(await Hg.readFile(u,"utf8"))}catch{throw new U("Spec sync input must contain readable valid JSON")}if(!f||typeof f!="object"||Object.keys(f).sort().join(",")!=="actor,affectedAcceptanceIds,expectedStateVersion,reason,replacements"||typeof f.actor!="string"||typeof f.reason!="string"||!Number.isSafeInteger(f.expectedStateVersion)||!Array.isArray(f.affectedAcceptanceIds)||!f.affectedAcceptanceIds.every(p=>typeof p=="string")||!Array.isArray(f.replacements)||!f.replacements.every(p=>p&&typeof p=="object"&&Object.keys(p).sort().join(",")==="from,to"&&typeof p.from=="string"&&typeof p.to=="string"))throw new U("Spec sync input fields are invalid");let{paths:h}=await xs(t),m=await ud({...f,paths:h,name:l,capability:c});return Cs("spec sync",{...m,continuation:Gn(m)},`Synced Native spec references in ${l}
289
+ `)}if(r==="disassociate"){let s=Sr(e,"change name"),l=pi(e,"--expected-state-version"),c=pi(e,"--expected-action");if(l===void 0||c===void 0)throw new U("--expected-state-version and --expected-action are required for spec disassociate");if(!/^[1-9]\d*$/u.test(l)||!Number.isSafeInteger(Number(l)))throw new U("--expected-state-version must be a positive integer");if(c!=="disassociate-capability")throw new U("--expected-action for spec disassociate must be disassociate-capability");Es(e);let{paths:u}=await xs(t);if(!await pr(u,s))throw new U("spec disassociate requires a current portable Native change");let d=await fd({paths:u,name:s,expectedContinuation:{stateVersion:Number(l),action:"disassociate-capability"}});return Cs("spec disassociate",{...d,continuation:Gn(d)},`Revoked Native capability association in ${s}
290
+ `)}if(r!=="remove")throw new U(`Unknown spec command: ${r}`);let i=Sr(e,"change name"),n=Sr(e,"capability");Es(e);let{paths:a}=await xs(t);await pr(a,i)||await pg({paths:a,name:i});let o=await dd({paths:a,name:i,capability:n});return Cs("spec remove",{...o,continuation:Gn(o)},`Marked Native capability ${n} for removal in ${i}
291
+ `)}async function Lg(e,t,r=process.argv.slice(2)){let i=r.indexOf("--"),n=i<0?[...r]:r.slice(0,i),a=i<0?[]:r.slice(i),o=n.includes("--json"),s=n.includes("--verbose"),l,c;try{wd(n,"--json"),wd(n,"--verbose"),l=pi(n,"--project-root");let d=[...n,...a],f=async()=>{let h=await Ig(l);return{executionCwd:h,...await t(d,h)}};c=Tg(e,d)?await Ad(f):await f()}catch(d){c=jg(e,d)}let u=Og(c,o,s);return u.stdout&&process.stdout.write(u.stdout),u.stderr&&process.stderr.write(u.stderr+(u.stderr.endsWith(`
207
292
  `)?"":`
208
- `)),u.exitCode}process.exitCode=await ov("spec",av);
293
+ `)),u.exitCode}process.exitCode=await Lg("spec",Dg);