@rpamis/comet 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/assets/manifest.json +1 -1
- package/assets/skills/comet/scripts/comet-archive.mjs +109 -96
- package/assets/skills/comet/scripts/comet-check.mjs +117 -104
- package/assets/skills/comet/scripts/comet-entry-runtime.mjs +59 -59
- package/assets/skills/comet/scripts/comet-guard.mjs +173 -160
- package/assets/skills/comet/scripts/comet-handoff.mjs +110 -97
- package/assets/skills/comet/scripts/comet-hook-guard.mjs +110 -97
- package/assets/skills/comet/scripts/comet-hook-router.mjs +269 -159
- package/assets/skills/comet/scripts/comet-intent.mjs +31 -31
- package/assets/skills/comet/scripts/comet-resume-probe.mjs +104 -91
- package/assets/skills/comet/scripts/comet-runtime.mjs +272 -259
- package/assets/skills/comet/scripts/comet-state.mjs +204 -191
- package/assets/skills/comet/scripts/comet-yaml-validate.mjs +25 -25
- package/assets/skills/comet-archive/SKILL.md +4 -4
- package/assets/skills/comet-build/SKILL.md +4 -6
- package/assets/skills/comet-classic/SKILL.md +3 -1
- package/assets/skills/comet-classic/reference/scripts.md +17 -1
- package/assets/skills/comet-design/SKILL.md +0 -2
- package/assets/skills/comet-hotfix/SKILL.md +2 -3
- package/assets/skills/comet-native/SKILL.md +11 -8
- package/assets/skills/comet-native/reference/artifacts.md +7 -7
- package/assets/skills/comet-native/reference/clarification.md +4 -4
- package/assets/skills/comet-native/reference/commands.md +25 -13
- package/assets/skills/comet-native/reference/recovery.md +3 -3
- package/assets/skills/comet-native/reference/workspace.md +10 -4
- package/assets/skills/comet-native/scripts/comet-native-archive.mjs +230 -149
- package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +239 -161
- package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +232 -122
- package/assets/skills/comet-native/scripts/comet-native-init.mjs +184 -107
- package/assets/skills/comet-native/scripts/comet-native-new.mjs +219 -142
- package/assets/skills/comet-native/scripts/comet-native-next.mjs +239 -161
- package/assets/skills/comet-native/scripts/comet-native-root.mjs +205 -128
- package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +276 -195
- package/assets/skills/comet-native/scripts/comet-native-select.mjs +204 -127
- package/assets/skills/comet-native/scripts/comet-native-show.mjs +202 -125
- package/assets/skills/comet-native/scripts/comet-native-spec.mjs +203 -125
- package/assets/skills/comet-native/scripts/comet-native-status.mjs +200 -123
- package/assets/skills/comet-open/SKILL.md +0 -2
- package/assets/skills/comet-tweak/SKILL.md +2 -1
- package/assets/skills/comet-verify/SKILL.md +0 -2
- package/assets/skills-zh/comet-archive/SKILL.md +4 -4
- package/assets/skills-zh/comet-build/SKILL.md +4 -6
- package/assets/skills-zh/comet-classic/SKILL.md +3 -1
- package/assets/skills-zh/comet-classic/reference/scripts.md +11 -1
- package/assets/skills-zh/comet-design/SKILL.md +0 -2
- package/assets/skills-zh/comet-hotfix/SKILL.md +2 -3
- package/assets/skills-zh/comet-native/SKILL.md +11 -8
- package/assets/skills-zh/comet-native/reference/artifacts.md +7 -7
- package/assets/skills-zh/comet-native/reference/clarification.md +4 -4
- package/assets/skills-zh/comet-native/reference/commands.md +26 -10
- package/assets/skills-zh/comet-native/reference/recovery.md +3 -3
- package/assets/skills-zh/comet-native/reference/workspace.md +10 -4
- package/assets/skills-zh/comet-open/SKILL.md +0 -2
- package/assets/skills-zh/comet-tweak/SKILL.md +2 -1
- package/assets/skills-zh/comet-verify/SKILL.md +0 -2
- package/bin/comet-daemon-router.js +57 -13
- package/bin/fast-runtime-router.js +1 -1
- package/dist/app/commands/daemon-server.d.ts.map +1 -1
- package/dist/app/commands/daemon-server.js +14 -2
- package/dist/app/commands/daemon-server.js.map +1 -1
- package/dist/app/commands/project-knowledge.d.ts.map +1 -1
- package/dist/app/commands/project-knowledge.js +0 -1
- package/dist/app/commands/project-knowledge.js.map +1 -1
- package/dist/domains/comet-classic/classic-archive-entry.d.ts +1 -1
- package/dist/domains/comet-classic/classic-archive-entry.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-archive-entry.js +5 -2
- package/dist/domains/comet-classic/classic-archive-entry.js.map +1 -1
- package/dist/domains/comet-classic/classic-branch-binding.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-branch-binding.js +5 -4
- package/dist/domains/comet-classic/classic-branch-binding.js.map +1 -1
- package/dist/domains/comet-classic/classic-check-entry.d.ts +1 -1
- package/dist/domains/comet-classic/classic-check-entry.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-check-entry.js +5 -2
- package/dist/domains/comet-classic/classic-check-entry.js.map +1 -1
- package/dist/domains/comet-classic/classic-check-snapshot.d.ts +2 -0
- package/dist/domains/comet-classic/classic-check-snapshot.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-check-snapshot.js +90 -27
- package/dist/domains/comet-classic/classic-check-snapshot.js.map +1 -1
- package/dist/domains/comet-classic/classic-guard-entry.d.ts +1 -1
- package/dist/domains/comet-classic/classic-guard-entry.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-guard-entry.js +5 -2
- package/dist/domains/comet-classic/classic-guard-entry.js.map +1 -1
- package/dist/domains/comet-classic/classic-handoff-entry.d.ts +1 -1
- package/dist/domains/comet-classic/classic-handoff-entry.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-handoff-entry.js +5 -2
- package/dist/domains/comet-classic/classic-handoff-entry.js.map +1 -1
- package/dist/domains/comet-classic/classic-resume-probe.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-resume-probe.js +3 -2
- package/dist/domains/comet-classic/classic-resume-probe.js.map +1 -1
- package/dist/domains/comet-classic/classic-script-entry.d.ts +3 -1
- package/dist/domains/comet-classic/classic-script-entry.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-script-entry.js +34 -3
- package/dist/domains/comet-classic/classic-script-entry.js.map +1 -1
- package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-state-command.js +3 -2
- package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
- package/dist/domains/comet-classic/classic-state-entry.d.ts +1 -1
- package/dist/domains/comet-classic/classic-state-entry.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-state-entry.js +5 -2
- package/dist/domains/comet-classic/classic-state-entry.js.map +1 -1
- package/dist/domains/comet-classic/classic-store.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-store.js +67 -1
- package/dist/domains/comet-classic/classic-store.js.map +1 -1
- package/dist/domains/comet-entry/resume-probe.d.ts.map +1 -1
- package/dist/domains/comet-entry/resume-probe.js +3 -2
- package/dist/domains/comet-entry/resume-probe.js.map +1 -1
- package/dist/domains/comet-native/native-acceptance.d.ts +5 -1
- package/dist/domains/comet-native/native-acceptance.d.ts.map +1 -1
- package/dist/domains/comet-native/native-acceptance.js +13 -2
- package/dist/domains/comet-native/native-acceptance.js.map +1 -1
- package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-archive-command.js +167 -37
- package/dist/domains/comet-native/native-archive-command.js.map +1 -1
- package/dist/domains/comet-native/native-artifact-language.d.ts +3 -1
- package/dist/domains/comet-native/native-artifact-language.d.ts.map +1 -1
- package/dist/domains/comet-native/native-artifact-language.js +4 -11
- package/dist/domains/comet-native/native-artifact-language.js.map +1 -1
- package/dist/domains/comet-native/native-artifacts.d.ts +8 -1
- package/dist/domains/comet-native/native-artifacts.d.ts.map +1 -1
- package/dist/domains/comet-native/native-artifacts.js +14 -2
- package/dist/domains/comet-native/native-artifacts.js.map +1 -1
- package/dist/domains/comet-native/native-builder-acceptance-review.d.ts +16 -0
- package/dist/domains/comet-native/native-builder-acceptance-review.d.ts.map +1 -0
- package/dist/domains/comet-native/native-builder-acceptance-review.js +65 -0
- package/dist/domains/comet-native/native-builder-acceptance-review.js.map +1 -0
- package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli-help.js +8 -4
- package/dist/domains/comet-native/native-cli-help.js.map +1 -1
- package/dist/domains/comet-native/native-cli-shared.d.ts +4 -2
- package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli-shared.js +37 -9
- package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
- package/dist/domains/comet-native/native-cli.d.ts +4 -1
- package/dist/domains/comet-native/native-cli.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli.js +9 -5
- package/dist/domains/comet-native/native-cli.js.map +1 -1
- package/dist/domains/comet-native/native-doctor-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-doctor-command.js +144 -3
- package/dist/domains/comet-native/native-doctor-command.js.map +1 -1
- package/dist/domains/comet-native/native-git-provenance.d.ts.map +1 -1
- package/dist/domains/comet-native/native-git-provenance.js +3 -2
- package/dist/domains/comet-native/native-git-provenance.js.map +1 -1
- package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
- package/dist/domains/comet-native/native-hook-guard.js +56 -26
- package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
- package/dist/domains/comet-native/native-local-execution.d.ts +1 -0
- package/dist/domains/comet-native/native-local-execution.d.ts.map +1 -1
- package/dist/domains/comet-native/native-local-execution.js +7 -0
- package/dist/domains/comet-native/native-local-execution.js.map +1 -1
- package/dist/domains/comet-native/native-lock.d.ts.map +1 -1
- package/dist/domains/comet-native/native-lock.js +12 -0
- package/dist/domains/comet-native/native-lock.js.map +1 -1
- package/dist/domains/comet-native/native-loop-runtime.d.ts +2 -0
- package/dist/domains/comet-native/native-loop-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-loop-runtime.js +6 -0
- package/dist/domains/comet-native/native-loop-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-next-command.js +57 -28
- package/dist/domains/comet-native/native-next-command.js.map +1 -1
- package/dist/domains/comet-native/native-output-language.d.ts.map +1 -1
- package/dist/domains/comet-native/native-output-language.js +7 -0
- package/dist/domains/comet-native/native-output-language.js.map +1 -1
- package/dist/domains/comet-native/native-portable-acceptance.d.ts +2 -0
- package/dist/domains/comet-native/native-portable-acceptance.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-acceptance.js +11 -1
- package/dist/domains/comet-native/native-portable-acceptance.js.map +1 -1
- package/dist/domains/comet-native/native-portable-archive.d.ts +1 -0
- package/dist/domains/comet-native/native-portable-archive.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-archive.js +3 -0
- package/dist/domains/comet-native/native-portable-archive.js.map +1 -1
- package/dist/domains/comet-native/native-portable-checks.d.ts +15 -4
- package/dist/domains/comet-native/native-portable-checks.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-checks.js +167 -66
- package/dist/domains/comet-native/native-portable-checks.js.map +1 -1
- package/dist/domains/comet-native/native-portable-continuation.d.ts +2 -1
- package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-continuation.js +121 -39
- package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
- package/dist/domains/comet-native/native-portable-requirements.d.ts +1 -0
- package/dist/domains/comet-native/native-portable-requirements.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-requirements.js +61 -18
- package/dist/domains/comet-native/native-portable-requirements.js.map +1 -1
- package/dist/domains/comet-native/native-portable-shape-coordination.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-shape-coordination.js +18 -5
- package/dist/domains/comet-native/native-portable-shape-coordination.js.map +1 -1
- package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-state.js +10 -3
- package/dist/domains/comet-native/native-portable-state.js.map +1 -1
- package/dist/domains/comet-native/native-portable-status.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-status.js +10 -4
- package/dist/domains/comet-native/native-portable-status.js.map +1 -1
- package/dist/domains/comet-native/native-portable-types.d.ts +2 -1
- package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-types.js.map +1 -1
- package/dist/domains/comet-native/native-portable-verification.d.ts +3 -0
- package/dist/domains/comet-native/native-portable-verification.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-verification.js +28 -35
- package/dist/domains/comet-native/native-portable-verification.js.map +1 -1
- package/dist/domains/comet-native/native-portable-verifier-coordination.d.ts +2 -0
- package/dist/domains/comet-native/native-portable-verifier-coordination.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-verifier-coordination.js +9 -0
- package/dist/domains/comet-native/native-portable-verifier-coordination.js.map +1 -1
- package/dist/domains/comet-native/native-runner-input-artifacts.d.ts +9 -0
- package/dist/domains/comet-native/native-runner-input-artifacts.d.ts.map +1 -0
- package/dist/domains/comet-native/native-runner-input-artifacts.js +102 -0
- package/dist/domains/comet-native/native-runner-input-artifacts.js.map +1 -0
- package/dist/domains/comet-native/native-runner-input.d.ts +90 -64
- package/dist/domains/comet-native/native-runner-input.d.ts.map +1 -1
- package/dist/domains/comet-native/native-runner-input.js +107 -22
- package/dist/domains/comet-native/native-runner-input.js.map +1 -1
- package/dist/domains/comet-native/native-script-entry.d.ts.map +1 -1
- package/dist/domains/comet-native/native-script-entry.js +9 -3
- package/dist/domains/comet-native/native-script-entry.js.map +1 -1
- package/dist/domains/comet-native/native-snapshot.d.ts.map +1 -1
- package/dist/domains/comet-native/native-snapshot.js +7 -2
- package/dist/domains/comet-native/native-snapshot.js.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt-runtime.js +5 -4
- package/dist/domains/comet-native/native-verification-receipt-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-workspace-finish.d.ts +26 -0
- package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -1
- package/dist/domains/comet-native/native-workspace-finish.js +520 -15
- package/dist/domains/comet-native/native-workspace-finish.js.map +1 -1
- package/dist/domains/dashboard/web/assets/{abnfDiagram-VCTEODGH-qlcciI25.js → abnfDiagram-VCTEODGH-CFEU4PQU.js} +1 -1
- package/dist/domains/dashboard/web/assets/{arc-KVm4k9kp.js → arc-BeYYJor9.js} +1 -1
- package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-YphM8Wtg.js +1 -0
- package/dist/domains/dashboard/web/assets/{architectureDiagram-5GKGNRK7-C366RdBK.js → architectureDiagram-5GKGNRK7-CqTy4fyH.js} +1 -1
- package/dist/domains/dashboard/web/assets/{blockDiagram-I7D4REHJ-DAuTc2OO.js → blockDiagram-I7D4REHJ-SR_5S4SA.js} +1 -1
- package/dist/domains/dashboard/web/assets/{c4Diagram-7LVT6UL2-CFB0RZmL.js → c4Diagram-7LVT6UL2-DzphG2XS.js} +1 -1
- package/dist/domains/dashboard/web/assets/channel-BkwcGbYR.js +1 -0
- package/dist/domains/dashboard/web/assets/{chunk-4HAMMTFA-DTV6lyGQ.js → chunk-4HAMMTFA-BpthUtIs.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-75Z2AOVW-DgJm4cEX.js → chunk-75Z2AOVW-CxAdhPhG.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-DU6HZSFF-NAtcgGZr.js → chunk-DU6HZSFF-5peVNfxp.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-F27PBJKO-BcFXHZMJ.js → chunk-F27PBJKO-CwG4xi2V.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-GMAD6QVW-wNemar9b.js → chunk-GMAD6QVW-BuFFY783.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-GVQU2GXP-BiVCDO9d.js → chunk-GVQU2GXP-OyUFmjE-.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-IMKFNOWR-D9GDj4b6.js → chunk-IMKFNOWR-DmTme45C.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-L3NEJ4N5-DkPl5vac.js → chunk-L3NEJ4N5-D6BHbKty.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-OSK3NFVY-RbbxGqtJ.js → chunk-OSK3NFVY-CCz1v1Nv.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-P2QGCYS3-B9_X57eT.js → chunk-P2QGCYS3-C1_7kDYS.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-POPQ4Y6H-DE4bOH0D.js → chunk-POPQ4Y6H-buFKlAdG.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-PWAF6VOD-Bo-W1iA1.js → chunk-PWAF6VOD-B_K6Jrsv.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-SHT3W25Y-BhLxs4rZ.js → chunk-SHT3W25Y-CRRLsXmS.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-SVP7TREG-BCXfn8uF.js → chunk-SVP7TREG-Q5zCQTul.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-TICWLB2K-DqSBgE5L.js → chunk-TICWLB2K-Zc5XaO5Z.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-XXDRQBXY-Dbkt1xEZ.js → chunk-XXDRQBXY-BAIB2h_r.js} +1 -1
- package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-DzpQhyL3.js +1 -0
- package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-DzpQhyL3.js +1 -0
- package/dist/domains/dashboard/web/assets/{cose-bilkent-JH36ORCC-DrwNpMyX.js → cose-bilkent-JH36ORCC-C7jkFYhm.js} +1 -1
- package/dist/domains/dashboard/web/assets/{cynefin-OW5HDTMX-BbDlivxs.js → cynefin-OW5HDTMX-4yS-l7kx.js} +1 -1
- package/dist/domains/dashboard/web/assets/{cynefinDiagram-5FMLGOSQ-DmLmRN42.js → cynefinDiagram-5FMLGOSQ-DAkfQ8jW.js} +1 -1
- package/dist/domains/dashboard/web/assets/{dagre-GXQ25YYZ-Cgm5DNgI.js → dagre-GXQ25YYZ-D3b16ruz.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-S7CK7UJ4-Bnht1X2m.js → diagram-S7CK7UJ4-BXZHtdNz.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-UQ7AKVKN-LELTI4PR.js → diagram-UQ7AKVKN-B4nIzofw.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-VSXAHHWV-Do0fZuNG.js → diagram-VSXAHHWV-B6d7KNj1.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-VX7I27RA-B0rZTUwt.js → diagram-VX7I27RA-CHr0Rg8a.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-Z3DM3KII-wn8xCc_j.js → diagram-Z3DM3KII-BO2IxR9N.js} +1 -1
- package/dist/domains/dashboard/web/assets/{dist-CYwDKy2m.js → dist-0wyW4qbm.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ebnfDiagram-PWID7BFC-CMDOpP2T.js → ebnfDiagram-PWID7BFC-CHRK8Hyg.js} +1 -1
- package/dist/domains/dashboard/web/assets/{erDiagram-RLTQ6QDP-C2d43bdq.js → erDiagram-RLTQ6QDP-_HFHzZlc.js} +1 -1
- package/dist/domains/dashboard/web/assets/{es-BzaOcXwu.js → es-kjndkyYX.js} +1 -1
- package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-CG-cVTEg.js +1 -0
- package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-C3RaJz-z.js +1 -0
- package/dist/domains/dashboard/web/assets/{ganttDiagram-EL5Y4UJY-hTH7TzhY.js → ganttDiagram-EL5Y4UJY-CxhSw1PI.js} +1 -1
- package/dist/domains/dashboard/web/assets/{gitGraph-4MIJSDKK-C3CCywb-.js → gitGraph-4MIJSDKK-Cbw-3Dnk.js} +1 -1
- package/dist/domains/dashboard/web/assets/{gitGraphDiagram-WWUBYQGX-DW6jDckj.js → gitGraphDiagram-WWUBYQGX-Cx93hwtL.js} +1 -1
- package/dist/domains/dashboard/web/assets/{index-CTZPz_mx.js → index-CQb8j5OE.js} +3 -3
- package/dist/domains/dashboard/web/assets/{index-CWNqBYyI.css → index-Gaxnq6Jd.css} +1 -1
- package/dist/domains/dashboard/web/assets/{info-A6RAGUB7-Bg3eKis8.js → info-A6RAGUB7--d4EMiIK.js} +1 -1
- package/dist/domains/dashboard/web/assets/{infoDiagram-27XIBGKW-7zk6ytVJ.js → infoDiagram-27XIBGKW-DMkRRNGB.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ishikawaDiagram-5VMMS53U-CGDCTmCQ.js → ishikawaDiagram-5VMMS53U-CjKh_jHT.js} +1 -1
- package/dist/domains/dashboard/web/assets/{journeyDiagram-3NMN7TZE-C8_L_e8a.js → journeyDiagram-3NMN7TZE-CG735M_M.js} +1 -1
- package/dist/domains/dashboard/web/assets/{kanban-definition-UXKFOSKX-D5x6qTgM.js → kanban-definition-UXKFOSKX-CgXFmhFM.js} +1 -1
- package/dist/domains/dashboard/web/assets/{line-DC93oja4.js → line-Bhf8l3gG.js} +1 -1
- package/dist/domains/dashboard/web/assets/{linear-81TNubkB.js → linear-YWT9mnmu.js} +1 -1
- package/dist/domains/dashboard/web/assets/{mermaid-parser.core-D60d8uy9.js → mermaid-parser.core-COzQ1kq0.js} +3 -3
- package/dist/domains/dashboard/web/assets/{mermaid.core-l4Wgjz2Q.js → mermaid.core-Cc1lMpx-.js} +4 -4
- package/dist/domains/dashboard/web/assets/{mindmap-definition-YA3MSWOX-Dfqu1201.js → mindmap-definition-YA3MSWOX-B_VOgUSO.js} +1 -1
- package/dist/domains/dashboard/web/assets/{packet-AYTQ26CC-CsFZBhTs.js → packet-AYTQ26CC-CXbJLNC9.js} +1 -1
- package/dist/domains/dashboard/web/assets/{pegDiagram-XKGWAZYB-myFMaA7n.js → pegDiagram-XKGWAZYB-BuS0hioo.js} +1 -1
- package/dist/domains/dashboard/web/assets/{pie-WAS4IAKB-FMuCTNSk.js → pie-WAS4IAKB-BEaGwdWZ.js} +1 -1
- package/dist/domains/dashboard/web/assets/{pieDiagram-E7YTZNPT-CSR4B4Z1.js → pieDiagram-E7YTZNPT-DDzYv-_9.js} +1 -1
- package/dist/domains/dashboard/web/assets/purify.es-Bvo9QlJ8.js +3 -0
- package/dist/domains/dashboard/web/assets/{quadrantDiagram-AXDQQJYC-BiE4kEeP.js → quadrantDiagram-AXDQQJYC-DExT--Ut.js} +1 -1
- package/dist/domains/dashboard/web/assets/{radar-RG4KPBEZ-BZ-n7JtG.js → radar-RG4KPBEZ-C1JtzGr8.js} +1 -1
- package/dist/domains/dashboard/web/assets/{railroad-74A4TZTK-CWVtRfHu.js → railroad-74A4TZTK-CMpkXATR.js} +1 -1
- package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-BM35gYWg.js +1 -0
- package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-CN60GGp0.js +1 -0
- package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-DRUSW4g7.js +1 -0
- package/dist/domains/dashboard/web/assets/{railroadDiagram-O6MQD6OU-CBj7v1de.js → railroadDiagram-O6MQD6OU-BCE65sLR.js} +1 -1
- package/dist/domains/dashboard/web/assets/{requirementDiagram-BXWQKSXE-DSDgb54n.js → requirementDiagram-BXWQKSXE-CmyX3vGG.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sankeyDiagram-P5KCCOFB-1-oXLUAP.js → sankeyDiagram-P5KCCOFB-BFKrX2dv.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sequenceDiagram-WJ2MYXX4-DAF4nGs_.js → sequenceDiagram-WJ2MYXX4-DqodS9W-.js} +1 -1
- package/dist/domains/dashboard/web/assets/{src-CTWLVUqE.js → src-BVUP3QzK.js} +1 -1
- package/dist/domains/dashboard/web/assets/{stateDiagram-D77RDMKH-DzENBaJT.js → stateDiagram-D77RDMKH-nHai_EZh.js} +1 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-BL6vE1m9.js +1 -0
- package/dist/domains/dashboard/web/assets/{swimlanes-42K2YHIH-CnxFUZJc.js → swimlanes-42K2YHIH-BODBARYN.js} +1 -1
- package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-XHK_nuTj.js +8 -0
- package/dist/domains/dashboard/web/assets/{timeline-definition-24CTP7MA-KtvPzpZM.js → timeline-definition-24CTP7MA-RVnG8rgK.js} +1 -1
- package/dist/domains/dashboard/web/assets/{treeView-Q6P3EWNA-Bdu3P9iY.js → treeView-Q6P3EWNA-B6lrg3KQ.js} +1 -1
- package/dist/domains/dashboard/web/assets/{treemap-WGGIJYW6-DFnn23JR.js → treemap-WGGIJYW6-CJfMKVf4.js} +1 -1
- package/dist/domains/dashboard/web/assets/{vennDiagram-4TSXK5OY-BjpviP26.js → vennDiagram-4TSXK5OY-CZMWJiN7.js} +1 -1
- package/dist/domains/dashboard/web/assets/{wardley-WFR3VGLG-CEo4a-j4.js → wardley-WFR3VGLG-BoUsbNlx.js} +1 -1
- package/dist/domains/dashboard/web/assets/{wardleyDiagram-VM6X3IG4-Bf54n6im.js → wardleyDiagram-VM6X3IG4-BwBCykVb.js} +1 -1
- package/dist/domains/dashboard/web/assets/{xychartDiagram-S5SC5T6Z-CU-hI0Cm.js → xychartDiagram-S5SC5T6Z-vutnbx57.js} +1 -1
- package/dist/domains/dashboard/web/index.html +2 -2
- package/dist/domains/project-knowledge/corpus.d.ts +5 -0
- package/dist/domains/project-knowledge/corpus.d.ts.map +1 -1
- package/dist/domains/project-knowledge/corpus.js +34 -9
- package/dist/domains/project-knowledge/corpus.js.map +1 -1
- package/dist/domains/project-knowledge/index-store.d.ts +5 -2
- package/dist/domains/project-knowledge/index-store.d.ts.map +1 -1
- package/dist/domains/project-knowledge/index-store.js +95 -52
- package/dist/domains/project-knowledge/index-store.js.map +1 -1
- package/dist/domains/project-knowledge/local-provider.d.ts.map +1 -1
- package/dist/domains/project-knowledge/local-provider.js +14 -3
- package/dist/domains/project-knowledge/local-provider.js.map +1 -1
- package/dist/domains/project-knowledge/local-store.d.ts +2 -2
- package/dist/domains/project-knowledge/local-store.d.ts.map +1 -1
- package/dist/domains/project-knowledge/local-store.js +2 -2
- package/dist/domains/project-knowledge/local-store.js.map +1 -1
- package/dist/domains/project-knowledge/plugin.d.ts.map +1 -1
- package/dist/domains/project-knowledge/plugin.js +5 -4
- package/dist/domains/project-knowledge/plugin.js.map +1 -1
- package/dist/domains/project-knowledge/provider-factory.d.ts.map +1 -1
- package/dist/domains/project-knowledge/provider-factory.js +7 -5
- package/dist/domains/project-knowledge/provider-factory.js.map +1 -1
- package/dist/domains/project-knowledge/types.d.ts +1 -0
- package/dist/domains/project-knowledge/types.d.ts.map +1 -1
- package/dist/domains/skill/platform-install.d.ts.map +1 -1
- package/dist/domains/skill/platform-install.js +31 -3
- package/dist/domains/skill/platform-install.js.map +1 -1
- package/dist/domains/workflow-contract/hook-target-scope.d.ts.map +1 -1
- package/dist/domains/workflow-contract/hook-target-scope.js +2 -1
- package/dist/domains/workflow-contract/hook-target-scope.js.map +1 -1
- package/dist/platform/paths/git-worktree-cache.d.ts +3 -0
- package/dist/platform/paths/git-worktree-cache.d.ts.map +1 -0
- package/dist/platform/paths/git-worktree-cache.js +109 -0
- package/dist/platform/paths/git-worktree-cache.js.map +1 -0
- package/dist/platform/paths/git-worktree.d.ts +6 -0
- package/dist/platform/paths/git-worktree.d.ts.map +1 -1
- package/dist/platform/paths/git-worktree.js +191 -30
- package/dist/platform/paths/git-worktree.js.map +1 -1
- package/dist/platform/process/comet-daemon.d.ts +3 -0
- package/dist/platform/process/comet-daemon.d.ts.map +1 -1
- package/dist/platform/process/comet-daemon.js +9 -6
- package/dist/platform/process/comet-daemon.js.map +1 -1
- package/dist/platform/process/external-command.d.ts +3 -0
- package/dist/platform/process/external-command.d.ts.map +1 -1
- package/dist/platform/process/external-command.js +69 -2
- package/dist/platform/process/external-command.js.map +1 -1
- package/dist/platform/process/git.d.ts.map +1 -1
- package/dist/platform/process/git.js +3 -4
- package/dist/platform/process/git.js.map +1 -1
- package/dist/platform/process/hook-adapter.d.ts +2 -0
- package/dist/platform/process/hook-adapter.d.ts.map +1 -1
- package/dist/platform/process/hook-adapter.js +32 -3
- package/dist/platform/process/hook-adapter.js.map +1 -1
- package/dist/platform/process/hook-read-cache.d.ts +2 -0
- package/dist/platform/process/hook-read-cache.d.ts.map +1 -1
- package/dist/platform/process/hook-read-cache.js +25 -13
- package/dist/platform/process/hook-read-cache.js.map +1 -1
- package/dist/platform/process/process-identity.d.ts.map +1 -1
- package/dist/platform/process/process-identity.js +18 -51
- package/dist/platform/process/process-identity.js.map +1 -1
- package/dist/platform/process/runtime-metrics.d.ts +10 -1
- package/dist/platform/process/runtime-metrics.d.ts.map +1 -1
- package/dist/platform/process/runtime-metrics.js +37 -2
- package/dist/platform/process/runtime-metrics.js.map +1 -1
- package/dist/platform/process/windows-process-broker.d.ts +13 -0
- package/dist/platform/process/windows-process-broker.d.ts.map +1 -0
- package/dist/platform/process/windows-process-broker.js +150 -0
- package/dist/platform/process/windows-process-broker.js.map +1 -0
- package/dist/platform/process/windows-process-identity.d.ts +6 -0
- package/dist/platform/process/windows-process-identity.d.ts.map +1 -0
- package/dist/platform/process/windows-process-identity.js +190 -0
- package/dist/platform/process/windows-process-identity.js.map +1 -0
- package/package.json +1 -1
- package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-QeljAKq2.js +0 -1
- package/dist/domains/dashboard/web/assets/channel-_AqwP0KA.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-CRo4aB_7.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-CRo4aB_7.js +0 -1
- package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-KYANo3DQ.js +0 -1
- package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-CSROlLuj.js +0 -1
- package/dist/domains/dashboard/web/assets/purify.es-ChwZkWde.js +0 -3
- package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CkHwwI2i.js +0 -1
- package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-8xzEHL6v.js +0 -1
- package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-nSHBw0tH.js +0 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-CNw52Fkn.js +0 -1
- package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-6TRvbqqI.js +0 -8
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cometCreateRequire } from 'module';
|
|
3
3
|
const require = __cometCreateRequire(import.meta.url);
|
|
4
|
-
var
|
|
5
|
-
`)}};
|
|
6
|
-
`)?
|
|
4
|
+
var hm=Object.create;var lo=Object.defineProperty;var gm=Object.getOwnPropertyDescriptor;var wm=Object.getOwnPropertyNames;var ym=Object.getPrototypeOf,vm=Object.prototype.hasOwnProperty;var ur=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var T=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var k=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}},km=(t,e)=>{for(var n in e)lo(t,n,{get:e[n],enumerable:!0})},bm=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wm(e))!vm.call(t,i)&&i!==n&&lo(t,i,{get:()=>e[i],enumerable:!(r=gm(e,i))||r.enumerable});return t};var ve=(t,e,n)=>(n=t!=null?hm(ym(t)):{},bm(e||!t||!t.__esModule?lo(n,"default",{value:t,enumerable:!0}):n,t));var P=k(G=>{"use strict";var uo=Symbol.for("yaml.alias"),Va=Symbol.for("yaml.document"),fr=Symbol.for("yaml.map"),Xa=Symbol.for("yaml.pair"),fo=Symbol.for("yaml.scalar"),dr=Symbol.for("yaml.seq"),$e=Symbol.for("yaml.node.type"),Em=t=>!!t&&typeof t=="object"&&t[$e]===uo,xm=t=>!!t&&typeof t=="object"&&t[$e]===Va,_m=t=>!!t&&typeof t=="object"&&t[$e]===fr,Rm=t=>!!t&&typeof t=="object"&&t[$e]===Xa,Qa=t=>!!t&&typeof t=="object"&&t[$e]===fo,Pm=t=>!!t&&typeof t=="object"&&t[$e]===dr;function Za(t){if(t&&typeof t=="object")switch(t[$e]){case fr:case dr:return!0}return!1}function Om(t){if(t&&typeof t=="object")switch(t[$e]){case uo:case fr:case fo:case dr:return!0}return!1}var Am=t=>(Qa(t)||Za(t))&&!!t.anchor;G.ALIAS=uo;G.DOC=Va;G.MAP=fr;G.NODE_TYPE=$e;G.PAIR=Xa;G.SCALAR=fo;G.SEQ=dr;G.hasAnchor=Am;G.isAlias=Em;G.isCollection=Za;G.isDocument=xm;G.isMap=_m;G.isNode=Om;G.isPair=Rm;G.isScalar=Qa;G.isSeq=Pm});var un=k(mo=>{"use strict";var M=P(),ne=Symbol("break visit"),ec=Symbol("skip children"),ke=Symbol("remove node");function mr(t,e){let n=tc(e);M.isDocument(t)?Pt(null,t.contents,n,Object.freeze([t]))===ke&&(t.contents=null):Pt(null,t,n,Object.freeze([]))}mr.BREAK=ne;mr.SKIP=ec;mr.REMOVE=ke;function Pt(t,e,n,r){let i=nc(t,e,n,r);if(M.isNode(i)||M.isPair(i))return rc(t,r,i),Pt(t,i,n,r);if(typeof i!="symbol"){if(M.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let s=Pt(o,e.items[o],n,r);if(typeof s=="number")o=s-1;else{if(s===ne)return ne;s===ke&&(e.items.splice(o,1),o-=1)}}}else if(M.isPair(e)){r=Object.freeze(r.concat(e));let o=Pt("key",e.key,n,r);if(o===ne)return ne;o===ke&&(e.key=null);let s=Pt("value",e.value,n,r);if(s===ne)return ne;s===ke&&(e.value=null)}}return i}async function pr(t,e){let n=tc(e);M.isDocument(t)?await Ot(null,t.contents,n,Object.freeze([t]))===ke&&(t.contents=null):await Ot(null,t,n,Object.freeze([]))}pr.BREAK=ne;pr.SKIP=ec;pr.REMOVE=ke;async function Ot(t,e,n,r){let i=await nc(t,e,n,r);if(M.isNode(i)||M.isPair(i))return rc(t,r,i),Ot(t,i,n,r);if(typeof i!="symbol"){if(M.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let s=await Ot(o,e.items[o],n,r);if(typeof s=="number")o=s-1;else{if(s===ne)return ne;s===ke&&(e.items.splice(o,1),o-=1)}}}else if(M.isPair(e)){r=Object.freeze(r.concat(e));let o=await Ot("key",e.key,n,r);if(o===ne)return ne;o===ke&&(e.key=null);let s=await Ot("value",e.value,n,r);if(s===ne)return ne;s===ke&&(e.value=null)}}return i}function tc(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function nc(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(M.isMap(e))return n.Map?.(t,e,r);if(M.isSeq(e))return n.Seq?.(t,e,r);if(M.isPair(e))return n.Pair?.(t,e,r);if(M.isScalar(e))return n.Scalar?.(t,e,r);if(M.isAlias(e))return n.Alias?.(t,e,r)}function rc(t,e,n){let r=e[e.length-1];if(M.isCollection(r))r.items[t]=n;else if(M.isPair(r))t==="key"?r.key=n:r.value=n;else if(M.isDocument(r))r.contents=n;else{let i=M.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}mo.visit=mr;mo.visitAsync=pr});var po=k(oc=>{"use strict";var ic=P(),Nm=un(),Tm={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Im=t=>t.replace(/[!,[\]{}]/g,e=>Tm[e]),fn=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[o,s]=r;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[o]=r;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return n(6,`Unsupported YAML version ${o}`,s),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);return s==="!"||s==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),s)}let[,r,i]=e.match(/^(.*!)([^!]*)$/s);i||n(`The ${e} tag has no suffix`);let o=this.tags[r];if(o)try{return o+decodeURIComponent(i)}catch(s){return n(String(s)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+Im(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),i;if(e&&r.length>0&&ic.isNode(e.contents)){let o={};Nm.visit(e.contents,(s,a)=>{ic.isNode(a)&&a.tag&&(o[a.tag]=!0)}),i=Object.keys(o)}else i=[];for(let[o,s]of r)o==="!!"&&s==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(s)))&&n.push(`%TAG ${o} ${s}`);return n.join(`
|
|
5
|
+
`)}};fn.defaultYaml={explicit:!1,version:"1.2"};fn.defaultTags={"!!":"tag:yaml.org,2002:"};oc.Directives=fn});var hr=k(dn=>{"use strict";var sc=P(),jm=un();function $m(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function ac(t){let e=new Set;return jm.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function cc(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Lm(t,e){let n=[],r=new Map,i=null;return{onAnchor:o=>{n.push(o),i??(i=ac(t));let s=cc(e,i);return i.add(s),s},setAnchors:()=>{for(let o of n){let s=r.get(o);if(typeof s=="object"&&s.anchor&&(sc.isScalar(s.node)||sc.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:r}}dn.anchorIsValid=$m;dn.anchorNames=ac;dn.createNodeAnchors=Lm;dn.findNewAnchor=cc});var ho=k(lc=>{"use strict";function mn(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let i=0,o=r.length;i<o;++i){let s=r[i],a=mn(t,r,String(i),s);a===void 0?delete r[i]:a!==s&&(r[i]=a)}else if(r instanceof Map)for(let i of Array.from(r.keys())){let o=r.get(i),s=mn(t,r,i,o);s===void 0?r.delete(i):s!==o&&r.set(i,s)}else if(r instanceof Set)for(let i of Array.from(r)){let o=mn(t,r,i,i);o===void 0?r.delete(i):o!==i&&(r.delete(i),r.add(o))}else for(let[i,o]of Object.entries(r)){let s=mn(t,r,i,o);s===void 0?delete r[i]:s!==o&&(r[i]=s)}return t.call(e,n,r)}lc.applyReviver=mn});var Ue=k(fc=>{"use strict";var qm=P();function uc(t,e,n){if(Array.isArray(t))return t.map((r,i)=>uc(r,String(i),n));if(t&&typeof t.toJSON=="function"){if(!n||!qm.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=o=>{r.res=o,delete n.onCreate};let i=t.toJSON(e,n);return n.onCreate&&n.onCreate(i),i}return typeof t=="bigint"&&!n?.keep?Number(t):t}fc.toJS=uc});var gr=k(mc=>{"use strict";var Wm=ho(),dc=P(),Dm=Ue(),go=class{constructor(e){Object.defineProperty(this,dc.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){if(!dc.isDocument(e))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=Dm.toJS(this,"",s);if(typeof i=="function")for(let{count:c,res:l}of s.anchors.values())i(l,c);return typeof o=="function"?Wm.applyReviver(o,{"":a},"",a):a}};mc.NodeBase=go});var pn=k(pc=>{"use strict";var Mm=hr(),Fm=un(),At=P(),Bm=gr(),Um=Ue(),wo=class extends Bm.NodeBase{constructor(e){super(At.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Fm.visit(e,{Node:(o,s)=>{(At.isAlias(s)||At.hasAnchor(s))&&r.push(s)}}),n&&(n.aliasResolveCache=r));let i;for(let o of r){if(o===this)break;o.anchor===this.source&&(i=o)}return i}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:i,maxAliasCount:o}=n,s=this.resolve(i,n);if(!s){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=r.get(s);if(a||(Um.toJS(s,null,n),a=r.get(s)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=wr(i,s,r)),a.count*a.aliasCount>o)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(Mm.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${i} `}return i}};function wr(t,e,n){if(At.isAlias(e)){let r=e.resolve(t),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(At.isCollection(e)){let r=0;for(let i of e.items){let o=wr(t,i,n);o>r&&(r=o)}return r}else if(At.isPair(e)){let r=wr(t,e.key,n),i=wr(t,e.value,n);return Math.max(r,i)}return 1}pc.Alias=wo});var q=k(yo=>{"use strict";var Km=P(),Gm=gr(),Hm=Ue(),zm=t=>!t||typeof t!="function"&&typeof t!="object",Ke=class extends Gm.NodeBase{constructor(e){super(Km.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:Hm.toJS(this.value,e,n)}toString(){return String(this.value)}};Ke.BLOCK_FOLDED="BLOCK_FOLDED";Ke.BLOCK_LITERAL="BLOCK_LITERAL";Ke.PLAIN="PLAIN";Ke.QUOTE_DOUBLE="QUOTE_DOUBLE";Ke.QUOTE_SINGLE="QUOTE_SINGLE";yo.Scalar=Ke;yo.isScalarValue=zm});var hn=k(gc=>{"use strict";var Jm=pn(),ft=P(),hc=q(),Ym="tag:yaml.org,2002:";function Vm(t,e,n){if(e){let r=n.filter(o=>o.tag===e),i=r.find(o=>!o.format)??r[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return n.find(r=>r.identify?.(t)&&!r.format)}function Xm(t,e,n){if(ft.isDocument(t)&&(t=t.contents),ft.isNode(t))return t;if(ft.isPair(t)){let f=n.schema[ft.MAP].createNode?.(n.schema,null,n);return f.items.push(t),f}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:o,schema:s,sourceObjects:a}=n,c;if(r&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=i(t)),new Jm.Alias(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=Ym+e.slice(2));let l=Vm(t,e,s.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let f=new hc.Scalar(t);return c&&(c.node=f),f}l=t instanceof Map?s[ft.MAP]:Symbol.iterator in Object(t)?s[ft.SEQ]:s[ft.MAP]}o&&(o(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,t,n):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(n.schema,t,n):new hc.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}gc.createNode=Xm});var vr=k(yr=>{"use strict";var Qm=hn(),be=P(),Zm=gr();function vo(t,e,n){let r=n;for(let i=e.length-1;i>=0;--i){let o=e[i];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=r,r=s}else r=new Map([[o,r]])}return Qm.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var wc=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,ko=class extends Zm.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>be.isNode(r)||be.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(wc(e))this.add(n);else{let[r,...i]=e,o=this.get(r,!0);if(be.isCollection(o))o.addIn(i,n);else if(o===void 0&&this.schema)this.set(r,vo(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let i=this.get(n,!0);if(be.isCollection(i))return i.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...i]=e,o=this.get(r,!0);return i.length===0?!n&&be.isScalar(o)?o.value:o:be.isCollection(o)?o.getIn(i,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!be.isPair(n))return!1;let r=n.value;return r==null||e&&be.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let i=this.get(n,!0);return be.isCollection(i)?i.hasIn(r):!1}setIn(e,n){let[r,...i]=e;if(i.length===0)this.set(r,n);else{let o=this.get(r,!0);if(be.isCollection(o))o.setIn(i,n);else if(o===void 0&&this.schema)this.set(r,vo(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};yr.Collection=ko;yr.collectionFromPath=vo;yr.isEmptyPath=wc});var gn=k(kr=>{"use strict";var ep=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function bo(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var tp=(t,e,n)=>t.endsWith(`
|
|
6
|
+
`)?bo(n,e):n.includes(`
|
|
7
7
|
`)?`
|
|
8
|
-
`+
|
|
9
|
-
`)n===
|
|
8
|
+
`+bo(n,e):(t.endsWith(" ")?"":" ")+n;kr.indentComment=bo;kr.lineComment=tp;kr.stringifyComment=ep});var vc=k(wn=>{"use strict";var np="flow",Co="block",br="quoted";function rp(t,e,n="flow",{indentAtStart:r,lineWidth:i=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!i||i<0)return t;i<o&&(o=0);let c=Math.max(1+o,1+i-e.length);if(t.length<=c)return t;let l=[],u={},f=i-e.length;typeof r=="number"&&(r>i-Math.max(2,o)?l.push(0):f=i-r);let d,p,g=!1,m=-1,h=-1,w=-1;n===Co&&(m=yc(t,m,e.length),m!==-1&&(f=m+c));for(let C;C=t[m+=1];){if(n===br&&C==="\\"){switch(h=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}w=m}if(C===`
|
|
9
|
+
`)n===Co&&(m=yc(t,m,e.length)),f=m+e.length+c,d=void 0;else{if(C===" "&&p&&p!==" "&&p!==`
|
|
10
10
|
`&&p!==" "){let b=t[m+1];b&&b!==" "&&b!==`
|
|
11
|
-
`&&b!==" "&&(d=m)}if(m>=f)if(d)l.push(d),f=d+c,d=void 0;else if(n===
|
|
12
|
-
${e}${t.slice(0,x)}`:(n===
|
|
13
|
-
${e}${t.slice(b+1,x)}`)}return y}function
|
|
14
|
-
`);r=e,i=e+1,o=t[i]}return r}
|
|
15
|
-
`){if(o-s>r)return!0;if(s=o+1,i-s<=r)return!1}return!0}function
|
|
11
|
+
`&&b!==" "&&(d=m)}if(m>=f)if(d)l.push(d),f=d+c,d=void 0;else if(n===br){for(;p===" "||p===" ";)p=C,C=t[m+=1],g=!0;let b=m>w+1?m-2:h-1;if(u[b])return t;l.push(b),u[b]=!0,f=b+c,d=void 0}else g=!0}p=C}if(g&&a&&a(),l.length===0)return t;s&&s();let y=t.slice(0,l[0]);for(let C=0;C<l.length;++C){let b=l[C],x=l[C+1]||t.length;b===0?y=`
|
|
12
|
+
${e}${t.slice(0,x)}`:(n===br&&u[b]&&(y+=`${t[b]}\\`),y+=`
|
|
13
|
+
${e}${t.slice(b+1,x)}`)}return y}function yc(t,e,n){let r=e,i=e+1,o=t[i];for(;o===" "||o===" ";)if(e<i+n)o=t[++e];else{do o=t[++e];while(o&&o!==`
|
|
14
|
+
`);r=e,i=e+1,o=t[i]}return r}wn.FOLD_BLOCK=Co;wn.FOLD_FLOW=np;wn.FOLD_QUOTED=br;wn.foldFlowLines=rp});var vn=k(kc=>{"use strict";var de=q(),Ge=vc(),Sr=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Er=t=>/^(%|---|\.\.\.)/m.test(t);function ip(t,e,n){if(!e||e<0)return!1;let r=e-n,i=t.length;if(i<=r)return!1;for(let o=0,s=0;o<i;++o)if(t[o]===`
|
|
15
|
+
`){if(o-s>r)return!0;if(s=o+1,i-s<=r)return!1}return!0}function yn(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,i=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Er(t)?" ":""),s="",a=0;for(let c=0,l=n[c];l;l=n[++c])if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(s+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(n[c+1]){case"u":{s+=n.slice(a,c);let u=n.substr(c+2,4);switch(u){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:u.substr(0,2)==="00"?s+="\\x"+u.substr(2):s+=n.substr(c,6)}c+=5,a=c+1}break;case"n":if(r||n[c+2]==='"'||n.length<i)c+=1;else{for(s+=n.slice(a,c)+`
|
|
16
16
|
|
|
17
17
|
`;n[c+2]==="\\"&&n[c+3]==="n"&&n[c+4]!=='"';)s+=`
|
|
18
|
-
`,c+=2;s+=o,n[c+2]===" "&&(s+="\\"),c+=1,a=c+1}break;default:c+=1}return s=a?s+n.slice(a):n,r?s:
|
|
19
|
-
`)||/[ \t]\n|\n[ \t]/.test(t))return
|
|
20
|
-
${n}`)+"'";return e.implicitKey?r:
|
|
18
|
+
`,c+=2;s+=o,n[c+2]===" "&&(s+="\\"),c+=1,a=c+1}break;default:c+=1}return s=a?s+n.slice(a):n,r?s:Ge.foldFlowLines(s,o,Ge.FOLD_QUOTED,Sr(e,!1))}function So(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
19
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return yn(t,e);let n=e.indent||(Er(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
20
|
+
${n}`)+"'";return e.implicitKey?r:Ge.foldFlowLines(r,n,Ge.FOLD_FLOW,Sr(e,!1))}function Nt(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=yn;else{let i=t.includes('"'),o=t.includes("'");i&&!o?r=So:o&&!i?r=yn:r=n?So:yn}return r(t,e)}var Eo;try{Eo=new RegExp(`(^|(?<!
|
|
21
21
|
))
|
|
22
22
|
+(?!
|
|
23
|
-
|$)`,"g")}catch{
|
|
23
|
+
|$)`,"g")}catch{Eo=/\n+(?!\n|$)/g}function Cr({comment:t,type:e,value:n},r,i,o){let{blockQuote:s,commentString:a,lineWidth:c}=r.options;if(!s||/\n[\t ]+$/.test(n))return Nt(n,r);let l=r.indent||(r.forceBlockIndent||Er(n)?" ":""),u=s==="literal"?!0:s==="folded"||e===de.Scalar.BLOCK_FOLDED?!1:e===de.Scalar.BLOCK_LITERAL?!0:!ip(n,c,l.length);if(!n)return u?`|
|
|
24
24
|
`:`>
|
|
25
25
|
`;let f,d;for(d=n.length;d>0;--d){let x=n[d-1];if(x!==`
|
|
26
26
|
`&&x!==" "&&x!==" ")break}let p=n.substring(d),g=p.indexOf(`
|
|
27
27
|
`);g===-1?f="-":n===p||g!==p.length-1?(f="+",o&&o()):f="",p&&(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
28
|
-
`&&(p=p.slice(0,-1)),p=p.replace(
|
|
28
|
+
`&&(p=p.slice(0,-1)),p=p.replace(Eo,`$&${l}`));let m=!1,h,w=-1;for(h=0;h<n.length;++h){let x=n[h];if(x===" ")m=!0;else if(x===`
|
|
29
29
|
`)w=h;else break}let y=n.substring(0,w<h?w+1:h);y&&(n=n.substring(y.length),y=y.replace(/\n+/g,`$&${l}`));let b=(m?l?"2":"1":"")+f;if(t&&(b+=" "+a(t.replace(/ ?[\r\n]+/g," ")),i&&i()),!u){let x=n.replace(/\n+/g,`
|
|
30
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,S=
|
|
30
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,S=Sr(r,!0);s!=="folded"&&e!==de.Scalar.BLOCK_FOLDED&&(S.onOverflow=()=>{E=!0});let v=Ge.foldFlowLines(`${y}${x}${p}`,l,Ge.FOLD_BLOCK,S);if(!E)return`>${b}
|
|
31
31
|
${l}${v}`}return n=n.replace(/\n+/g,`$&${l}`),`|${b}
|
|
32
|
-
${l}${y}${n}${p}`}function
|
|
33
|
-
`)||u&&/[[\]{},]/.test(o))return
|
|
34
|
-
`)?
|
|
35
|
-
`))return
|
|
36
|
-
${c}`);if(s){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(f),{compat:p,tags:g}=e.doc.schema;if(g.some(d)||p?.some(d))return
|
|
37
|
-
${e.indent}${a}`:a}
|
|
38
|
-
${a}:`):(h=`${h}:`,d&&(h+=
|
|
32
|
+
${l}${y}${n}${p}`}function op(t,e,n,r){let{type:i,value:o}=t,{actualString:s,implicitKey:a,indent:c,indentStep:l,inFlow:u}=e;if(a&&o.includes(`
|
|
33
|
+
`)||u&&/[[\]{},]/.test(o))return Nt(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes(`
|
|
34
|
+
`)?Nt(o,e):Cr(t,e,n,r);if(!a&&!u&&i!==de.Scalar.PLAIN&&o.includes(`
|
|
35
|
+
`))return Cr(t,e,n,r);if(Er(o)){if(c==="")return e.forceBlockIndent=!0,Cr(t,e,n,r);if(a&&c===l)return Nt(o,e)}let f=o.replace(/\n+/g,`$&
|
|
36
|
+
${c}`);if(s){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(f),{compat:p,tags:g}=e.doc.schema;if(g.some(d)||p?.some(d))return Nt(o,e)}return a?f:Ge.foldFlowLines(f,c,Ge.FOLD_FLOW,Sr(e,!1))}function sp(t,e,n,r){let{implicitKey:i,inFlow:o}=e,s=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==de.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=de.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case de.Scalar.BLOCK_FOLDED:case de.Scalar.BLOCK_LITERAL:return i||o?Nt(s.value,e):Cr(s,e,n,r);case de.Scalar.QUOTE_DOUBLE:return yn(s.value,e);case de.Scalar.QUOTE_SINGLE:return So(s.value,e);case de.Scalar.PLAIN:return op(s,e,n,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:f}=e.options,d=i&&u||f;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}kc.stringifyString=sp});var kn=k(xo=>{"use strict";var ap=hr(),He=P(),cp=gn(),lp=vn();function up(t,e){let n=Object.assign({blockQuote:!0,commentString:cp.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function fp(t,e){if(e.tag){let i=t.filter(o=>o.tag===e.tag);if(i.length>0)return i.find(o=>o.format===e.format)??i[0]}let n,r;if(He.isScalar(e)){r=e.value;let i=t.filter(o=>o.identify?.(r));if(i.length>1){let o=i.filter(s=>s.test);o.length>0&&(i=o)}n=i.find(o=>o.format===e.format)??i.find(o=>!o.format)}else r=e,n=t.find(i=>i.nodeClass&&r instanceof i.nodeClass);if(!n){let i=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${i} value`)}return n}function dp(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let i=[],o=(He.isScalar(t)||He.isCollection(t))&&t.anchor;o&&ap.anchorIsValid(o)&&(n.add(o),i.push(`&${o}`));let s=t.tag??(e.default?null:e.tag);return s&&i.push(r.directives.tagString(s)),i.join(" ")}function mp(t,e,n,r){if(He.isPair(t))return t.toString(e,n,r);if(He.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let i,o=He.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>i=c});i??(i=fp(e.doc.schema.tags,o));let s=dp(o,i,e);s.length>0&&(e.indentAtStart=(e.indentAtStart??0)+s.length+1);let a=typeof i.stringify=="function"?i.stringify(o,e,n,r):He.isScalar(o)?lp.stringifyString(o,e,n,r):o.toString(e,n,r);return s?He.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
|
|
37
|
+
${e.indent}${a}`:a}xo.createStringifyContext=up;xo.stringify=mp});var Ec=k(Sc=>{"use strict";var Le=P(),bc=q(),Cc=kn(),bn=gn();function pp({key:t,value:e},n,r,i){let{allNullValues:o,doc:s,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:f}}=n,d=Le.isNode(t)&&t.comment||null;if(f){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Le.isCollection(t)||!Le.isNode(t)&&typeof t=="object"){let S="With simple keys, collection cannot be used as a key value";throw new Error(S)}}let p=!f&&(!t||d&&e==null&&!n.inFlow||Le.isCollection(t)||(Le.isScalar(t)?t.type===bc.Scalar.BLOCK_FOLDED||t.type===bc.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(f||!o),indent:a+c});let g=!1,m=!1,h=Cc.stringify(t,n,()=>g=!0,()=>m=!0);if(!p&&!n.inFlow&&h.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(o||e==null)return g&&r&&r(),h===""?"?":p?`? ${h}`:h}else if(o&&!f||e==null&&p)return h=`? ${h}`,d&&!g?h+=bn.lineComment(h,n.indent,l(d)):m&&i&&i(),h;g&&(d=null),p?(d&&(h+=bn.lineComment(h,n.indent,l(d))),h=`? ${h}
|
|
38
|
+
${a}:`):(h=`${h}:`,d&&(h+=bn.lineComment(h,n.indent,l(d))));let w,y,C;Le.isNode(e)?(w=!!e.spaceBefore,y=e.commentBefore,C=e.comment):(w=!1,y=null,C=null,e&&typeof e=="object"&&(e=s.createNode(e))),n.implicitKey=!1,!p&&!d&&Le.isScalar(e)&&(n.indentAtStart=h.length+1),m=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Le.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=Cc.stringify(e,n,()=>b=!0,()=>m=!0),E=" ";if(d||w||y){if(E=w?`
|
|
39
39
|
`:"",y){let S=l(y);E+=`
|
|
40
|
-
${
|
|
40
|
+
${bn.indentComment(S,n.indent)}`}x===""&&!n.inFlow?E===`
|
|
41
41
|
`&&C&&(E=`
|
|
42
42
|
|
|
43
43
|
`):E+=`
|
|
44
|
-
${n.indent}`}else if(!p&&
|
|
44
|
+
${n.indent}`}else if(!p&&Le.isCollection(e)){let S=x[0],v=x.indexOf(`
|
|
45
45
|
`),R=v!==-1,K=n.inFlow??e.flow??e.items.length===0;if(R||!K){let N=!1;if(R&&(S==="&"||S==="!")){let A=x.indexOf(" ");S==="&"&&A!==-1&&A<v&&x[A+1]==="!"&&(A=x.indexOf(" ",A+1)),(A===-1||v<A)&&(N=!0)}N||(E=`
|
|
46
46
|
${n.indent}`)}}else(x===""||x[0]===`
|
|
47
|
-
`)&&(E="");return h+=E+x,n.inFlow?b&&r&&r():C&&!b?h+=
|
|
47
|
+
`)&&(E="");return h+=E+x,n.inFlow?b&&r&&r():C&&!b?h+=bn.lineComment(h,n.indent,l(C)):m&&i&&i(),h}Sc.stringifyPair=pp});var Ro=k(_o=>{"use strict";var xc=ur("process");function hp(t,...e){t==="debug"&&console.log(...e)}function gp(t,e){(t==="debug"||t==="warn")&&(typeof xc.emitWarning=="function"?xc.emitWarning(e):console.warn(e))}_o.debug=hp;_o.warn=gp});var Or=k(Pr=>{"use strict";var Rr=P(),_c=q(),xr="<<",_r={identify:t=>t===xr||typeof t=="symbol"&&t.description===xr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new _c.Scalar(Symbol(xr)),{addToJSMap:Rc}),stringify:()=>xr},wp=(t,e)=>(_r.identify(e)||Rr.isScalar(e)&&(!e.type||e.type===_c.Scalar.PLAIN)&&_r.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===_r.tag&&n.default);function Rc(t,e,n){let r=Pc(t,n);if(Rr.isSeq(r))for(let i of r.items)Po(t,e,i);else if(Array.isArray(r))for(let i of r)Po(t,e,i);else Po(t,e,r)}function Po(t,e,n){let r=Pc(t,n);if(!Rr.isMap(r))throw new Error("Merge sources must be maps or map aliases");let i=r.toJSON(null,t,Map);for(let[o,s]of i)e instanceof Map?e.has(o)||e.set(o,s):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0});return e}function Pc(t,e){return t&&Rr.isAlias(e)?e.resolve(t.doc,t):e}Pr.addMergeToJSMap=Rc;Pr.isMergeKey=wp;Pr.merge=_r});var Ao=k(Nc=>{"use strict";var yp=Ro(),Oc=Or(),vp=kn(),Ac=P(),Oo=Ue();function kp(t,e,{key:n,value:r}){if(Ac.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(Oc.isMergeKey(t,n))Oc.addMergeToJSMap(t,e,r);else{let i=Oo.toJS(n,"",t);if(e instanceof Map)e.set(i,Oo.toJS(r,i,t));else if(e instanceof Set)e.add(i);else{let o=bp(n,i,t),s=Oo.toJS(r,o,t);o in e?Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0}):e[o]=s}}return e}function bp(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Ac.isNode(t)&&n?.doc){let r=vp.createStringifyContext(n.doc,{});r.anchors=new Set;for(let o of n.anchors.keys())r.anchors.add(o.anchor);r.inFlow=!0,r.inStringifyKey=!0;let i=t.toString(r);if(!n.mapKeyWarned){let o=JSON.stringify(i);o.length>40&&(o=o.substring(0,36)+'..."'),yp.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return i}return JSON.stringify(e)}Nc.addPairToJSMap=kp});var ze=k(No=>{"use strict";var Tc=hn(),Cp=Ec(),Sp=Ao(),Ar=P();function Ep(t,e,n){let r=Tc.createNode(t,void 0,n),i=Tc.createNode(e,void 0,n);return new Nr(r,i)}var Nr=class t{constructor(e,n=null){Object.defineProperty(this,Ar.NODE_TYPE,{value:Ar.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return Ar.isNode(n)&&(n=n.clone(e)),Ar.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return Sp.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?Cp.stringifyPair(this,e,n,r):JSON.stringify(this)}};No.Pair=Nr;No.createPair=Ep});var To=k(jc=>{"use strict";var dt=P(),Ic=kn(),Tr=gn();function xp(t,e,n){return(e.inFlow??t.flow?Rp:_p)(t,e,n)}function _p({comment:t,items:e},n,{blockItemPrefix:r,flowChars:i,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:o,type:null}),f=!1,d=[];for(let g=0;g<e.length;++g){let m=e[g],h=null;if(dt.isNode(m))!f&&m.spaceBefore&&d.push(""),Ir(n,d,m.commentBefore,f),m.comment&&(h=m.comment);else if(dt.isPair(m)){let y=dt.isNode(m.key)?m.key:null;y&&(!f&&y.spaceBefore&&d.push(""),Ir(n,d,y.commentBefore,f))}f=!1;let w=Ic.stringify(m,u,()=>h=null,()=>f=!0);h&&(w+=Tr.lineComment(w,o,l(h))),f&&h&&(f=!1),d.push(r+w)}let p;if(d.length===0)p=i.start+i.end;else{p=d[0];for(let g=1;g<d.length;++g){let m=d[g];p+=m?`
|
|
48
48
|
${c}${m}`:`
|
|
49
49
|
`}}return t?(p+=`
|
|
50
|
-
`+
|
|
51
|
-
`)),g<t.length-1?w+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=f.reduce((y,C)=>y+C.length+2,2)+(w.length+2)>e.options.lineWidth)),l&&(w+=",")),h&&(w+=
|
|
50
|
+
`+Tr.indentComment(l(t),c),a&&a()):f&&s&&s(),p}function Rp({items:t},e,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:o,flowCollectionPadding:s,options:{commentString:a}}=e;r+=o;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,u=0,f=[];for(let g=0;g<t.length;++g){let m=t[g],h=null;if(dt.isNode(m))m.spaceBefore&&f.push(""),Ir(e,f,m.commentBefore,!1),m.comment&&(h=m.comment);else if(dt.isPair(m)){let y=dt.isNode(m.key)?m.key:null;y&&(y.spaceBefore&&f.push(""),Ir(e,f,y.commentBefore,!1),y.comment&&(l=!0));let C=dt.isNode(m.value)?m.value:null;C?(C.comment&&(h=C.comment),C.commentBefore&&(l=!0)):m.value==null&&y?.comment&&(h=y.comment)}h&&(l=!0);let w=Ic.stringify(m,c,()=>h=null);l||(l=f.length>u||w.includes(`
|
|
51
|
+
`)),g<t.length-1?w+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=f.reduce((y,C)=>y+C.length+2,2)+(w.length+2)>e.options.lineWidth)),l&&(w+=",")),h&&(w+=Tr.lineComment(w,r,a(h))),f.push(w),u=f.length}let{start:d,end:p}=n;if(f.length===0)return d+p;if(!l){let g=f.reduce((m,h)=>m+h.length+2,2);l=e.options.lineWidth>0&&g>e.options.lineWidth}if(l){let g=d;for(let m of f)g+=m?`
|
|
52
52
|
${o}${i}${m}`:`
|
|
53
53
|
`;return`${g}
|
|
54
|
-
${i}${p}`}else return`${d}${s}${f.join(" ")}${s}${p}`}function
|
|
55
|
-
`:" ")}return
|
|
54
|
+
${i}${p}`}else return`${d}${s}${f.join(" ")}${s}${p}`}function Ir({indent:t,options:{commentString:e}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,"")),r){let o=Tr.indentComment(e(r),t);n.push(o.trimStart())}}jc.stringifyCollection=xp});var Ye=k(jo=>{"use strict";var Pp=To(),Op=Ao(),Ap=vr(),Je=P(),jr=ze(),Np=q();function Cn(t,e){let n=Je.isScalar(e)?e.value:e;for(let r of t)if(Je.isPair(r)&&(r.key===e||r.key===n||Je.isScalar(r.key)&&r.key.value===n))return r}var Io=class extends Ap.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Je.MAP,e),this.items=[]}static from(e,n,r){let{keepUndefined:i,replacer:o}=r,s=new this(e),a=(c,l)=>{if(typeof o=="function")l=o.call(n,c,l);else if(Array.isArray(o)&&!o.includes(c))return;(l!==void 0||i)&&s.items.push(jr.createPair(c,l,r))};if(n instanceof Map)for(let[c,l]of n)a(c,l);else if(n&&typeof n=="object")for(let c of Object.keys(n))a(c,n[c]);return typeof e.sortMapEntries=="function"&&s.items.sort(e.sortMapEntries),s}add(e,n){let r;Je.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new jr.Pair(e,e?.value):r=new jr.Pair(e.key,e.value);let i=Cn(this.items,r.key),o=this.schema?.sortMapEntries;if(i){if(!n)throw new Error(`Key ${r.key} already set`);Je.isScalar(i.value)&&Np.isScalarValue(r.value)?i.value.value=r.value:i.value=r.value}else if(o){let s=this.items.findIndex(a=>o(r,a)<0);s===-1?this.items.push(r):this.items.splice(s,0,r)}else this.items.push(r)}delete(e){let n=Cn(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let i=Cn(this.items,e)?.value;return(!n&&Je.isScalar(i)?i.value:i)??void 0}has(e){return!!Cn(this.items,e)}set(e,n){this.add(new jr.Pair(e,n),!0)}toJSON(e,n,r){let i=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(i);for(let o of this.items)Op.addPairToJSMap(n,i,o);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!Je.isPair(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Pp.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};jo.YAMLMap=Io;jo.findPair=Cn});var Tt=k(Lc=>{"use strict";var Tp=P(),$c=Ye(),Ip={collection:"map",default:!0,nodeClass:$c.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Tp.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>$c.YAMLMap.from(t,e,n)};Lc.map=Ip});var Ve=k(qc=>{"use strict";var jp=hn(),$p=To(),Lp=vr(),Lr=P(),qp=q(),Wp=Ue(),$o=class extends Lp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Lr.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=$r(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=$r(e);if(typeof r!="number")return;let i=this.items[r];return!n&&Lr.isScalar(i)?i.value:i}has(e){let n=$r(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=$r(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let i=this.items[r];Lr.isScalar(i)&&qp.isScalarValue(n)?i.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let i=0;for(let o of this.items)r.push(Wp.toJS(o,String(i++),n));return r}toString(e,n,r){return e?$p.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,o=new this(e);if(n&&Symbol.iterator in Object(n)){let s=0;for(let a of n){if(typeof i=="function"){let c=n instanceof Set?a:String(s++);a=i.call(n,c,a)}o.items.push(jp.createNode(a,void 0,r))}}return o}};function $r(t){let e=Lr.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}qc.YAMLSeq=$o});var It=k(Dc=>{"use strict";var Dp=P(),Wc=Ve(),Mp={collection:"seq",default:!0,nodeClass:Wc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Dp.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Wc.YAMLSeq.from(t,e,n)};Dc.seq=Mp});var Sn=k(Mc=>{"use strict";var Fp=vn(),Bp={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),Fp.stringifyString(t,e,n,r)}};Mc.string=Bp});var qr=k(Uc=>{"use strict";var Fc=q(),Bc={identify:t=>t==null,createNode:()=>new Fc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Fc.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Bc.test.test(t)?t:e.options.nullStr};Uc.nullTag=Bc});var Lo=k(Gc=>{"use strict";var Up=q(),Kc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Up.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Kc.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};Gc.boolTag=Kc});var jt=k(Hc=>{"use strict";function Kp({format:t,minFractionDigits:e,tag:n,value:r}){if(typeof r=="bigint")return String(r);let i=typeof r=="number"?r:Number(r);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let o=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let s=o.indexOf(".");s<0&&(s=o.length,o+=".");let a=e-(o.length-s-1);for(;a-- >0;)o+="0"}return o}Hc.stringifyNumber=Kp});var Wo=k(Wr=>{"use strict";var Gp=q(),qo=jt(),Hp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:qo.stringifyNumber},zp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():qo.stringifyNumber(t)}},Jp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new Gp.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:qo.stringifyNumber};Wr.float=Jp;Wr.floatExp=zp;Wr.floatNaN=Hp});var Mo=k(Mr=>{"use strict";var zc=jt(),Dr=t=>typeof t=="bigint"||Number.isInteger(t),Do=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function Jc(t,e,n){let{value:r}=t;return Dr(r)&&r>=0?n+r.toString(e):zc.stringifyNumber(t)}var Yp={identify:t=>Dr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Do(t,2,8,n),stringify:t=>Jc(t,8,"0o")},Vp={identify:Dr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Do(t,0,10,n),stringify:zc.stringifyNumber},Xp={identify:t=>Dr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Do(t,2,16,n),stringify:t=>Jc(t,16,"0x")};Mr.int=Vp;Mr.intHex=Xp;Mr.intOct=Yp});var Vc=k(Yc=>{"use strict";var Qp=Tt(),Zp=qr(),eh=It(),th=Sn(),nh=Lo(),Fo=Wo(),Bo=Mo(),rh=[Qp.map,eh.seq,th.string,Zp.nullTag,nh.boolTag,Bo.intOct,Bo.int,Bo.intHex,Fo.floatNaN,Fo.floatExp,Fo.float];Yc.schema=rh});var Zc=k(Qc=>{"use strict";var ih=q(),oh=Tt(),sh=It();function Xc(t){return typeof t=="bigint"||Number.isInteger(t)}var Fr=({value:t})=>JSON.stringify(t),ah=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Fr},{identify:t=>t==null,createNode:()=>new ih.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Fr},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Fr},{identify:Xc,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>Xc(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:Fr}],ch={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},lh=[oh.map,sh.seq].concat(ah,ch);Qc.schema=lh});var Ko=k(el=>{"use strict";var En=ur("buffer"),Uo=q(),uh=vn(),fh={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof En.Buffer=="function")return En.Buffer.from(t,"base64");if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},r,i,o){if(!n)return"";let s=n,a;if(typeof En.Buffer=="function")a=s instanceof En.Buffer?s.toString("base64"):En.Buffer.from(s.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<s.length;++l)c+=String.fromCharCode(s[l]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Uo.Scalar.BLOCK_LITERAL),e!==Uo.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(a.length/c),u=new Array(l);for(let f=0,d=0;f<l;++f,d+=c)u[f]=a.substr(d,c);a=u.join(e===Uo.Scalar.BLOCK_LITERAL?`
|
|
55
|
+
`:" ")}return uh.stringifyString({comment:t,type:e,value:a},r,i,o)}};el.binary=fh});var Kr=k(Ur=>{"use strict";var Br=P(),Go=ze(),dh=q(),mh=Ve();function tl(t,e){if(Br.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!Br.isPair(r)){if(Br.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let i=r.items[0]||new Go.Pair(new dh.Scalar(null));if(r.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${r.commentBefore}
|
|
56
56
|
${i.key.commentBefore}`:r.commentBefore),r.comment){let o=i.value??i.key;o.comment=o.comment?`${r.comment}
|
|
57
|
-
${o.comment}`:r.comment}r=i}t.items[n]=Nr.isPair(r)?r:new To.Pair(r)}}else e("Expected a sequence for this tag");return t}function Mc(t,e,n){let{replacer:r}=n,i=new Bp.YAMLSeq(t);i.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let s of e){typeof r=="function"&&(s=r.call(e,String(o++),s));let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw new TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let l=Object.keys(s);if(l.length===1)a=l[0],c=s[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;i.items.push(To.createPair(a,c,n))}return i}var Up={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Fc,createNode:Mc};Tr.createPairs=Mc;Tr.pairs=Up;Tr.resolvePairs=Fc});var $o=k(jo=>{"use strict";var Bc=P(),Io=De(),yn=Ge(),Kp=He(),Uc=Ir(),lt=class t extends Kp.YAMLSeq{constructor(){super(),this.add=yn.YAMLMap.prototype.add.bind(this),this.delete=yn.YAMLMap.prototype.delete.bind(this),this.get=yn.YAMLMap.prototype.get.bind(this),this.has=yn.YAMLMap.prototype.has.bind(this),this.set=yn.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let i of this.items){let o,s;if(Bc.isPair(i)?(o=Io.toJS(i.key,"",n),s=Io.toJS(i.value,o,n)):o=Io.toJS(i,"",n),r.has(o))throw new Error("Ordered maps must not include duplicate keys");r.set(o,s)}return r}static from(e,n,r){let i=Uc.createPairs(e,n,r),o=new this;return o.items=i.items,o}};lt.tag="tag:yaml.org,2002:omap";var Gp={collection:"seq",identify:t=>t instanceof Map,nodeClass:lt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Uc.resolvePairs(t,e),r=[];for(let{key:i}of n.items)Bc.isScalar(i)&&(r.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):r.push(i.value));return Object.assign(new lt,n)},createNode:(t,e,n)=>lt.from(t,e,n)};jo.YAMLOMap=lt;jo.omap=Gp});var zc=k(Lo=>{"use strict";var Kc=q();function Gc({value:t,source:e},n){return e&&(t?Hc:Jc).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Hc={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Kc.Scalar(!0),stringify:Gc},Jc={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Kc.Scalar(!1),stringify:Gc};Lo.falseTag=Jc;Lo.trueTag=Hc});var Yc=k(jr=>{"use strict";var Hp=q(),qo=Ot(),Jp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:qo.stringifyNumber},zp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():qo.stringifyNumber(t)}},Yp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new Hp.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:qo.stringifyNumber};jr.float=Yp;jr.floatExp=zp;jr.floatNaN=Jp});var Xc=k(kn=>{"use strict";var Vc=Ot(),vn=t=>typeof t=="bigint"||Number.isInteger(t);function $r(t,e,n,{intAsBigInt:r}){let i=t[0];if((i==="-"||i==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let s=BigInt(t);return i==="-"?BigInt(-1)*s:s}let o=parseInt(t,n);return i==="-"?-1*o:o}function Wo(t,e,n){let{value:r}=t;if(vn(r)){let i=r.toString(e);return r<0?"-"+n+i.substr(1):n+i}return Vc.stringifyNumber(t)}var Vp={identify:vn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>$r(t,2,2,n),stringify:t=>Wo(t,2,"0b")},Xp={identify:vn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>$r(t,1,8,n),stringify:t=>Wo(t,8,"0")},Qp={identify:vn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>$r(t,0,10,n),stringify:Vc.stringifyNumber},Zp={identify:vn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>$r(t,2,16,n),stringify:t=>Wo(t,16,"0x")};kn.int=Qp;kn.intBin=Vp;kn.intHex=Zp;kn.intOct=Xp});var Fo=k(Do=>{"use strict";var Wr=P(),Lr=Ue(),qr=Ge(),ut=class t extends qr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;Wr.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new Lr.Pair(e.key,null):n=new Lr.Pair(e,null),qr.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=qr.findPair(this.items,e);return!n&&Wr.isPair(r)?Wr.isScalar(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=qr.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new Lr.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:i}=r,o=new this(e);if(n&&Symbol.iterator in Object(n))for(let s of n)typeof i=="function"&&(s=i.call(n,s,s)),o.items.push(Lr.createPair(s,null,r));return o}};ut.tag="tag:yaml.org,2002:set";var eh={collection:"map",identify:t=>t instanceof Set,nodeClass:ut,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>ut.from(t,e,n),resolve(t,e){if(Wr.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new ut,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Do.YAMLSet=ut;Do.set=eh});var Bo=k(Dr=>{"use strict";var th=Ot();function Mo(t,e){let n=t[0],r=n==="-"||n==="+"?t.substring(1):t,i=s=>e?BigInt(s):Number(s),o=r.replace(/_/g,"").split(":").reduce((s,a)=>s*i(60)+i(a),i(0));return n==="-"?i(-1)*o:o}function Qc(t){let{value:e}=t,n=s=>s;if(typeof e=="bigint")n=s=>BigInt(s);else if(isNaN(e)||!isFinite(e))return th.stringifyNumber(t);let r="";e<0&&(r="-",e*=n(-1));let i=n(60),o=[e%i];return e<60?o.unshift(0):(e=(e-o[0])/i,o.unshift(e%i),e>=60&&(e=(e-o[0])/i,o.unshift(e))),r+o.map(s=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var nh={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Mo(t,n),stringify:Qc},rh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Mo(t,!1),stringify:Qc},Zc={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Zc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,i,o,s,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(n,r-1,i,o||0,s||0,a||0,c),u=e[8];if(u&&u!=="Z"){let f=Mo(u,!1);Math.abs(f)<30&&(f*=60),l-=6e4*f}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Dr.floatTime=rh;Dr.intTime=nh;Dr.timestamp=Zc});var nl=k(tl=>{"use strict";var ih=Rt(),oh=_r(),sh=Pt(),ah=gn(),ch=No(),el=zc(),Uo=Yc(),Fr=Xc(),lh=yr(),uh=$o(),fh=Ir(),dh=Fo(),Ko=Bo(),mh=[ih.map,sh.seq,ah.string,oh.nullTag,el.trueTag,el.falseTag,Fr.intBin,Fr.intOct,Fr.int,Fr.intHex,Uo.floatNaN,Uo.floatExp,Uo.float,ch.binary,lh.merge,uh.omap,fh.pairs,dh.set,Ko.intTime,Ko.floatTime,Ko.timestamp];tl.schema=mh});var dl=k(Jo=>{"use strict";var sl=Rt(),ph=_r(),al=Pt(),hh=gn(),gh=So(),Go=xo(),Ho=Ro(),wh=$c(),yh=Wc(),cl=No(),bn=yr(),ll=$o(),ul=Ir(),rl=nl(),fl=Fo(),Mr=Bo(),il=new Map([["core",wh.schema],["failsafe",[sl.map,al.seq,hh.string]],["json",yh.schema],["yaml11",rl.schema],["yaml-1.1",rl.schema]]),ol={binary:cl.binary,bool:gh.boolTag,float:Go.float,floatExp:Go.floatExp,floatNaN:Go.floatNaN,floatTime:Mr.floatTime,int:Ho.int,intHex:Ho.intHex,intOct:Ho.intOct,intTime:Mr.intTime,map:sl.map,merge:bn.merge,null:ph.nullTag,omap:ll.omap,pairs:ul.pairs,seq:al.seq,set:fl.set,timestamp:Mr.timestamp},vh={"tag:yaml.org,2002:binary":cl.binary,"tag:yaml.org,2002:merge":bn.merge,"tag:yaml.org,2002:omap":ll.omap,"tag:yaml.org,2002:pairs":ul.pairs,"tag:yaml.org,2002:set":fl.set,"tag:yaml.org,2002:timestamp":Mr.timestamp};function kh(t,e,n){let r=il.get(e);if(r&&!t)return n&&!r.includes(bn.merge)?r.concat(bn.merge):r.slice();let i=r;if(!i)if(Array.isArray(t))i=[];else{let o=Array.from(il.keys()).filter(s=>s!=="yaml11").map(s=>JSON.stringify(s)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)i=i.concat(o);else typeof t=="function"&&(i=t(i.slice()));return n&&(i=i.concat(bn.merge)),i.reduce((o,s)=>{let a=typeof s=="string"?ol[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(ol).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}Jo.coreKnownTags=vh;Jo.getTags=kh});var Vo=k(ml=>{"use strict";var zo=P(),bh=Rt(),Ch=Pt(),Sh=gn(),Br=dl(),Eh=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Yo=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(e)?Br.getTags(e,"compat"):e?Br.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?Br.coreKnownTags:{},this.tags=Br.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,zo.MAP,{value:bh.map}),Object.defineProperty(this,zo.SCALAR,{value:Sh.string}),Object.defineProperty(this,zo.SEQ,{value:Ch.seq}),this.sortMapEntries=typeof s=="function"?s:s===!0?Eh:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};ml.Schema=Yo});var hl=k(pl=>{"use strict";var xh=P(),Xo=mn(),Cn=ln();function _h(t,e){let n=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(n.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&n.push("---");let i=Xo.createStringifyContext(t,e),{commentString:o}=i.options;if(t.commentBefore){n.length!==1&&n.unshift("");let c=o(t.commentBefore);n.unshift(Cn.indentComment(c,""))}let s=!1,a=null;if(t.contents){if(xh.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let u=o(t.contents.commentBefore);n.push(Cn.indentComment(u,""))}i.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>s=!0,l=Xo.stringify(t.contents,i,()=>a=null,c);a&&(l+=Cn.lineComment(l,"",o(a))),(l[0]==="|"||l[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${l}`:n.push(l)}else n.push(Xo.stringify(t.contents,i));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
|
|
58
|
-
`)?(n.push("..."),n.push(
|
|
57
|
+
${o.comment}`:r.comment}r=i}t.items[n]=Br.isPair(r)?r:new Go.Pair(r)}}else e("Expected a sequence for this tag");return t}function nl(t,e,n){let{replacer:r}=n,i=new mh.YAMLSeq(t);i.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let s of e){typeof r=="function"&&(s=r.call(e,String(o++),s));let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw new TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let l=Object.keys(s);if(l.length===1)a=l[0],c=s[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;i.items.push(Go.createPair(a,c,n))}return i}var ph={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:tl,createNode:nl};Ur.createPairs=nl;Ur.pairs=ph;Ur.resolvePairs=tl});var Jo=k(zo=>{"use strict";var rl=P(),Ho=Ue(),xn=Ye(),hh=Ve(),il=Kr(),mt=class t extends hh.YAMLSeq{constructor(){super(),this.add=xn.YAMLMap.prototype.add.bind(this),this.delete=xn.YAMLMap.prototype.delete.bind(this),this.get=xn.YAMLMap.prototype.get.bind(this),this.has=xn.YAMLMap.prototype.has.bind(this),this.set=xn.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let i of this.items){let o,s;if(rl.isPair(i)?(o=Ho.toJS(i.key,"",n),s=Ho.toJS(i.value,o,n)):o=Ho.toJS(i,"",n),r.has(o))throw new Error("Ordered maps must not include duplicate keys");r.set(o,s)}return r}static from(e,n,r){let i=il.createPairs(e,n,r),o=new this;return o.items=i.items,o}};mt.tag="tag:yaml.org,2002:omap";var gh={collection:"seq",identify:t=>t instanceof Map,nodeClass:mt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=il.resolvePairs(t,e),r=[];for(let{key:i}of n.items)rl.isScalar(i)&&(r.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):r.push(i.value));return Object.assign(new mt,n)},createNode:(t,e,n)=>mt.from(t,e,n)};zo.YAMLOMap=mt;zo.omap=gh});var ll=k(Yo=>{"use strict";var ol=q();function sl({value:t,source:e},n){return e&&(t?al:cl).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var al={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new ol.Scalar(!0),stringify:sl},cl={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new ol.Scalar(!1),stringify:sl};Yo.falseTag=cl;Yo.trueTag=al});var ul=k(Gr=>{"use strict";var wh=q(),Vo=jt(),yh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Vo.stringifyNumber},vh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Vo.stringifyNumber(t)}},kh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new wh.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:Vo.stringifyNumber};Gr.float=kh;Gr.floatExp=vh;Gr.floatNaN=yh});var dl=k(Rn=>{"use strict";var fl=jt(),_n=t=>typeof t=="bigint"||Number.isInteger(t);function Hr(t,e,n,{intAsBigInt:r}){let i=t[0];if((i==="-"||i==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let s=BigInt(t);return i==="-"?BigInt(-1)*s:s}let o=parseInt(t,n);return i==="-"?-1*o:o}function Xo(t,e,n){let{value:r}=t;if(_n(r)){let i=r.toString(e);return r<0?"-"+n+i.substr(1):n+i}return fl.stringifyNumber(t)}var bh={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>Hr(t,2,2,n),stringify:t=>Xo(t,2,"0b")},Ch={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>Hr(t,1,8,n),stringify:t=>Xo(t,8,"0")},Sh={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>Hr(t,0,10,n),stringify:fl.stringifyNumber},Eh={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>Hr(t,2,16,n),stringify:t=>Xo(t,16,"0x")};Rn.int=Sh;Rn.intBin=bh;Rn.intHex=Eh;Rn.intOct=Ch});var Zo=k(Qo=>{"use strict";var Yr=P(),zr=ze(),Jr=Ye(),pt=class t extends Jr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;Yr.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new zr.Pair(e.key,null):n=new zr.Pair(e,null),Jr.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=Jr.findPair(this.items,e);return!n&&Yr.isPair(r)?Yr.isScalar(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=Jr.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new zr.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:i}=r,o=new this(e);if(n&&Symbol.iterator in Object(n))for(let s of n)typeof i=="function"&&(s=i.call(n,s,s)),o.items.push(zr.createPair(s,null,r));return o}};pt.tag="tag:yaml.org,2002:set";var xh={collection:"map",identify:t=>t instanceof Set,nodeClass:pt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>pt.from(t,e,n),resolve(t,e){if(Yr.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new pt,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Qo.YAMLSet=pt;Qo.set=xh});var ts=k(Vr=>{"use strict";var _h=jt();function es(t,e){let n=t[0],r=n==="-"||n==="+"?t.substring(1):t,i=s=>e?BigInt(s):Number(s),o=r.replace(/_/g,"").split(":").reduce((s,a)=>s*i(60)+i(a),i(0));return n==="-"?i(-1)*o:o}function ml(t){let{value:e}=t,n=s=>s;if(typeof e=="bigint")n=s=>BigInt(s);else if(isNaN(e)||!isFinite(e))return _h.stringifyNumber(t);let r="";e<0&&(r="-",e*=n(-1));let i=n(60),o=[e%i];return e<60?o.unshift(0):(e=(e-o[0])/i,o.unshift(e%i),e>=60&&(e=(e-o[0])/i,o.unshift(e))),r+o.map(s=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Rh={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>es(t,n),stringify:ml},Ph={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>es(t,!1),stringify:ml},pl={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(pl.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,i,o,s,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(n,r-1,i,o||0,s||0,a||0,c),u=e[8];if(u&&u!=="Z"){let f=es(u,!1);Math.abs(f)<30&&(f*=60),l-=6e4*f}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Vr.floatTime=Ph;Vr.intTime=Rh;Vr.timestamp=pl});var wl=k(gl=>{"use strict";var Oh=Tt(),Ah=qr(),Nh=It(),Th=Sn(),Ih=Ko(),hl=ll(),ns=ul(),Xr=dl(),jh=Or(),$h=Jo(),Lh=Kr(),qh=Zo(),rs=ts(),Wh=[Oh.map,Nh.seq,Th.string,Ah.nullTag,hl.trueTag,hl.falseTag,Xr.intBin,Xr.intOct,Xr.int,Xr.intHex,ns.floatNaN,ns.floatExp,ns.float,Ih.binary,jh.merge,$h.omap,Lh.pairs,qh.set,rs.intTime,rs.floatTime,rs.timestamp];gl.schema=Wh});var Rl=k(ss=>{"use strict";var bl=Tt(),Dh=qr(),Cl=It(),Mh=Sn(),Fh=Lo(),is=Wo(),os=Mo(),Bh=Vc(),Uh=Zc(),Sl=Ko(),Pn=Or(),El=Jo(),xl=Kr(),yl=wl(),_l=Zo(),Qr=ts(),vl=new Map([["core",Bh.schema],["failsafe",[bl.map,Cl.seq,Mh.string]],["json",Uh.schema],["yaml11",yl.schema],["yaml-1.1",yl.schema]]),kl={binary:Sl.binary,bool:Fh.boolTag,float:is.float,floatExp:is.floatExp,floatNaN:is.floatNaN,floatTime:Qr.floatTime,int:os.int,intHex:os.intHex,intOct:os.intOct,intTime:Qr.intTime,map:bl.map,merge:Pn.merge,null:Dh.nullTag,omap:El.omap,pairs:xl.pairs,seq:Cl.seq,set:_l.set,timestamp:Qr.timestamp},Kh={"tag:yaml.org,2002:binary":Sl.binary,"tag:yaml.org,2002:merge":Pn.merge,"tag:yaml.org,2002:omap":El.omap,"tag:yaml.org,2002:pairs":xl.pairs,"tag:yaml.org,2002:set":_l.set,"tag:yaml.org,2002:timestamp":Qr.timestamp};function Gh(t,e,n){let r=vl.get(e);if(r&&!t)return n&&!r.includes(Pn.merge)?r.concat(Pn.merge):r.slice();let i=r;if(!i)if(Array.isArray(t))i=[];else{let o=Array.from(vl.keys()).filter(s=>s!=="yaml11").map(s=>JSON.stringify(s)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)i=i.concat(o);else typeof t=="function"&&(i=t(i.slice()));return n&&(i=i.concat(Pn.merge)),i.reduce((o,s)=>{let a=typeof s=="string"?kl[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(kl).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}ss.coreKnownTags=Kh;ss.getTags=Gh});var ls=k(Pl=>{"use strict";var as=P(),Hh=Tt(),zh=It(),Jh=Sn(),Zr=Rl(),Yh=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,cs=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(e)?Zr.getTags(e,"compat"):e?Zr.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?Zr.coreKnownTags:{},this.tags=Zr.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,as.MAP,{value:Hh.map}),Object.defineProperty(this,as.SCALAR,{value:Jh.string}),Object.defineProperty(this,as.SEQ,{value:zh.seq}),this.sortMapEntries=typeof s=="function"?s:s===!0?Yh:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Pl.Schema=cs});var Al=k(Ol=>{"use strict";var Vh=P(),us=kn(),On=gn();function Xh(t,e){let n=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(n.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&n.push("---");let i=us.createStringifyContext(t,e),{commentString:o}=i.options;if(t.commentBefore){n.length!==1&&n.unshift("");let c=o(t.commentBefore);n.unshift(On.indentComment(c,""))}let s=!1,a=null;if(t.contents){if(Vh.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let u=o(t.contents.commentBefore);n.push(On.indentComment(u,""))}i.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>s=!0,l=us.stringify(t.contents,i,()=>a=null,c);a&&(l+=On.lineComment(l,"",o(a))),(l[0]==="|"||l[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${l}`:n.push(l)}else n.push(us.stringify(t.contents,i));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
|
|
58
|
+
`)?(n.push("..."),n.push(On.indentComment(c,""))):n.push(`... ${c}`)}else n.push("...");else{let c=t.comment;c&&s&&(c=c.replace(/^\n+/,"")),c&&((!s||a)&&n[n.length-1]!==""&&n.push(""),n.push(On.indentComment(o(c),"")))}return n.join(`
|
|
59
59
|
`)+`
|
|
60
|
-
`}
|
|
60
|
+
`}Ol.stringifyDocument=Xh});var An=k(Nl=>{"use strict";var Qh=pn(),$t=vr(),le=P(),Zh=ze(),eg=Ue(),tg=ls(),ng=Al(),fs=hr(),rg=ho(),ig=hn(),ds=po(),ms=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,le.NODE_TYPE,{value:le.DOC});let i=null;typeof n=="function"||Array.isArray(n)?i=n:r===void 0&&n&&(r=n,n=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=o;let{version:s}=o;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new ds.Directives({version:s}),this.setSchema(s,r),this.contents=e===void 0?null:this.createNode(e,i,r)}clone(){let e=Object.create(t.prototype,{[le.NODE_TYPE]:{value:le.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=le.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Lt(this.contents)&&this.contents.add(e)}addIn(e,n){Lt(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=fs.anchorNames(this);e.anchor=!n||r.has(n)?fs.findNewAnchor(n||"a",r):n}return new Qh.Alias(e.anchor)}createNode(e,n,r){let i;if(typeof n=="function")e=n.call({"":e},"",e),i=n;else if(Array.isArray(n)){let h=y=>typeof y=="number"||y instanceof String||y instanceof Number,w=n.filter(h).map(String);w.length>0&&(n=n.concat(w)),i=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:o,anchorPrefix:s,flow:a,keepUndefined:c,onTagObj:l,tag:u}=r??{},{onAnchor:f,setAnchors:d,sourceObjects:p}=fs.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:o??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:p},m=ig.createNode(e,u,g);return a&&le.isCollection(m)&&(m.flow=!0),d(),m}createPair(e,n,r={}){let i=this.createNode(e,null,r),o=this.createNode(n,null,r);return new Zh.Pair(i,o)}delete(e){return Lt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return $t.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Lt(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return le.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return $t.isEmptyPath(e)?!n&&le.isScalar(this.contents)?this.contents.value:this.contents:le.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return le.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return $t.isEmptyPath(e)?this.contents!==void 0:le.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=$t.collectionFromPath(this.schema,[e],n):Lt(this.contents)&&this.contents.set(e,n)}setIn(e,n){$t.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=$t.collectionFromPath(this.schema,Array.from(e),n):Lt(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new ds.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new ds.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let i=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new tg.Schema(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:i,onAnchor:o,reviver:s}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},c=eg.toJS(this.contents,n??"",a);if(typeof o=="function")for(let{count:l,res:u}of a.anchors.values())o(u,l);return typeof s=="function"?rg.applyReviver(s,{"":c},"",c):c}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return ng.stringifyDocument(this,e)}};function Lt(t){if(le.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Nl.Document=ms});var In=k(Tn=>{"use strict";var Nn=class extends Error{constructor(e,n,r,i){super(),this.name=e,this.code=r,this.message=i,this.pos=n}},ps=class extends Nn{constructor(e,n,r){super("YAMLParseError",e,n,r)}},hs=class extends Nn{constructor(e,n,r){super("YAMLWarning",e,n,r)}},og=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let o=i-1,s=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(o>=60&&s.length>80){let a=Math.min(o-39,s.length-79);s="…"+s.substring(a),o-=a-1}if(s.length>80&&(s=s.substring(0,79)+"…"),r>1&&/^ *$/.test(s.substring(0,o))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`…
|
|
61
61
|
`),s=a+s}if(/[^ ]/.test(s)){let a=1,c=n.linePos[1];c?.line===r&&c.col>i&&(a=Math.max(1,Math.min(c.col-i,80-o)));let l=" ".repeat(o)+"^".repeat(a);n.message+=`:
|
|
62
62
|
|
|
63
63
|
${s}
|
|
64
64
|
${l}
|
|
65
|
-
`}};
|
|
66
|
-
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(
|
|
67
|
-
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||
|
|
68
|
-
`+C.comment:y.comment=C.comment);let b=new
|
|
69
|
-
`+E.comment:l.comment=E.comment),f=E.end;continue}!s&&n.options.strict&&
|
|
70
|
-
`+S:v.comment=S,E.comment=E.comment.substring(S.length+1)}}if(!s&&!b&&!E.found){let S=x?t(n,x,E,i):e(n,E.end,b,null,E,i);l.items.push(S),f=S.range[2],
|
|
71
|
-
`+R.comment:v.comment=R.comment);let N=new
|
|
72
|
-
`+h.comment:l.comment=h.comment),l.range=[r.offset,m,h.offset]}else l.range=[r.offset,m,m];return l}
|
|
65
|
+
`}};Tn.YAMLError=Nn;Tn.YAMLParseError=ps;Tn.YAMLWarning=hs;Tn.prettifyError=og});var jn=k(Tl=>{"use strict";function sg(t,{flow:e,indicator:n,next:r,offset:i,onError:o,parentIndent:s,startOnNewline:a}){let c=!1,l=a,u=a,f="",d="",p=!1,g=!1,m=null,h=null,w=null,y=null,C=null,b=null,x=null;for(let v of t)switch(g&&(v.type!=="space"&&v.type!=="newline"&&v.type!=="comma"&&o(v.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),m&&(l&&v.type!=="comment"&&v.type!=="newline"&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),v.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&v.source.includes(" ")&&(m=v),u=!0;break;case"comment":{u||o(v,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let R=v.source.substring(1)||" ";f?f+=d+R:f=R,d="",l=!1;break}case"newline":l?f?f+=v.source:(!b||n!=="seq-item-ind")&&(c=!0):d+=v.source,l=!0,p=!0,(h||w)&&(y=v),u=!0;break;case"anchor":h&&o(v,"MULTIPLE_ANCHORS","A node can have at most one anchor"),v.source.endsWith(":")&&o(v.offset+v.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=v,x??(x=v.offset),l=!1,u=!1,g=!0;break;case"tag":{w&&o(v,"MULTIPLE_TAGS","A node can have at most one tag"),w=v,x??(x=v.offset),l=!1,u=!1,g=!0;break}case n:(h||w)&&o(v,"BAD_PROP_ORDER",`Anchors and tags must be after the ${v.source} indicator`),b&&o(v,"UNEXPECTED_TOKEN",`Unexpected ${v.source} in ${e??"collection"}`),b=v,l=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(e){C&&o(v,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),C=v,l=!1,u=!1;break}default:o(v,"UNEXPECTED_TOKEN",`Unexpected ${v.type} token`),l=!1,u=!1}let E=t[t.length-1],S=E?E.offset+E.source.length:i;return g&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&o(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(l&&m.indent<=s||r?.type==="block-map"||r?.type==="block-seq")&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:C,found:b,spaceBefore:c,comment:f,hasNewline:p,anchor:h,tag:w,newlineAfterProp:y,end:S,start:x??S}}Tl.resolveProps=sg});var ei=k(Il=>{"use strict";function gs(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
|
|
66
|
+
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(gs(e.key)||gs(e.value))return!0}return!1;default:return!0}}Il.containsNewline=gs});var ws=k(jl=>{"use strict";var ag=ei();function cg(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&ag.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}jl.flowIndentCheck=cg});var ys=k(Ll=>{"use strict";var $l=P();function lg(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let i=typeof r=="function"?r:(o,s)=>o===s||$l.isScalar(o)&&$l.isScalar(s)&&o.value===s.value;return e.some(o=>i(o.key,n))}Ll.mapIncludes=lg});var Bl=k(Fl=>{"use strict";var ql=ze(),ug=Ye(),Wl=jn(),fg=ei(),Dl=ws(),dg=ys(),Ml="All mapping items must start at the same column";function mg({composeNode:t,composeEmptyNode:e},n,r,i,o){let s=o?.nodeClass??ug.YAMLMap,a=new s(n.schema);n.atRoot&&(n.atRoot=!1);let c=r.offset,l=null;for(let u of r.items){let{start:f,key:d,sep:p,value:g}=u,m=Wl.resolveProps(f,{indicator:"explicit-key-ind",next:d??p?.[0],offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0}),h=!m.found;if(h){if(d&&(d.type==="block-seq"?i(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==r.indent&&i(c,"BAD_INDENT",Ml)),!m.anchor&&!m.tag&&!p){l=m.end,m.comment&&(a.comment?a.comment+=`
|
|
67
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||fg.containsNewline(d))&&i(d??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&i(c,"BAD_INDENT",Ml);n.atKey=!0;let w=m.end,y=d?t(n,d,m,i):e(n,w,f,null,m,i);n.schema.compat&&Dl.flowIndentCheck(r.indent,d,i),n.atKey=!1,dg.mapIncludes(n,a.items,y)&&i(w,"DUPLICATE_KEY","Map keys must be unique");let C=Wl.resolveProps(p??[],{indicator:"map-value-ind",next:g,offset:y.range[2],onError:i,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=C.end,C.found){h&&(g?.type==="block-map"&&!C.hasNewline&&i(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<C.found.offset-1024&&i(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let b=g?t(n,g,C,i):e(n,c,p,null,C,i);n.schema.compat&&Dl.flowIndentCheck(r.indent,g,i),c=b.range[2];let x=new ql.Pair(y,b);n.options.keepSourceTokens&&(x.srcToken=u),a.items.push(x)}else{h&&i(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),C.comment&&(y.comment?y.comment+=`
|
|
68
|
+
`+C.comment:y.comment=C.comment);let b=new ql.Pair(y);n.options.keepSourceTokens&&(b.srcToken=u),a.items.push(b)}}return l&&l<c&&i(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,l??c],a}Fl.resolveBlockMap=mg});var Kl=k(Ul=>{"use strict";var pg=Ve(),hg=jn(),gg=ws();function wg({composeNode:t,composeEmptyNode:e},n,r,i,o){let s=o?.nodeClass??pg.YAMLSeq,a=new s(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let c=r.offset,l=null;for(let{start:u,value:f}of r.items){let d=hg.resolveProps(u,{indicator:"seq-item-ind",next:f,offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||f)f?.type==="block-seq"?i(d.end,"BAD_INDENT","All sequence items must start at the same column"):i(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(a.comment=d.comment);continue}let p=f?t(n,f,d,i):e(n,d.end,u,null,d,i);n.schema.compat&&gg.flowIndentCheck(r.indent,f,i),c=p.range[2],a.items.push(p)}return a.range=[r.offset,c,l??c],a}Ul.resolveBlockSeq=wg});var qt=k(Gl=>{"use strict";function yg(t,e,n,r){let i="";if(t){let o=!1,s="";for(let a of t){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{n&&!o&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";i?i+=s+u:i=u,s="";break}case"newline":i&&(s+=c),o=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:i,offset:e}}Gl.resolveEnd=yg});var Yl=k(Jl=>{"use strict";var vg=P(),kg=ze(),Hl=Ye(),bg=Ve(),Cg=qt(),zl=jn(),Sg=ei(),Eg=ys(),vs="Block collections are not allowed within flow collections",ks=t=>t&&(t.type==="block-map"||t.type==="block-seq");function xg({composeNode:t,composeEmptyNode:e},n,r,i,o){let s=r.start.source==="{",a=s?"flow map":"flow sequence",c=o?.nodeClass??(s?Hl.YAMLMap:bg.YAMLSeq),l=new c(n.schema);l.flow=!0;let u=n.atRoot;u&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let f=r.offset+r.start.source.length;for(let h=0;h<r.items.length;++h){let w=r.items[h],{start:y,key:C,sep:b,value:x}=w,E=zl.resolveProps(y,{flow:a,indicator:"explicit-key-ind",next:C??b?.[0],offset:f,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!b&&!x){h===0&&E.comma?i(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):h<r.items.length-1&&i(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),E.comment&&(l.comment?l.comment+=`
|
|
69
|
+
`+E.comment:l.comment=E.comment),f=E.end;continue}!s&&n.options.strict&&Sg.containsNewline(C)&&i(C,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)E.comma&&i(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(E.comma||i(E.start,"MISSING_CHAR",`Missing , between ${a} items`),E.comment){let S="";e:for(let v of y)switch(v.type){case"comma":case"space":break;case"comment":S=v.source.substring(1);break e;default:break e}if(S){let v=l.items[l.items.length-1];vg.isPair(v)&&(v=v.value??v.key),v.comment?v.comment+=`
|
|
70
|
+
`+S:v.comment=S,E.comment=E.comment.substring(S.length+1)}}if(!s&&!b&&!E.found){let S=x?t(n,x,E,i):e(n,E.end,b,null,E,i);l.items.push(S),f=S.range[2],ks(x)&&i(S.range,"BLOCK_IN_FLOW",vs)}else{n.atKey=!0;let S=E.end,v=C?t(n,C,E,i):e(n,S,y,null,E,i);ks(C)&&i(v.range,"BLOCK_IN_FLOW",vs),n.atKey=!1;let R=zl.resolveProps(b??[],{flow:a,indicator:"map-value-ind",next:x,offset:v.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(R.found){if(!s&&!E.found&&n.options.strict){if(b)for(let A of b){if(A===R.found)break;if(A.type==="newline"){i(A,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<R.found.offset-1024&&i(R.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]===":"?i(x,"MISSING_CHAR",`Missing space after : in ${a}`):i(R.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let K=x?t(n,x,R,i):R.found?e(n,R.end,b,null,R,i):null;K?ks(x)&&i(K.range,"BLOCK_IN_FLOW",vs):R.comment&&(v.comment?v.comment+=`
|
|
71
|
+
`+R.comment:v.comment=R.comment);let N=new kg.Pair(v,K);if(n.options.keepSourceTokens&&(N.srcToken=w),s){let A=l;Eg.mapIncludes(n,A.items,v)&&i(S,"DUPLICATE_KEY","Map keys must be unique"),A.items.push(N)}else{let A=new Hl.YAMLMap(n.schema);A.flow=!0,A.items.push(N);let U=(K??v).range;A.range=[v.range[0],U[1],U[2]],l.items.push(A)}f=K?K.range[2]:R.end}}let d=s?"}":"]",[p,...g]=r.end,m=f;if(p?.source===d)m=p.offset+p.source.length;else{let h=a[0].toUpperCase()+a.substring(1),w=u?`${h} must end with a ${d}`:`${h} in block collection must be sufficiently indented and end with a ${d}`;i(f,u?"MISSING_CHAR":"BAD_INDENT",w),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let h=Cg.resolveEnd(g,m,n.options.strict,i);h.comment&&(l.comment?l.comment+=`
|
|
72
|
+
`+h.comment:l.comment=h.comment),l.range=[r.offset,m,h.offset]}else l.range=[r.offset,m,m];return l}Jl.resolveFlowCollection=xg});var Xl=k(Vl=>{"use strict";var _g=P(),Rg=q(),Pg=Ye(),Og=Ve(),Ag=Bl(),Ng=Kl(),Tg=Yl();function bs(t,e,n,r,i,o){let s=n.type==="block-map"?Ag.resolveBlockMap(t,e,n,r,o):n.type==="block-seq"?Ng.resolveBlockSeq(t,e,n,r,o):Tg.resolveFlowCollection(t,e,n,r,o),a=s.constructor;return i==="!"||i===a.tagName?(s.tag=a.tagName,s):(i&&(s.tag=i),s)}function Ig(t,e,n,r,i){let o=r.tag,s=o?e.directives.tagName(o.source,d=>i(o,"TAG_RESOLVE_FAILED",d)):null;if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=r,g=d&&o?d.offset>o.offset?d:o:d??o;g&&(!p||p.offset<g.offset)&&i(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!o||!s||s==="!"||s===Pg.YAMLMap.tagName&&a==="map"||s===Og.YAMLSeq.tagName&&a==="seq")return bs(t,e,n,i,s);let c=e.schema.tags.find(d=>d.tag===s&&d.collection===a);if(!c){let d=e.schema.knownTags[s];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?i(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):i(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0),bs(t,e,n,i,s)}let l=bs(t,e,n,i,s,c),u=c.resolve?.(l,d=>i(o,"TAG_RESOLVE_FAILED",d),e.options)??l,f=_g.isNode(u)?u:new Rg.Scalar(u);return f.range=l.range,f.tag=s,c?.format&&(f.format=c.format),f}Vl.composeCollection=Ig});var Ss=k(Ql=>{"use strict";var Cs=q();function jg(t,e,n){let r=e.offset,i=$g(e,t.options.strict,n);if(!i)return{value:"",type:null,comment:"",range:[r,r,r]};let o=i.mode===">"?Cs.Scalar.BLOCK_FOLDED:Cs.Scalar.BLOCK_LITERAL,s=e.source?Lg(e.source):[],a=s.length;for(let m=s.length-1;m>=0;--m){let h=s[m][1];if(h===""||h==="\r")a=m;else break}if(a===0){let m=i.chomp==="+"&&s.length>0?`
|
|
73
73
|
`.repeat(Math.max(1,s.length-1)):"",h=r+i.length;return e.source&&(h+=e.source.length),{value:m,type:o,comment:i.comment,range:[r,h,h]}}let c=e.indent+i.indent,l=e.offset+i.length,u=0;for(let m=0;m<a;++m){let[h,w]=s[m];if(w===""||w==="\r")i.indent===0&&h.length>c&&(c=h.length);else{h.length<c&&n(l+h.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),i.indent===0&&(c=h.length),u=m,c===0&&!t.atRoot&&n(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=h.length+w.length+1}for(let m=s.length-1;m>=a;--m)s[m][0].length>c&&(a=m+1);let f="",d="",p=!1;for(let m=0;m<u;++m)f+=s[m][0].slice(c)+`
|
|
74
|
-
`;for(let m=u;m<a;++m){let[h,w]=s[m];l+=h.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&h.length<c){let b=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;n(l-w.length-(y?2:1),"BAD_INDENT",b),h=""}o===
|
|
74
|
+
`;for(let m=u;m<a;++m){let[h,w]=s[m];l+=h.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&h.length<c){let b=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;n(l-w.length-(y?2:1),"BAD_INDENT",b),h=""}o===Cs.Scalar.BLOCK_LITERAL?(f+=d+h.slice(c)+w,d=`
|
|
75
75
|
`):h.length>c||w[0]===" "?(d===" "?d=`
|
|
76
76
|
`:!p&&d===`
|
|
77
77
|
`&&(d=`
|
|
@@ -84,96 +84,109 @@ ${l}
|
|
|
84
84
|
`+s[m][0].slice(c);f[f.length-1]!==`
|
|
85
85
|
`&&(f+=`
|
|
86
86
|
`);break;default:f+=`
|
|
87
|
-
`}let g=r+i.length+e.source.length;return{value:f,type:o,comment:i.comment,range:[r,g,g]}}function
|
|
87
|
+
`}let g=r+i.length+e.source.length;return{value:f,type:o,comment:i.comment,range:[r,g,g]}}function $g({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=e[0],o=i[0],s=0,a="",c=-1;for(let d=1;d<i.length;++d){let p=i[d];if(!a&&(p==="-"||p==="+"))a=p;else{let g=Number(p);!s&&g?s=g:c===-1&&(c=t+d)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let l=!1,u="",f=i.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":l=!0;case"newline":f+=p.source.length;break;case"comment":n&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=p.source.length,u=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),f+=p.source.length;break;default:{let g=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",g);let m=p.source;m&&typeof m=="string"&&(f+=m.length)}}}return{mode:o,indent:s,chomp:a,comment:u,length:f}}function Lg(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),o=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let s=1;s<e.length;s+=2)o.push([e[s],e[s+1]]);return o}Ql.resolveBlockScalar=jg});var xs=k(eu=>{"use strict";var Es=q(),qg=qt();function Wg(t,e,n){let{offset:r,type:i,source:o,end:s}=t,a,c,l=(d,p,g)=>n(r+d,p,g);switch(i){case"scalar":a=Es.Scalar.PLAIN,c=Dg(o,l);break;case"single-quoted-scalar":a=Es.Scalar.QUOTE_SINGLE,c=Mg(o,l);break;case"double-quoted-scalar":a=Es.Scalar.QUOTE_DOUBLE,c=Fg(o,l);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[r,r+o.length,r+o.length]}}let u=r+o.length,f=qg.resolveEnd(s,u,e,n);return{value:c,type:a,comment:f.comment,range:[r,u,f.offset]}}function Dg(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Zl(t)}function Mg(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Zl(t.slice(1,-1)).replace(/''/g,"'")}function Zl(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
88
88
|
`,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
89
89
|
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let i=r[1],o=" ",s=e.lastIndex;for(n.lastIndex=s;r=n.exec(t);)r[1]===""?o===`
|
|
90
90
|
`?i+=o:o=`
|
|
91
|
-
`:(i+=o+r[1],o=" "),s=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=s,r=a.exec(t),i+o+(r?.[1]??"")}function
|
|
91
|
+
`:(i+=o+r[1],o=" "),s=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=s,r=a.exec(t),i+o+(r?.[1]??"")}function Fg(t,e){let n="";for(let r=1;r<t.length-1;++r){let i=t[r];if(!(i==="\r"&&t[r+1]===`
|
|
92
92
|
`))if(i===`
|
|
93
|
-
`){let{fold:o,offset:s}=
|
|
93
|
+
`){let{fold:o,offset:s}=Bg(t,r);n+=o,r=s}else if(i==="\\"){let o=t[++r],s=Ug[o];if(s)n+=s;else if(o===`
|
|
94
94
|
`)for(o=t[r+1];o===" "||o===" ";)o=t[++r+1];else if(o==="\r"&&t[r+1]===`
|
|
95
|
-
`)for(o=t[++r+1];o===" "||o===" ";)o=t[++r+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=
|
|
95
|
+
`)for(o=t[++r+1];o===" "||o===" ";)o=t[++r+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=Kg(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(i===" "||i===" "){let o=r,s=t[r+1];for(;s===" "||s===" ";)s=t[++r+1];s!==`
|
|
96
96
|
`&&!(s==="\r"&&t[r+2]===`
|
|
97
|
-
`)&&(n+=r>o?t.slice(o,r+1):i)}else n+=i}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function
|
|
97
|
+
`)&&(n+=r>o?t.slice(o,r+1):i)}else n+=i}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function Bg(t,e){let n="",r=t[e+1];for(;(r===" "||r===" "||r===`
|
|
98
98
|
`||r==="\r")&&!(r==="\r"&&t[e+2]!==`
|
|
99
99
|
`);)r===`
|
|
100
100
|
`&&(n+=`
|
|
101
|
-
`),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var
|
|
102
|
-
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
101
|
+
`),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var Ug={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Kg(t,e,n,r){let i=t.substr(e,n),s=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(s)}catch{let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}eu.resolveFlowScalar=Wg});var ru=k(nu=>{"use strict";var ht=P(),tu=q(),Gg=Ss(),Hg=xs();function zg(t,e,n,r){let{value:i,type:o,comment:s,range:a}=e.type==="block-scalar"?Gg.resolveBlockScalar(t,e,r):Hg.resolveFlowScalar(e,t.options.strict,r),c=n?t.directives.tagName(n.source,f=>r(n,"TAG_RESOLVE_FAILED",f)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[ht.SCALAR]:c?l=Jg(t.schema,i,c,n,r):e.type==="scalar"?l=Yg(t,i,e,r):l=t.schema[ht.SCALAR];let u;try{let f=l.resolve(i,d=>r(n??e,"TAG_RESOLVE_FAILED",d),t.options);u=ht.isScalar(f)?f:new tu.Scalar(f)}catch(f){let d=f instanceof Error?f.message:String(f);r(n??e,"TAG_RESOLVE_FAILED",d),u=new tu.Scalar(i)}return u.range=a,u.source=i,o&&(u.type=o),c&&(u.tag=c),l.format&&(u.format=l.format),s&&(u.comment=s),u}function Jg(t,e,n,r,i){if(n==="!")return t[ht.SCALAR];let o=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(e))return a;let s=t.knownTags[n];return s&&!s.collection?(t.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[ht.SCALAR])}function Yg({atKey:t,directives:e,schema:n},r,i,o){let s=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[ht.SCALAR];if(n.compat){let a=n.compat.find(c=>c.default&&c.test?.test(r))??n[ht.SCALAR];if(s.tag!==a.tag){let c=e.tagString(s.tag),l=e.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;o(i,"TAG_RESOLVE_FAILED",u,!0)}}return s}nu.composeScalar=zg});var ou=k(iu=>{"use strict";function Vg(t,e,n){if(e){n??(n=e.length);for(let r=n-1;r>=0;--r){let i=e[r];switch(i.type){case"space":case"comment":case"newline":t-=i.source.length;continue}for(i=e[++r];i?.type==="space";)t+=i.source.length,i=e[++r];break}}return t}iu.emptyScalarPosition=Vg});var cu=k(Rs=>{"use strict";var Xg=pn(),Qg=P(),Zg=Xl(),su=ru(),ew=qt(),tw=ou(),nw={composeNode:au,composeEmptyNode:_s};function au(t,e,n,r){let i=t.atKey,{spaceBefore:o,comment:s,anchor:a,tag:c}=n,l,u=!0;switch(e.type){case"alias":l=rw(t,e,r),(a||c)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=su.composeScalar(t,e,c,r),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Zg.composeCollection(nw,t,e,n,r),a&&(l.anchor=a.source.substring(1))}catch(f){let d=f instanceof Error?f.message:String(f);r(e,"RESOURCE_EXHAUSTION",d)}break;default:{let f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",f),u=!1}}return l??(l=_s(t,e.offset,void 0,null,n,r)),a&&l.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&t.options.stringKeys&&(!Qg.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(l.spaceBefore=!0),s&&(e.type==="scalar"&&e.source===""?l.comment=s:l.commentBefore=s),t.options.keepSourceTokens&&u&&(l.srcToken=e),l}function _s(t,e,n,r,{spaceBefore:i,comment:o,anchor:s,tag:a,end:c},l){let u={type:"scalar",offset:tw.emptyScalarPosition(e,n,r),indent:-1,source:""},f=su.composeScalar(t,u,a,l);return s&&(f.anchor=s.source.substring(1),f.anchor===""&&l(s,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(f.spaceBefore=!0),o&&(f.comment=o,f.range[2]=c),f}function rw({options:t},{offset:e,source:n,end:r},i){let o=new Xg.Alias(n.substring(1));o.source===""&&i(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&i(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=e+n.length,a=ew.resolveEnd(r,s,t.strict,i);return o.range=[e,s,a.offset],a.comment&&(o.comment=a.comment),o}Rs.composeEmptyNode=_s;Rs.composeNode=au});var fu=k(uu=>{"use strict";var iw=An(),lu=cu(),ow=qt(),sw=jn();function aw(t,e,{offset:n,start:r,value:i,end:o},s){let a=Object.assign({_directives:e},t),c=new iw.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=sw.resolveProps(r,{indicator:"doc-start",next:i??o?.[0],offset:n,onError:s,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!u.hasNewline&&s(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=i?lu.composeNode(l,i,u,s):lu.composeEmptyNode(l,u.end,r,null,u,s);let f=c.contents.range[2],d=ow.resolveEnd(o,f,!1,s);return d.comment&&(c.comment=d.comment),c.range=[n,f,d.offset],c}uu.composeDoc=aw});var Os=k(pu=>{"use strict";var cw=ur("process"),lw=po(),uw=An(),$n=In(),du=P(),fw=fu(),dw=qt();function Ln(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function mu(t){let e="",n=!1,r=!1;for(let i=0;i<t.length;++i){let o=t[i];switch(o[0]){case"#":e+=(e===""?"":r?`
|
|
103
103
|
|
|
104
104
|
`:`
|
|
105
|
-
`)+(o.substring(1)||" "),n=!0,r=!1;break;case"%":t[i+1]?.[0]!=="#"&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var
|
|
106
|
-
${r}`:r;else if(i||e.directives.docStart||!o)e.commentBefore=r;else if(
|
|
105
|
+
`)+(o.substring(1)||" "),n=!0,r=!1;break;case"%":t[i+1]?.[0]!=="#"&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var Ps=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,i,o)=>{let s=Ln(n);o?this.warnings.push(new $n.YAMLWarning(s,r,i)):this.errors.push(new $n.YAMLParseError(s,r,i))},this.directives=new lw.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:i}=mu(this.prelude);if(r){let o=e.contents;if(n)e.comment=e.comment?`${e.comment}
|
|
106
|
+
${r}`:r;else if(i||e.directives.docStart||!o)e.commentBefore=r;else if(du.isCollection(o)&&!o.flow&&o.items.length>0){let s=o.items[0];du.isPair(s)&&(s=s.key);let a=s.commentBefore;s.commentBefore=a?`${r}
|
|
107
107
|
${a}`:r}else{let s=o.commentBefore;o.commentBefore=s?`${r}
|
|
108
|
-
${s}`:r}}if(n){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
109
|
-
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new
|
|
108
|
+
${s}`:r}}if(n){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:mu(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let i of e)yield*this.next(i);yield*this.end(n,r)}*next(e){switch(cw.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,i)=>{let o=Ln(e);o[0]+=n,this.onError(o,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=fw.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new $n.YAMLParseError(Ln(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new $n.YAMLParseError(Ln(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=dw.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
|
|
109
|
+
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new $n.YAMLParseError(Ln(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),i=new uw.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,n,n],this.decorate(i,!1),yield i}}};pu.Composer=Ps});var wu=k(ti=>{"use strict";var mw=Ss(),pw=xs(),hw=In(),hu=vn();function gw(t,e=!0,n){if(t){let r=(i,o,s)=>{let a=typeof i=="number"?i:Array.isArray(i)?i[0]:i.offset;if(n)n(a,o,s);else throw new hw.YAMLParseError([a,a+1],o,s)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return pw.resolveFlowScalar(t,e,r);case"block-scalar":return mw.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function ww(t,e){let{implicitKey:n=!1,indent:r,inFlow:i=!1,offset:o=-1,type:s="PLAIN"}=e,a=hu.stringifyString({type:s,value:t},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
|
|
110
110
|
`}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
|
|
111
111
|
`),u=a.substring(0,l),f=a.substring(l+1)+`
|
|
112
|
-
`,d=[{type:"block-scalar-header",offset:o,indent:r,source:u}];return
|
|
113
|
-
`}),{type:"block-scalar",offset:o,indent:r,props:d,source:f}}case'"':return{type:"double-quoted-scalar",offset:o,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:r,source:a,end:c};default:return{type:"scalar",offset:o,indent:r,source:a,end:c}}}function
|
|
112
|
+
`,d=[{type:"block-scalar-header",offset:o,indent:r,source:u}];return gu(d,c)||d.push({type:"newline",offset:-1,indent:r,source:`
|
|
113
|
+
`}),{type:"block-scalar",offset:o,indent:r,props:d,source:f}}case'"':return{type:"double-quoted-scalar",offset:o,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:r,source:a,end:c};default:return{type:"scalar",offset:o,indent:r,source:a,end:c}}}function yw(t,e,n={}){let{afterKey:r=!1,implicitKey:i=!1,inFlow:o=!1,type:s}=n,a="indent"in t?t.indent:null;if(r&&typeof a=="number"&&(a+=2),!s)switch(t.type){case"single-quoted-scalar":s="QUOTE_SINGLE";break;case"double-quoted-scalar":s="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");s=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=hu.stringifyString({type:s,value:e},{implicitKey:i||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":vw(t,c);break;case'"':As(t,c,"double-quoted-scalar");break;case"'":As(t,c,"single-quoted-scalar");break;default:As(t,c,"scalar")}}function vw(t,e){let n=e.indexOf(`
|
|
114
114
|
`),r=e.substring(0,n),i=e.substring(n+1)+`
|
|
115
|
-
`;if(t.type==="block-scalar"){let o=t.props[0];if(o.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o.source=r,t.source=i}else{let{offset:o}=t,s="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:s,source:r}];
|
|
116
|
-
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:s,props:a,source:i})}}function
|
|
117
|
-
`};delete t.items,Object.assign(t,{type:n,source:e,end:[i]});break}default:{let r="indent"in t?t.indent:-1,i="end"in t&&Array.isArray(t.end)?t.end.filter(o=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(t))o!=="type"&&o!=="offset"&&delete t[o];Object.assign(t,{type:n,indent:r,source:e,end:i})}}}
|
|
115
|
+
`;if(t.type==="block-scalar"){let o=t.props[0];if(o.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o.source=r,t.source=i}else{let{offset:o}=t,s="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:s,source:r}];gu(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:s,source:`
|
|
116
|
+
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:s,props:a,source:i})}}function gu(t,e){if(e)for(let n of e)switch(n.type){case"space":case"comment":t.push(n);break;case"newline":return t.push(n),!0}return!1}function As(t,e,n){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=n,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),i=e.length;t.props[0].type==="block-scalar-header"&&(i-=t.props[0].source.length);for(let o of r)o.offset+=i;delete t.props,Object.assign(t,{type:n,source:e,end:r});break}case"block-map":case"block-seq":{let i={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
|
|
117
|
+
`};delete t.items,Object.assign(t,{type:n,source:e,end:[i]});break}default:{let r="indent"in t?t.indent:-1,i="end"in t&&Array.isArray(t.end)?t.end.filter(o=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(t))o!=="type"&&o!=="offset"&&delete t[o];Object.assign(t,{type:n,indent:r,source:e,end:i})}}}ti.createScalarToken=ww;ti.resolveAsScalar=gw;ti.setScalarValue=yw});var vu=k(yu=>{"use strict";var kw=t=>"type"in t?ri(t):ni(t);function ri(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=ri(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=ni(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=ni(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=ni(t);if(t.end)for(let n of t.end)e+=n.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let n of t.end)e+=n.source;return e}}}function ni({start:t,key:e,sep:n,value:r}){let i="";for(let o of t)i+=o.source;if(e&&(i+=ri(e)),n)for(let o of n)i+=o.source;return r&&(i+=ri(r)),i}yu.stringify=kw});var Su=k(Cu=>{"use strict";var Ns=Symbol("break visit"),bw=Symbol("skip children"),ku=Symbol("remove item");function gt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),bu(Object.freeze([]),t,e)}gt.BREAK=Ns;gt.SKIP=bw;gt.REMOVE=ku;gt.itemAtPath=(t,e)=>{let n=t;for(let[r,i]of e){let o=n?.[r];if(o&&"items"in o)n=o.items[i];else return}return n};gt.parentCollection=(t,e)=>{let n=gt.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],i=n?.[r];if(i&&"items"in i)return i;throw new Error("Parent collection not found")};function bu(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let i of["key","value"]){let o=e[i];if(o&&"items"in o){for(let s=0;s<o.items.length;++s){let a=bu(Object.freeze(t.concat([[i,s]])),o.items[s],n);if(typeof a=="number")s=a-1;else{if(a===Ns)return Ns;a===ku&&(o.items.splice(s,1),s-=1)}}typeof r=="function"&&i==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Cu.visit=gt});var ii=k(re=>{"use strict";var Ts=wu(),Cw=vu(),Sw=Su(),Is="\uFEFF",js="",$s="",Ls="",Ew=t=>!!t&&"items"in t,xw=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function _w(t){switch(t){case Is:return"<BOM>";case js:return"<DOC>";case $s:return"<FLOW_END>";case Ls:return"<SCALAR>";default:return JSON.stringify(t)}}function Rw(t){switch(t){case Is:return"byte-order-mark";case js:return"doc-mode";case $s:return"flow-error-end";case Ls:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
118
118
|
`:case`\r
|
|
119
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}re.createScalarToken=
|
|
120
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
121
|
-
\r `),
|
|
119
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}re.createScalarToken=Ts.createScalarToken;re.resolveAsScalar=Ts.resolveAsScalar;re.setScalarValue=Ts.setScalarValue;re.stringify=Cw.stringify;re.visit=Sw.visit;re.BOM=Is;re.DOCUMENT=js;re.FLOW_END=$s;re.SCALAR=Ls;re.isCollection=Ew;re.isScalar=xw;re.prettyToken=_w;re.tokenType=Rw});var Ds=k(xu=>{"use strict";var qn=ii();function me(t){switch(t){case void 0:case" ":case`
|
|
120
|
+
`:case"\r":case" ":return!0;default:return!1}}var Eu=new Set("0123456789ABCDEFabcdef"),Pw=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),oi=new Set(",[]{}"),Ow=new Set(` ,[]{}
|
|
121
|
+
\r `),qs=t=>!t||Ow.has(t),Ws=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
|
|
122
122
|
`?!0:n==="\r"?this.buffer[e+1]===`
|
|
123
123
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let r=0;for(;n===" ";)n=this.buffer[++r+e];if(n==="\r"){let i=this.buffer[r+e+1];if(i===`
|
|
124
124
|
`||!i&&!this.atEnd)return e+r+1}return n===`
|
|
125
|
-
`||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&
|
|
126
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===
|
|
125
|
+
`||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&me(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
126
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===qn.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let o=e[r-1];if(o===" "||o===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let o=e[n-1];if(o===" "||o===" ")n-=1;else break}let i=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield qn.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&me(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!me(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&me(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);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(qs),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let i=this.getLine();if(i===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&i[0]!=="#"||r===0&&(i.startsWith("---")||i.startsWith("..."))&&me(i[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield qn.FLOW_END,yield*this.parseLineStart();let o=0;for(;i[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),i[o]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-o),"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(qs),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let s=this.charAt(1);if(this.flowKey||me(s)||s===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let o=0;for(;this.buffer[n-1-o]==="\\";)o+=1;if(o%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),i=r.indexOf(`
|
|
127
127
|
`,this.pos);if(i!==-1){for(;i!==-1;){let o=this.continueScalar(i+1);if(o===-1)break;i=r.indexOf(`
|
|
128
|
-
`,o)}i!==-1&&(n=i-(r[i-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>
|
|
128
|
+
`,o)}i!==-1&&(n=i-(r[i-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>me(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,r;e:for(let o=this.pos;r=this.buffer[o];++o)switch(r){case" ":n+=1;break;case`
|
|
129
129
|
`:e=o,n=0;break;case"\r":{let s=this.buffer[o+1];if(!s&&!this.atEnd)return this.setNext("block-scalar");if(s===`
|
|
130
130
|
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(e+1);if(o===-1)break;e=this.buffer.indexOf(`
|
|
131
131
|
`,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let i=e+1;for(r=this.buffer[i];r===" ";)r=this.buffer[++i];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
|
|
132
132
|
`;)r=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let o=e-1,s=this.buffer[o];s==="\r"&&(s=this.buffer[--o]);let a=o;for(;s===" ";)s=this.buffer[--o];if(s===`
|
|
133
|
-
`&&o>=this.pos&&o+1+n>a)e=o;else break}while(!0);return yield
|
|
133
|
+
`&&o>=this.pos&&o+1+n>a)e=o;else break}while(!0);return yield qn.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,r=this.pos-1,i;for(;i=this.buffer[++r];)if(i===":"){let o=this.buffer[r+1];if(me(o)||e&&oi.has(o))break;n=r}else if(me(i)){let o=this.buffer[r+1];if(i==="\r"&&(o===`
|
|
134
134
|
`?(r+=1,i=`
|
|
135
|
-
`,o=this.buffer[r+1]):n=r),o==="#"||e&&
|
|
136
|
-
`){let s=this.continueScalar(r+1);if(s===-1)break;r=Math.max(r,s-2)}}else{if(e&&
|
|
135
|
+
`,o=this.buffer[r+1]):n=r),o==="#"||e&&oi.has(o))break;if(i===`
|
|
136
|
+
`){let s=this.continueScalar(r+1);if(s===-1)break;r=Math.max(r,s-2)}}else{if(e&&oi.has(i))break;n=r}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield qn.SCALAR,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(qs),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,r=this.charAt(1);if(me(r)||n&&oi.has(r)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!me(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(Pw.has(n))n=this.buffer[++e];else if(n==="%"&&Eu.has(this.buffer[e+1])&&Eu.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
137
137
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
138
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let i=n-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=n),i}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};
|
|
138
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let i=n-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=n),i}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};xu.Lexer=Ws});var Fs=k(_u=>{"use strict";var Ms=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let o=n+r>>1;this.lineStarts[o]<e?n=o+1:r=o}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let i=this.lineStarts[n-1];return{line:n,col:e-i+1}}}};_u.LineCounter=Ms});var Us=k(Nu=>{"use strict";var Aw=ur("process"),Ru=ii(),Nw=Ds();function Xe(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function Pu(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Au(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function si(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Wt(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function ai(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let n=0;n<e.length;++n)t.push(e[n])}function Ou(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Xe(e.start,"explicit-key-ind")&&!Xe(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Au(e.value)?e.value.end?ai(e.value.end,e.sep):e.value.end=e.sep:ai(e.start,e.sep),delete e.sep)}var Bs=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Nw.Lexer,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,Aw.env.LOG_TOKENS&&console.log("|",Ru.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Ru.tokenType(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&Ou(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let i=r.items[r.items.length-1];if(i.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=n;else{Object.assign(i,{key:n,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{let i=r.items[r.items.length-1];i.value?r.items.push({start:[],value:n}):i.value=n;break}case"flow-collection":{let i=r.items[r.items.length-1];!i||i.value?r.items.push({start:[],key:n,sep:[]}):i.sep?i.value=n:Object.assign(i,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let i=n.items[n.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&Pu(i.start)===-1&&(n.indent===0||i.start.every(o=>o.type!=="comment"||o.indent<n.indent))&&(r.type==="document"?r.end=i.start:r.items.push({start:i.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Pu(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=si(this.peek(2)),r=Wt(n),i;e.end?(i=e.end,i.push(this.sourceToken),delete e.end):i=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
|
|
139
139
|
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
|
|
140
|
-
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){
|
|
140
|
+
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){ai(i,n.start),i.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,i=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",o=[];if(i&&n.sep&&!n.value){let s=[];for(let a=0;a<n.sep.length;++a){let c=n.sep[a];switch(c.type){case"newline":s.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(s.length=0);break;default:s.length=0}}s.length>=2&&(o=n.sep.splice(s[1]))}switch(this.type){case"anchor":case"tag":i||n.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):i||n.value?(o.push(this.sourceToken),e.items.push({start:o,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(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Xe(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(Au(n.key)&&!Xe(n.sep,"newline")){let s=Wt(n.start),a=n.key,c=n.sep;c.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:a,sep:c}]})}else o.length>0?n.sep=n.sep.concat(o,this.sourceToken):n.sep.push(this.sourceToken);else if(Xe(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let s=Wt(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||i?e.items.push({start:o,key:null,sep:[this.sourceToken]}):Xe(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);i||n.value?(e.items.push({start:o,key:s,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(s):(Object.assign(n,{key:s,sep:[]}),this.onKeyLine=!0);return}default:{let s=this.startBlockValue(e);if(s){if(s.type==="block-seq"){if(!n.explicitKey&&n.sep&&!Xe(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:o});this.stack.push(s);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){ai(i,n.start),i.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||Xe(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:i,sep:[]}):n.sep?this.stack.push(i):Object.assign(n,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let i=si(r),o=Wt(i);Ou(e);let s=e.end.splice(1,e.end.length);s.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
|
|
141
141
|
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
|
|
142
|
-
`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=Yr(e),r=It(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=Yr(e),r=It(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};gu.Parser=Os});var bu=k(Tn=>{"use strict";var wu=gs(),aw=Sn(),Nn=_n(),cw=po(),lw=P(),uw=Ps(),yu=As();function vu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new uw.LineCounter||null,prettyErrors:e}}function fw(t,e={}){let{lineCounter:n,prettyErrors:r}=vu(e),i=new yu.Parser(n?.addNewLine),o=new wu.Composer(e),s=Array.from(o.compose(i.parse(t)));if(r&&n)for(let a of s)a.errors.forEach(Nn.prettifyError(t,n)),a.warnings.forEach(Nn.prettifyError(t,n));return s.length>0?s:Object.assign([],{empty:!0},o.streamInfo())}function ku(t,e={}){let{lineCounter:n,prettyErrors:r}=vu(e),i=new yu.Parser(n?.addNewLine),o=new wu.Composer(e),s=null;for(let a of o.compose(i.parse(t),!0,t.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new Nn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(s.errors.forEach(Nn.prettifyError(t,n)),s.warnings.forEach(Nn.prettifyError(t,n))),s}function dw(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let i=ku(t,n);if(!i)return null;if(i.warnings.forEach(o=>cw.warn(i.options.logLevel,o)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function mw(t,e,n){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let i=Math.round(n);n=i<1?void 0:i>8?{indent:8}:{indent:i}}if(t===void 0){let{keepUndefined:i}=n??e??{};if(!i)return}return lw.isDocument(t)&&!r?t.toString(n):new aw.Document(t,r,n).toString(n)}Tn.parse=dw;Tn.parseAllDocuments=fw;Tn.parseDocument=ku;Tn.stringify=mw});var de=k(O=>{"use strict";var pw=gs(),hw=Sn(),gw=Vo(),Ns=_n(),ww=an(),ze=P(),yw=Ue(),vw=q(),kw=Ge(),bw=He(),Cw=Jr(),Sw=_s(),Ew=Ps(),xw=As(),Xr=bu(),Cu=nn();O.Composer=pw.Composer;O.Document=hw.Document;O.Schema=gw.Schema;O.YAMLError=Ns.YAMLError;O.YAMLParseError=Ns.YAMLParseError;O.YAMLWarning=Ns.YAMLWarning;O.Alias=ww.Alias;O.isAlias=ze.isAlias;O.isCollection=ze.isCollection;O.isDocument=ze.isDocument;O.isMap=ze.isMap;O.isNode=ze.isNode;O.isPair=ze.isPair;O.isScalar=ze.isScalar;O.isSeq=ze.isSeq;O.Pair=yw.Pair;O.Scalar=vw.Scalar;O.YAMLMap=kw.YAMLMap;O.YAMLSeq=bw.YAMLSeq;O.CST=Cw;O.Lexer=Sw.Lexer;O.LineCounter=Ew.LineCounter;O.Parser=xw.Parser;O.parse=Xr.parse;O.parseAllDocuments=Xr.parseAllDocuments;O.parseDocument=Xr.parseDocument;O.stringify=Xr.stringify;O.visit=Cu.visit;O.visitAsync=Cu.visitAsync});import Ye from"path";function Tw(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||Ye.posix.isAbsolute(n)||Ye.win32.isAbsolute(n)||/^(?:~|[\\/])/u.test(n))throw new Error(`${e} must be a project-relative path`);if(n===".")return[];let r=n.replaceAll("\\","/").split("/");if(r.some(i=>i===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(i=>i===""||i==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function Qr(t){let e=Tw(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Ou(t,e="docs"){let n=t??e;if(n!=="legacy"&&n!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return n}function $e(t,e,n=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim().replaceAll("\\","/");if(r.length===0||Ye.posix.isAbsolute(r)||Ye.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let i=r.split("/");if(i.some(o=>o===".."))throw new Error(`${e} must stay inside its declared path base`);if(i.some(o=>o===""||o==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!n&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return i.join("/")}function je(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Au(t,e,n){let r=t??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${n} must be en or zh-CN`);return r}function Nu(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>Is)throw new Error(`${e} exceeds ${Is} characters`);let n=0;for(let r=0;r<t.length;r+=1)t[r]==="?"?n+=1:t[r]==="*"&&(n+=1,t[r+1]==="*"&&(r+=1));if(n>js)throw new Error(`${e} contains more than ${js} wildcard tokens`);return t}function Ru(t,e,n){if(t===void 0)return[...n];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(r=>Nu(r,e)))].sort((r,i)=>r.localeCompare(i,"en"))}function In(t,e,n){let r=t??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${n} must be a positive integer`);return r}function Pu(t,e,n){let r=In(t,e,n);if(r>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${n} is too large to convert to bytes safely`);return r}function Iw(t){if(t===void 0)return{...ke,include:[...ke.include],exclude:[...ke.exclude]};let e=je(t,"native.snapshot");return{include:Ru(e.include,"native.snapshot.include",ke.include),exclude:Ru(e.exclude,"native.snapshot.exclude",ke.exclude),max_files:In(e.max_files,ke.max_files,"native.snapshot.max_files"),max_total_bytes:In(e.max_total_bytes,ke.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:In(e.max_duration_ms,ke.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:In(e.max_selection_records,ke.max_selection_records,"native.snapshot.max_selection_records")}}function jw(t){if(t===void 0)return;let e=je(t,"native.pending_root_move"),n=e.id,r=e.from_artifact_root,i=e.to_artifact_root,o=e.stage;if(typeof n!="string"||!/^[a-f0-9-]{8,}$/u.test(n))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof i!="string")throw new Error("native.pending_root_move roots must be strings");if(o!=="copying"&&o!=="ready"&&o!=="switched")throw new Error("native.pending_root_move.stage is invalid");let s;if(e.cleanup!==void 0){let a=je(e.cleanup,"native.pending_root_move.cleanup"),c=a.kind,l=a.state,u=a.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");s={kind:c,state:l,manifestHash:u}}return{id:n,fromArtifactRoot:Qr(r),toArtifactRoot:Qr(i),stage:o,...s?{cleanup:s}:{}}}function $w(t){if(t===void 0)return;let e=je(t,"native.finish");if(e.pull_request===void 0)return{};let n=je(e.pull_request,"native.finish.pull_request");if(n.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(n.command)||n.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(n.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let r=n.command.map((o,s)=>{if(typeof o!="string"||o.trim().length===0||o.length>4096||/[\0\r\n]/u.test(o))throw new Error(`native.finish.pull_request.command[${s}] must be a non-empty single-line string of at most 4096 characters`);return o});if(Ye.posix.isAbsolute(r[0])||Ye.win32.isAbsolute(r[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let i=n.timeout_ms??Pw;if(!Number.isSafeInteger(i)||i<1||i>_u)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${_u}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:i}}}function Lw(t,e={}){let n=je(t,"native"),r=n.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let i=n.clarification_mode??"batch";if(i!=="sequential"&&i!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let o=n.archive_confirmation??"automatic";if(o!=="automatic"&&o!=="required")throw new Error("native.archive_confirmation must be automatic or required");let s=n.max_verify_failures??_w;if(!Number.isSafeInteger(s)||s<1)throw new Error("native.max_verify_failures must be a positive integer");let a=n.document_writes??"allow";if(a!=="allow"&&a!=="revert")throw new Error("native.document_writes must be allow or revert");let c=jw(n.pending_root_move),l=$w(n.finish);return{artifact_root:Qr(r),language:Au(n.language,"en","native.language"),clarification_mode:i,archive_confirmation:o,max_verify_failures:s,...a==="revert"?{document_writes:a}:{},snapshot:Iw(n.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function qw(t){let e=je(t,"classic"),n=e.context_compression??"off";if(n!=="off"&&n!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let i=e.auto_transition??!0;if(typeof i!="boolean")throw new Error("classic.auto_transition must be true or false");let o=e.document_evidence??"neutral";if(o!=="neutral"&&o!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:Ou(e.artifact_layout),language:Au(e.language,"zh-CN","classic.language"),context_compression:n,review_mode:r,auto_transition:i,...o==="strict"?{document_evidence:o}:{}}}function Ww(t){let n=je(t,"hook").allow_paths??[];if(!Array.isArray(n))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(n.map((r,i)=>$e(r,`hook.allow_paths[${i}]`)))]}}function Dw(t){if(t===void 0)return{...Ts};let e=je(t,"memory"),n=e.learning??Ts.learning,r=e.retrieval??Ts.retrieval;if(typeof n!="boolean")throw new Error("memory.learning must be true or false");if(typeof r!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:n,retrieval:r}}function Ls(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Fw(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||n.includes("\\")||n.includes("\0")||Ye.posix.isAbsolute(n)||Ye.win32.isAbsolute(n)||n.startsWith("~")||n.split("/").some(i=>i===""||i==="."||i===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!n.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(n.length>Su)throw new Error(`${e} exceeds ${Su} characters`);let r=0;for(let i=0;i<n.length;i+=1)n[i]==="?"?r+=1:n[i]==="*"&&(r+=1,n[i+1]==="*"&&(i+=1));if(r>Eu)throw new Error(`${e} contains more than ${Eu} wildcard tokens`);return n}function Mw(t){let e=Ls(t,"knowledge.local"),n=e.include??[];if(!Array.isArray(n))throw new Error("knowledge.local.include must be an array");let r={include:[...new Set(n.map((i,o)=>Fw(i,`knowledge.local.include[${o}]`)))],max_file_mb:Pu(e.max_file_mb,xu.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Pu(e.max_total_mb,xu.max_total_mb,"knowledge.local.max_total_mb")};if(r.max_file_mb>r.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return r}function Bw(t){if(typeof t!="string"||t.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(t)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let n=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),r=n==="localhost"||n==="127.0.0.1"||n==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&r))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function Uw(t){let e=Ls(t,"knowledge.remote"),n=Bw(e.endpoint),r=e.token_env;if(r!==void 0&&(typeof r!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(r)))throw new Error("knowledge.remote.token_env must be an environment variable name");let i=e.scope;if(i!==void 0&&(typeof i!="string"||i.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let o=e.timeout_ms??5e3;if(typeof o!="number"||!Number.isSafeInteger(o)||o<100||o>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:n,...r===void 0?{}:{token_env:r},...i===void 0?{}:{scope:i},timeout_ms:o}}function Kw(t){if(t===void 0)return{...Rw};let e=Ls(t,"knowledge"),n=e.provider??"local";if(n!=="local"&&n!=="remote")throw new Error("knowledge.provider must be local or remote");let r=e.local===void 0?void 0:Mw(e.local);if(n==="local")return{provider:n,...r?{local:r}:{}};let i=e.remote===void 0?void 0:Uw(e.remote);if(i===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:n,...r?{local:r}:{},remote:i}}function Gw(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function Hw(t,e,n,r,i,o,s,a){let c=t.schema!==void 0;if(!(c||t.default_workflow!==void 0||t.workflows!==void 0||!a.allowPartialProject&&t.native!==void 0)||a.allowPartialProject&&!c)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let u=t.workflows??[t.default_workflow];if(!Array.isArray(u)||u.length===0||u.some(d=>d!=="native"&&d!=="classic"))throw new Error("workflows must contain native and/or classic");let f=[...new Set(u)];if(!f.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(f.includes("native")&&!i)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:f,ambient_resume:s,...e?{hook:e}:{},memory:n,knowledge:r,...i?{native:i}:{},...o?{classic:o}:{}}}function $t(t,e={}){let n=(0,$s.parseDocument)(t,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${n.errors[0].message}`);let r=n.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let i=r,o=Gw(i.ambient_resume),s=i.hook===void 0?void 0:Ww(i.hook),a=Dw(i.memory),c=Kw(i.knowledge),l=i.native===void 0?void 0:Lw(i.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=i.classic===void 0?void 0:qw(i.classic),f=Hw(i,s,a,c,l,u,o,{allowPartialProject:e.allowPartialProject??!1});return{value:i,config:f,ambient_resume:o,memory:a,knowledge:c,...s?{hook:s}:{},...l?{native:l}:{},...u?{classic:u}:{}}}var $s,jt,Is,js,Su,Eu,_w,Ts,xu,Rw,Pw,_u,Ow,Aw,Nw,ke,be=T(()=>{"use strict";$s=we(de(),1),jt=Number.MAX_SAFE_INTEGER,Is=1024,js=64,Su=1024,Eu=64,_w=5,Ts={learning:!0,retrieval:!0},xu={include:[],max_file_mb:1,max_total_mb:32},Rw={provider:"local"},Pw=12e4,_u=6e5,Ow=[".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/**"],Aw=["**/.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"],Nw=[...Ow,...Aw].sort((t,e)=>t.localeCompare(e,"en")),ke={include:["**/*"],exclude:[...Nw],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});function Ve(t){return t!==0&&t!==0n&&t!=="0"}function Tu(t,e){return Ve(t.dev)&&Ve(e.dev)&&Ve(t.ino)&&Ve(e.ino)}function Xe(t,e){let n=Ve(t.dev)&&Ve(e.dev);if(n&&t.dev!==e.dev)return!1;let r=Ve(t.ino)&&Ve(e.ino);return r&&t.ino!==e.ino?!1:n&&r?!0:t.birthtime===e.birthtime}var Zr=T(()=>{"use strict"});import{constants as ei,promises as mt}from"fs";function qs(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Iu(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function jn(t){return{dev:t.dev,ino:t.ino,birthtime:qs(t)}}function ti(t,e){let n=jn(t),r=jn(e);return Tu(n,r)?Xe(n,r):Xe(n,r)&&qs(t)===qs(e)&&Iu(t)===Iu(e)&&t.size===e.size}async function ni(t,e,n={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=n.label??"file",i=n.bigint===!0,o=await mt.lstat(t,{bigint:i});if(!o.isFile()||o.isSymbolicLink())throw new Qe("not-regular-file",`${r} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new Qe("too-large",`${r} exceeds ${e} bytes`);let s=await mt.realpath(t);await n.verify?.("pre-open",{realPath:s,identity:jn(o)});let a=process.platform==="win32"?ei.O_RDONLY:ei.O_RDONLY|ei.O_NOFOLLOW|ei.O_NONBLOCK,c;try{c=await mt.open(t,a)}catch(l){throw l.code==="ELOOP"?new Qe("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,f]=await Promise.all([c.stat({bigint:i}),mt.lstat(t,{bigint:i}),mt.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||f!==s||!ti(o,l)||!ti(o,u))throw new Qe("changed",`${r} changed while opening`);await n.verify?.("post-open",{realPath:f,identity:jn(l)}),await n.hooks?.afterOpen?.();let d=[],p=0,g=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let y=e+1-p,{bytesRead:C}=await c.read(g,0,Math.min(g.length,y),null);if(C===0)break;if(p+=C,p>e)throw new Qe("too-large",`${r} exceeds ${e} bytes`);d.push(Buffer.from(g.subarray(0,C)))}await n.hooks?.beforeFinalCheck?.();let[m,h,w]=await Promise.all([c.stat({bigint:i}),mt.lstat(t,{bigint:i}),mt.realpath(t)]);if(!h.isFile()||h.isSymbolicLink()||w!==s||!ti(o,m)||!ti(o,h))throw new Qe("changed",`${r} changed while reading`);return await n.verify?.("post-read",{realPath:w,identity:jn(m)}),{bytes:Buffer.concat(d,p),stat:m,realPath:w}}finally{await c.close()}}var Qe,Ws=T(()=>{"use strict";Zr();Qe=class extends Error{reason;constructor(e,n,r){super(n,r),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Ze}from"fs";import me from"path";function ju(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function ri(t,e){let n=me.relative(t,e);return n===""||!me.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${me.sep}`)}async function Ds(t,e){let n=me.resolve(t),r=await Ze.lstat(n);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Ze.realpath(n)}async function Fs(t,e,n,r){let i=t;for(let o=0;o<n.length;o++){i=me.join(i,n[o]);let s;try{s=await Ze.lstat(i)}catch(u){if(ju(u))return{exists:!1,kind:"missing"};throw u}let a=me.relative(t,i).replaceAll("\\","/");if(s.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${a}`);let c=o===n.length-1;if(!c&&!s.isDirectory())throw new Error(`${r.label} ancestor ${a} must be a real directory`);if(c&&(r.expected==="file"&&!s.isFile()||r.expected==="directory"&&!s.isDirectory()||r.expected==="any"&&!s.isFile()&&!s.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await Ze.realpath(i);if(!ri(e,l))throw new Error(`${r.label} resolves outside the project root`);if(c)return{exists:!0,kind:s.isFile()?"file":s.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function I(t,e,n){let r=$e(e,n.label),i=me.resolve(t),o=await Ds(i,n.label),s=r.split("/"),a=me.resolve(i,...s);if(!ri(i,a))throw new Error(`${n.label} must stay inside the project root`);let c=await Fs(i,o,s,n);return{projectRoot:i,target:a,relative:r,exists:c.exists,kind:c.kind}}async function Ms(t,e,n){let r=$e(e,n.label),i=me.resolve(t),o=await Ds(i,n.label),s=r.split("/"),a=i;for(let c of s){a=me.join(a,c);let l;try{l=await Ze.lstat(a)}catch(d){if(!ju(d))throw d;try{await Ze.mkdir(a)}catch(p){if(p.code!=="EEXIST")throw p}l=await Ze.lstat(a)}let u=me.relative(i,a).replaceAll("\\","/");if(l.isSymbolicLink())throw new Error(`${n.label} crosses a symbolic link or junction at ${u}`);if(!l.isDirectory())throw new Error(`${n.label} directory ${u} must be a real directory`);let f=await Ze.realpath(a);if(!ri(o,f))throw new Error(`${n.label} resolves outside the project root`)}return await Fs(i,o,s,{label:n.label,expected:"directory"}),a}async function Bs(t,e,n){return(await I(t,e,{...n,expected:"file"})).exists}async function j(t,e,n,r){let i=await I(t,e,{label:r.label,expected:"file"});if(!i.exists){let s=new Error(`${r.label} does not exist`);throw s.code="ENOENT",s}let o=await Ds(i.projectRoot,r.label);return ni(i.target,n,{...r,verify:async(s,a)=>{if(!ri(o,a.realPath))throw new Error(`${r.label} resolves outside the project root`);await Fs(i.projectRoot,o,i.relative.split("/"),{label:r.label,expected:"file"})}})}var z=T(()=>{"use strict";Ws();be()});import{createHash as Jw}from"crypto";function zw(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Lt(t,e={}){return(await ii(t,e)).document}async function Yw(t){try{return(await j(t,$n,jt,{label:$n})).bytes}catch(e){if(zw(e))return null;throw e}}function Vw(t){return t?{exists:!0,sha256:Jw("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function ii(t,e={}){let n=await Yw(t);return{document:n?$t(n.toString("utf8"),e):null,identity:Vw(n)}}async function Us(t){return(await Lt(t))?.config??null}var $n,pt=T(()=>{"use strict";be();z();$n=".comet/config.yaml"});import{promises as Gs}from"node:fs";async function Hs(t,e){let n;for(let r=0;r<=Ks.length;r+=1)try{return await t()}catch(i){n=i;let o=i.code;if(r===Ks.length||!Xw.has(o??""))throw i;await new Promise(s=>setTimeout(s,Ks[r]))}throw n}async function $u(t,e){await Hs(()=>Gs.rename(t,e),`rename ${e}`)}async function oi(t){await Hs(()=>Gs.unlink(t),`unlink ${t}`)}async function Lu(t,e){await Hs(()=>Gs.link(t,e),`link ${e}`)}var Xw,Ks,Js=T(()=>{"use strict";Xw=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),Ks=[50,100,200]});import{randomUUID as Qw}from"crypto";import{constants as Zw,promises as M}from"fs";import H from"path";async function zs(t,e){try{return await Lu(t,e),{linked:!0}}catch(n){let r=n.code;if(r!=="ENOTSUP"&&r!=="EOPNOTSUPP")throw n}return await M.copyFile(t,e,Zw.COPYFILE_EXCL),{linked:!1}}function ht(t,e){let n=H.relative(t,e);return n===""||!H.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${H.sep}`)}function si(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function ey(t,e){return Xe(t,si(e))}function ai(t,e){return Xe(si(t),si(e))}function qu(t,e){return ai(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function ci(t){let e=await M.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Contained atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await M.realpath(t),...si(e)}}async function Le(t){for(let e of t){let n=await M.lstat(e.path);if(!n.isDirectory()||n.isSymbolicLink()||!ey(e,n)||await M.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function ty(t,e,n){let[r,i]=await Promise.all([M.lstat(t),M.realpath(t),Le(n)]);if(!r.isFile()||r.isSymbolicLink()||!ai(r,e)||!ht(n[0].realPath,i))throw new Error("Contained atomic write temporary file changed after close");return r}async function ny(t,e){let n=H.resolve(t),r=H.resolve(e);if(!ht(n,r))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let i=[await ci(n)],o=H.relative(n,r).split(H.sep).filter(Boolean),s=n;for(let a of o){await Le(i),s=H.join(s,a);try{await M.mkdir(s)}catch(l){if(l.code!=="EEXIST")throw l}let c=await ci(s);if(!ht(i[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${s}`);i.push(c)}return await Le(i),i}async function ry(t,e){let n=H.resolve(t),r=H.resolve(e);if(!ht(n,r))throw new Error(`Contained file parent is outside its managed root: ${e}`);let i=[await ci(n)],o=H.relative(n,r).split(H.sep).filter(Boolean),s=n;for(let a of o){s=H.join(s,a);try{let c=await ci(s);if(!ht(i[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${s}`);i.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await Le(i),i}async function Wu(t){let e;try{e=await M.open(t,"r"),await e.sync()}catch(n){let r=n.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw n}finally{await e?.close()}}async function iy(t,e,n){let r=H.dirname(t),i=await ny(n.containedRoot,r),o=H.join(r,`.${H.basename(t)}.${Qw()}.tmp`),s,a,c;try{await n.beforeTemporaryOpen?.(),s=await M.open(o,"wx"),a=await s.stat();let[l,u]=await Promise.all([M.lstat(o),M.realpath(o)]);if(await Le(i),!l.isFile()||l.isSymbolicLink()||!ai(a,l)||!ht(i[0].realPath,u))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await s.writeFile(e,"utf8"):await s.writeFile(e),await s.sync(),c=await s.stat(),!ai(a,c))throw new Error("Contained atomic write temporary file changed while writing");if(await s.close(),s=void 0,await n.afterTemporaryClose?.(),!c)throw new Error("Contained atomic write temporary file was not written");c=await ty(o,c,i),await n.beforeCommit?.(),await Le(i);let f=await M.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!c||!qu(f,c))throw new Error("Contained atomic write temporary file changed before commit");n.exclusive?(await zs(o,t),await M.unlink(o)):await $u(o,t),await Wu(r)}catch(l){await s?.close();try{await Le(i),await M.rm(o,{force:!0})}catch{}throw l}}async function X(t,e,n){await iy(t,e,n)}async function qt(t,e){let n=H.dirname(t),r=await ry(e.containedRoot,n);if(!r)return!1;let i,o;try{i=await M.lstat(t),o=await M.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!i.isFile()||i.isSymbolicLink()||!ht(r[0].realPath,o))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await Le(r);let[s,a]=await Promise.all([M.lstat(t),M.realpath(t)]);if(!s.isFile()||s.isSymbolicLink()||!qu(i,s)||a!==o)throw new Error("Contained file removal target changed before removal");return await oi(t),await Le(r),await Wu(n),!0}var Ce=T(()=>{"use strict";Js();Zr()});var sS,Ys=T(()=>{"use strict";Ce();pt();z();sS=16*1024});var li=T(()=>{"use strict";Ce();be();pt();z();Ys()});import{existsSync as py}from"node:fs";import Wn from"node:path";function zu(t,e){let n=e.toLowerCase();return Object.entries(t).find(([r,i])=>r.toLowerCase()===n&&i!==void 0)?.[1]}function gy(t){let e=(zu(t,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").map(n=>n.trim().toLowerCase()).filter(Boolean);return[...new Set([...e,".ps1"])]}function wy(t,e,n){let i=Wn.win32.isAbsolute(t)||/[\\/]/u.test(t)?[""]:(zu(e,"PATH")??"").split(Wn.delimiter).map(a=>a.trim().replace(/^"(.*)"$/u,"$1")).filter(Boolean),s=Wn.win32.extname(t)?[t]:gy(e).map(a=>`${t}${a}`);return i.flatMap(a=>s.map(c=>a?Wn.join(a,c):Wn.resolve(n,c)))}function ui(t,e,n){return wy(t,e,n).find(r=>py(r))??t}function Yu(t){if(t.some(e=>hy.test(e)))throw new Error("Windows batch check arguments must not contain shell syntax")}var hy,PS,Xs=T(()=>{"use strict";hy=/[&|<>()^%"!\r\n]/u,PS=["$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 By}from"node:child_process";import pf from"node:path";function Gy(t){return t instanceof Error&&(t.code==="ETIMEDOUT"||t.killed===!0&&t.signal==="SIGTERM")}function Jt(t,e,n={}){let r=n.timeoutMs??Uy,i=n.maxBufferBytes??Ky;if(!Number.isSafeInteger(r)||r<1)throw new Error("External command timeout must be a positive integer");if(!Number.isSafeInteger(i)||i<1)throw new Error("External command max buffer must be a positive integer");let o=pf.resolve(n.cwd??process.cwd()),s=n.env??process.env,a=process.platform==="win32"?ui(t,s,o):t,c=pf.win32.extname(a).toLowerCase(),l=c===".bat"||c===".cmd";process.platform==="win32"&&l&&Yu(e);try{return By(a,[...e],{cwd:o,env:s,...n.input!==void 0?{input:n.input}:{},encoding:"utf8",stdio:[n.input===void 0?"ignore":"pipe","pipe","pipe"],timeout:r,maxBuffer:i,windowsHide:!0,shell:process.platform==="win32"&&l})}catch(u){let f=typeof u.stderr=="string"?u.stderr.trim():Buffer.isBuffer(u.stderr)?u.stderr.toString("utf8").trim():"";throw new Ht(t,e,f,{cause:u,timedOut:Gy(u)})}}var Uy,Ky,Ht,oa=T(()=>{"use strict";Xs();Uy=6e4,Ky=8*1024*1024,Ht=class extends Error{constructor(n,r,i,o){super(`${n} ${r.join(" ")} failed${i?`: ${i}`:""}`,o);this.command=n;this.args=r;this.stderr=i;this.name="ExternalCommandError",this.timedOut=o?.timedOut===!0}command;args;stderr;timedOut}});import{promises as hf}from"node:fs";import gf from"node:path";function zy(t){let e=aa.get(t);if(!e)return;let n=e.value===null?Jy:Hy;if(Date.now()-e.at>n){aa.delete(t);return}return e.value}async function ca(t){if(t===process.pid&&sa!==null)return sa;let e=zy(t);if(e!==void 0)return e;let n=await Yy(t);return t===process.pid&&n!==null&&(sa=n),t!==process.pid&&aa.set(t,{value:n,at:Date.now()}),n}async function Yy(t){if(!Number.isSafeInteger(t)||t<=0)return null;try{if(process.platform==="linux"){let[e,n]=await Promise.all([hf.readFile(`/proc/${t}/stat`,"utf8"),hf.readFile("/proc/sys/kernel/random/boot_id","utf8")]),r=e.slice(e.lastIndexOf(")")+2).trim().split(/\s+/u)[19];return/^\d+$/u.test(r??"")?`linux:${n.trim()}:${r}`:null}if(process.platform==="win32")return await Xy(t);if(process.platform==="darwin"){let e=Jt("/bin/ps",["-p",String(t),"-o","lstart="],{timeoutMs:5e3,maxBufferBytes:4096,env:{...process.env,LC_ALL:"C",TZ:"UTC0"}}).trim();return e?`darwin:${e}`:null}}catch{}return null}function Vy(t){let e=t.trim();return/^\d+$/u.test(e)?`win32-ps:${e}`:null}async function Xy(t){try{let i=Jt(gf.win32.join(process.env.SystemRoot??"C:\\Windows","System32","wbem","WMIC.exe"),["process","where",`processid=${t}`,"get","creationdate","/value"],{timeoutMs:5e3,maxBufferBytes:4096}),o=/^CreationDate=(\S+)/mu.exec(i);if(o)return`win32-wmic:${o[1]}`}catch{}let e=process.env.SystemRoot??"C:\\Windows",n=gf.win32.join(e,"System32","WindowsPowerShell","v1.0","powershell.exe"),r=Jt(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${t} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`],{timeoutMs:8e3,maxBufferBytes:4096}).trim();return Vy(r)}function vi(t){let e=t.indexOf(":");return e===-1?"":t.slice(0,e)}async function yf(t,e){if(!Number.isSafeInteger(t)||t<=0)return"alive";try{process.kill(t,0)}catch(r){if(r.code==="ESRCH")return"dead"}if(!e)return"unknown";let n=await ca(t);return n===e?"alive":n===null||vi(n)!==vi(e)&&wf.has(vi(n))&&wf.has(vi(e))?"unknown":"dead"}var sa,Hy,Jy,aa,wf,vf=T(()=>{"use strict";oa();sa=null,Hy=6e4,Jy=1e4,aa=new Map;wf=new Set(["win32-wmic","win32-ps"])});import{randomUUID as Qy}from"node:crypto";import{promises as wt}from"node:fs";import bf from"node:os";import kf from"node:path";async function Cf(t,e,n={}){let r=kf.resolve(t);await wt.mkdir(kf.dirname(r),{recursive:!0});let i=Date.now(),o=n.timeoutMs??Zy,s=n.retryMs??ev,a=n.malformedLockStaleMs??tv,c=await ca(process.pid),l={pid:process.pid,nonce:Qy(),createdAt:Date.now(),hostname:bf.hostname(),...c===null?{}:{processIdentity:c}},u=!1;for(;!u;){let f;try{f=await wt.open(r,"wx"),await f.writeFile(JSON.stringify(l),"utf8"),u=!0}catch(d){if(d.code!=="EEXIST")throw d;if(await rv(r,a))continue;if(Date.now()-i>=o)throw new Error(`Timed out waiting for file lock: ${r}`,{cause:d});await new Promise(p=>setTimeout(p,s))}finally{await f?.close()}}try{return await e()}finally{await iv(r,l.nonce)}}async function rv(t,e){let n,r;try{[n,r]=await Promise.all([wt.readFile(t,"utf8"),wt.stat(t)])}catch(o){return o.code==="ENOENT"}let i=Sf(n);if(i!==null&&(i.hostname!==void 0&&i.hostname!==bf.hostname()||await yf(i.pid,i.processIdentity)!=="dead"))return!1;if(i===null){let o=n.trim().length===0?nv:e;if(Date.now()-Number(r.mtimeMs)<o)return!1}try{return await wt.readFile(t,"utf8")!==n?!1:(await wt.rm(t),!0)}catch(o){return o.code==="ENOENT"}}async function iv(t,e){try{if(Sf(await wt.readFile(t,"utf8"))?.nonce!==e)return;await oi(t)}catch(n){let r=n.code;if(r==="ENOENT")return;process.stderr.write(`[comet] warning: could not remove lock file ${t} (${r??n}); it will be recovered automatically
|
|
143
|
-
`)}}function Sf(t){try{let e=JSON.parse(t);return Number.isSafeInteger(e.pid)&&Number(e.pid)>0&&typeof e.nonce=="string"&&e.nonce.length>0&&typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)&&(e.hostname===void 0||typeof e.hostname=="string"&&e.hostname.length>0)&&(e.processIdentity===void 0||typeof e.processIdentity=="string"&&e.processIdentity.length>0)?{pid:Number(e.pid),nonce:e.nonce,createdAt:e.createdAt,...e.hostname===void 0?{}:{hostname:e.hostname},...e.processIdentity===void 0?{}:{processIdentity:e.processIdentity}}:null}catch{return null}}var Zy,ev,tv,nv,Ef=T(()=>{"use strict";Js();vf();Zy=3e4,ev=20,tv=5*6e4,nv=1e4});var ki=T(()=>{"use strict"});var xf=T(()=>{"use strict"});var la=T(()=>{"use strict";ki()});var _f=T(()=>{"use strict";ki();la()});var fv,Rf=T(()=>{"use strict";fv=we(de(),1);Ce();be();z()});var dx,Pf=T(()=>{"use strict";Ce();z();dx=4*1024*1024});function Af(t,e){let n=t;for(let r of e)n+="\0"+(typeof r=="string"?r:JSON.stringify(r));return n}function bi(t,e){return(...n)=>{let r=Of;if(r===null)return e(...n);let i=Af(`async:${t}`,n),o=r.entries.get(i);if(o)return o.value;let s=e(...n).catch(a=>{throw r.entries.delete(i),a});return r.entries.set(i,{value:s}),s}}function ua(t,e){return(...n)=>{let r=Of;if(r===null)return e(...n);let i=Af(`sync:${t}`,n),o=r.entries.get(i);if(o)return o.value;let s=e(...n);return r.entries.set(i,{value:s}),s}}var Of,Ci=T(()=>{"use strict";Of=null});var wx,Nf=T(()=>{"use strict";Ci();pt();wx=bi("hookWritePolicy",async t=>(await Us(t))?.hook??{allow_paths:[]})});import{promises as dv}from"node:fs";import mv from"node:path";function Ei(t){return mv.join(t,".comet","current-change.json")}function pv(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Tf(t){return t===null||typeof t=="string"}function hv(t){let e;try{e=JSON.parse(t)}catch(n){throw new Error(`current change selection contains invalid JSON: ${n instanceof Error?n.message:String(n)}`,{cause:n})}if(!pv(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!Tf(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:Si,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==Si)throw new Error(`current change selection schema must be ${Si}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!Tf(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function xi(t){let e;try{let r=Ei(t),{bytes:i}=await ni(r,If,{label:"current change selection"});e=i.toString("utf8")}catch(r){if(r.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${r instanceof Error?r.message:String(r)}`,{cause:r})}return{status:"selected",...hv(e)}}async function fa(t){await dv.rm(Ei(t),{force:!0})}async function da(t,e,n){let r=await xi(t);return r.status!=="selected"||r.selection.workflow!==e||r.selection.change!==n?!1:(await fa(t),!0)}var Si,If,ma=T(()=>{"use strict";Ws();Si="comet.selection.v2",If=16*1024});var jf=T(()=>{"use strict";ki();Ce();xf();_f();be();Rf();z();pt();li();Pf();Nf();ma();Ys();la()});import{TextDecoder as wv}from"util";function $f(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function yv(t,e){try{return new wv("utf-8",{fatal:!0}).decode(t.bytes)}catch(n){throw new Error(`${e} is not valid UTF-8`,{cause:n})}}async function pa(t,e,n,r,i={}){try{let o=await j(t,e,n,{label:r,hooks:i.hooks});return{result:o,text:yv(o,r)}}catch(o){let s=o.code;if(s==="ENOENT"||s==="ENOTDIR")return null;throw o}}async function tt(t,e,n,r,i={}){return(await pa(t,e,n,r,i))?.text??null}async function nt(t,e,n,r,i,o={}){if(Buffer.byteLength(n,"utf8")>r)throw new Error(`${i} exceeds ${r} bytes`);let s=await pa(t,e,r,i),a=await I(t,e,{label:i,expected:"file"});await X(a.target,n,{containedRoot:a.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await pa(t,e,r,i);if(!(!s&&!c)){if(!s||!c)throw new Error(`${i} changed before commit`);if(s.result.realPath!==c.result.realPath||!Xe($f(s.result.stat),$f(c.result.stat))||s.text!==c.text)throw new Error(`${i} changed before commit`)}}})}async function _i(t,e,n,r,i,o={}){let s=await tt(t,e,r,i);await nt(t,e,`${s??""}${n}`,r,i,o)}async function Ri(t,e,n,r={}){let i=await I(t,e,{label:n,expected:"file"});return i.exists?qt(i.target,{containedRoot:i.projectRoot,beforeRemove:r.beforeRemove}):!1}var Pi=T(()=>{"use strict";jf();Zr()});var Wf={};Yd(Wf,{RUN_STATE_FILE:()=>Oi,applyRunStateToDocument:()=>ha,readRunState:()=>Ai,removeRunState:()=>Gn,runStateFromDocument:()=>zt,writeRunState:()=>Yt});import vv from"path";function Kn(t,e){let n=t[e];if(typeof n!="string"||n.length===0)throw new Error(`Invalid Run state: ${e} must be a non-empty string`);return n}function Un(t,e){let n=Kn(t,e);if(vv.isAbsolute(n)||/^(?:[A-Za-z]:|[\\/]|~)/u.test(n)||n.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Run state: ${e} must stay inside the change directory`);return n}function kv(t){let e=t.run_retries??"{}",n;try{n=typeof e=="string"?JSON.parse(e):e}catch(r){throw new Error("Invalid Run state: run_retries must be a JSON object",{cause:r})}if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Invalid Run state: run_retries must be a JSON object");for(let r of Object.values(n))if(!Number.isInteger(r)||Number(r)<0)throw new Error("Invalid Run state: retry counts must be non-negative integers");return n}function zt(t){if(!t.run_id)return null;let e=Kn(t,"run_id"),n=Kn(t,"skill"),r=Kn(t,"skill_version"),i=Kn(t,"skill_hash"),o=Un(t,"pending_ref"),s=Un(t,"trajectory_ref"),a=Un(t,"context_ref"),c=Un(t,"artifacts_ref"),l=Un(t,"checkpoint_ref"),u=Number(t.iteration);if(!Number.isInteger(u)||u<0)throw new Error("Invalid Run state: iteration must be a non-negative integer");if(t.orchestration!=="deterministic"&&t.orchestration!=="adaptive")throw new Error("Invalid Run state: orchestration must be deterministic or adaptive");if(t.run_status!=="running"&&t.run_status!=="waiting"&&t.run_status!=="completed"&&t.run_status!=="failed")throw new Error("Invalid Run state: run_status is invalid");return{runId:e,skill:n,skillVersion:r,skillHash:i,orchestration:t.orchestration,currentStep:Lf(t,"current_step"),iteration:u,pending:Lf(t,"pending"),pendingRef:o,trajectoryRef:s,contextRef:a,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:kv(t)}}function ha(t,e){e?t.run_id=e.runId:delete t.run_id}function bv(t){return{runId:t.runId,skill:t.skill,skillVersion:t.skillVersion,skillHash:t.skillHash,orchestration:t.orchestration,currentStep:t.currentStep,iteration:t.iteration,pending:t.pending,pendingRef:t.pendingRef,trajectoryRef:t.trajectoryRef,contextRef:t.contextRef,artifactsRef:t.artifactsRef,checkpointRef:t.checkpointRef,status:t.status,retries:t.retries}}function Cv(t){let e={run_id:t.runId,skill:t.skill,skill_version:t.skillVersion,skill_hash:t.skillHash,orchestration:t.orchestration,current_step:t.currentStep,iteration:t.iteration,pending:t.pending,pending_ref:t.pendingRef,trajectory_ref:t.trajectoryRef,context_ref:t.contextRef,artifacts_ref:t.artifactsRef,checkpoint_ref:t.checkpointRef,run_status:t.status,run_retries:JSON.stringify(t.retries)};return zt(e)}async function Ai(t,e={}){let n=await tt(t,Oi,qf,"Run state",e);if(n===null)return null;let r=JSON.parse(n);return Cv(r)}async function Yt(t,e,n={}){await nt(t,Oi,JSON.stringify(bv(e),null,2),qf,"Run state",n)}async function Gn(t,e={}){await Ri(t,Oi,"Run state",e)}var Lf,Oi,qf,Ni=T(()=>{"use strict";Pi();Lf=(t,e)=>{let n=t[e];return n==null?null:String(n)};Oi=".comet/run-state.json",qf=Number.MAX_SAFE_INTEGER});var $d=T(()=>{"use strict"});var YR,Ld=T(()=>{"use strict";$d();YR=8*1024*1024});import{createHash as Xk}from"crypto";import Z from"node:path";import{createHash as _y}from"node:crypto";import{AsyncLocalStorage as dy}from"async_hooks";import{promises as Uu}from"fs";import $ from"path";import{promises as Xd}from"fs";async function tn(t){try{return await Xd.access(t),!0}catch(e){if(Qd(e))return!1;throw e}}function Qd(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}be();pt();li();z();var Wt=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Mu=".comet/config.yaml";function Ku(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Gu(t){await I(t,Mu,{label:Mu,expected:"file"})}function Ln(t,e){let n=$.resolve(t),r=e==="docs"?$.join(n,"docs"):n,i=$.join(r,"openspec"),o=$.join(n,"docs","superpowers");return{projectRoot:n,artifactLayout:e,openSpecBase:r,openSpecRoot:i,changesDir:$.join(i,"changes"),archiveDir:$.join(i,"changes","archive"),specsDir:$.join(i,"specs"),superpowersRoot:o,superpowersSpecsDir:$.join(o,"specs"),superpowersPlansDir:$.join(o,"plans"),superpowersReportsDir:$.join(o,"reports")}}async function Hu(t){await Gu(t);let e=await Lt(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new Wt;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new Wt("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function cy(t,e){return Ln(t,e??await Hu(t))}async function ly(t){try{return await Uu.lstat(t),!0}catch(e){if(Ku(e))return!1;throw e}}async function uy(t,e){let n=await cy(t,e),r=n.artifactLayout==="legacy"?"docs":"legacy",i=Ln(t,r).openSpecRoot,[o,s]=await Promise.all([I(n.projectRoot,L(n.projectRoot,n.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),ly(i)]),a=o.exists;return{paths:n,configuredRootExists:a,alternateRoot:i,alternateRootExists:s,dualRoots:a&&s}}async function fy(t){let e=[t.openSpecRoot,t.changesDir,t.archiveDir,t.specsDir,t.superpowersRoot,t.superpowersSpecsDir,t.superpowersPlansDir,t.superpowersReportsDir];for(let n of e){let r=L(t.projectRoot,n);await I(t.projectRoot,r,{label:`Classic managed physical path ${r}`,expected:"directory"})}}async function Q(t,e){let n=await uy(t,e);if(await fy(n.paths),!n.configuredRootExists){let r=L(n.paths.projectRoot,n.paths.openSpecRoot),i=L(n.paths.projectRoot,n.alternateRoot);throw new Wt(`Configured Classic OpenSpec root is missing: ${r} (alternate ${i} is ${n.alternateRootExists?"present":"missing"})`)}return n.paths}async function qn(t,e){let n=$.join($.resolve(t),".comet","classic-root-move.json");if(await tn(n))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let r=await Q(t,e);if(!await tn(r.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${L(r.projectRoot,r.openSpecRoot)}`);return r}async function Se(t){let e=$.resolve(t),n=null;try{(await Uu.lstat(e)).isDirectory()||(e=$.dirname(e))}catch(r){if(!Ku(r))throw r}for(;;){$.basename(e)==="openspec"&&(n=$.dirname(e));let r=$.join(e,".comet","config.yaml"),i=!1;if(await tn(r))try{await Gu(e);let s=(await Lt(e))?.value;i=!!s&&typeof s=="object"&&!Array.isArray(s)&&(s.schema==="comet.project.v1"||s.default_workflow!==void 0||s.native!==void 0)}catch{}if(i||await tn($.join(e,".git")))return e;let o=$.dirname(e);if(o===e)return n??$.resolve(t);e=o}}function L(t,e){return $.relative($.resolve(t),e).replaceAll("\\","/")}var my=new dy;async function Ju(t,e){let n=my.getStore();if(!n)return e();let r=n.observations.get(t);if(r)return r;let i=e();n.observations.set(t,i);try{return await i}catch(o){throw n.observations.delete(t),o}}var rf=we(de(),1);import{spawnSync as Cy}from"child_process";Xs();import{existsSync as Vu,readFileSync as yy}from"node:fs";import Dt from"node:path";function vy(t){let e=t.replaceAll(`\r
|
|
142
|
+
`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=si(e),r=Wt(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=si(e),r=Wt(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Nu.Parser=Bs});var Lu=k(Dn=>{"use strict";var Tu=Os(),Tw=An(),Wn=In(),Iw=Ro(),jw=P(),$w=Fs(),Iu=Us();function ju(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new $w.LineCounter||null,prettyErrors:e}}function Lw(t,e={}){let{lineCounter:n,prettyErrors:r}=ju(e),i=new Iu.Parser(n?.addNewLine),o=new Tu.Composer(e),s=Array.from(o.compose(i.parse(t)));if(r&&n)for(let a of s)a.errors.forEach(Wn.prettifyError(t,n)),a.warnings.forEach(Wn.prettifyError(t,n));return s.length>0?s:Object.assign([],{empty:!0},o.streamInfo())}function $u(t,e={}){let{lineCounter:n,prettyErrors:r}=ju(e),i=new Iu.Parser(n?.addNewLine),o=new Tu.Composer(e),s=null;for(let a of o.compose(i.parse(t),!0,t.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new Wn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(s.errors.forEach(Wn.prettifyError(t,n)),s.warnings.forEach(Wn.prettifyError(t,n))),s}function qw(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let i=$u(t,n);if(!i)return null;if(i.warnings.forEach(o=>Iw.warn(i.options.logLevel,o)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function Ww(t,e,n){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let i=Math.round(n);n=i<1?void 0:i>8?{indent:8}:{indent:i}}if(t===void 0){let{keepUndefined:i}=n??e??{};if(!i)return}return jw.isDocument(t)&&!r?t.toString(n):new Tw.Document(t,r,n).toString(n)}Dn.parse=qw;Dn.parseAllDocuments=Lw;Dn.parseDocument=$u;Dn.stringify=Ww});var pe=k(O=>{"use strict";var Dw=Os(),Mw=An(),Fw=ls(),Ks=In(),Bw=pn(),Qe=P(),Uw=ze(),Kw=q(),Gw=Ye(),Hw=Ve(),zw=ii(),Jw=Ds(),Yw=Fs(),Vw=Us(),ci=Lu(),qu=un();O.Composer=Dw.Composer;O.Document=Mw.Document;O.Schema=Fw.Schema;O.YAMLError=Ks.YAMLError;O.YAMLParseError=Ks.YAMLParseError;O.YAMLWarning=Ks.YAMLWarning;O.Alias=Bw.Alias;O.isAlias=Qe.isAlias;O.isCollection=Qe.isCollection;O.isDocument=Qe.isDocument;O.isMap=Qe.isMap;O.isNode=Qe.isNode;O.isPair=Qe.isPair;O.isScalar=Qe.isScalar;O.isSeq=Qe.isSeq;O.Pair=Uw.Pair;O.Scalar=Kw.Scalar;O.YAMLMap=Gw.YAMLMap;O.YAMLSeq=Hw.YAMLSeq;O.CST=zw;O.Lexer=Jw.Lexer;O.LineCounter=Yw.LineCounter;O.Parser=Vw.Parser;O.parse=ci.parse;O.parseAllDocuments=ci.parseAllDocuments;O.parseDocument=ci.parseDocument;O.stringify=ci.stringify;O.visit=qu.visit;O.visitAsync=qu.visitAsync});import Ze from"path";function ry(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||Ze.posix.isAbsolute(n)||Ze.win32.isAbsolute(n)||/^(?:~|[\\/])/u.test(n))throw new Error(`${e} must be a project-relative path`);if(n===".")return[];let r=n.replaceAll("\\","/").split("/");if(r.some(i=>i===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(i=>i===""||i==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function li(t){let e=ry(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Ku(t,e="docs"){let n=t??e;if(n!=="legacy"&&n!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return n}function We(t,e,n=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim().replaceAll("\\","/");if(r.length===0||Ze.posix.isAbsolute(r)||Ze.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let i=r.split("/");if(i.some(o=>o===".."))throw new Error(`${e} must stay inside its declared path base`);if(i.some(o=>o===""||o==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!n&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return i.join("/")}function qe(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Gu(t,e,n){let r=t??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${n} must be en or zh-CN`);return r}function Hu(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>Hs)throw new Error(`${e} exceeds ${Hs} characters`);let n=0;for(let r=0;r<t.length;r+=1)t[r]==="?"?n+=1:t[r]==="*"&&(n+=1,t[r+1]==="*"&&(r+=1));if(n>zs)throw new Error(`${e} contains more than ${zs} wildcard tokens`);return t}function Bu(t,e,n){if(t===void 0)return[...n];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(r=>Hu(r,e)))].sort((r,i)=>r.localeCompare(i,"en"))}function Mn(t,e,n){let r=t??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${n} must be a positive integer`);return r}function Uu(t,e,n){let r=Mn(t,e,n);if(r>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${n} is too large to convert to bytes safely`);return r}function iy(t){if(t===void 0)return{...Ce,include:[...Ce.include],exclude:[...Ce.exclude]};let e=qe(t,"native.snapshot");return{include:Bu(e.include,"native.snapshot.include",Ce.include),exclude:Bu(e.exclude,"native.snapshot.exclude",Ce.exclude),max_files:Mn(e.max_files,Ce.max_files,"native.snapshot.max_files"),max_total_bytes:Mn(e.max_total_bytes,Ce.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Mn(e.max_duration_ms,Ce.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:Mn(e.max_selection_records,Ce.max_selection_records,"native.snapshot.max_selection_records")}}function oy(t){if(t===void 0)return;let e=qe(t,"native.pending_root_move"),n=e.id,r=e.from_artifact_root,i=e.to_artifact_root,o=e.stage;if(typeof n!="string"||!/^[a-f0-9-]{8,}$/u.test(n))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof i!="string")throw new Error("native.pending_root_move roots must be strings");if(o!=="copying"&&o!=="ready"&&o!=="switched")throw new Error("native.pending_root_move.stage is invalid");let s;if(e.cleanup!==void 0){let a=qe(e.cleanup,"native.pending_root_move.cleanup"),c=a.kind,l=a.state,u=a.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");s={kind:c,state:l,manifestHash:u}}return{id:n,fromArtifactRoot:li(r),toArtifactRoot:li(i),stage:o,...s?{cleanup:s}:{}}}function sy(t){if(t===void 0)return;let e=qe(t,"native.finish");if(e.pull_request===void 0)return{};let n=qe(e.pull_request,"native.finish.pull_request");if(n.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(n.command)||n.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(n.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let r=n.command.map((o,s)=>{if(typeof o!="string"||o.trim().length===0||o.length>4096||/[\0\r\n]/u.test(o))throw new Error(`native.finish.pull_request.command[${s}] must be a non-empty single-line string of at most 4096 characters`);return o});if(Ze.posix.isAbsolute(r[0])||Ze.win32.isAbsolute(r[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let i=n.timeout_ms??Zw;if(!Number.isSafeInteger(i)||i<1||i>Fu)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Fu}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:i}}}function ay(t,e={}){let n=qe(t,"native"),r=n.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let i=n.clarification_mode??"batch";if(i!=="sequential"&&i!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let o=n.archive_confirmation??"automatic";if(o!=="automatic"&&o!=="required")throw new Error("native.archive_confirmation must be automatic or required");let s=n.max_verify_failures??Xw;if(!Number.isSafeInteger(s)||s<1)throw new Error("native.max_verify_failures must be a positive integer");let a=n.document_writes??"allow";if(a!=="allow"&&a!=="revert")throw new Error("native.document_writes must be allow or revert");let c=oy(n.pending_root_move),l=sy(n.finish);return{artifact_root:li(r),language:Gu(n.language,"en","native.language"),clarification_mode:i,archive_confirmation:o,max_verify_failures:s,...a==="revert"?{document_writes:a}:{},snapshot:iy(n.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function cy(t){let e=qe(t,"classic"),n=e.context_compression??"off";if(n!=="off"&&n!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let i=e.auto_transition??!0;if(typeof i!="boolean")throw new Error("classic.auto_transition must be true or false");let o=e.document_evidence??"neutral";if(o!=="neutral"&&o!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:Ku(e.artifact_layout),language:Gu(e.language,"zh-CN","classic.language"),context_compression:n,review_mode:r,auto_transition:i,...o==="strict"?{document_evidence:o}:{}}}function ly(t){let n=qe(t,"hook").allow_paths??[];if(!Array.isArray(n))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(n.map((r,i)=>We(r,`hook.allow_paths[${i}]`)))]}}function uy(t){if(t===void 0)return{...Gs};let e=qe(t,"memory"),n=e.learning??Gs.learning,r=e.retrieval??Gs.retrieval;if(typeof n!="boolean")throw new Error("memory.learning must be true or false");if(typeof r!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:n,retrieval:r}}function Ys(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function fy(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||n.includes("\\")||n.includes("\0")||Ze.posix.isAbsolute(n)||Ze.win32.isAbsolute(n)||n.startsWith("~")||n.split("/").some(i=>i===""||i==="."||i===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!n.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(n.length>Wu)throw new Error(`${e} exceeds ${Wu} characters`);let r=0;for(let i=0;i<n.length;i+=1)n[i]==="?"?r+=1:n[i]==="*"&&(r+=1,n[i+1]==="*"&&(i+=1));if(r>Du)throw new Error(`${e} contains more than ${Du} wildcard tokens`);return n}function dy(t){let e=Ys(t,"knowledge.local"),n=e.include??[];if(!Array.isArray(n))throw new Error("knowledge.local.include must be an array");let r={include:[...new Set(n.map((i,o)=>fy(i,`knowledge.local.include[${o}]`)))],max_file_mb:Uu(e.max_file_mb,Mu.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Uu(e.max_total_mb,Mu.max_total_mb,"knowledge.local.max_total_mb")};if(r.max_file_mb>r.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return r}function my(t){if(typeof t!="string"||t.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(t)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let n=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),r=n==="localhost"||n==="127.0.0.1"||n==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&r))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function py(t){let e=Ys(t,"knowledge.remote"),n=my(e.endpoint),r=e.token_env;if(r!==void 0&&(typeof r!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(r)))throw new Error("knowledge.remote.token_env must be an environment variable name");let i=e.scope;if(i!==void 0&&(typeof i!="string"||i.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let o=e.timeout_ms??5e3;if(typeof o!="number"||!Number.isSafeInteger(o)||o<100||o>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:n,...r===void 0?{}:{token_env:r},...i===void 0?{}:{scope:i},timeout_ms:o}}function hy(t){if(t===void 0)return{...Qw};let e=Ys(t,"knowledge"),n=e.provider??"local";if(n!=="local"&&n!=="remote")throw new Error("knowledge.provider must be local or remote");let r=e.local===void 0?void 0:dy(e.local);if(n==="local")return{provider:n,...r?{local:r}:{}};let i=e.remote===void 0?void 0:py(e.remote);if(i===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:n,...r?{local:r}:{},remote:i}}function gy(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function wy(t,e,n,r,i,o,s,a){let c=t.schema!==void 0;if(!(c||t.default_workflow!==void 0||t.workflows!==void 0||!a.allowPartialProject&&t.native!==void 0)||a.allowPartialProject&&!c)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let u=t.workflows??[t.default_workflow];if(!Array.isArray(u)||u.length===0||u.some(d=>d!=="native"&&d!=="classic"))throw new Error("workflows must contain native and/or classic");let f=[...new Set(u)];if(!f.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(f.includes("native")&&!i)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:f,ambient_resume:s,...e?{hook:e}:{},memory:n,knowledge:r,...i?{native:i}:{},...o?{classic:o}:{}}}function Mt(t,e={}){let n=(0,Js.parseDocument)(t,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${n.errors[0].message}`);let r=n.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let i=r,o=gy(i.ambient_resume),s=i.hook===void 0?void 0:ly(i.hook),a=uy(i.memory),c=hy(i.knowledge),l=i.native===void 0?void 0:ay(i.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=i.classic===void 0?void 0:cy(i.classic),f=wy(i,s,a,c,l,u,o,{allowPartialProject:e.allowPartialProject??!1});return{value:i,config:f,ambient_resume:o,memory:a,knowledge:c,...s?{hook:s}:{},...l?{native:l}:{},...u?{classic:u}:{}}}var Js,Dt,Hs,zs,Wu,Du,Xw,Gs,Mu,Qw,Zw,Fu,ey,ty,ny,Ce,Se=T(()=>{"use strict";Js=ve(pe(),1),Dt=Number.MAX_SAFE_INTEGER,Hs=1024,zs=64,Wu=1024,Du=64,Xw=5,Gs={learning:!0,retrieval:!0},Mu={include:[],max_file_mb:1,max_total_mb:32},Qw={provider:"local"},Zw=12e4,Fu=6e5,ey=[".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/**"],ty=["**/.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"],ny=[...ey,...ty].sort((t,e)=>t.localeCompare(e,"en")),Ce={include:["**/*"],exclude:[...ny],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});function et(t){return t!==0&&t!==0n&&t!=="0"}function zu(t,e){return et(t.dev)&&et(e.dev)&&et(t.ino)&&et(e.ino)}function tt(t,e){let n=et(t.dev)&&et(e.dev);if(n&&t.dev!==e.dev)return!1;let r=et(t.ino)&&et(e.ino);return r&&t.ino!==e.ino?!1:n&&r?!0:t.birthtime===e.birthtime}var ui=T(()=>{"use strict"});import{constants as fi,promises as wt}from"fs";function Vs(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Ju(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function Fn(t){return{dev:t.dev,ino:t.ino,birthtime:Vs(t)}}function di(t,e){let n=Fn(t),r=Fn(e);return zu(n,r)?tt(n,r):tt(n,r)&&Vs(t)===Vs(e)&&Ju(t)===Ju(e)&&t.size===e.size}async function mi(t,e,n={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=n.label??"file",i=n.bigint===!0,o=await wt.lstat(t,{bigint:i});if(!o.isFile()||o.isSymbolicLink())throw new nt("not-regular-file",`${r} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new nt("too-large",`${r} exceeds ${e} bytes`);let s=await wt.realpath(t);await n.verify?.("pre-open",{realPath:s,identity:Fn(o)});let a=process.platform==="win32"?fi.O_RDONLY:fi.O_RDONLY|fi.O_NOFOLLOW|fi.O_NONBLOCK,c;try{c=await wt.open(t,a)}catch(l){throw l.code==="ELOOP"?new nt("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,f]=await Promise.all([c.stat({bigint:i}),wt.lstat(t,{bigint:i}),wt.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||f!==s||!di(o,l)||!di(o,u))throw new nt("changed",`${r} changed while opening`);await n.verify?.("post-open",{realPath:f,identity:Fn(l)}),await n.hooks?.afterOpen?.();let d=[],p=0,g=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let y=e+1-p,{bytesRead:C}=await c.read(g,0,Math.min(g.length,y),null);if(C===0)break;if(p+=C,p>e)throw new nt("too-large",`${r} exceeds ${e} bytes`);d.push(Buffer.from(g.subarray(0,C)))}await n.hooks?.beforeFinalCheck?.();let[m,h,w]=await Promise.all([c.stat({bigint:i}),wt.lstat(t,{bigint:i}),wt.realpath(t)]);if(!h.isFile()||h.isSymbolicLink()||w!==s||!di(o,m)||!di(o,h))throw new nt("changed",`${r} changed while reading`);return await n.verify?.("post-read",{realPath:w,identity:Fn(m)}),{bytes:Buffer.concat(d,p),stat:m,realPath:w}}finally{await c.close()}}var nt,Xs=T(()=>{"use strict";ui();nt=class extends Error{reason;constructor(e,n,r){super(n,r),this.name="RaceSafeReadError",this.reason=e}}});import{promises as rt}from"fs";import he from"path";function Yu(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function pi(t,e){let n=he.relative(t,e);return n===""||!he.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${he.sep}`)}async function Qs(t,e){let n=he.resolve(t),r=await rt.lstat(n);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return rt.realpath(n)}async function Zs(t,e,n,r){let i=t;for(let o=0;o<n.length;o++){i=he.join(i,n[o]);let s;try{s=await rt.lstat(i)}catch(u){if(Yu(u))return{exists:!1,kind:"missing"};throw u}let a=he.relative(t,i).replaceAll("\\","/");if(s.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${a}`);let c=o===n.length-1;if(!c&&!s.isDirectory())throw new Error(`${r.label} ancestor ${a} must be a real directory`);if(c&&(r.expected==="file"&&!s.isFile()||r.expected==="directory"&&!s.isDirectory()||r.expected==="any"&&!s.isFile()&&!s.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await rt.realpath(i);if(!pi(e,l))throw new Error(`${r.label} resolves outside the project root`);if(c)return{exists:!0,kind:s.isFile()?"file":s.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function I(t,e,n){let r=We(e,n.label),i=he.resolve(t),o=await Qs(i,n.label),s=r.split("/"),a=he.resolve(i,...s);if(!pi(i,a))throw new Error(`${n.label} must stay inside the project root`);let c=await Zs(i,o,s,n);return{projectRoot:i,target:a,relative:r,exists:c.exists,kind:c.kind}}async function ea(t,e,n){let r=We(e,n.label),i=he.resolve(t),o=await Qs(i,n.label),s=r.split("/"),a=i;for(let c of s){a=he.join(a,c);let l;try{l=await rt.lstat(a)}catch(d){if(!Yu(d))throw d;try{await rt.mkdir(a)}catch(p){if(p.code!=="EEXIST")throw p}l=await rt.lstat(a)}let u=he.relative(i,a).replaceAll("\\","/");if(l.isSymbolicLink())throw new Error(`${n.label} crosses a symbolic link or junction at ${u}`);if(!l.isDirectory())throw new Error(`${n.label} directory ${u} must be a real directory`);let f=await rt.realpath(a);if(!pi(o,f))throw new Error(`${n.label} resolves outside the project root`)}return await Zs(i,o,s,{label:n.label,expected:"directory"}),a}async function ta(t,e,n){return(await I(t,e,{...n,expected:"file"})).exists}async function j(t,e,n,r){let i=await I(t,e,{label:r.label,expected:"file"});if(!i.exists){let s=new Error(`${r.label} does not exist`);throw s.code="ENOENT",s}let o=await Qs(i.projectRoot,r.label);return mi(i.target,n,{...r,verify:async(s,a)=>{if(!pi(o,a.realPath))throw new Error(`${r.label} resolves outside the project root`);await Zs(i.projectRoot,o,i.relative.split("/"),{label:r.label,expected:"file"})}})}var J=T(()=>{"use strict";Xs();Se()});import{createHash as yy}from"crypto";function vy(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Ft(t,e={}){return(await hi(t,e)).document}async function ky(t){try{return(await j(t,Bn,Dt,{label:Bn})).bytes}catch(e){if(vy(e))return null;throw e}}function by(t){return t?{exists:!0,sha256:yy("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function hi(t,e={}){let n=await ky(t);return{document:n?Mt(n.toString("utf8"),e):null,identity:by(n)}}async function na(t){return(await Ft(t))?.config??null}var Bn,yt=T(()=>{"use strict";Se();J();Bn=".comet/config.yaml"});import{promises as ia}from"node:fs";async function oa(t,e){let n;for(let r=0;r<=ra.length;r+=1)try{return await t()}catch(i){n=i;let o=i.code;if(r===ra.length||!Cy.has(o??""))throw i;await new Promise(s=>setTimeout(s,ra[r]))}throw n}async function Vu(t,e){await oa(()=>ia.rename(t,e),`rename ${e}`)}async function gi(t){await oa(()=>ia.unlink(t),`unlink ${t}`)}async function Xu(t,e){await oa(()=>ia.link(t,e),`link ${e}`)}var Cy,ra,sa=T(()=>{"use strict";Cy=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),ra=[50,100,200]});import{randomUUID as Sy}from"crypto";import{constants as Ey,promises as F}from"fs";import H from"path";async function aa(t,e){try{return await Xu(t,e),{linked:!0}}catch(n){let r=n.code;if(r!=="ENOTSUP"&&r!=="EOPNOTSUPP")throw n}return await F.copyFile(t,e,Ey.COPYFILE_EXCL),{linked:!1}}function vt(t,e){let n=H.relative(t,e);return n===""||!H.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${H.sep}`)}function wi(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function xy(t,e){return tt(t,wi(e))}function yi(t,e){return tt(wi(t),wi(e))}function Qu(t,e){return yi(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function vi(t){let e=await F.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Contained atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await F.realpath(t),...wi(e)}}async function De(t){for(let e of t){let n=await F.lstat(e.path);if(!n.isDirectory()||n.isSymbolicLink()||!xy(e,n)||await F.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function _y(t,e,n){let[r,i]=await Promise.all([F.lstat(t),F.realpath(t),De(n)]);if(!r.isFile()||r.isSymbolicLink()||!yi(r,e)||!vt(n[0].realPath,i))throw new Error("Contained atomic write temporary file changed after close");return r}async function Ry(t,e){let n=H.resolve(t),r=H.resolve(e);if(!vt(n,r))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let i=[await vi(n)],o=H.relative(n,r).split(H.sep).filter(Boolean),s=n;for(let a of o){await De(i),s=H.join(s,a);try{await F.mkdir(s)}catch(l){if(l.code!=="EEXIST")throw l}let c=await vi(s);if(!vt(i[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${s}`);i.push(c)}return await De(i),i}async function Py(t,e){let n=H.resolve(t),r=H.resolve(e);if(!vt(n,r))throw new Error(`Contained file parent is outside its managed root: ${e}`);let i=[await vi(n)],o=H.relative(n,r).split(H.sep).filter(Boolean),s=n;for(let a of o){s=H.join(s,a);try{let c=await vi(s);if(!vt(i[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${s}`);i.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await De(i),i}async function Zu(t){let e;try{e=await F.open(t,"r"),await e.sync()}catch(n){let r=n.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw n}finally{await e?.close()}}async function Oy(t,e,n){let r=H.dirname(t),i=await Ry(n.containedRoot,r),o=H.join(r,`.${H.basename(t)}.${Sy()}.tmp`),s,a,c;try{await n.beforeTemporaryOpen?.(),s=await F.open(o,"wx"),a=await s.stat();let[l,u]=await Promise.all([F.lstat(o),F.realpath(o)]);if(await De(i),!l.isFile()||l.isSymbolicLink()||!yi(a,l)||!vt(i[0].realPath,u))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await s.writeFile(e,"utf8"):await s.writeFile(e),await s.sync(),c=await s.stat(),!yi(a,c))throw new Error("Contained atomic write temporary file changed while writing");if(await s.close(),s=void 0,await n.afterTemporaryClose?.(),!c)throw new Error("Contained atomic write temporary file was not written");c=await _y(o,c,i),await n.beforeCommit?.(),await De(i);let f=await F.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!c||!Qu(f,c))throw new Error("Contained atomic write temporary file changed before commit");n.exclusive?(await aa(o,t),await F.unlink(o)):await Vu(o,t),await Zu(r)}catch(l){await s?.close();try{await De(i),await F.rm(o,{force:!0})}catch{}throw l}}async function X(t,e,n){await Oy(t,e,n)}async function Bt(t,e){let n=H.dirname(t),r=await Py(e.containedRoot,n);if(!r)return!1;let i,o;try{i=await F.lstat(t),o=await F.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!i.isFile()||i.isSymbolicLink()||!vt(r[0].realPath,o))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await De(r);let[s,a]=await Promise.all([F.lstat(t),F.realpath(t)]);if(!s.isFile()||s.isSymbolicLink()||!Qu(i,s)||a!==o)throw new Error("Contained file removal target changed before removal");return await gi(t),await De(r),await Zu(n),!0}var Ee=T(()=>{"use strict";sa();ui()});var FS,ca=T(()=>{"use strict";Ee();yt();J();FS=16*1024});var ki=T(()=>{"use strict";Ee();Se();yt();J();ca()});import{existsSync as Dy}from"node:fs";import Gn from"node:path";function uf(t,e){let n=e.toLowerCase();return Object.entries(t).find(([r,i])=>r.toLowerCase()===n&&i!==void 0)?.[1]}function Fy(t){let e=(uf(t,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").map(n=>n.trim().toLowerCase()).filter(Boolean);return[...new Set([...e,".ps1"])]}function By(t,e,n){let i=Gn.win32.isAbsolute(t)||/[\\/]/u.test(t)?[""]:(uf(e,"PATH")??"").split(Gn.delimiter).map(a=>a.trim().replace(/^"(.*)"$/u,"$1")).filter(Boolean),s=Gn.win32.extname(t)?[t]:Fy(e).map(a=>`${t}${a}`);return i.flatMap(a=>s.map(c=>a?Gn.join(a,c):Gn.resolve(n,c)))}function Kt(t,e,n){return By(t,e,n).find(r=>Dy(r))??t}function ua(t){if(t.some(e=>My.test(e)))throw new Error("Windows batch check arguments must not contain shell syntax")}var My,lE,bi=T(()=>{"use strict";My=/[&|<>()^%"!\r\n]/u,lE=["$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{AsyncLocalStorage as mv}from"node:async_hooks";import{performance as Ai}from"node:perf_hooks";function Pf(t=0){pv+=1,hv+=t;let e=gv.getStore();e&&(e.gitCommands+=1,e.gitDurationMs+=t)}function bt(t){let e=Ai.now();try{return t()}finally{Pf(Ai.now()-e)}}async function Of(t){let e=Ai.now();try{return await t()}finally{Pf(Ai.now()-e)}}var pv,hv,gv,Vn=T(()=>{"use strict";pv=0,hv=0,gv=new mv});import{execFile as wv,execFileSync as yv}from"node:child_process";import Xn from"node:path";async function ot(t,e,n={}){let r=n.timeoutMs??Af,i=n.maxBufferBytes??Nf;if(!Number.isSafeInteger(r)||r<1||!Number.isSafeInteger(i)||i<1)throw new Error("External command limits must be positive integers");let o=Xn.resolve(n.cwd??process.cwd()),s=n.env??process.env,a=process.platform==="win32"?Kt(t,s,o):t,c=process.platform==="win32"&&/\.(?:bat|cmd)$/iu.test(a);c&&ua(e);let l=()=>new Promise((u,f)=>{let d=!1,p=wv(a,[...e],{cwd:o,env:s,encoding:"utf8",maxBuffer:i,windowsHide:!0,shell:c},(w,y,C)=>{d||(d=!0,clearTimeout(h),n.signal?.removeEventListener("abort",m),w?f(new Me(t,e,C.trim(),{cause:w,timedOut:Tf(w)})):u(y))}),g=w=>{d||(d=!0,clearTimeout(h),n.signal?.removeEventListener("abort",m),p.kill("SIGKILL"),p.stdin?.destroy(),p.stdout?.destroy(),p.stderr?.destroy(),p.unref(),f(new Me(t,e,"",{timedOut:w})))},m=()=>g(!1),h=setTimeout(()=>g(!0),r);n.signal?.addEventListener("abort",m,{once:!0}),n.signal?.aborted&&m(),p.stdin?.end(n.input)});return/^(?:git|git\.exe)$/iu.test(Xn.win32.basename(t))?Of(l):l()}function Tf(t){return t instanceof Error&&(t.code==="ETIMEDOUT"||t.killed===!0&&t.signal==="SIGTERM")}function If(t,e,n={}){let r=n.timeoutMs??Af,i=n.maxBufferBytes??Nf;if(!Number.isSafeInteger(r)||r<1)throw new Error("External command timeout must be a positive integer");if(!Number.isSafeInteger(i)||i<1)throw new Error("External command max buffer must be a positive integer");let o=Xn.resolve(n.cwd??process.cwd()),s=n.env??process.env,a=process.platform==="win32"?Kt(t,s,o):t,c=Xn.win32.extname(a).toLowerCase(),l=c===".bat"||c===".cmd";process.platform==="win32"&&l&&ua(e);try{let u=()=>yv(a,[...e],{cwd:o,env:s,...n.input!==void 0?{input:n.input}:{},encoding:"utf8",stdio:[n.input===void 0?"ignore":"pipe","pipe","pipe"],timeout:r,maxBuffer:i,windowsHide:!0,shell:process.platform==="win32"&&l});return/^(?:git|git\.exe)$/iu.test(Xn.win32.basename(t))?bt(u):u()}catch(u){let f=typeof u.stderr=="string"?u.stderr.trim():Buffer.isBuffer(u.stderr)?u.stderr.toString("utf8").trim():"";throw new Me(t,e,f,{cause:u,timedOut:Tf(u)})}}var Af,Nf,Me,Qn=T(()=>{"use strict";Vn();bi();Af=6e4,Nf=8*1024*1024;Me=class extends Error{constructor(n,r,i,o){super(`${n} ${r.join(" ")} failed${i?`: ${i}`:""}`,o);this.command=n;this.args=r;this.stderr=i;this.name="ExternalCommandError",this.timedOut=o?.timedOut===!0}command;args;stderr;timedOut}});import{createHash as va,randomUUID as vv}from"node:crypto";import{promises as ae}from"node:fs";import kv from"node:os";import ie from"node:path";async function ya(t,e){let n=await ae.lstat(t,{bigint:!0});if(!n.isFile()||n.isSymbolicLink()||n.size>BigInt(e))throw new Error("Invalid process probe cache");let r=await ae.readFile(t),i=await ae.lstat(t,{bigint:!0});if(n.ino!==i.ino||n.ctimeNs!==i.ctimeNs||n.size!==i.size)throw new Error("Process probe cache changed");return r}async function Lf(t){try{let e=JSON.parse((await ya(ie.join(t,"probe.json"),4096)).toString("utf8"));if(!/^probe-[a-f0-9-]+\.exe$/u.test(e.file??""))return null;let n=ie.join(t,e.file),r=await ya(n,65536);return va("sha256").update(r).digest("hex")===e.hash?n:null}catch{return null}}async function Sv(t,e){let n,r=vv(),i=ie.join(t,`probe-${r}.cs`),o=ie.join(t,`probe-${r}.exe`),s=ie.join(t,`probe-${r}.json`);try{if(await ae.mkdir(t,{recursive:!0,mode:448}),(await ae.lstat(t)).isSymbolicLink())return null;n=await ae.open(ie.join(t,"prepare.lock"),"wx",384);let a=await Lf(t);if(a)return a;await ae.writeFile(i,$f,{flag:"wx",mode:384});let c;for(let u of["Framework64","Framework"]){let f=ie.join(e,"Microsoft.NET",u,"v4.0.30319","csc.exe");try{await ae.access(f),c=f;break}catch{}}if(!c)return null;await ot(c,["/nologo","/target:exe","/platform:anycpu",`/out:${o}`,i],{timeoutMs:1500,maxBufferBytes:4096});let l=va("sha256").update(await ya(o,65536)).digest("hex");return await ae.writeFile(s,JSON.stringify({file:ie.basename(o),hash:l}),{flag:"wx",mode:384}),await ae.rename(s,ie.join(t,"probe.json")),o}catch{return null}finally{await ae.unlink(i).catch(()=>{}),await ae.unlink(s).catch(()=>{}),n&&(await n.close().catch(()=>{}),await ae.unlink(ie.join(t,"prepare.lock")).catch(()=>{}))}}async function jf(t,e,n){try{let r=await ot(ie.join(e,"System32","wbem","WMIC.exe"),["process","where",`processid=${t}`,"get","creationdate","/value"],{timeoutMs:300,maxBufferBytes:4096,signal:n}),i=/^CreationDate=(\S+)/mu.exec(r);if(i)return`win32-wmic:${i[1]}`}catch{}if(n.aborted)return null;try{let i=(await ot(ie.join(e,"System32","WindowsPowerShell","v1.0","powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${t} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`],{timeoutMs:1e3,maxBufferBytes:4096,signal:n})).trim();return/^\d+$/u.test(i)?`win32-ps:${i}`:null}catch{return null}}function Ev(t,e){let n=Ni.get(t);if(n&&performance.now()<n.retryAfter)return n.promise;let r={promise:Sv(t,e),retryAfter:1/0};return Ni.set(t,r),r.promise.then(i=>{Ni.get(t)===r&&(i?Ni.delete(t):r.retryAfter=performance.now()+Cv)}),r.promise}async function qf(t,e={}){if(!Number.isSafeInteger(t)||t<=0)return null;let n=e.systemRoot??process.env.SystemRoot??"C:\\Windows",r=ie.join(e.cacheRoot??ie.join(kv.tmpdir(),"comet-process-identity"),bv),i=async l=>{if(!l)return null;try{let f=(await ot(l,[String(t)],{timeoutMs:1e3,maxBufferBytes:4096})).trim();return/^\d+$/u.test(f)?`win32-ps:${f}`:null}catch{return null}},o=await Lf(r);if(o){let l=await i(o);return l||jf(t,n,new AbortController().signal)}let s=Ev(r,n),a=new AbortController,c=l=>{if(!l)throw new Error("Probe unavailable");return l};try{return await Promise.any([s.then(i).then(c),jf(t,n,a.signal).then(c)])}catch{return null}finally{a.abort()}}var $f,bv,Cv,Ni,Wf=T(()=>{"use strict";Qn();$f=`using System;
|
|
143
|
+
using System.Runtime.InteropServices;
|
|
144
|
+
class CometProcessIdentity {
|
|
145
|
+
[DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
|
|
146
|
+
[DllImport("kernel32.dll")] static extern bool GetProcessTimes(IntPtr process, out long creation, out long exit, out long kernel, out long user);
|
|
147
|
+
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
148
|
+
static int Main(string[] args) {
|
|
149
|
+
int pid; if(args.Length != 1 || !int.TryParse(args[0], out pid) || pid <= 0) return 1;
|
|
150
|
+
IntPtr handle=OpenProcess(0x1000, false, pid); if(handle == IntPtr.Zero) return 1;
|
|
151
|
+
try { long creation, exit, kernel, user; if(!GetProcessTimes(handle,out creation,out exit,out kernel,out user)) return 1;
|
|
152
|
+
Console.WriteLine(DateTime.FromFileTimeUtc(creation).Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); return 0;
|
|
153
|
+
} finally { CloseHandle(handle); }
|
|
154
|
+
}
|
|
155
|
+
}`,bv=va("sha256").update($f).digest("hex"),Cv=1e4,Ni=new Map});import{promises as Df}from"node:fs";function _v(t){let e=ba.get(t);if(e){if(Date.now()-e.at>xv){ba.delete(t);return}return e.value}}async function Ca(t){if(t===process.pid&&ka!==null)return ka;let e=_v(t);if(e!==void 0)return e;let n=Ti.get(t);n||(n=Rv(t),Ti.set(t,n));let r=await n;return Ti.get(t)===n&&Ti.delete(t),t===process.pid&&r!==null&&(ka=r),r===null&&ba.set(t,{value:null,at:Date.now()}),r}async function Rv(t){if(!Number.isSafeInteger(t)||t<=0)return null;try{if(process.platform==="linux"){let[e,n]=await Promise.all([Df.readFile(`/proc/${t}/stat`,"utf8"),Df.readFile("/proc/sys/kernel/random/boot_id","utf8")]),r=e.slice(e.lastIndexOf(")")+2).trim().split(/\s+/u)[19];return/^\d+$/u.test(r??"")?`linux:${n.trim()}:${r}`:null}if(process.platform==="win32")return await qf(t);if(process.platform==="darwin"){let e=(await ot("/bin/ps",["-p",String(t),"-o","lstart="],{timeoutMs:5e3,maxBufferBytes:4096,env:{...process.env,LC_ALL:"C",TZ:"UTC0"}})).trim();return e?`darwin:${e}`:null}}catch{}return null}function Ii(t){let e=t.indexOf(":");return e===-1?"":t.slice(0,e)}async function Ff(t,e){if(!Number.isSafeInteger(t)||t<=0)return"alive";try{process.kill(t,0)}catch(r){if(r.code==="ESRCH")return"dead"}if(!e)return"unknown";let n=await Ca(t);return n===e?"alive":n===null||Ii(n)!==Ii(e)&&Mf.has(Ii(n))&&Mf.has(Ii(e))?"unknown":"dead"}var ka,xv,ba,Ti,Mf,Bf=T(()=>{"use strict";Qn();Wf();ka=null,xv=1e4,ba=new Map,Ti=new Map;Mf=new Set(["win32-wmic","win32-ps"])});import{randomUUID as Pv}from"node:crypto";import{promises as Ct}from"node:fs";import Kf from"node:os";import Uf from"node:path";async function Gf(t,e,n={}){let r=Uf.resolve(t);await Ct.mkdir(Uf.dirname(r),{recursive:!0});let i=Date.now(),o=n.timeoutMs??Ov,s=n.retryMs??Av,a=n.malformedLockStaleMs??Nv,c=await Ca(process.pid),l={pid:process.pid,nonce:Pv(),createdAt:Date.now(),hostname:Kf.hostname(),...c===null?{}:{processIdentity:c}},u=!1;for(;!u;){let f;try{f=await Ct.open(r,"wx"),await f.writeFile(JSON.stringify(l),"utf8"),u=!0}catch(d){if(d.code!=="EEXIST")throw d;if(await Iv(r,a))continue;if(Date.now()-i>=o)throw new Error(`Timed out waiting for file lock: ${r}`,{cause:d});await new Promise(p=>setTimeout(p,s))}finally{await f?.close()}}try{return await e()}finally{await jv(r,l.nonce)}}async function Iv(t,e){let n,r;try{[n,r]=await Promise.all([Ct.readFile(t,"utf8"),Ct.stat(t)])}catch(o){return o.code==="ENOENT"}let i=Hf(n);if(i!==null&&(i.hostname!==void 0&&i.hostname!==Kf.hostname()||await Ff(i.pid,i.processIdentity)!=="dead"))return!1;if(i===null){let o=n.trim().length===0?Tv:e;if(Date.now()-Number(r.mtimeMs)<o)return!1}try{return await Ct.readFile(t,"utf8")!==n?!1:(await Ct.rm(t),!0)}catch(o){return o.code==="ENOENT"}}async function jv(t,e){try{if(Hf(await Ct.readFile(t,"utf8"))?.nonce!==e)return;await gi(t)}catch(n){let r=n.code;if(r==="ENOENT")return;process.stderr.write(`[comet] warning: could not remove lock file ${t} (${r??n}); it will be recovered automatically
|
|
156
|
+
`)}}function Hf(t){try{let e=JSON.parse(t);return Number.isSafeInteger(e.pid)&&Number(e.pid)>0&&typeof e.nonce=="string"&&e.nonce.length>0&&typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)&&(e.hostname===void 0||typeof e.hostname=="string"&&e.hostname.length>0)&&(e.processIdentity===void 0||typeof e.processIdentity=="string"&&e.processIdentity.length>0)?{pid:Number(e.pid),nonce:e.nonce,createdAt:e.createdAt,...e.hostname===void 0?{}:{hostname:e.hostname},...e.processIdentity===void 0?{}:{processIdentity:e.processIdentity}}:null}catch{return null}}var Ov,Av,Nv,Tv,zf=T(()=>{"use strict";sa();Bf();Ov=3e4,Av=20,Nv=5*6e4,Tv=1e4});var ji=T(()=>{"use strict"});var Jf=T(()=>{"use strict"});var Sa=T(()=>{"use strict";ji()});var Yf=T(()=>{"use strict";ji();Sa()});var Fv,Vf=T(()=>{"use strict";Fv=ve(pe(),1);Ee();Se();J()});var r_,Xf=T(()=>{"use strict";Ee();J();r_=4*1024*1024});import{AsyncLocalStorage as Bv}from"node:async_hooks";function Qf(){let t=Uv.getStore();return t?.active?t:null}function Zf(t,e){let n=t;for(let r of e)n+="\0"+(typeof r=="string"?r:JSON.stringify(r));return n}function $i(t,e){return(...n)=>{let r=Qf();if(r===null)return e(...n);let i=Zf(`async:${t}`,n),o=r.entries.get(i);if(o)return o.value;let s=e(...n).catch(a=>{throw r.entries.get(i)?.value===s&&r.entries.delete(i),a});return r.entries.set(i,{value:s}),s}}function Ea(t,e){return(...n)=>{let r=Qf();if(r===null)return e(...n);let i=Zf(`sync:${t}`,n),o=r.entries.get(i);if(o)return o.value;let s=e(...n);return r.entries.set(i,{value:s}),s}}var Uv,Li=T(()=>{"use strict";Uv=new Bv});var l_,ed=T(()=>{"use strict";Li();yt();l_=$i("hookWritePolicy",async t=>(await na(t))?.hook??{allow_paths:[]})});import{promises as Kv}from"node:fs";import Gv from"node:path";function Wi(t){return Gv.join(t,".comet","current-change.json")}function Hv(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function td(t){return t===null||typeof t=="string"}function zv(t){let e;try{e=JSON.parse(t)}catch(n){throw new Error(`current change selection contains invalid JSON: ${n instanceof Error?n.message:String(n)}`,{cause:n})}if(!Hv(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!td(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:qi,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==qi)throw new Error(`current change selection schema must be ${qi}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!td(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function Di(t){let e;try{let r=Wi(t),{bytes:i}=await mi(r,nd,{label:"current change selection"});e=i.toString("utf8")}catch(r){if(r.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${r instanceof Error?r.message:String(r)}`,{cause:r})}return{status:"selected",...zv(e)}}async function xa(t){await Kv.rm(Wi(t),{force:!0})}async function _a(t,e,n){let r=await Di(t);return r.status!=="selected"||r.selection.workflow!==e||r.selection.change!==n?!1:(await xa(t),!0)}var qi,nd,Ra=T(()=>{"use strict";Xs();qi="comet.selection.v2",nd=16*1024});var rd=T(()=>{"use strict";ji();Ee();Jf();Yf();Se();Vf();J();yt();ki();Xf();ed();Ra();ca();Sa()});import{TextDecoder as Yv}from"util";function id(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Vv(t,e){try{return new Yv("utf-8",{fatal:!0}).decode(t.bytes)}catch(n){throw new Error(`${e} is not valid UTF-8`,{cause:n})}}async function Pa(t,e,n,r,i={}){try{let o=await j(t,e,n,{label:r,hooks:i.hooks});return{result:o,text:Vv(o,r)}}catch(o){let s=o.code;if(s==="ENOENT"||s==="ENOTDIR")return null;throw o}}async function st(t,e,n,r,i={}){return(await Pa(t,e,n,r,i))?.text??null}async function at(t,e,n,r,i,o={}){if(Buffer.byteLength(n,"utf8")>r)throw new Error(`${i} exceeds ${r} bytes`);let s=await Pa(t,e,r,i),a=await I(t,e,{label:i,expected:"file"});await X(a.target,n,{containedRoot:a.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await Pa(t,e,r,i);if(!(!s&&!c)){if(!s||!c)throw new Error(`${i} changed before commit`);if(s.result.realPath!==c.result.realPath||!tt(id(s.result.stat),id(c.result.stat))||s.text!==c.text)throw new Error(`${i} changed before commit`)}}})}async function Mi(t,e,n,r,i,o={}){let s=await st(t,e,r,i);await at(t,e,`${s??""}${n}`,r,i,o)}async function Fi(t,e,n,r={}){let i=await I(t,e,{label:n,expected:"file"});return i.exists?Bt(i.target,{containedRoot:i.projectRoot,beforeRemove:r.beforeRemove}):!1}var Bi=T(()=>{"use strict";rd();ui()});var ad={};km(ad,{RUN_STATE_FILE:()=>Zt,applyRunStateToDocument:()=>Oa,readRunState:()=>tr,removeRunState:()=>nr,runStateFromDocument:()=>Qt,writeRunState:()=>en});import Xv from"path";function er(t,e){let n=t[e];if(typeof n!="string"||n.length===0)throw new Error(`Invalid Run state: ${e} must be a non-empty string`);return n}function Zn(t,e){let n=er(t,e);if(Xv.isAbsolute(n)||/^(?:[A-Za-z]:|[\\/]|~)/u.test(n)||n.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Run state: ${e} must stay inside the change directory`);return n}function Qv(t){let e=t.run_retries??"{}",n;try{n=typeof e=="string"?JSON.parse(e):e}catch(r){throw new Error("Invalid Run state: run_retries must be a JSON object",{cause:r})}if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Invalid Run state: run_retries must be a JSON object");for(let r of Object.values(n))if(!Number.isInteger(r)||Number(r)<0)throw new Error("Invalid Run state: retry counts must be non-negative integers");return n}function Qt(t){if(!t.run_id)return null;let e=er(t,"run_id"),n=er(t,"skill"),r=er(t,"skill_version"),i=er(t,"skill_hash"),o=Zn(t,"pending_ref"),s=Zn(t,"trajectory_ref"),a=Zn(t,"context_ref"),c=Zn(t,"artifacts_ref"),l=Zn(t,"checkpoint_ref"),u=Number(t.iteration);if(!Number.isInteger(u)||u<0)throw new Error("Invalid Run state: iteration must be a non-negative integer");if(t.orchestration!=="deterministic"&&t.orchestration!=="adaptive")throw new Error("Invalid Run state: orchestration must be deterministic or adaptive");if(t.run_status!=="running"&&t.run_status!=="waiting"&&t.run_status!=="completed"&&t.run_status!=="failed")throw new Error("Invalid Run state: run_status is invalid");return{runId:e,skill:n,skillVersion:r,skillHash:i,orchestration:t.orchestration,currentStep:od(t,"current_step"),iteration:u,pending:od(t,"pending"),pendingRef:o,trajectoryRef:s,contextRef:a,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:Qv(t)}}function Oa(t,e){e?t.run_id=e.runId:delete t.run_id}function Zv(t){return{runId:t.runId,skill:t.skill,skillVersion:t.skillVersion,skillHash:t.skillHash,orchestration:t.orchestration,currentStep:t.currentStep,iteration:t.iteration,pending:t.pending,pendingRef:t.pendingRef,trajectoryRef:t.trajectoryRef,contextRef:t.contextRef,artifactsRef:t.artifactsRef,checkpointRef:t.checkpointRef,status:t.status,retries:t.retries}}function ek(t){let e={run_id:t.runId,skill:t.skill,skill_version:t.skillVersion,skill_hash:t.skillHash,orchestration:t.orchestration,current_step:t.currentStep,iteration:t.iteration,pending:t.pending,pending_ref:t.pendingRef,trajectory_ref:t.trajectoryRef,context_ref:t.contextRef,artifacts_ref:t.artifactsRef,checkpoint_ref:t.checkpointRef,run_status:t.status,run_retries:JSON.stringify(t.retries)};return Qt(e)}async function tr(t,e={}){let n=await st(t,Zt,sd,"Run state",e);if(n===null)return null;let r=JSON.parse(n);return ek(r)}async function en(t,e,n={}){await at(t,Zt,JSON.stringify(Zv(e),null,2),sd,"Run state",n)}async function nr(t,e={}){await Fi(t,Zt,"Run state",e)}var od,Zt,sd,Ui=T(()=>{"use strict";Bi();od=(t,e)=>{let n=t[e];return n==null?null:String(n)};Zt=".comet/run-state.json",sd=Number.MAX_SAFE_INTEGER});var FP,rm=T(()=>{"use strict";Vn();FP=8*1024*1024});import{createHash as Nb}from"crypto";import Z from"node:path";import{createHash as Xy}from"node:crypto";import{AsyncLocalStorage as qy}from"async_hooks";import{promises as of}from"fs";import $ from"path";import{promises as Cm}from"fs";async function ln(t){try{return await Cm.access(t),!0}catch(e){if(Sm(e))return!1;throw e}}function Sm(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}Se();yt();ki();J();var Ut=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},nf=".comet/config.yaml";function sf(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function af(t){await I(t,nf,{label:nf,expected:"file"})}function Un(t,e){let n=$.resolve(t),r=e==="docs"?$.join(n,"docs"):n,i=$.join(r,"openspec"),o=$.join(n,"docs","superpowers");return{projectRoot:n,artifactLayout:e,openSpecBase:r,openSpecRoot:i,changesDir:$.join(i,"changes"),archiveDir:$.join(i,"changes","archive"),specsDir:$.join(i,"specs"),superpowersRoot:o,superpowersSpecsDir:$.join(o,"specs"),superpowersPlansDir:$.join(o,"plans"),superpowersReportsDir:$.join(o,"reports")}}async function cf(t){await af(t);let e=await Ft(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new Ut;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new Ut("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function Iy(t,e){return Un(t,e??await cf(t))}async function jy(t){try{return await of.lstat(t),!0}catch(e){if(sf(e))return!1;throw e}}async function $y(t,e){let n=await Iy(t,e),r=n.artifactLayout==="legacy"?"docs":"legacy",i=Un(t,r).openSpecRoot,[o,s]=await Promise.all([I(n.projectRoot,L(n.projectRoot,n.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),jy(i)]),a=o.exists;return{paths:n,configuredRootExists:a,alternateRoot:i,alternateRootExists:s,dualRoots:a&&s}}async function Ly(t){let e=[t.openSpecRoot,t.changesDir,t.archiveDir,t.specsDir,t.superpowersRoot,t.superpowersSpecsDir,t.superpowersPlansDir,t.superpowersReportsDir];for(let n of e){let r=L(t.projectRoot,n);await I(t.projectRoot,r,{label:`Classic managed physical path ${r}`,expected:"directory"})}}async function Q(t,e){let n=await $y(t,e);if(await Ly(n.paths),!n.configuredRootExists){let r=L(n.paths.projectRoot,n.paths.openSpecRoot),i=L(n.paths.projectRoot,n.alternateRoot);throw new Ut(`Configured Classic OpenSpec root is missing: ${r} (alternate ${i} is ${n.alternateRootExists?"present":"missing"})`)}return n.paths}async function Kn(t,e){let n=$.join($.resolve(t),".comet","classic-root-move.json");if(await ln(n))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let r=await Q(t,e);if(!await ln(r.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${L(r.projectRoot,r.openSpecRoot)}`);return r}async function xe(t){let e=$.resolve(t),n=null;try{(await of.lstat(e)).isDirectory()||(e=$.dirname(e))}catch(r){if(!sf(r))throw r}for(;;){$.basename(e)==="openspec"&&(n=$.dirname(e));let r=$.join(e,".comet","config.yaml"),i=!1;if(await ln(r))try{await af(e);let s=(await Ft(e))?.value;i=!!s&&typeof s=="object"&&!Array.isArray(s)&&(s.schema==="comet.project.v1"||s.default_workflow!==void 0||s.native!==void 0)}catch{}if(i||await ln($.join(e,".git")))return e;let o=$.dirname(e);if(o===e)return n??$.resolve(t);e=o}}function L(t,e){return $.relative($.resolve(t),e).replaceAll("\\","/")}var Wy=new qy;async function lf(t,e){let n=Wy.getStore();if(!n)return e();let r=n.observations.get(t);if(r)return r;let i=e();n.observations.set(t,i);try{return await i}catch(o){throw n.observations.delete(t),o}}var yf=ve(pe(),1);import{spawnSync as zy}from"child_process";bi();import{existsSync as ff,readFileSync as Uy}from"node:fs";import Gt from"node:path";function Ky(t){let e=t.replaceAll(`\r
|
|
144
157
|
`,`
|
|
145
|
-
`).trim(),n=/^@ECHO off\nGOTO start\n:find_dp0\nSET dp0=%~dp0\nEXIT \/b\n:start\nSETLOCAL\nCALL :find_dp0\n\nIF EXIST "%dp0%\\node\.exe" \(\n {2}SET "_prog=%dp0%\\node\.exe"\n\) ELSE \(\n {2}SET "_prog=node"\n {2}SET PATHEXT=%PATHEXT:;\.JS;=;%\n\)\n\nendLocal & goto #_undefined_# 2>NUL \|\| title %COMSPEC% & "%_prog%" {2}"%dp0%\\([^"%\r\n]+\.(?:mjs|cjs|js))" %\*$/u.exec(e);if(n)return{target:n[1]};let r=/^@SETLOCAL\n(?:@IF NOT DEFINED NODE_PATH \(\n {2}@SET "NODE_PATH=([^"\r\n]+)"\n\) ELSE \(\n {2}@SET "NODE_PATH=\1;%NODE_PATH%"\n\)\n)?@IF EXIST "%~dp0\\node\.exe" \(\n {2}"%~dp0\\node\.exe" {2}"%~dp0\\([^"%\r\n]+\.(?:mjs|cjs|js))" %\*\n\) ELSE \(\n {2}@SET PATHEXT=%PATHEXT:;\.JS;=;%\n {2}node {2}"%~dp0\\\2" %\*\n\)$/u.exec(e);return r?{target:r[2],...r[1]?{nodePath:r[1]}:{}}:null}function
|
|
146
|
-
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function
|
|
147
|
-
`));n.source!=="legacy"&&await
|
|
148
|
-
`,{label:"Classic archive requirements"})}async function af(t,e){let n=Z.join(e,of),r=["proposal.md","design.md","tasks.md"];if(await Y(t,n,{label:"Classic archive requirements",expected:"file"})){let o=JSON.parse(await V(t,n,{label:"Classic archive requirements"}));if(o?.schema!=="comet.classic.archive-requirements.v1")throw new Error("Unsupported Classic archive requirements");r=o.files}if(!Array.isArray(r)||!r.includes("proposal.md")||!r.includes("tasks.md")||r.some(o=>typeof o!="string"||!(["proposal.md","design.md","tasks.md"].includes(o)||/^specs\/(?:[^/\\:]+\/)+spec\.md$/u.test(o))||o.split("/").some(s=>s==="."||s==="..")))throw new Error("Invalid Classic archive required files");let i=[];for(let o of r)await di(t,Z.join(e,o),"Classic archived required file")||i.push(`Required archived artifact is missing or empty: ${o}`);return i}function Ry(t){if(!t||typeof t!="object")throw new Error("Unsupported OpenSpec status: expected an object");let e=t;if(!Array.isArray(e.artifacts)||!Array.isArray(e.applyRequires))throw new Error("OpenSpec must expose artifacts and applyRequires; upgrade to a supported version");let n=new Map;for(let a of e.artifacts){if(!a||typeof a!="object"||typeof a.id!="string"||typeof a.outputPath!="string"||!["done","skipped","ready","blocked"].includes(a.status)||!Array.isArray(a.requires)||a.requires.some(c=>typeof c!="string"))throw new Error("OpenSpec must expose dependency edges for every artifact; upgrade to a supported version");if(n.has(a.id))throw new Error(`Duplicate OpenSpec artifact: ${a.id}`);n.set(a.id,a)}let r=[],i=new Set,o=new Set,s=a=>{if(typeof a!="string"||!n.has(a))throw new Error(`Missing OpenSpec dependency: ${String(a)}`);if(o.has(a))throw new Error(`Cyclic OpenSpec dependency: ${a}`);if(i.has(a))return;o.add(a);let c=n.get(a);for(let l of c.requires)s(l);o.delete(a),i.add(a),r.push(c)};for(let a of[...e.applyRequires,"proposal","tasks"])s(a);return r}async function Py(t,e){let n=Z.join(e,".openspec.yaml");if(!await Y(t,n,{label:"OpenSpec change metadata",expected:"file"}))return{source:"legacy",required:["proposal","design","tasks"],skipped:[],designRequired:!0,files:["proposal.md","design.md","tasks.md"].map(g=>Z.join(e,g)),problems:[]};let r=(0,rf.parseDocument)(await V(t,n,{label:"OpenSpec change metadata"}));if(r.errors.length)throw new Error(`Invalid OpenSpec metadata: ${r.errors[0].message}`);let i=await Q(t),o=await Mt(t,Z.join(e,"specs")),s=_y("sha256");for(let g of[Z.join(i.openSpecRoot,"config.yaml"),n,...["proposal.md","design.md","tasks.md"].map(m=>Z.join(e,m)),...o])s.update(g),await Y(t,g,{label:"OpenSpec observation input",expected:"file"})?s.update(await V(t,g,{label:"OpenSpec observation input"})):s.update("<missing>");let a=()=>pi(["status","--change",Z.basename(e),"--json"],t),l=await Y(t,Z.join(i.openSpecRoot,"schemas"),{label:"OpenSpec local schemas",expected:"directory"})?await a():await Ju(`openspec-status:${e}:${s.digest("hex")}`,a);if(l.exitCode!==0)throw new Error(`Cannot inspect OpenSpec artifact requirements: ${l.stderr??l.exitCode}`);let u;try{u=JSON.parse(l.stdout??"")}catch{throw new Error("Unsupported OpenSpec status: expected JSON")}if(!u||typeof u.changeRoot!="string"||Z.resolve(u.changeRoot)!==Z.resolve(e))throw new Error("OpenSpec status resolves outside the selected Classic change");let f=Ry(u),d=o,p={source:"openspec",required:f.map(g=>g.id),skipped:[],designRequired:f.some(g=>g.id==="design"),files:[],problems:[]};for(let g of f){if(!["proposal","specs","design","tasks"].includes(g.id))throw new Error(`Unsupported Classic artifact: ${g.id}; use a schema with supported artifact roles`);if(g.id!=="specs"&&g.outputPath!==`${g.id}.md`)throw new Error(`Unsupported Classic artifact output: ${g.outputPath}`);if(g.status==="skipped"){if(g.id!=="specs"||r.get("skip_specs")!==!0||d.length)throw new Error("OpenSpec skipped specs require explicit skip_specs: true and no conflicting spec files");p.skipped.push(g.id);continue}let m=g.outputPath.replaceAll("\\","/");if(Z.posix.isAbsolute(m)||/^[A-Za-z]:/u.test(m)||m.split("/").includes(".."))throw new Error(`Unsafe OpenSpec artifact path: ${m}`);let h;if(g.id==="specs"&&["specs/**/*.md","specs/**/spec.md","specs/*/spec.md"].includes(m))h=d;else{if(["?","*","[","]","{","}"].some(w=>m.includes(w)))throw new Error(`Unsupported OpenSpec artifact pattern: ${m}`);h=[Z.join(e,m)]}(g.status!=="done"||!h.length)&&p.problems.push(`Required OpenSpec artifact is not complete: ${g.id}`);for(let w of h)await di(t,w,`OpenSpec required artifact ${g.id}`)||p.problems.push(`Required OpenSpec file is missing or empty: ${w}`),p.files.push(w)}return p}import Oe from"path";function na(t){return t==="zh-CN"?"zh-CN":"en"}function cf(t,e,n){return t==="zh-CN"?n:e}function lf(t){let{name:e,stepsOk:n,stepsTotal:r,dryRun:i,locale:o}=t,s=n===r;return i?{summary:cf(o,`Archive dry run for ${e}: ${s?`all ${r} steps would succeed`:`${r-n} of ${r} steps would fail`}.`,`需求 ${e} 归档预演:${s?`全部 ${r} 步均可成功`:`${r-n}/${r} 步会失败`}。`)}:{summary:cf(o,s?`Change ${e} was archived successfully (${n}/${r} steps).`:`Archive for ${e} stopped: ${r-n} of ${r} steps failed.`,s?`需求 ${e} 归档成功(${n}/${r} 步)。`:`需求 ${e} 归档中止:${r-n}/${r} 步失败。`)}}import{promises as kd}from"fs";import se from"path";import{fileURLToPath as bd}from"url";import et from"path";function uf(t){if(t.workflow!=="full")return{missingFields:[],invalidFields:[]};let e=[],n=[];return t.buildMode||e.push("build_mode"),t.tddMode||e.push("tdd_mode"),t.reviewMode||e.push("review_mode"),t.buildMode==="subagent-driven-development"&&t.subagentDispatch!=="confirmed"&&e.push("subagent_dispatch"),t.buildMode==="autonomous"&&t.reviewMode==="off"&&n.push({field:"review_mode",reason:"autonomous full build requires review_mode=standard or thorough"}),t.buildMode==="direct"&&t.directOverride!==!0&&n.push({field:"direct_override",reason:"full workflow direct execution requires direct_override=true"}),{missingFields:e,invalidFields:n}}function ff(t){let e=uf(t);return e.missingFields.length===0&&e.invalidFields.length===0}var Oy=we(de(),1);import gt from"node:path";async function df(t,e,n={}){if(!e||e==="null")return{status:"missing",recordedPath:null};let r=await Q(t),i=gt.resolve(t,e),o=gt.relative(r.superpowersPlansDir,i);return gt.isAbsolute(e)||!o||o.startsWith(`..${gt.sep}`)||gt.isAbsolute(o)||o.includes(gt.sep)||gt.extname(o).toLowerCase()!==".md"?{status:"broken",recordedPath:e}:await Y(t,e,{label:`Classic build plan ${e}`,expected:"file"})&&(!n.requireNonempty||(await V(t,e,{label:`Classic build plan ${e}`})).trim().length>0)?{status:"ready",recordedPath:e}:{status:"broken",recordedPath:e}}var Ay=/^(\s*[-*]\s+\[)([ xX])(\]\s+)(.*)$/u,Ny=/\s*<!-- comet-task:([a-zA-Z0-9][a-zA-Z0-9_-]{0,79}) -->\s*$/u;function ra(t){let e=[],n=new Set,r=null;for(let[i,o]of t.split(/\r?\n/u).entries()){let s=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(o);if(s){r?s[1][0]===r.marker&&s[1].length>=r.length&&!s[2].trim()&&(r=null):r={marker:s[1][0],length:s[1].length};continue}if(r)continue;let a=Ay.exec(o);if(!a)continue;let c=Ny.exec(a[4]),l=c?.[1]??null;if(a[4].includes("<!-- comet-task:")&&(!c||a[4].slice(0,c.index).includes("<!-- comet-task:")))throw new Error(`Malformed Classic task ID at line ${i+1}`);if(l&&n.has(l))throw new Error(`Duplicate Classic task ID: ${l}`);l&&n.add(l);let u=a[4].slice(0,c?.index).trim();if(!u)throw new Error(`Empty Classic task at line ${i+1}`);e.push({id:l,text:u,completed:a[2].toLowerCase()==="x",line:i+1})}return e}z();be();import Mn from"path";function Ty(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function mf(t,e,n,r){let i=$e(n,"Classic handoff artifact pointer");if((await I(t,i,{label:"Classic handoff artifact",expected:"file"})).exists)return null;let s=await Q(t),a=`${L(t,s.changesDir)}/`,l=(s.artifactLayout==="docs"?[a,"openspec/changes/"]:[a]).find(y=>i.startsWith(y));if(!l)return null;let u=i.slice(l.length).split("/");if(u.length<4||u[1]!==".comet"||u.slice(2).some(y=>y.length===0))return null;let f=u[0];Bt(f);let d=u.slice(2),p=Mn.resolve(e);if(Mn.dirname(p)!==Mn.resolve(s.archiveDir))return null;let g=Mn.basename(p),m=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(g);if(g!==f&&m?.[1]!==f)return null;await I(t,L(t,p),{label:"Classic archived change directory",expected:"directory"});let h=Mn.join(p,".comet",...d),w=L(t,h);try{return await j(t,w,r,{label:"Historical Classic archived handoff artifact"}),w}catch(y){if(Ty(y))return null;throw y}}z();function ia(t,e){return et.relative(t,e).split(et.sep).join("/")}async function Bn(t,e,n,r,i){if(!n)return{code:e,satisfied:!1};let o=n.replaceAll("\\","/");if(i)return{code:e,satisfied:!1,source:o,detail:`Classic layout is unsafe or unavailable: ${i instanceof Error?i.message:String(i)}`};try{if(r){let a=r.artifactLayout==="legacy"?"docs":"legacy",c=L(t,Ln(t,a).openSpecRoot);if((o===c||o.startsWith(`${c}/`))&&(await I(t,o,{label:`${e} artifact`,expected:"file"})).exists)return{code:e,satisfied:!1,source:o,detail:"standalone OpenSpec root is not a Comet artifact root"}}let s=await Bs(t,o,{label:`${e} artifact`});return{code:e,satisfied:s,source:o,...s?{resolvedSource:o}:{}}}catch(s){return{code:e,satisfied:!1,source:o,detail:`unsafe artifact pointer outside the project or through a special path: ${s instanceof Error?s.message:String(s)}`}}}async function Iy(t,e,n,r){try{r??=await Q(t)}catch(o){return{code:"design.handoff",satisfied:!1,...n?{source:n.replaceAll("\\","/")}:{},detail:`Classic layout is unsafe or unavailable for handoff evidence: ${o instanceof Error?o.message:String(o)}`}}let i=await Bn(t,"design.handoff",n,r);if(!n||i.satisfied||i.detail)return i;try{let o=await mf(t,e,n,Number.MAX_SAFE_INTEGER);return o?{...i,satisfied:!0,resolvedSource:o,detail:`resolved historical legacy pointer from archived change: ${o}`}:i}catch(o){return{...i,satisfied:!1,detail:`unsafe archived handoff fallback: ${o instanceof Error?o.message:String(o)}`}}}async function wi(t,e,n){return Bn(t,e,ia(t,n))}async function jy(t,e){let n=et.join(e,"specs"),r;try{r=await Mt(t,n)}catch(i){return i.code==="ENOENT"?{code:"openspec.delta-spec",satisfied:!1}:{code:"openspec.delta-spec",satisfied:!1,detail:`unsafe delta-spec path: ${i instanceof Error?i.message:String(i)}`}}return{code:"openspec.delta-spec",satisfied:r.length>0,source:r[0]?ia(t,r[0]):void 0,detail:`${r.length} delta spec${r.length===1?"":"s"}`}}async function $y(t,e){let n,r=ia(t,e);try{n=(await j(t,r,Number.MAX_SAFE_INTEGER,{label:"Classic tasks artifact"})).bytes.toString("utf8")}catch(s){return s.code==="ENOENT"?{code:"build.tasks-complete",satisfied:!1}:{code:"build.tasks-complete",satisfied:!1,source:r,detail:`unsafe tasks artifact: ${s instanceof Error?s.message:String(s)}`}}let i;try{i=ra(n)}catch(s){return{code:"build.tasks-complete",satisfied:!1,source:r,detail:`malformed tasks.md: ${s instanceof Error?s.message:String(s)}`}}let o=i.filter(s=>s.completed).length;return{code:"build.tasks-complete",satisfied:i.length>0&&o===i.length,source:r,detail:`${o} of ${i.length} tasks complete`}}function Kt(t,e){return t.some(n=>n.code===e&&n.satisfied)}async function Gt(t,e){let n=await Se(t),r=e.classic,i=et.join(t,"proposal.md"),o=et.join(t,"design.md"),s=et.join(t,"tasks.md"),a=e.run?et.resolve(t,e.run.checkpointRef):et.join(t,".comet","checkpoint.json"),c,l;try{c=await Q(n)}catch(d){l=d}let u=await Promise.all([wi(n,"openspec.proposal",i),wi(n,"openspec.design",o),wi(n,"openspec.tasks",s),jy(n,t),Bn(n,"design.document",r?.designDoc??null,c,l),(async()=>{let d=await Bn(n,"build.plan",r?.plan??null,c,l);if(!d.satisfied)return d;try{let p=await df(n,r?.plan??null,{requireNonempty:r?.buildMode==="autonomous"});return p.status==="ready"?d:{code:d.code,source:d.source,satisfied:!1,detail:`Implementation plan is ${p.status}`}}catch(p){return{code:d.code,source:d.source,satisfied:!1,detail:p instanceof Error?p.message:String(p)}}})(),$y(n,s),Bn(n,"verification.report",r?.verificationReport??null,c,l),Iy(n,t,r?.handoffContext??null,c),wi(n,"run.checkpoint",a)]),f=u.find(d=>d.code==="design.handoff");return f&&!r?.handoffHash&&(f.satisfied=!1,f.detail="handoff hash is missing"),u.push({code:"archive.confirmed",satisfied:r?.archiveConfirmation==="confirmed"}),u}import{createHash as gk,randomUUID as wk}from"crypto";import{promises as _a}from"fs";import We from"path";function Ly(t){return t.classicProfile??t.workflow}function qy(t){return t.isolation!==null&&ff(t)}function Wy(t){return(t.buildMode==="direct"||t.buildMode==="autonomous")&&t.tddMode==="direct"&&t.isolation!==null&&t.verifyMode==="light"}function Dy(t,e,n){if(t!=="full"&&e.verifyResult==="fail")return`${t}.build.execute`;if(t==="full"){if(Kt(n,"build.plan")&&e.buildPause==="plan-ready")return"full.build.plan-ready";if(!qy(e))return"full.build.configure";if(!Kt(n,"build.plan"))return"full.build.plan";if(e.verifyResult==="fail")return"full.build.fix"}else if(!Wy(e))throw new Error(`${t} build configuration is incomplete`);return Kt(n,"build.tasks-complete")?`${t}.build.complete`:`${t}.build.execute`}function Fy(t,e,n){return e.verifyResult!=="pass"||!Kt(n,"verification.report")?`${t}.verify.run`:`${t}.verify.branch`}function My(t,e){if(e.verifyResult!=="pass")throw new Error("archive requires verify_result=pass");return e.archiveConfirmation==="confirmed"?`${t}.archive.execute`:`${t}.archive.confirm`}function yi(t,e){let n=Ly(t);if(t.archived&&t.phase!=="archive")throw new Error("archived=true requires phase=archive");if(t.archived)return"completed";if(n!=="full"&&t.phase==="design")throw new Error(`${n} workflow cannot enter design`);switch(t.phase){case"open":return`${n}.open`;case"design":return Kt(e,"design.handoff")?"full.design.document":"full.design.handoff";case"build":return Dy(n,t,e);case"verify":return Fy(n,t,e);case"archive":return My(n,t)}}Ef();z();var Ii=we(de(),1);Ce();z();import it from"path";import{AsyncLocalStorage as Mv}from"node:async_hooks";Ni();var Df=["full","hotfix","tweak"],yt=1,Sv=["open","design","build","verify","archive"],Ev=["en","zh-CN"],xv=["off","beta"],_v=["subagent-driven-development","executing-plans","direct","autonomous"],Rv=["plan-ready"],Pv=["confirmed"],Ov=["tdd","direct"],Av=["off","standard","thorough"],Nv=["current","branch","worktree"],Tv=["light","full"],Iv=["pending","pass","fail"],jv=["pending","handled"],$v=["pending","confirmed"],rt=["workflow","language","phase","context_compression","build_mode","build_pause","subagent_dispatch","tdd_mode","review_mode","isolation","bound_branch","verify_mode","auto_transition","base_ref","design_doc","plan","verify_result","verify_failures","check_epoch","verification_report","branch_status","created_at","verified_at","archive_confirmation","archived","direct_override","handoff_context","handoff_hash","classic_profile","classic_migration"],Hn=["run_id"],Lv=new Set([...rt,...Hn]),qv=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function ga(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Vt(t,e){let n=t[e];if(n==null||n==="")return null;if(typeof n!="string")throw new Error(`Invalid Classic state: ${e} must be a string or null`);return n}function ee(t,e,n,r=!0){let i=t[e];if(i==null||i===""){if(r)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof i!="string"||!n.includes(i))throw new Error(`Invalid Classic state: ${e} must be one of ${n.join(", ")}${r?" or null":""}`);return i}function wa(t,e,n=!0){let r=t[e];if(r==null||r===""){if(n)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof r!="boolean")throw new Error(`Invalid Classic state: ${e} must be true or false`);return r}function Ff(t,e,n=0){let r=t[e];if(r==null||r==="")return n;if(typeof r!="number"||!Number.isSafeInteger(r)||r<0)throw new Error(`Invalid Classic state: ${e} must be a non-negative integer`);return r}function Ti(t,e){let n=Vt(t,e);if(n===null)return null;if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(n)||n.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Classic state: ${e} must be a relative repository path`);return n}function Wv(t,e){let n=Vt(t,e);if(n!==null&&!/^[a-f0-9]{64}$/u.test(n))throw new Error(`Invalid Classic state: ${e} must be a sha256 hex digest`);return n}function Dv(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==yt)throw new Error(`Invalid Classic state: classic_migration must be ${yt}`);return e}function Fv(t){if(!rt.some(n=>ga(t,n)))return null;for(let n of qv)if(!ga(t,n))return null;return{workflow:ee(t,"workflow",Df,!1),language:ee(t,"language",Ev),phase:ee(t,"phase",Sv,!1),contextCompression:ee(t,"context_compression",xv),buildMode:ee(t,"build_mode",_v),buildPause:ee(t,"build_pause",Rv),subagentDispatch:ee(t,"subagent_dispatch",Pv),tddMode:ee(t,"tdd_mode",Ov),reviewMode:ee(t,"review_mode",Av),isolation:ee(t,"isolation",Nv),boundBranch:Vt(t,"bound_branch"),verifyMode:ee(t,"verify_mode",Tv),autoTransition:wa(t,"auto_transition"),baseRef:Vt(t,"base_ref"),designDoc:Ti(t,"design_doc"),plan:Ti(t,"plan"),verifyResult:ee(t,"verify_result",Iv,!1),verifyFailures:Ff(t,"verify_failures"),...ga(t,"check_epoch")?{checkEpoch:Ff(t,"check_epoch")}:{},verificationReport:Ti(t,"verification_report"),branchStatus:ee(t,"branch_status",jv),createdAt:Vt(t,"created_at"),verifiedAt:Vt(t,"verified_at"),archiveConfirmation:ee(t,"archive_confirmation",$v),archived:wa(t,"archived",!1),directOverride:wa(t,"direct_override"),handoffContext:Ti(t,"handoff_context"),handoffHash:Wv(t,"handoff_hash"),classicProfile:ee(t,"classic_profile",Df),classicMigration:Dv(t)}}function ya(t,e){let n=e??null;if(n===null&&e===void 0&&t.run_id&&t.skill)try{n=zt(t)}catch(r){let i=r instanceof Error?r.message:String(r);throw new Error(i.replace(/^Invalid Run state:/u,"Invalid Classic state:"),{cause:r})}return{classic:Fv(t),run:n,unknownKeys:Object.keys(t).filter(r=>!Lv.has(r))}}function Mf(t){return{workflow:t.workflow,language:t.language,phase:t.phase,context_compression:t.contextCompression,build_mode:t.buildMode,build_pause:t.buildPause,subagent_dispatch:t.subagentDispatch,tdd_mode:t.tddMode,review_mode:t.reviewMode,isolation:t.isolation,bound_branch:t.boundBranch,verify_mode:t.verifyMode,auto_transition:t.autoTransition,base_ref:t.baseRef,design_doc:t.designDoc,plan:t.plan,verify_result:t.verifyResult,verify_failures:t.verifyFailures,...t.checkEpoch===void 0?{}:{check_epoch:t.checkEpoch},verification_report:t.verificationReport,branch_status:t.branchStatus,created_at:t.createdAt,verified_at:t.verifiedAt,archive_confirmation:t.archiveConfirmation,archived:t.archived,direct_override:t.directOverride,handoff_context:t.handoffContext,handoff_hash:t.handoffHash,classic_profile:t.classicProfile,classic_migration:t.classicMigration}}Ni();var Bf=new Mv,va=".comet-state-transaction.json";async function Ee(t,e){let n=it.resolve(t);return Bf.getStore()===n?e():(await I(n,".comet-state.lock",{label:"Classic state lock",expected:"file"}),Cf(it.join(n,".comet-state.lock"),()=>Bf.run(n,async()=>(await Kf(n),e()))))}async function ka(t,e){try{return(await j(t,e,Number.MAX_SAFE_INTEGER,{label:"Classic state transaction"})).bytes.toString("utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}}function Bv(t){if(t===null)return null;if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid Classic transaction Run");let e=t,n=zt({run_id:e.runId,skill:e.skill,skill_version:e.skillVersion,skill_hash:e.skillHash,orchestration:e.orchestration,current_step:e.currentStep,iteration:e.iteration,pending:e.pending,pending_ref:e.pendingRef,trajectory_ref:e.trajectoryRef,context_ref:e.contextRef,artifacts_ref:e.artifactsRef,checkpoint_ref:e.checkpointRef,run_status:e.status,run_retries:e.retries});if(!n)throw new Error("Invalid Classic transaction Run identity");return n}async function Kf(t){let e=await ka(t,va);if(e===null)return;let n=JSON.parse(e);if(!n||n.schema!=="comet.classic.state-transaction.v1"||n.beforeYaml!==null&&typeof n.beforeYaml!="string"||typeof n.afterYaml!="string")throw new Error("Invalid Classic state transaction");let r=await ka(t,".comet.yaml");if(r!==n.beforeYaml&&r!==n.afterYaml)throw new Error("Classic state transaction conflicts with current YAML; preserve files for recovery");let i=Bv(r===n.afterYaml?n.afterRun:n.beforeRun);i?await Yt(t,i):await Gn(t),await qt(it.join(t,va),{containedRoot:t})}function Jn(t){let e=t.toJS();if(e===null)return{};if(typeof e!="object"||Array.isArray(e))throw new Error("Invalid Classic state document: root must be a mapping");return e}function Uf(t,e,n){t.get(e)!==n&&t.set(e,n)}function Uv(t,e){if(e.classic)for(let[n,r]of Object.entries(Mf(e.classic)))n==="auto_transition"&&r===null&&!t.has(n)||Uf(t,n,r);else for(let n of rt)t.delete(n);ha(t.toJS(),e.run),e.run?Uf(t,"run_id",e.run.runId):t.delete("run_id")}function Kv(t){let e=["skill","skill_version","skill_hash","orchestration","current_step","iteration","pending","pending_ref","trajectory_ref","context_ref","artifacts_ref","checkpoint_ref","run_status","run_retries"];for(let n of e)t.delete(n)}function Gv(t){let e=!1;for(let n of["build_command","verify_command"])t.has(n)&&(t.delete(n),e=!0);return e}async function Gf(t){let e;try{e=(await j(it.dirname(t),it.basename(t),Number.MAX_SAFE_INTEGER,{label:"Classic state document"})).bytes.toString("utf8")}catch(r){if(r.code!=="ENOENT")throw r;return new Ii.Document({})}let n=(0,Ii.parseDocument)(e);if(n.errors.length>0)throw new Error(`Invalid Classic state document: ${n.errors[0].message}`);return Jn(n),n}async function xe(t,e={}){return Ee(t,()=>Hv(t,e))}async function Hv(t,e){let n=e.migrate!==!1,r=it.join(t,".comet.yaml"),i=await Gf(r),o=Jn(i),s=Gv(i);s&&(o=Jn(i));let a=await Ai(t);if(!a&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(Ni(),Wf));a=c(o),a&&n&&(await Yt(t,a),Kv(i),s=!0)}return s&&n&&await X(r,i.toString(),{containedRoot:t}),ya(Jn(i),a)}async function vt(t,e,n={}){return Ee(t,()=>Jv(t,e,n))}async function Jv(t,e,n){let r=it.join(t,".comet.yaml"),i=await Gf(r),o=i.get("check_epoch")??0;if(typeof o=="number"&&o>(e.classic?.checkEpoch??0))throw new Error("Classic state changed during this operation; reload before retrying");Uv(i,{...e,unknownKeys:e.unknownKeys??[]}),ya(Jn(i),e.run??null);let s=await ka(t,".comet.yaml"),a=i.toString();if(s===a){await n.beforeCommit?.(),e.run?await Yt(t,e.run):await Gn(t);return}let c=it.join(t,va);await X(c,JSON.stringify({schema:"comet.classic.state-transaction.v1",beforeYaml:s,afterYaml:a,beforeRun:await Ai(t),afterRun:e.run}),{containedRoot:t});try{e.run?await Yt(t,e.run):await Gn(t),await X(r,a,{containedRoot:t,beforeCommit:n.beforeCommit})}catch(l){throw await Kf(t).catch(()=>{}),l}await qt(c,{containedRoot:t}).catch(()=>{})}function Hf(t,e,n){return{runId:e,skill:t.definition.metadata.name,skillVersion:t.definition.metadata.version,skillHash:n,orchestration:t.definition.orchestration.mode,currentStep:t.definition.orchestration.entry??null,iteration:0,pending:null,pendingRef:".comet/pending-action.json",trajectoryRef:".comet/trajectory.jsonl",contextRef:".comet/context.md",artifactsRef:".comet/artifacts.json",checkpointRef:".comet/checkpoint.json",status:"running",retries:{}}}Pi();import ji from"path";var qe={trajectory:Number.MAX_SAFE_INTEGER,artifacts:Number.MAX_SAFE_INTEGER,context:Number.MAX_SAFE_INTEGER,pendingAction:Number.MAX_SAFE_INTEGER,checkpoint:Number.MAX_SAFE_INTEGER};function _e(t,e){if(ji.isAbsolute(e))throw new Error("Run path must stay inside the change directory");let n=ji.resolve(t),r=ji.resolve(n,e);if(r!==n&&!r.startsWith(n+ji.sep))throw new Error("Run path must stay inside the change directory")}async function Xt(t,e,n,r={}){_e(t,e),await _i(t,e,`${JSON.stringify(n)}
|
|
149
|
-
`,
|
|
150
|
-
`,
|
|
151
|
-
`,
|
|
152
|
-
`,
|
|
153
|
-
`}async function
|
|
154
|
-
`),await B.rename(o,i)}catch(s){if(await
|
|
155
|
-
`));let l=await
|
|
156
|
-
`,Tk,"Classic state event log"),n}var xd=["open-complete","design-complete","build-complete","verify-pass","verify-fail","archive-confirm","archive-reopen","archived","preset-escalate"],Ik={"open-complete":{event:"open-complete",from:"open",guardRefs:["open-artifacts-present"]},"design-complete":{event:"design-complete",from:"design",guardRefs:["design-evidence-present"]},"build-complete":{event:"build-complete",from:"build",guardRefs:["build-decisions-selected"]},"verify-pass":{event:"verify-pass",from:"verify",guardRefs:["verification-report-present"]},"verify-fail":{event:"verify-fail",from:"verify",guardRefs:["verification-failed"]},"archive-confirm":{event:"archive-confirm",from:"archive",guardRefs:["archive-final-confirmation"]},"archive-reopen":{event:"archive-reopen",from:"archive",guardRefs:["archive-not-finalized"]},archived:{event:"archived",from:"archive",guardRefs:["verify-result-pass","archive-confirmed"]},"preset-escalate":{event:"preset-escalate",from:"build",guardRefs:["preset-workflow"]}};function jk(t){return t.toISOString().slice(0,10)}function _(t,e,n,r){let i=t[n];t[n]=r,i!==r&&e.push({field:n,from:i,to:r})}function _d(t,e,n={}){let r=Ik[e];if(t.phase!==r.from)throw new Error(`Cannot apply ${e}: phase is '${t.phase}', expected '${r.from}'`);let i={...t},o=[],s=t.checkEpoch??0;if(!Number.isSafeInteger(s)||s<0||s===Number.MAX_SAFE_INTEGER)throw new Error("Invalid Classic check epoch");_(i,o,"checkEpoch",s+1);let a=n.now??new Date;if(e==="open-complete")_(i,o,"phase",i.workflow==="full"?"design":"build");else if(e==="design-complete")_(i,o,"phase","build");else if(e==="build-complete"){let c=i.verifyResult==="fail";_(i,o,"phase","verify"),_(i,o,"verifyResult","pending"),_(i,o,"branchStatus","pending"),c||_(i,o,"verificationReport",null)}else if(e==="verify-pass")_(i,o,"verifyResult","pass"),_(i,o,"verifyFailures",0),_(i,o,"phase","archive"),_(i,o,"verifiedAt",jk(a)),_(i,o,"archiveConfirmation","pending"),_(i,o,"branchStatus","pending");else if(e==="verify-fail")_(i,o,"verifyResult","fail"),_(i,o,"verifyFailures",i.verifyFailures+1),_(i,o,"phase","build"),_(i,o,"branchStatus","pending");else if(e==="preset-escalate"){if(i.workflow!=="hotfix"&&i.workflow!=="tweak")throw new Error(`Cannot apply ${e}: workflow must be hotfix or tweak, got '${i.workflow}'`);_(i,o,"workflow","full"),_(i,o,"classicProfile","full"),_(i,o,"phase","design"),_(i,o,"designDoc",null),_(i,o,"buildPause",null),_(i,o,"buildMode",null),_(i,o,"subagentDispatch",null),_(i,o,"tddMode",null),_(i,o,"reviewMode",null),_(i,o,"isolation",null),_(i,o,"boundBranch",null),_(i,o,"verifyMode",null),_(i,o,"directOverride",null)}else if(e==="archive-confirm"){if(i.verifyResult!=="pass")throw new Error(`Cannot apply ${e}: verifyResult must be pass`);if(i.archived)throw new Error(`Cannot apply ${e}: already archived`);_(i,o,"archiveConfirmation","confirmed")}else if(e==="archive-reopen"){if(i.archived)throw new Error(`Cannot apply ${e}: already archived`);_(i,o,"verifyResult","pending"),_(i,o,"verifyFailures",0),_(i,o,"phase","verify"),_(i,o,"verifiedAt",null),_(i,o,"archiveConfirmation",null),_(i,o,"branchStatus","pending")}else{if(i.verifyResult!=="pass")throw new Error(`Cannot apply ${e}: verifyResult must be pass`);if(i.archiveConfirmation!=="confirmed")throw new Error(`Cannot apply ${e}: archiveConfirmation must be confirmed`);_(i,o,"archived",!0)}return{classic:i,effects:o,definition:r}}ma();Ci();import{execFileSync as Rd}from"child_process";var $k=we(de(),1);Ci();Ce();z();function Lk(t){try{let e=Rd("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim();return e&&e!=="HEAD"?e:null}catch{return null}}var IR=ua("liveGitBranch",t=>Lk(t));function qk(t){try{return Rd("git",["rev-parse","--is-inside-work-tree"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()==="true"}catch{return!1}}var jR=ua("isGitWorkTree",t=>qk(t));var Td=we(de(),1);oa();import Pe from"node:path";import{createHash as Ui,randomUUID as FR}from"node:crypto";var Wk=new Set(["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_GRAFT_FILE","GIT_SHALLOW_FILE","GIT_PREFIX","GIT_IMPLICIT_WORK_TREE","GIT_NO_REPLACE_OBJECTS","GIT_REPLACE_REF_BASE","GIT_CONFIG","GIT_CONFIG_PARAMETERS","GIT_CONFIG_COUNT"]);function Dk(t=process.env){return Object.fromEntries(Object.entries(t).filter(([e])=>{let n=e.toUpperCase();return!Wk.has(n)&&!/^GIT_CONFIG_(KEY|VALUE)_\d+$/u.test(n)}))}function Pd(t){return{...Dk(t.environment),...t.authentication?{}:{GIT_CONFIG_GLOBAL:process.platform==="win32"?"NUL":"/dev/null",GIT_CONFIG_NOSYSTEM:"1"},GIT_TERMINAL_PROMPT:"0",GCM_INTERACTIVE:"never",SSH_ASKPASS_REQUIRE:"never",GIT_NO_REPLACE_OBJECTS:"1",GH_PROMPT_DISABLED:"1"}}function bt(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Classic progress requires a JSON object");return t}function Pa(t,e){let n=Object.keys(t).filter(r=>!e.includes(r));if(n.length)throw new Error(`Unknown Classic progress field(s): ${n.join(", ")}; allowed fields: ${e.join(", ")}`)}function Re(t,e){if(typeof t!="string"||!t.trim()||t.length>4096||[...t].some(n=>n.charCodeAt(0)<32||n.charCodeAt(0)===127))throw new Error(`Invalid Classic progress ${e}`);return t}async function Fk(t,e,n){let r=Pe.join(e,".comet",n);if(await Y(t,r,{label:"Classic progress",expected:"file"}))return JSON.parse(await V(t,r,{label:"Classic progress"}))}function Mk(t,e){let n=Ui("sha256").update(e).digest("hex");return Pe.join(t,".comet","runtime","classic-delivery",`${n}.json`)}async function Bk(t,e){let n=Mk(t,e);if(!await Y(t,n,{label:"Classic delivery reauthorization",expected:"file"}))return null;let r=bt(JSON.parse(await V(t,n,{label:"Classic delivery reauthorization"})));if(Pa(r,["schemaVersion","changeIdentity","previousAuthorizationId","authorizationId","action","targetBranch","remote","authorizedRemoteUrl"]),r.schemaVersion!==1||r.changeIdentity!==e)throw new Error("Classic delivery reauthorization identity is invalid");let i=Oa({action:r.action,targetBranch:r.targetBranch,...r.remote===void 0?{}:{remote:r.remote}},!0);if(i.commit!==void 0||i.prUrl!==void 0)throw new Error("Classic delivery reauthorization cannot change sealed commit or PR evidence");return{schemaVersion:1,changeIdentity:e,previousAuthorizationId:Re(r.previousAuthorizationId,"previousAuthorizationId"),authorizationId:Re(r.authorizationId,"authorizationId"),...i,...r.authorizedRemoteUrl===void 0?{}:{authorizedRemoteUrl:Re(r.authorizedRemoteUrl,"authorizedRemoteUrl")}}}function Oa(t,e=!1){let n=bt(t);if(Pa(n,["action","targetBranch","remote","commit","prUrl",...e?["schemaVersion","changeIdentity","authorizedRemoteUrl","authorizationId"]:[]]),!["local","push","pr"].includes(n.action))throw new Error(`Invalid Classic delivery action '${String(n.action)}'; actions: local|push|pr`);let r=Re(n.targetBranch,"targetBranch");if(r.startsWith("-")||/[~^:?*[\\\s]/u.test(r)||r.includes("..")||r.includes("@{"))throw new Error("Invalid Classic delivery targetBranch");let i={action:n.action,targetBranch:r};if(n.remote!==void 0){let o=Re(n.remote,"remote");if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}$/u.test(o))throw new Error("Classic delivery remote must be a name, not a URL");i.remote=o}if(n.commit!==void 0){let o=Re(n.commit,"commit");if(!/^(?:[a-fA-F0-9]{40}|[a-fA-F0-9]{64})$/u.test(o))throw new Error("Classic delivery commit must be a full object ID");i.commit=o.toLowerCase()}if(n.prUrl!==void 0){let o=Re(n.prUrl,"prUrl"),s=new URL(o);if(s.protocol!=="https:"||s.username||s.password)throw new Error("Invalid Classic delivery prUrl");i.prUrl=o}return i}function Id(t){let e=(0,Td.parseDocument)(t,{uniqueKeys:!0});if(e.errors.length)throw new Error("Invalid Classic delivery change state");return bt(e.toJS())}function jd(t,e){if(typeof t.run_id=="string"&&t.run_id)return`run:${t.run_id}`;let n=t.archived===!0?Pe.basename(e).replace(/^\d{4}-\d{2}-\d{2}-/u,""):Pe.basename(e);if(typeof t.created_at!="string"||typeof t.base_ref!="string")throw new Error("Classic delivery requires stable change identity");return`legacy:${Ui("sha256").update(JSON.stringify([n,t.created_at,t.base_ref])).digest("hex")}`}async function Uk(t,e){return Id(await V(t,Pe.join(e,".comet.yaml"),{label:"Classic delivery state"}))}var Bi=class extends Error{constructor(e,n){super(`Classic delivery git command timed out: ${[e,...n].join(" ")}`)}};function Ra(t,e,n,r){return Jt(e,n,{cwd:t,timeoutMs:5e3,env:Pd({authentication:r})}).trim()}function Xn(t,e,n,r=!1){try{return Ra(t,e,n,r)}catch{return null}}function Kk(t,e,n,r=!1){try{return Ra(t,e,n,r)}catch(i){if(!(i instanceof Ht)||!i.timedOut)return null;try{return Ra(t,e,n,r)}catch(o){if(o instanceof Ht&&o.timedOut)throw new Bi(e,n);return null}}}function Yn(t,e){return Xn(t,"git",["-C",t,...e])}function Vn(t,e){return Kk(t,"git",["-C",t,...e])}function Od(t,e,n=!1){return Xn(t,"git",["-C",t,"remote","get-url",...n?["--push"]:[],e],!0)}function Gk(t,e){let n=Pe.relative(t,e).replaceAll("\\","/");return[`:(literal)${n}`,...[".comet-state.lock",".comet-state-transaction.json"].map(r=>`:(exclude,literal)${n}/${r}`)]}function Ad(t,e,n,r){let i=Pe.relative(t,e).replaceAll("\\","/"),o=Gk(t,e),s=Vn(t,["show",`${n}:${i}/.comet.yaml`]);if(!s)return!1;try{let a=Id(s);return a.archived===!0&&jd(a,e)===r&&Vn(t,["merge-base","--is-ancestor",n,"HEAD"])!==null&&Vn(t,["diff","--quiet","--no-ext-diff","--no-textconv",n,"--",...o])!==null&&Vn(t,["ls-files","--others","--exclude-standard","--",...o])===""}catch(a){if(a instanceof Bi)throw a;return!1}}function Hk(t,e){let n=`${Ui("sha256").update(e).digest("hex")}.json`,r=Vn(t,["rev-parse","--path-format=absolute","--git-common-dir"]);return[{root:t,file:Pe.join(t,".comet","classic-deliveries",n)},...r?[{root:r,file:Pe.join(r,"comet","classic-deliveries",n)}]:[]]}async function Jk(t,e){let n=null;for(let r of Hk(t,e)){if(!await Y(r.root,r.file,{label:"Classic delivery receipt",expected:"file"}))continue;let i=bt(JSON.parse(await V(r.root,r.file,{label:"Classic delivery receipt"})));if(Pa(i,["schemaVersion","changeIdentity","authorizationId","invalidated","commit","prUrl"]),i.schemaVersion!==1||i.changeIdentity!==e)throw new Error("Invalid Classic delivery receipt schema or identity");if(i.invalidated!==void 0&&typeof i.invalidated!="boolean")throw new Error("Invalid Classic delivery receipt invalidation");let o=Oa({action:"local",targetBranch:"main",...i.commit!==void 0?{commit:i.commit}:{},...i.prUrl!==void 0?{prUrl:i.prUrl}:{}}),s={schemaVersion:1,changeIdentity:e,authorizationId:Re(i.authorizationId,"authorizationId"),...i.invalidated===!0?{invalidated:!0}:{},...o.commit?{commit:o.commit}:{},...o.prUrl?{prUrl:o.prUrl}:{}};if(n&&JSON.stringify(n)!==JSON.stringify(s))throw new Error("Conflicting Classic delivery receipts");n=s}return n}function zk(t){return t.authorizationId===void 0?`legacy:${Ui("sha256").update(JSON.stringify(t)).digest("hex")}`:Re(t.authorizationId,"authorizationId")}function Nd(t,e,n){return e===n||Yn(t,["merge-base","--is-ancestor",e,n])!==null}function Yk(t){let e=/^git@([^:/]+):([^/]+\/[^/]+)$/u.exec(t);try{let n=new URL(e?`ssh://git@${e[1]}/${e[2]}`:t);if(!["https:","ssh:"].includes(n.protocol)||n.password||n.search||n.hash||n.port||n.protocol==="https:"&&n.username)return null;let r=n.pathname.replace(/\.git\/?$/u,"").replace(/\/$/u,"").split("/").filter(Boolean);return r.length!==2||r.some(i=>!/^[a-zA-Z0-9_.-]+$/u.test(i))?null:`${n.hostname}/${r.join("/")}`.toLowerCase()}catch{return null}}function Mi(t,e){try{let n=new URL(t);if(n.protocol!=="https:"||n.username||n.password||n.port||n.search||n.hash)return null;let r=/^\/([^/]+)\/([^/]+)\/pull\/([1-9]\d*)\/?$/u.exec(n.pathname);return r&&`${n.hostname}/${r[1]}/${r[2]}`.toLowerCase()===e?`https://${n.hostname}/${r[1]}/${r[2]}/pull/${r[3]}`:null}catch{return null}}async function Ki(t,e,n={}){let r=await Fk(t,e,"delivery.json");if(r===void 0)return{delivery:null,verification:{status:"needsAuthorization"}};let i=bt(r);if(i.schemaVersion!==1)throw new Error("Unsupported Classic delivery schemaVersion");let o=Oa(i,!0),s=await Uk(t,e),a=jd(s,e);if(i.changeIdentity!==a)throw new Error("Classic delivery change identity mismatch");let c=zk(i),l=await Bk(t,a);if(l&&l.previousAuthorizationId!==c)throw new Error("Classic delivery reauthorization is stale for the sealed authorization");let u=l?{action:l.action,targetBranch:l.targetBranch,...l.remote===void 0?{}:{remote:l.remote}}:o,f=l?.authorizationId??c,d=await Jk(t,a),p=d?.authorizationId===f?d:null;if(p?.invalidated)return{delivery:null,verification:{status:"needsAuthorization",invalidated:!0}};for(let U of["commit","prUrl"]){if(U==="commit"&&p?.[U]&&u[U]&&p[U]!==u[U])throw new Error("Classic delivery receipt conflicts with authorization evidence");p?.[U]&&(u[U]=p[U])}let g=i.authorizedRemoteUrl===void 0?void 0:Re(i.authorizedRemoteUrl,"authorizedRemoteUrl"),m=l?.authorizedRemoteUrl??g,h={...u,schemaVersion:1,changeIdentity:a,authorizationId:f,...m?{authorizedRemoteUrl:m}:{}},w=Yn(t,["symbolic-ref","--quiet","--short","HEAD"]),y=Pe.relative(t,e).replaceAll("\\","/"),C=null;!u.commit&&s.archived===!0&&(C=Yn(t,["log","-20","--format=%H","HEAD","--",`:(literal)${y}/.comet.yaml`])?.split(/\r?\n/u).find(ge=>/^[a-f0-9]{40,64}$/u.test(ge)&&Ad(t,e,ge,a))??null);let b=u.commit??C,x=!!b&&Yn(t,["cat-file","-t",b])==="commit",E=s.archived===!0&&x&&Ad(t,e,b,a),S=w===u.targetBranch&&(!s.bound_branch||l!==null||s.bound_branch===w)&&E,v=!1,R=!1,K=null,N=n.verifyRemote&&u.action!=="local"?"unavailable":"notChecked",A="notChecked";if(n.verifyRemote&&S&&u.action!=="local"&&u.remote&&m&&Od(t,u.remote)===m&&Od(t,u.remote,!0)===m){let U=`refs/heads/${u.targetBranch}`,ge=Xn(t,"git",["-C",t,"-c","protocol.allow=never","-c","protocol.https.allow=always","-c","protocol.ssh.allow=always","-c","protocol.file.allow=always","ls-remote","--refs",u.remote,U],!0),Zt=ge?.split(/\r?\n/u)??[],Ia=Zt.length===1?/^([a-f0-9]{40}|[a-f0-9]{64})\t(.+)$/u.exec(Zt[0]):null,en=Ia?.[2]===U?Ia[1]:null;v=!!b&&!!en&&Nd(t,b,en),N=v?"verified":ge===""?"missing":ge===null||!en||Yn(t,["cat-file","-t",en])!=="commit"?"unavailable":"missing";let Ae=Yk(m),Hi=Ae&&u.prUrl?Mi(u.prUrl,Ae):null,Ji=v||ge==="",ja=oe=>oe.headRefName===u.targetBranch&&typeof oe.headRefOid=="string"&&/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(oe.headRefOid)&&(v?oe.headRefOid===en&&["OPEN","MERGED"].includes(oe.state):ge===""&&oe.state==="MERGED"&&!!b&&Nd(t,b,oe.headRefOid));if(Ji&&u.action==="pr"&&(A="unavailable"),Ji&&u.action==="pr"&&Hi&&Ae){let oe=Xn(t,"gh",["pr","view",Hi,"--repo",Ae,"--json","url,headRefName,headRefOid,state"],!0);try{let Ne=oe?bt(JSON.parse(oe)):null;R=!!Ne&&typeof Ne.url=="string"&&Mi(Ne.url,Ae)===Hi&&ja(Ne),A=R?"verified":Ne?"missing":"unavailable"}catch{R=!1,A="unavailable"}}else if(Ji&&u.action==="pr"&&!u.prUrl&&Ae){let oe=Xn(t,"gh",["pr","list","--repo",Ae,"--head",u.targetBranch,"--state","all","--json","url,headRefName,headRefOid,state","--limit","100"],!0);try{let Ne=oe===null?null:JSON.parse(oe);if(!Array.isArray(Ne)||Ne.length>=100)throw new Error("Incomplete PR discovery");let zi=Ne.map(bt).filter(Yi=>typeof Yi.url=="string"&&Mi(Yi.url,Ae)&&ja(Yi));zi.length===1?(K=Mi(zi[0].url,Ae),R=!0,A="verified"):A=zi.length===0?"missing":"unavailable"}catch{A="unavailable"}}}return{delivery:h,verification:{status:S&&(u.action==="local"||(u.action==="push"?v:R))?"complete":"needsVerification",currentBranch:w,commitExists:x,archiveCommitted:E,observedCommit:C,observedPrUrl:K,remoteVerified:v,prVerified:R,remoteStatus:N,prStatus:A}}}var Vk=we(de(),1);Ld();pt();li();z();be();Ce();var RP=bi("readCometCurrentSelection",t=>xi(t));async function qd(t,e){return da(t,"classic",e)}var Qk="\x1B[32m",Zk="\x1B[31m",eb="\x1B[33m",Na="\x1B[0m";function le(t){return`${Qk}${t}${Na}`}function J(t){return`${Zk}${t}${Na}`}function Qn(t){return`${eb}${t}${Na}`}var D=class extends Error{constructor(n,r=1){super(n);this.exitCode=r}exitCode},Aa=class{stderr=[];openSpecStdout=[];openSpecStderr=[];stepsOk=0;stepsTotal=0;envelope;captureOpenSpec(e){e.stdout&&this.openSpecStdout.push(e.stdout),e.stderr&&this.openSpecStderr.push(e.stderr)}finishEnvelope(e){this.envelope=lf({name:e.name,stepsOk:this.stepsOk,stepsTotal:this.stepsTotal,dryRun:e.dryRun,locale:e.locale}),this.stderr.push(this.envelope.summary)}toResult(e=0){let n=this.stderr.length>0?this.stderr.join(`
|
|
158
|
+
`).trim(),n=/^@ECHO off\nGOTO start\n:find_dp0\nSET dp0=%~dp0\nEXIT \/b\n:start\nSETLOCAL\nCALL :find_dp0\n\nIF EXIST "%dp0%\\node\.exe" \(\n {2}SET "_prog=%dp0%\\node\.exe"\n\) ELSE \(\n {2}SET "_prog=node"\n {2}SET PATHEXT=%PATHEXT:;\.JS;=;%\n\)\n\nendLocal & goto #_undefined_# 2>NUL \|\| title %COMSPEC% & "%_prog%" {2}"%dp0%\\([^"%\r\n]+\.(?:mjs|cjs|js))" %\*$/u.exec(e);if(n)return{target:n[1]};let r=/^@SETLOCAL\n(?:@IF NOT DEFINED NODE_PATH \(\n {2}@SET "NODE_PATH=([^"\r\n]+)"\n\) ELSE \(\n {2}@SET "NODE_PATH=\1;%NODE_PATH%"\n\)\n)?@IF EXIST "%~dp0\\node\.exe" \(\n {2}"%~dp0\\node\.exe" {2}"%~dp0\\([^"%\r\n]+\.(?:mjs|cjs|js))" %\*\n\) ELSE \(\n {2}@SET PATHEXT=%PATHEXT:;\.JS;=;%\n {2}node {2}"%~dp0\\\2" %\*\n\)$/u.exec(e);return r?{target:r[2],...r[1]?{nodePath:r[1]}:{}}:null}function df(t,e,n){if((n.platform??process.platform)!=="win32")return{command:t,args:[...e]};let r=Kt(t,n.env??process.env,n.cwd),i=Gt.extname(r).toLowerCase();if([".mjs",".cjs",".js"].includes(i))return{command:process.execPath,args:[Gt.resolve(n.cwd,r),...e]};if(i===".cmd"){let o=Ky(Uy(r,"utf8"));if(o){let s=Gt.resolve(Gt.dirname(r),o.target);if(!ff(s))throw new Error(`Node CLI entry is missing: ${s}`);let a=Gt.join(Gt.dirname(r),"node.exe"),c={...n.env??process.env},l=Object.keys(c).find(f=>f.toUpperCase()==="NODE_PATH"),u=l?c[l]:void 0;return o.nodePath&&(l&&delete c[l],c.NODE_PATH=o.nodePath+(u?`;${u}`:"")),{command:ff(a)?a:process.execPath,args:[s,...e],...o.nodePath?{env:c}:{}}}}if([".cmd",".bat",".ps1"].includes(i))throw new Error(`Unsupported Node CLI shim: ${r}. Use a standard npm/pnpm .cmd launcher or the Node CLI .js/.mjs/.cjs entry; no shell fallback is allowed.`);return{command:r,args:[...e]}}function fa(t,e){let n=u=>u!==null&&typeof u=="object"&&!Array.isArray(u)?u:{},r=n(t),i=n(r.entry),o=n(r.state??i.state??r),s=n(r.preparation??r.workspace??i.workspace),a=n(r.continuation??i.continuation),c=typeof s.projectRoot=="string"&&s.projectRoot!=="."?s.projectRoot:e??null,l=o.stateVersion??o.state_version;return{phase:typeof o.phase=="string"?o.phase:null,status:typeof o.status=="string"?o.status:null,stateVersion:typeof l=="number"?l:null,workspace:{cwd:c},continuation:Object.keys(a).length?{...a,cwd:c}:null}}import{stripVTControlCharacters as Gy}from"node:util";function da(t,e={}){return{code:"CLASSIC_COMMAND_FAILED",message:Gy(t instanceof Error?t.message:String(t)),...e}}var mf=ve(pe(),1);J();import Hy from"path";async function pf(t,e){let n=e??await Q(t),r=Hy.join(n.openSpecRoot,"config.yaml"),i=L(n.projectRoot,r),o;try{o=(await j(n.projectRoot,i,Number.MAX_SAFE_INTEGER,{label:"Classic OpenSpec project config",bigint:!0})).bytes.toString("utf8")}catch(l){throw l.code==="ENOENT"?new Error(`Classic OpenSpec root is unhealthy: ${i} is missing; rerun OpenSpec initialization for the configured Classic layout`,{cause:l}):new Error(`Classic OpenSpec root is unhealthy: ${l instanceof Error?l.message:String(l)}`,{cause:l})}let s=(0,mf.parseDocument)(o,{uniqueKeys:!0});if(s.errors.length>0)throw new Error(`Classic OpenSpec root is unhealthy: ${i} is invalid YAML (${s.errors[0].message})`);let a=s.toJS();if(!a||typeof a!="object"||Array.isArray(a))throw new Error(`Classic OpenSpec root is unhealthy: ${i} must contain a mapping`);let c=a.schema;if(typeof c!="string"||c.trim()==="")throw new Error(`Classic OpenSpec root is unhealthy: ${i} must declare a non-empty schema`);return{layout:n,configPath:i,schema:c}}Ee();Se();J();import Hn from"path";var hf=Number.MAX_SAFE_INTEGER;function Ci(t,e,n){let r=Hn.resolve(t),i=Hn.isAbsolute(e)?Hn.resolve(e):Hn.resolve(r,e),o=Hn.relative(r,i).replaceAll("\\","/");return{root:r,relative:We(o,n),target:i}}async function ge(t,e,n){let r=Ci(t,e,n.label);return I(r.root,r.relative,n)}async function Y(t,e,n){return(await ge(t,e,{label:n.label,expected:n.expected??"any"})).exists}async function Si(t,e,n,r){return await Y(t,e,{label:n,expected:"file"})?(await gf(t,e,{label:n,hooks:r})).byteLength>0:!1}async function V(t,e,n){return(await gf(t,e,n)).toString("utf8")}async function gf(t,e,n){let r=Ci(t,e,n.label);return(await j(r.root,r.relative,n.maxBytes??hf,{label:n.label,hooks:n.hooks})).bytes}async function Ei(t,e,n){let r=Ci(t,e,n);return ea(r.root,r.relative,{label:n})}async function Ht(t,e,n,r){let i=Ci(t,e,r.label);await I(i.root,i.relative,{label:r.label,expected:"file"}),await X(i.target,n,{containedRoot:i.root,beforeTemporaryOpen:r.beforeTemporaryOpen,beforeCommit:r.beforeCommit,exclusive:r.exclusive})}function Jy(t){return t[0]==="--"?t.slice(1):[...t]}async function xi(t,e=process.cwd()){let n=Jy(t);if(n.length===0)return{exitCode:64,stderr:"Usage: comet classic openspec -- <openspec-args...>"};let r=await xe(e),i=await Kn(r);await pf(r,i);let o=process.env.COMET_OPENSPEC||"openspec",s=df(o,n,{cwd:i.openSpecBase}),a=zy(s.command,s.args,{cwd:i.openSpecBase,encoding:"utf8",shell:!1,windowsHide:!0,timeout:12e4,...s.env?{env:s.env}:{}});if(a.error){let c=a.error.code;return{exitCode:c==="ENOENT"?127:70,stdout:a.stdout||void 0,stderr:a.stderr||(c==="ENOENT"?`OpenSpec CLI not found: ${o}`:a.error.message)}}return{exitCode:a.status??1,stdout:a.stdout||void 0,stderr:a.stderr||void 0}}import{promises as ma}from"fs";import zn from"path";async function zt(t,e){let n=[],r=new Set;async function i(o,s){let a=await ge(t,o,{label:"Classic capability directory",expected:"directory"});if(!a.exists)return;let c=await ma.realpath(a.target);if(r.has(c))throw new Error(`Classic capability directory cycle: ${o}`);if(r.add(c),s){let u=`${o}/spec.md`;(await ge(t,u,{label:"Classic capability spec",expected:"file"})).exists&&n.push(u)}let l=(await ma.readdir(a.target,{withFileTypes:!0})).sort((u,f)=>u.name.localeCompare(f.name));for(let u of l)if(u.isDirectory()||u.isSymbolicLink()){if(u.name==="spec.md")continue;await i(`${o}/${u.name}`,!0)}r.delete(c)}return await i(e.replaceAll("\\","/"),!1),n}function pa(t){return t?/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t)?t.includes("..")?"Change name cannot contain '..' (path traversal not allowed)":null:`Invalid change name: '${t}'
|
|
159
|
+
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function Jt(t){let e=pa(t);if(e)throw new Error(e)}function Yy(t,e){return{label:L(t,e),directory:e}}async function _i(t,e,n){let r=Yy(t,e);if(!(await ge(t,e,{label:n,expected:"directory"})).exists)return{change:r,exists:!1,stateExists:!1};let o=await ge(t,zn.join(e,".comet.yaml"),{label:`${n} state`,expected:"file"});return{change:r,exists:!0,stateExists:o.exists}}function wf(t,e){let n=e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`^\\d{4}-\\d{2}-\\d{2}-${n}$`,"u").test(t)}async function Vy(t,e,n,r={}){if(!r.skipExactCompatibility){let s=await _i(t,zn.join(e,n),`Classic archived change ${n}`);if(s.exists)return s.change}if(!(await ge(t,e,{label:"Classic archive directory",expected:"directory"})).exists)return null;let o=[];for(let s of await ma.readdir(e,{withFileTypes:!0})){if(!wf(s.name,n))continue;let a=await _i(t,zn.join(e,s.name),`Classic archived change ${s.name}`);a.exists&&a.stateExists&&o.push(a.change)}return o.sort((s,a)=>a.directory.localeCompare(s.directory))[0]??null}async function Ri(t,e=process.cwd()){Jt(t);let n=await Q(e),r=await _i(n.projectRoot,zn.join(n.changesDir,t),`Classic active change ${t}`);return{...r.change,exists:r.exists,stateExists:r.stateExists}}async function Yt(t,e=process.cwd(),n={}){Jt(t);let r=await Q(e);if(n.preferredArchiveName!==void 0){let i=n.preferredArchiveName;if(i!==t&&!wf(i,t))throw new Error(`Classic preferred archive name '${i}' does not belong to change '${t}'`);let o=await _i(r.projectRoot,zn.join(r.archiveDir,i),`Classic preferred archived change ${i}`);return o.exists&&o.stateExists?o.change:null}return Vy(r.projectRoot,r.archiveDir,t,n)}var vf=".comet/archive-requirements.json";async function kf(t,e){let n=await Zy(t,e);if(n.problems.length)throw new Error(n.problems.join(`
|
|
160
|
+
`));n.source!=="legacy"&&await Ht(t,Z.join(e,vf),JSON.stringify({schema:"comet.classic.archive-requirements.v1",files:n.files.map(r=>Z.relative(e,r).replaceAll("\\","/"))})+`
|
|
161
|
+
`,{label:"Classic archive requirements"})}async function bf(t,e){let n=Z.join(e,vf),r=["proposal.md","design.md","tasks.md"];if(await Y(t,n,{label:"Classic archive requirements",expected:"file"})){let o=JSON.parse(await V(t,n,{label:"Classic archive requirements"}));if(o?.schema!=="comet.classic.archive-requirements.v1")throw new Error("Unsupported Classic archive requirements");r=o.files}if(!Array.isArray(r)||!r.includes("proposal.md")||!r.includes("tasks.md")||r.some(o=>typeof o!="string"||!(["proposal.md","design.md","tasks.md"].includes(o)||/^specs\/(?:[^/\\:]+\/)+spec\.md$/u.test(o))||o.split("/").some(s=>s==="."||s==="..")))throw new Error("Invalid Classic archive required files");let i=[];for(let o of r)await Si(t,Z.join(e,o),"Classic archived required file")||i.push(`Required archived artifact is missing or empty: ${o}`);return i}function Qy(t){if(!t||typeof t!="object")throw new Error("Unsupported OpenSpec status: expected an object");let e=t;if(!Array.isArray(e.artifacts)||!Array.isArray(e.applyRequires))throw new Error("OpenSpec must expose artifacts and applyRequires; upgrade to a supported version");let n=new Map;for(let a of e.artifacts){if(!a||typeof a!="object"||typeof a.id!="string"||typeof a.outputPath!="string"||!["done","skipped","ready","blocked"].includes(a.status)||!Array.isArray(a.requires)||a.requires.some(c=>typeof c!="string"))throw new Error("OpenSpec must expose dependency edges for every artifact; upgrade to a supported version");if(n.has(a.id))throw new Error(`Duplicate OpenSpec artifact: ${a.id}`);n.set(a.id,a)}let r=[],i=new Set,o=new Set,s=a=>{if(typeof a!="string"||!n.has(a))throw new Error(`Missing OpenSpec dependency: ${String(a)}`);if(o.has(a))throw new Error(`Cyclic OpenSpec dependency: ${a}`);if(i.has(a))return;o.add(a);let c=n.get(a);for(let l of c.requires)s(l);o.delete(a),i.add(a),r.push(c)};for(let a of[...e.applyRequires,"proposal","tasks"])s(a);return r}async function Zy(t,e){let n=Z.join(e,".openspec.yaml");if(!await Y(t,n,{label:"OpenSpec change metadata",expected:"file"}))return{source:"legacy",required:["proposal","design","tasks"],skipped:[],designRequired:!0,files:["proposal.md","design.md","tasks.md"].map(g=>Z.join(e,g)),problems:[]};let r=(0,yf.parseDocument)(await V(t,n,{label:"OpenSpec change metadata"}));if(r.errors.length)throw new Error(`Invalid OpenSpec metadata: ${r.errors[0].message}`);let i=await Q(t),o=await zt(t,Z.join(e,"specs")),s=Xy("sha256");for(let g of[Z.join(i.openSpecRoot,"config.yaml"),n,...["proposal.md","design.md","tasks.md"].map(m=>Z.join(e,m)),...o])s.update(g),await Y(t,g,{label:"OpenSpec observation input",expected:"file"})?s.update(await V(t,g,{label:"OpenSpec observation input"})):s.update("<missing>");let a=()=>xi(["status","--change",Z.basename(e),"--json"],t),l=await Y(t,Z.join(i.openSpecRoot,"schemas"),{label:"OpenSpec local schemas",expected:"directory"})?await a():await lf(`openspec-status:${e}:${s.digest("hex")}`,a);if(l.exitCode!==0)throw new Error(`Cannot inspect OpenSpec artifact requirements: ${l.stderr??l.exitCode}`);let u;try{u=JSON.parse(l.stdout??"")}catch{throw new Error("Unsupported OpenSpec status: expected JSON")}if(!u||typeof u.changeRoot!="string"||Z.resolve(u.changeRoot)!==Z.resolve(e))throw new Error("OpenSpec status resolves outside the selected Classic change");let f=Qy(u),d=o,p={source:"openspec",required:f.map(g=>g.id),skipped:[],designRequired:f.some(g=>g.id==="design"),files:[],problems:[]};for(let g of f){if(!["proposal","specs","design","tasks"].includes(g.id))throw new Error(`Unsupported Classic artifact: ${g.id}; use a schema with supported artifact roles`);if(g.id!=="specs"&&g.outputPath!==`${g.id}.md`)throw new Error(`Unsupported Classic artifact output: ${g.outputPath}`);if(g.status==="skipped"){if(g.id!=="specs"||r.get("skip_specs")!==!0||d.length)throw new Error("OpenSpec skipped specs require explicit skip_specs: true and no conflicting spec files");p.skipped.push(g.id);continue}let m=g.outputPath.replaceAll("\\","/");if(Z.posix.isAbsolute(m)||/^[A-Za-z]:/u.test(m)||m.split("/").includes(".."))throw new Error(`Unsafe OpenSpec artifact path: ${m}`);let h;if(g.id==="specs"&&["specs/**/*.md","specs/**/spec.md","specs/*/spec.md"].includes(m))h=d;else{if(["?","*","[","]","{","}"].some(w=>m.includes(w)))throw new Error(`Unsupported OpenSpec artifact pattern: ${m}`);h=[Z.join(e,m)]}(g.status!=="done"||!h.length)&&p.problems.push(`Required OpenSpec artifact is not complete: ${g.id}`);for(let w of h)await Si(t,w,`OpenSpec required artifact ${g.id}`)||p.problems.push(`Required OpenSpec file is missing or empty: ${w}`),p.files.push(w)}return p}import Te from"path";function ha(t){return t==="zh-CN"?"zh-CN":"en"}function Cf(t,e,n){return t==="zh-CN"?n:e}function Sf(t){let{name:e,stepsOk:n,stepsTotal:r,dryRun:i,locale:o}=t,s=n===r;return i?{summary:Cf(o,`Archive dry run for ${e}: ${s?`all ${r} steps would succeed`:`${r-n} of ${r} steps would fail`}.`,`需求 ${e} 归档预演:${s?`全部 ${r} 步均可成功`:`${r-n}/${r} 步会失败`}。`)}:{summary:Cf(o,s?`Change ${e} was archived successfully (${n}/${r} steps).`:`Archive for ${e} stopped: ${r-n} of ${r} steps failed.`,s?`需求 ${e} 归档成功(${n}/${r} 步)。`:`需求 ${e} 归档中止:${r-n}/${r} 步失败。`)}}import{promises as Bd}from"fs";import ce from"path";import{fileURLToPath as Ud}from"url";import it from"path";function Ef(t){if(t.workflow!=="full")return{missingFields:[],invalidFields:[]};let e=[],n=[];return t.buildMode||e.push("build_mode"),t.tddMode||e.push("tdd_mode"),t.reviewMode||e.push("review_mode"),t.buildMode==="subagent-driven-development"&&t.subagentDispatch!=="confirmed"&&e.push("subagent_dispatch"),t.buildMode==="autonomous"&&t.reviewMode==="off"&&n.push({field:"review_mode",reason:"autonomous full build requires review_mode=standard or thorough"}),t.buildMode==="direct"&&t.directOverride!==!0&&n.push({field:"direct_override",reason:"full workflow direct execution requires direct_override=true"}),{missingFields:e,invalidFields:n}}function xf(t){let e=Ef(t);return e.missingFields.length===0&&e.invalidFields.length===0}var ev=ve(pe(),1);import kt from"node:path";async function _f(t,e,n={}){if(!e||e==="null")return{status:"missing",recordedPath:null};let r=await Q(t),i=kt.resolve(t,e),o=kt.relative(r.superpowersPlansDir,i);return kt.isAbsolute(e)||!o||o.startsWith(`..${kt.sep}`)||kt.isAbsolute(o)||o.includes(kt.sep)||kt.extname(o).toLowerCase()!==".md"?{status:"broken",recordedPath:e}:await Y(t,e,{label:`Classic build plan ${e}`,expected:"file"})&&(!n.requireNonempty||(await V(t,e,{label:`Classic build plan ${e}`})).trim().length>0)?{status:"ready",recordedPath:e}:{status:"broken",recordedPath:e}}var tv=/^(\s*[-*]\s+\[)([ xX])(\]\s+)(.*)$/u,nv=/\s*<!-- comet-task:([a-zA-Z0-9][a-zA-Z0-9_-]{0,79}) -->\s*$/u;function ga(t){let e=[],n=new Set,r=null;for(let[i,o]of t.split(/\r?\n/u).entries()){let s=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(o);if(s){r?s[1][0]===r.marker&&s[1].length>=r.length&&!s[2].trim()&&(r=null):r={marker:s[1][0],length:s[1].length};continue}if(r)continue;let a=tv.exec(o);if(!a)continue;let c=nv.exec(a[4]),l=c?.[1]??null;if(a[4].includes("<!-- comet-task:")&&(!c||a[4].slice(0,c.index).includes("<!-- comet-task:")))throw new Error(`Malformed Classic task ID at line ${i+1}`);if(l&&n.has(l))throw new Error(`Duplicate Classic task ID: ${l}`);l&&n.add(l);let u=a[4].slice(0,c?.index).trim();if(!u)throw new Error(`Empty Classic task at line ${i+1}`);e.push({id:l,text:u,completed:a[2].toLowerCase()==="x",line:i+1})}return e}J();Se();import Jn from"path";function rv(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Rf(t,e,n,r){let i=We(n,"Classic handoff artifact pointer");if((await I(t,i,{label:"Classic handoff artifact",expected:"file"})).exists)return null;let s=await Q(t),a=`${L(t,s.changesDir)}/`,l=(s.artifactLayout==="docs"?[a,"openspec/changes/"]:[a]).find(y=>i.startsWith(y));if(!l)return null;let u=i.slice(l.length).split("/");if(u.length<4||u[1]!==".comet"||u.slice(2).some(y=>y.length===0))return null;let f=u[0];Jt(f);let d=u.slice(2),p=Jn.resolve(e);if(Jn.dirname(p)!==Jn.resolve(s.archiveDir))return null;let g=Jn.basename(p),m=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(g);if(g!==f&&m?.[1]!==f)return null;await I(t,L(t,p),{label:"Classic archived change directory",expected:"directory"});let h=Jn.join(p,".comet",...d),w=L(t,h);try{return await j(t,w,r,{label:"Historical Classic archived handoff artifact"}),w}catch(y){if(rv(y))return null;throw y}}J();function wa(t,e){return it.relative(t,e).split(it.sep).join("/")}async function Yn(t,e,n,r,i){if(!n)return{code:e,satisfied:!1};let o=n.replaceAll("\\","/");if(i)return{code:e,satisfied:!1,source:o,detail:`Classic layout is unsafe or unavailable: ${i instanceof Error?i.message:String(i)}`};try{if(r){let a=r.artifactLayout==="legacy"?"docs":"legacy",c=L(t,Un(t,a).openSpecRoot);if((o===c||o.startsWith(`${c}/`))&&(await I(t,o,{label:`${e} artifact`,expected:"file"})).exists)return{code:e,satisfied:!1,source:o,detail:"standalone OpenSpec root is not a Comet artifact root"}}let s=await ta(t,o,{label:`${e} artifact`});return{code:e,satisfied:s,source:o,...s?{resolvedSource:o}:{}}}catch(s){return{code:e,satisfied:!1,source:o,detail:`unsafe artifact pointer outside the project or through a special path: ${s instanceof Error?s.message:String(s)}`}}}async function iv(t,e,n,r){try{r??=await Q(t)}catch(o){return{code:"design.handoff",satisfied:!1,...n?{source:n.replaceAll("\\","/")}:{},detail:`Classic layout is unsafe or unavailable for handoff evidence: ${o instanceof Error?o.message:String(o)}`}}let i=await Yn(t,"design.handoff",n,r);if(!n||i.satisfied||i.detail)return i;try{let o=await Rf(t,e,n,Number.MAX_SAFE_INTEGER);return o?{...i,satisfied:!0,resolvedSource:o,detail:`resolved historical legacy pointer from archived change: ${o}`}:i}catch(o){return{...i,satisfied:!1,detail:`unsafe archived handoff fallback: ${o instanceof Error?o.message:String(o)}`}}}async function Pi(t,e,n){return Yn(t,e,wa(t,n))}async function ov(t,e){let n=it.join(e,"specs"),r;try{r=await zt(t,n)}catch(i){return i.code==="ENOENT"?{code:"openspec.delta-spec",satisfied:!1}:{code:"openspec.delta-spec",satisfied:!1,detail:`unsafe delta-spec path: ${i instanceof Error?i.message:String(i)}`}}return{code:"openspec.delta-spec",satisfied:r.length>0,source:r[0]?wa(t,r[0]):void 0,detail:`${r.length} delta spec${r.length===1?"":"s"}`}}async function sv(t,e){let n,r=wa(t,e);try{n=(await j(t,r,Number.MAX_SAFE_INTEGER,{label:"Classic tasks artifact"})).bytes.toString("utf8")}catch(s){return s.code==="ENOENT"?{code:"build.tasks-complete",satisfied:!1}:{code:"build.tasks-complete",satisfied:!1,source:r,detail:`unsafe tasks artifact: ${s instanceof Error?s.message:String(s)}`}}let i;try{i=ga(n)}catch(s){return{code:"build.tasks-complete",satisfied:!1,source:r,detail:`malformed tasks.md: ${s instanceof Error?s.message:String(s)}`}}let o=i.filter(s=>s.completed).length;return{code:"build.tasks-complete",satisfied:i.length>0&&o===i.length,source:r,detail:`${o} of ${i.length} tasks complete`}}function Vt(t,e){return t.some(n=>n.code===e&&n.satisfied)}async function Xt(t,e){let n=await xe(t),r=e.classic,i=it.join(t,"proposal.md"),o=it.join(t,"design.md"),s=it.join(t,"tasks.md"),a=e.run?it.resolve(t,e.run.checkpointRef):it.join(t,".comet","checkpoint.json"),c,l;try{c=await Q(n)}catch(d){l=d}let u=await Promise.all([Pi(n,"openspec.proposal",i),Pi(n,"openspec.design",o),Pi(n,"openspec.tasks",s),ov(n,t),Yn(n,"design.document",r?.designDoc??null,c,l),(async()=>{let d=await Yn(n,"build.plan",r?.plan??null,c,l);if(!d.satisfied)return d;try{let p=await _f(n,r?.plan??null,{requireNonempty:r?.buildMode==="autonomous"});return p.status==="ready"?d:{code:d.code,source:d.source,satisfied:!1,detail:`Implementation plan is ${p.status}`}}catch(p){return{code:d.code,source:d.source,satisfied:!1,detail:p instanceof Error?p.message:String(p)}}})(),sv(n,s),Yn(n,"verification.report",r?.verificationReport??null,c,l),iv(n,t,r?.handoffContext??null,c),Pi(n,"run.checkpoint",a)]),f=u.find(d=>d.code==="design.handoff");return f&&!r?.handoffHash&&(f.satisfied=!1,f.detail="handoff hash is missing"),u.push({code:"archive.confirmed",satisfied:r?.archiveConfirmation==="confirmed"}),u}import{createHash as Vk,randomUUID as Xk}from"crypto";import{promises as Ma}from"fs";import Be from"path";function av(t){return t.classicProfile??t.workflow}function cv(t){return t.isolation!==null&&xf(t)}function lv(t){return(t.buildMode==="direct"||t.buildMode==="autonomous")&&t.tddMode==="direct"&&t.isolation!==null&&t.verifyMode==="light"}function uv(t,e,n){if(t!=="full"&&e.verifyResult==="fail")return`${t}.build.execute`;if(t==="full"){if(Vt(n,"build.plan")&&e.buildPause==="plan-ready")return"full.build.plan-ready";if(!cv(e))return"full.build.configure";if(!Vt(n,"build.plan"))return"full.build.plan";if(e.verifyResult==="fail")return"full.build.fix"}else if(!lv(e))throw new Error(`${t} build configuration is incomplete`);return Vt(n,"build.tasks-complete")?`${t}.build.complete`:`${t}.build.execute`}function fv(t,e,n){return e.verifyResult!=="pass"||!Vt(n,"verification.report")?`${t}.verify.run`:`${t}.verify.branch`}function dv(t,e){if(e.verifyResult!=="pass")throw new Error("archive requires verify_result=pass");return e.archiveConfirmation==="confirmed"?`${t}.archive.execute`:`${t}.archive.confirm`}function Oi(t,e){let n=av(t);if(t.archived&&t.phase!=="archive")throw new Error("archived=true requires phase=archive");if(t.archived)return"completed";if(n!=="full"&&t.phase==="design")throw new Error(`${n} workflow cannot enter design`);switch(t.phase){case"open":return`${n}.open`;case"design":return Vt(e,"design.handoff")?"full.design.document":"full.design.handoff";case"build":return uv(n,t,e);case"verify":return fv(n,t,e);case"archive":return dv(n,t)}}zf();J();var Hi=ve(pe(),1);Ee();J();import _e from"path";import{promises as vk}from"node:fs";import{AsyncLocalStorage as kk}from"node:async_hooks";Ui();var cd=["full","hotfix","tweak"],St=1,tk=["open","design","build","verify","archive"],nk=["en","zh-CN"],rk=["off","beta"],ik=["subagent-driven-development","executing-plans","direct","autonomous"],ok=["plan-ready"],sk=["confirmed"],ak=["tdd","direct"],ck=["off","standard","thorough"],lk=["current","branch","worktree"],uk=["light","full"],fk=["pending","pass","fail"],dk=["pending","handled"],mk=["pending","confirmed"],ct=["workflow","language","phase","context_compression","build_mode","build_pause","subagent_dispatch","tdd_mode","review_mode","isolation","bound_branch","verify_mode","auto_transition","base_ref","design_doc","plan","verify_result","verify_failures","check_epoch","verification_report","branch_status","created_at","verified_at","archive_confirmation","archived","direct_override","handoff_context","handoff_hash","classic_profile","classic_migration"],rr=["run_id"],pk=new Set([...ct,...rr]),hk=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function Aa(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function tn(t,e){let n=t[e];if(n==null||n==="")return null;if(typeof n!="string")throw new Error(`Invalid Classic state: ${e} must be a string or null`);return n}function ee(t,e,n,r=!0){let i=t[e];if(i==null||i===""){if(r)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof i!="string"||!n.includes(i))throw new Error(`Invalid Classic state: ${e} must be one of ${n.join(", ")}${r?" or null":""}`);return i}function Na(t,e,n=!0){let r=t[e];if(r==null||r===""){if(n)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof r!="boolean")throw new Error(`Invalid Classic state: ${e} must be true or false`);return r}function ld(t,e,n=0){let r=t[e];if(r==null||r==="")return n;if(typeof r!="number"||!Number.isSafeInteger(r)||r<0)throw new Error(`Invalid Classic state: ${e} must be a non-negative integer`);return r}function Ki(t,e){let n=tn(t,e);if(n===null)return null;if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(n)||n.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Classic state: ${e} must be a relative repository path`);return n}function gk(t,e){let n=tn(t,e);if(n!==null&&!/^[a-f0-9]{64}$/u.test(n))throw new Error(`Invalid Classic state: ${e} must be a sha256 hex digest`);return n}function wk(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==St)throw new Error(`Invalid Classic state: classic_migration must be ${St}`);return e}function yk(t){if(!ct.some(n=>Aa(t,n)))return null;for(let n of hk)if(!Aa(t,n))return null;return{workflow:ee(t,"workflow",cd,!1),language:ee(t,"language",nk),phase:ee(t,"phase",tk,!1),contextCompression:ee(t,"context_compression",rk),buildMode:ee(t,"build_mode",ik),buildPause:ee(t,"build_pause",ok),subagentDispatch:ee(t,"subagent_dispatch",sk),tddMode:ee(t,"tdd_mode",ak),reviewMode:ee(t,"review_mode",ck),isolation:ee(t,"isolation",lk),boundBranch:tn(t,"bound_branch"),verifyMode:ee(t,"verify_mode",uk),autoTransition:Na(t,"auto_transition"),baseRef:tn(t,"base_ref"),designDoc:Ki(t,"design_doc"),plan:Ki(t,"plan"),verifyResult:ee(t,"verify_result",fk,!1),verifyFailures:ld(t,"verify_failures"),...Aa(t,"check_epoch")?{checkEpoch:ld(t,"check_epoch")}:{},verificationReport:Ki(t,"verification_report"),branchStatus:ee(t,"branch_status",dk),createdAt:tn(t,"created_at"),verifiedAt:tn(t,"verified_at"),archiveConfirmation:ee(t,"archive_confirmation",mk),archived:Na(t,"archived",!1),directOverride:Na(t,"direct_override"),handoffContext:Ki(t,"handoff_context"),handoffHash:gk(t,"handoff_hash"),classicProfile:ee(t,"classic_profile",cd),classicMigration:wk(t)}}function Gi(t,e){let n=e??null;if(n===null&&e===void 0&&t.run_id&&t.skill)try{n=Qt(t)}catch(r){let i=r instanceof Error?r.message:String(r);throw new Error(i.replace(/^Invalid Run state:/u,"Invalid Classic state:"),{cause:r})}return{classic:yk(t),run:n,unknownKeys:Object.keys(t).filter(r=>!pk.has(r))}}function ud(t){return{workflow:t.workflow,language:t.language,phase:t.phase,context_compression:t.contextCompression,build_mode:t.buildMode,build_pause:t.buildPause,subagent_dispatch:t.subagentDispatch,tdd_mode:t.tddMode,review_mode:t.reviewMode,isolation:t.isolation,bound_branch:t.boundBranch,verify_mode:t.verifyMode,auto_transition:t.autoTransition,base_ref:t.baseRef,design_doc:t.designDoc,plan:t.plan,verify_result:t.verifyResult,verify_failures:t.verifyFailures,...t.checkEpoch===void 0?{}:{check_epoch:t.checkEpoch},verification_report:t.verificationReport,branch_status:t.branchStatus,created_at:t.createdAt,verified_at:t.verifiedAt,archive_confirmation:t.archiveConfirmation,archived:t.archived,direct_override:t.directOverride,handoff_context:t.handoffContext,handoff_hash:t.handoffHash,classic_profile:t.classicProfile,classic_migration:t.classicMigration}}Ui();var Ta=new kk,ir=".comet-state-transaction.json";async function Re(t,e){let n=_e.resolve(t);return Ta.getStore()===n?e():(await I(n,".comet-state.lock",{label:"Classic state lock",expected:"file"}),Gf(_e.join(n,".comet-state.lock"),()=>Ta.run(n,async()=>(await md(n),e()))))}async function Ia(t,e){try{return(await j(t,e,Number.MAX_SAFE_INTEGER,{label:"Classic state transaction"})).bytes.toString("utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}}function bk(t){if(t===null)return null;if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid Classic transaction Run");let e=t,n=Qt({run_id:e.runId,skill:e.skill,skill_version:e.skillVersion,skill_hash:e.skillHash,orchestration:e.orchestration,current_step:e.currentStep,iteration:e.iteration,pending:e.pending,pending_ref:e.pendingRef,trajectory_ref:e.trajectoryRef,context_ref:e.contextRef,artifacts_ref:e.artifactsRef,checkpoint_ref:e.checkpointRef,run_status:e.status,run_retries:e.retries});if(!n)throw new Error("Invalid Classic transaction Run identity");return n}async function md(t){let e=await Ia(t,ir);if(e===null)return;let n=JSON.parse(e);if(!n||n.schema!=="comet.classic.state-transaction.v1"||n.beforeYaml!==null&&typeof n.beforeYaml!="string"||typeof n.afterYaml!="string")throw new Error("Invalid Classic state transaction");let r=await Ia(t,".comet.yaml");if(r!==n.beforeYaml&&r!==n.afterYaml)throw new Error("Classic state transaction conflicts with current YAML; preserve files for recovery");let i=bk(r===n.afterYaml?n.afterRun:n.beforeRun);i?await en(t,i):await nr(t),await Bt(_e.join(t,ir),{containedRoot:t})}function rn(t){let e=t.toJS();if(e===null)return{};if(typeof e!="object"||Array.isArray(e))throw new Error("Invalid Classic state document: root must be a mapping");return e}function fd(t,e,n){t.get(e)!==n&&t.set(e,n)}function Ck(t,e){if(e.classic)for(let[n,r]of Object.entries(ud(e.classic)))n==="auto_transition"&&r===null&&!t.has(n)||fd(t,n,r);else for(let n of ct)t.delete(n);Oa(t.toJS(),e.run),e.run?fd(t,"run_id",e.run.runId):t.delete("run_id")}function Sk(t){let e=["skill","skill_version","skill_hash","orchestration","current_step","iteration","pending","pending_ref","trajectory_ref","context_ref","artifacts_ref","checkpoint_ref","run_status","run_retries"];for(let n of e)t.delete(n)}function Ek(t){let e=!1;for(let n of["build_command","verify_command"])t.has(n)&&(t.delete(n),e=!0);return e}async function ja(t){let e;try{e=(await j(_e.dirname(t),_e.basename(t),Number.MAX_SAFE_INTEGER,{label:"Classic state document"})).bytes.toString("utf8")}catch(r){if(r.code!=="ENOENT")throw r;return new Hi.Document({})}let n=(0,Hi.parseDocument)(e);if(n.errors.length>0)throw new Error(`Invalid Classic state document: ${n.errors[0].message}`);return rn(n),n}async function Pe(t,e={}){if(Ta.getStore()!==_e.resolve(t)){let n=await xk(t);if(n!==null)return n}return Re(t,()=>_k(t,e))}async function nn(t,e){let n=await I(t,e,{label:"Classic state snapshot",expected:"file"});if(!n.exists)return{stamp:"missing",comparable:!0};let r=await vk.lstat(n.target,{bigint:!0});if(!r.isFile()||r.isSymbolicLink())throw new Error("Classic state file changed");return{stamp:[r.dev,r.ino,r.birthtimeNs,r.ctimeNs,r.mtimeNs,r.size].join(":"),comparable:r.dev!==0n&&r.ino!==0n&&r.ctimeNs>0n}}async function dd(t){if((await nn(t,".comet-state.lock")).stamp!=="missing"||(await nn(t,ir)).stamp!=="missing")return null;let r=await nn(t,".comet.yaml"),i=await nn(t,Zt);return!r.comparable||!i.comparable?null:{yaml:r.stamp,run:i.stamp}}async function xk(t){try{let e=await dd(t);if(e===null)return null;let n=await ja(_e.join(t,".comet.yaml")),r=rn(n);if(n.has("build_command")||n.has("verify_command"))return null;let i=await tr(t);if(!i&&r.run_id&&r.skill)return null;let o=Gi(r,i),s=await dd(t);return s===null||e.yaml!==s.yaml||e.run!==s.run||(await nn(t,ir)).stamp!=="missing"||(await nn(t,".comet-state.lock")).stamp!=="missing"?null:o}catch{return null}}async function _k(t,e){let n=e.migrate!==!1,r=_e.join(t,".comet.yaml"),i=await ja(r),o=rn(i),s=Ek(i);s&&(o=rn(i));let a=await tr(t);if(!a&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(Ui(),ad));a=c(o),a&&n&&(await en(t,a),Sk(i),s=!0)}return s&&n&&await X(r,i.toString(),{containedRoot:t}),Gi(rn(i),a)}async function Et(t,e,n={}){return Re(t,()=>Rk(t,e,n))}async function Rk(t,e,n){let r=_e.join(t,".comet.yaml"),i=await ja(r),o=i.get("check_epoch")??0;if(typeof o=="number"&&o>(e.classic?.checkEpoch??0))throw new Error("Classic state changed during this operation; reload before retrying");Ck(i,{...e,unknownKeys:e.unknownKeys??[]}),Gi(rn(i),e.run??null);let s=await Ia(t,".comet.yaml"),a=i.toString();if(s===a){await n.beforeCommit?.(),e.run?await en(t,e.run):await nr(t);return}let c=_e.join(t,ir);await X(c,JSON.stringify({schema:"comet.classic.state-transaction.v1",beforeYaml:s,afterYaml:a,beforeRun:await tr(t),afterRun:e.run}),{containedRoot:t});try{e.run?await en(t,e.run):await nr(t),await X(r,a,{containedRoot:t,beforeCommit:n.beforeCommit})}catch(l){throw await md(t).catch(()=>{}),l}await Bt(c,{containedRoot:t}).catch(()=>{})}function pd(t,e,n){return{runId:e,skill:t.definition.metadata.name,skillVersion:t.definition.metadata.version,skillHash:n,orchestration:t.definition.orchestration.mode,currentStep:t.definition.orchestration.entry??null,iteration:0,pending:null,pendingRef:".comet/pending-action.json",trajectoryRef:".comet/trajectory.jsonl",contextRef:".comet/context.md",artifactsRef:".comet/artifacts.json",checkpointRef:".comet/checkpoint.json",status:"running",retries:{}}}Bi();import zi from"path";var Fe={trajectory:Number.MAX_SAFE_INTEGER,artifacts:Number.MAX_SAFE_INTEGER,context:Number.MAX_SAFE_INTEGER,pendingAction:Number.MAX_SAFE_INTEGER,checkpoint:Number.MAX_SAFE_INTEGER};function Oe(t,e){if(zi.isAbsolute(e))throw new Error("Run path must stay inside the change directory");let n=zi.resolve(t),r=zi.resolve(n,e);if(r!==n&&!r.startsWith(n+zi.sep))throw new Error("Run path must stay inside the change directory")}async function on(t,e,n,r={}){Oe(t,e),await Mi(t,e,`${JSON.stringify(n)}
|
|
162
|
+
`,Fe.trajectory,"Run trajectory",r)}async function or(t,e,n={}){Oe(t,e);let r=await st(t,e,Fe.trajectory,"Run trajectory",n);return r===null?[]:r.split(/\r?\n/).map((i,o)=>({line:i,number:o+1})).filter(({line:i})=>i.length>0).map(({line:i,number:o})=>{try{return JSON.parse(i)}catch(s){throw new Error(`Invalid Trajectory event at line ${o}`,{cause:s})}})}async function $a(t,e,n={}){Oe(t,e);let r=await st(t,e,Fe.artifacts,"Run artifacts",n);return r===null?{}:JSON.parse(r)}async function Ji(t,e,n,r={}){Oe(t,e),await at(t,e,JSON.stringify(n,null,2)+`
|
|
163
|
+
`,Fe.artifacts,"Run artifacts",r)}async function hd(t,e,n,r={}){Oe(t,e),await at(t,e,n,Fe.context,"Run context",r)}async function gd(t,e,n={}){return Oe(t,e),st(t,e,Fe.context,"Run context",n)}async function wd(t,e,n,r={}){Oe(t,e),await at(t,e,JSON.stringify(n,null,2)+`
|
|
164
|
+
`,Fe.pendingAction,"Run pending action",r)}async function yd(t,e,n={}){Oe(t,e);let r=await st(t,e,Fe.pendingAction,"Run pending action",n);return r===null?null:JSON.parse(r)}async function vd(t,e,n={}){Oe(t,e),await Fi(t,e,"Run pending action",n)}async function Yi(t,e,n,r={}){Oe(t,e),await at(t,e,JSON.stringify(n,null,2)+`
|
|
165
|
+
`,Fe.checkpoint,"Run checkpoint",r)}import{createHash as Id,randomUUID as Gk}from"crypto";import{promises as B}from"fs";import W from"path";var Cd=ve(pe(),1);import{promises as La}from"fs";import ue from"path";var Pk=["invoke_skill","call_tool","handoff","ask_user","checkpoint"],Ok=["deterministic","adaptive"],Ak=["function","mcp","script","agent"],Nk=["none","read","write","external"],Tk=["progress","step","completion"],Ik=["artifact_exists","state_equals"];function xt(t,e,n){return new Error(`${t}: ${e} ${n}`)}function oe(t,e,n="document"){if(t===null||typeof t!="object"||Array.isArray(t))throw xt(e,n,"must be an object")}function lt(t,e,n){if(!Array.isArray(t))throw xt(e,n,"must be an array")}function te(t,e,n){if(typeof t!="string")throw xt(e,n,"must be a string")}function we(t,e,n,r){e in t&&te(t[e],n,`${r}.${e}`)}function Sd(t,e,n,r){if(e in t&&typeof t[e]!="boolean")throw xt(n,`${r}.${e}`,"must be a boolean")}function ut(t,e,n,r){if(typeof t!="string"||!e.includes(t))throw xt(n,r,`must be one of ${e.join(", ")}`)}function Vi(t,e,n){lt(t,e,n),t.forEach((r,i)=>{te(r,e,`${n}[${i}]`)})}function kd(t,e,n){oe(t,e,n),te(t.name,e,`${n}.name`),te(t.description,e,`${n}.description`),Sd(t,"required",e,n)}function jk(t,e,n){oe(t,e,n),te(t.id,e,`${n}.id`),we(t,"source",e,n),we(t,"version",e,n)}function $k(t,e,n){oe(t,e,n),te(t.id,e,`${n}.id`),te(t.role,e,`${n}.role`),we(t,"instructions",e,n)}function Lk(t,e,n){oe(t,e,n),te(t.id,e,`${n}.id`),ut(t.kind,Ak,e,`${n}.kind`),te(t.source,e,`${n}.source`),ut(t.sideEffect,Nk,e,`${n}.sideEffect`),Sd(t,"requiresConfirmation",e,n)}function qk(t,e,n){oe(t,e,n),ut(t.type,Pk,e,`${n}.type`),we(t,"ref",e,n),we(t,"prompt",e,n),we(t,"question",e,n),"options"in t&&Vi(t.options,e,`${n}.options`)}function Wk(t,e,n){oe(t,e,n),te(t.id,e,`${n}.id`),qk(t.action,e,`${n}.action`),we(t,"next",e,n),"completionEvals"in t&&Vi(t.completionEvals,e,`${n}.completionEvals`)}function Dk(t,e){let n="goal";oe(t,e,n),te(t.statement,e,`${n}.statement`),lt(t.inputs,e,`${n}.inputs`),t.inputs.forEach((r,i)=>{kd(r,e,`${n}.inputs[${i}]`)}),lt(t.outputs,e,`${n}.outputs`),t.outputs.forEach((r,i)=>{kd(r,e,`${n}.outputs[${i}]`)}),Vi(t.success,e,`${n}.success`)}function Mk(t,e){let n="orchestration";oe(t,e,n),ut(t.mode,Ok,e,`${n}.mode`),we(t,"entry",e,n),"steps"in t&&(lt(t.steps,e,`${n}.steps`),t.steps.forEach((r,i)=>{Wk(r,e,`${n}.steps[${i}]`)}))}function Ed(t,e){return oe(t,e),ut(t.apiVersion,["comet/v1alpha1"],e,"apiVersion"),ut(t.kind,["Skill"],e,"kind"),oe(t.metadata,e,"metadata"),te(t.metadata.name,e,"metadata.name"),te(t.metadata.version,e,"metadata.version"),te(t.metadata.description,e,"metadata.description"),Dk(t.goal,e),Mk(t.orchestration,e),lt(t.skills,e,"skills"),t.skills.forEach((n,r)=>{jk(n,e,`skills[${r}]`)}),lt(t.agents,e,"agents"),t.agents.forEach((n,r)=>{$k(n,e,`agents[${r}]`)}),lt(t.tools,e,"tools"),t.tools.forEach((n,r)=>{Lk(n,e,`tools[${r}]`)}),t}function xd(t,e){oe(t,e);for(let n of["allowedSkills","allowedAgents","allowedTools","confirmationRequiredFor"])n in t&&Vi(t[n],e,n);for(let n of["maxIterations","maxRetriesPerAction"])if(n in t&&(typeof t[n]!="number"||!Number.isFinite(t[n])))throw xt(e,n,"must be a finite number");return t}function Fk(t,e){return oe(t,e),"runtime"in t&&_d(t.runtime,e,"runtime"),t}function _d(t,e,n){return lt(t,e,n),t.forEach((r,i)=>{let o=`${n}[${i}]`;oe(r,e,o),te(r.id,e,`${o}.id`),ut(r.scope,Tk,e,`${o}.scope`),ut(r.type,Ik,e,`${o}.type`),we(r,"artifact",e,o),we(r,"field",e,o),we(r,"equals",e,o)}),t}async function qa(t){let e=await La.readFile(t,"utf8");try{return(0,Cd.parse)(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw xt(t,"document",r)}}async function Bk(t){try{return await qa(t)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function bd(t){try{return await La.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Uk(t){let e=ue.join(t,"checks.yaml"),n=ue.join(t,"evals.yaml"),[r,i]=await Promise.all([bd(e),bd(n)]);if(i)throw new Error(`${n}: evals.yaml is no longer supported; use checks.yaml`);return r?{document:Fk(await qa(e),e)}:{document:null}}async function Rd(t){let e=ue.resolve(t.root),n=ue.resolve(t.controlRoot);t.requireSkillMarkdown&&await La.access(ue.join(e,"SKILL.md"));let r=ue.join(n,"skill.yaml"),i=ue.join(n,"guardrails.yaml"),o=Ed(await qa(r),r),s=await Bk(i),a=s===null?null:xd(s,i),c=await Uk(n),l={allowedSkills:o.skills.map(u=>u.id),allowedAgents:o.agents.map(u=>u.id),allowedTools:o.tools.map(u=>u.id),maxIterations:50,maxRetriesPerAction:3,confirmationRequiredFor:o.tools.filter(u=>u.requiresConfirmation).map(u=>u.id)};return{root:e,packageKind:t.packageKind==="runtime"?"runtime":void 0,definition:o,guardrails:{...l,...a},evals:c.document?.runtime??[]}}async function Pd(t){let e=ue.resolve(t);return Rd({root:e,controlRoot:ue.join(e,"comet"),packageKind:"skill",requireSkillMarkdown:!0})}async function Od(t){let e=ue.resolve(t);return Rd({root:e,controlRoot:e,packageKind:"runtime",requireSkillMarkdown:!1})}function Ad(t,e,n=ue.join(e,"package.json")){oe(t,n);let r=t.packageKind==="runtime"?"runtime":void 0,i=Ed(t.definition,n),o=xd(t.guardrails,n),s=_d(t.evals,n,"evals"),a={allowedSkills:i.skills.map(c=>c.id),allowedAgents:i.agents.map(c=>c.id),allowedTools:i.tools.map(c=>c.id),maxIterations:50,maxRetriesPerAction:3,confirmationRequiredFor:i.tools.filter(c=>c.requiresConfirmation).map(c=>c.id)};return{root:ue.resolve(e),packageKind:r,definition:i,guardrails:{...a,...o},evals:s}}import Nd from"path";function Kk(t,e,n,r){t.type==="invoke_skill"&&!e.definition.skills.some(i=>i.id===t.ref)&&n.push(`step ${r} references undeclared skill: ${t.ref??"(missing)"}`),t.type==="call_tool"&&!e.definition.tools.some(i=>i.id===t.ref)&&n.push(`step ${r} references undeclared tool: ${t.ref??"(missing)"}`),t.type==="handoff"&&!e.definition.agents.some(i=>i.id===t.ref)&&n.push(`step ${r} references undeclared agent: ${t.ref??"(missing)"}`),t.type==="ask_user"&&!t.question&&n.push(`step ${r} ask_user action requires question`)}function Td(t){let e=[],{definition:n,guardrails:r,evals:i}=t;n.apiVersion!=="comet/v1alpha1"&&e.push("unsupported apiVersion"),n.kind!=="Skill"&&e.push("kind must be Skill"),n.metadata.name||e.push("metadata.name is required"),n.goal.statement||e.push("goal.statement is required"),r.maxIterations<1&&e.push("maxIterations must be at least 1"),r.maxRetriesPerAction<0&&e.push("maxRetriesPerAction must not be negative");let o=n.orchestration.steps??[];if(n.orchestration.mode==="adaptive")(n.orchestration.entry||o.length>0)&&e.push("adaptive orchestration must not define entry or steps");else{let s=new Set;for(let a of o)s.has(a.id)&&e.push(`duplicate step id: ${a.id}`),s.add(a.id),Kk(a.action,t,e,a.id);(!n.orchestration.entry||!s.has(n.orchestration.entry))&&e.push(`orchestration.entry references unknown step: ${n.orchestration.entry??"(missing)"}`);for(let a of o){a.next&&!s.has(a.next)&&e.push(`step ${a.id} has unknown next step: ${a.next}`);for(let c of a.completionEvals??[])i.some(l=>l.id===c)||e.push(`step ${a.id} references unknown eval: ${c}`)}}for(let s of n.tools){if(s.kind!=="script")continue;let a=Nd.posix.normalize(s.source.replaceAll("\\","/"));(Nd.isAbsolute(s.source)||a===".."||a.startsWith("../"))&&e.push(`script tool ${s.id} must reference a relative path inside the Skill package`)}for(let s of r.allowedSkills)n.skills.some(a=>a.id===s)||e.push(`guardrails allow undeclared skill: ${s}`);for(let s of r.allowedAgents)n.agents.some(a=>a.id===s)||e.push(`guardrails allow undeclared agent: ${s}`);for(let s of r.allowedTools)n.tools.some(a=>a.id===s)||e.push(`guardrails allow undeclared tool: ${s}`);return e}function Xi(t){return Array.isArray(t)?t.map(Xi):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,Xi(n)])):t}function Hk(t){return Xi({...t.packageKind==="runtime"?{packageKind:"runtime"}:{},definition:t.definition,guardrails:t.guardrails,evals:t.evals})}function zk(t){return W.posix.normalize(t.replaceAll("\\","/"))}function sn(t,e,n){let r=W.relative(t,e);if(!(r===""||!W.isAbsolute(r)&&!r.startsWith(`..${W.sep}`)))throw new Error(`${n} resolves outside the Skill package`)}async function jd(t,e,n){let r=zk(e);if(W.posix.isAbsolute(r)||r===".."||r.startsWith("../"))throw new Error(`${n} resolves outside the Skill package`);let i=W.resolve(t,...r.split("/"));sn(t,i,n);let o;try{o=await B.realpath(i)}catch(s){throw s.code==="ENOENT"?new Error(`${n} does not exist: ${e}`,{cause:s}):s}if(sn(t,o,n),!(await B.stat(o)).isFile())throw new Error(`${n} is not a file: ${e}`);return{path:r,content:await B.readFile(o)}}async function Jk(t){let e=await B.realpath(t.root),n=t.packageKind==="runtime"?[]:[await jd(e,"SKILL.md","SKILL.md")];for(let r of t.definition.tools)r.kind==="script"&&n.push(await jd(e,r.source,`Script tool ${r.id}`));return n.sort((r,i)=>r.path.localeCompare(i.path))}function Yk(t,e){let n=e.map(r=>({path:r.path,sha256:Id("sha256").update(r.content).digest("hex")}));return Id("sha256").update(JSON.stringify(Xi({package:t,files:n}))).digest("hex")}function qd(t){return JSON.stringify(t,null,2)+`
|
|
166
|
+
`}async function Wd(t){let e=Hk(t),n=await Jk(t);return{document:e,files:n,hash:Yk(e,n)}}async function Qi(t){return(await Wd(t)).hash}async function $d(t){try{return await B.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Ld(t,e){try{if((await B.readFile(W.join(t,"sha256"),"utf8")).trim()!==e.hash)throw new Error("hash mismatch");if(await B.readFile(W.join(t,"package.json"),"utf8")!==qd(e.document))throw new Error("package mismatch");for(let i of e.files)if(!(await B.readFile(W.join(t,...i.path.split("/")))).equals(i.content))throw new Error(`file mismatch: ${i.path}`)}catch(n){throw new Error(`Existing Skill snapshot is invalid: ${e.hash}`,{cause:n})}}async function Wa(t,e){let n=await Wd(t),r=W.resolve(e,".comet","skill-snapshots"),i=W.join(r,n.hash);if(await B.mkdir(r,{recursive:!0}),await $d(i))return await Ld(i,n),{hash:n.hash,snapshotDir:i};let o=W.join(r,`.tmp-${Gk()}`);sn(r,o,"Temporary snapshot"),sn(r,i,"Published snapshot");try{await B.mkdir(o);for(let s of n.files){let a=W.join(o,...s.path.split("/"));sn(o,a,`Snapshot file ${s.path}`),await B.mkdir(W.dirname(a),{recursive:!0}),await B.writeFile(a,s.content)}await B.writeFile(W.join(o,"package.json"),qd(n.document)),await B.writeFile(W.join(o,"sha256"),n.hash+`
|
|
167
|
+
`),await B.rename(o,i)}catch(s){if(await $d(i)){try{await Ld(i,n)}finally{await B.rm(o,{recursive:!0,force:!0})}return{hash:n.hash,snapshotDir:i}}throw await B.rm(o,{recursive:!0,force:!0}),s}return{hash:n.hash,snapshotDir:i}}async function Da(t,e){if(!/^[a-f0-9]{64}$/u.test(e))throw new Error(`Invalid Skill snapshot hash: ${e}`);let n=W.resolve(t,".comet","skill-snapshots"),r=W.join(n,e);sn(n,r,"Skill snapshot");try{let i=(await B.readFile(W.join(r,"sha256"),"utf8")).trim();if(i!==e)throw new Error(`stored hash is ${i||"(empty)"}`);let o=W.join(r,"package.json"),s=JSON.parse(await B.readFile(o,"utf8")),a=Ad(s,r,o),c=Td(a);if(c.length>0)throw new Error(c.map(u=>` - ${u}`).join(`
|
|
168
|
+
`));let l=await Qi(a);if(l!==e)throw new Error(`calculated hash is ${l}`);return a}catch(i){throw new Error(`Skill snapshot is invalid or missing: ${e}`,{cause:i})}}async function Dd(t){try{return await Ma.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Md(t){return Vk("sha256").update(t).digest("hex")}function Qk(t){return Md(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}function Zk(t){return t.replaceAll(".","_").replaceAll("-","_")}async function eb(t,e){let n=await xe(t),r=Object.fromEntries(e.filter(s=>s.satisfied&&s.source).map(s=>[Zk(s.code),s.source])),i=Be.join(t,"subagent-progress.md");await Dd(i)&&(r.subagent_progress=Be.relative(n,i).split(Be.sep).join("/"));let o=e.find(s=>s.code==="design.handoff"&&s.satisfied);return o?.source&&(r.handoff_context=o.source),r}function tb(t,e,n){return[{sequence:1,timestamp:n,type:"run_started",runId:t.runId,data:{skill:t.skill,skillVersion:t.skillVersion,skillHash:t.skillHash}},{sequence:2,timestamp:n,type:"state_migrated",runId:t.runId,data:{kind:"classic",migrationVersion:St,profile:e,source:"pre-migration"}}]}async function nb(t){await Promise.all(t.map(e=>Ma.rm(e,{recursive:!0,force:!0})))}async function Fd(t,e){return Re(t,()=>rb(t,e))}async function rb(t,e){let n=await Pe(t);if(!n.classic)throw new Error("Classic migration requires a legacy state projection");let r=n.classic,i=r.classicProfile??r.workflow;if(n.run){if(r.classicMigration!==St)throw new Error("Classic Run exists without a supported classic_migration marker");if(n.run.skill!==e.skillPackage.definition.metadata.name)throw new Error(`Classic Run skill mismatch: expected ${e.skillPackage.definition.metadata.name}, got ${n.run.skill}`);if(await Qi(e.skillPackage)!==n.run.skillHash)return await Da(t,n.run.skillHash),{classic:r,run:n.run,evidence:await Xt(t,n),migrated:!1,snapshotDir:Be.join(t,".comet","skill-snapshots",n.run.skillHash)};let d=await Wa(e.skillPackage,t);return{classic:r,run:n.run,evidence:await Xt(t,n),migrated:!1,snapshotDir:d.snapshotDir}}let o=await Xt(t,n),s=Oi(r,o);if(!e.skillPackage.definition.orchestration.steps?.some(f=>f.id===s))throw new Error(`Classic Skill package does not define resolved step: ${s}`);let a=await Qi(e.skillPackage),c=Be.join(t,".comet","skill-snapshots",a),l=await Dd(c),u=[];try{let f=await Wa(e.skillPackage,t),d=pd(e.skillPackage,e.runId?.()??Xk(),f.hash);d.currentStep=s,s==="completed"&&(d.status="completed");let p={...r,classicProfile:i,classicMigration:St},g=await eb(t,o),m=await xe(t),h=o.find(b=>b.code==="design.handoff"&&b.satisfied),w=null;h?.source&&(w=await V(m,h.resolvedSource??h.source,{label:"Classic migration handoff context",hooks:e.handoffReadHooks}),await hd(t,d.contextRef,w),u.push(Be.resolve(t,d.contextRef))),await Ji(t,d.artifactsRef,g),u.push(Be.resolve(t,d.artifactsRef));let y=(e.now?.()??new Date).toISOString(),C={runId:d.runId,stateVersion:1,trajectoryOffset:2,contextHash:w===null?null:Md(w),artifactsHash:Qk(g),createdAt:y};await Yi(t,d.checkpointRef,C),u.push(Be.resolve(t,d.checkpointRef)),u.push(Be.resolve(t,d.trajectoryRef));for(let b of tb(d,i,y))await on(t,d.trajectoryRef,b);return await Et(t,{classic:p,run:d,unknownKeys:n.unknownKeys}),{classic:p,run:d,evidence:o,migrated:!0,snapshotDir:f.snapshotDir}}catch(f){throw await nb(u),l||await Ma.rm(c,{recursive:!0,force:!0}),f}}async function ib(t){try{return(await Bd.stat(t)).isDirectory()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Zi(t){try{return(await Bd.stat(t)).isFile()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function ob(t){return await ib(t)?await Zi(ce.join(t,"skill.yaml"))?!0:await Zi(ce.join(t,"SKILL.md"))&&await Zi(ce.join(t,"comet","skill.yaml")):!1}function sb(t){return{root:t,packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-classic",version:"1",description:"Internal compatibility orchestration for classic Comet full, hotfix, and tweak workflows"},goal:{statement:"Advance or restore a classic Comet Run without changing the user command surface",inputs:[{name:"classic-state",description:"Validated ClassicState consistent with the Run projection",required:!0},{name:"evidence",description:"Structured evidence produced by the Classic Evidence collector",required:!0}],outputs:[{name:"run-state",description:"Atomically synchronized Classic and Run state",required:!0}],success:["Legacy fields and Run fields remain consistent","Every step invokes only a declared public Comet Skill","The completed state passes its completion eval"]},orchestration:{mode:"deterministic",entry:"full.open",steps:[{id:"full.open",action:{type:"invoke_skill",ref:"comet-open"},next:"full.design.handoff"},{id:"full.design.handoff",action:{type:"invoke_skill",ref:"comet-design"},next:"full.design.document"},{id:"full.design.document",action:{type:"invoke_skill",ref:"comet-design"},next:"full.build.configure"},{id:"full.build.plan",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.plan-ready"},{id:"full.build.plan-ready",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.execute"},{id:"full.build.configure",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.plan"},{id:"full.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.complete"},{id:"full.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"full.verify.run"},{id:"full.build.fix",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.execute"},{id:"full.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"full.verify.branch"},{id:"full.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"full.archive.confirm"},{id:"full.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"full.archive.execute"},{id:"full.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"hotfix.open",action:{type:"invoke_skill",ref:"comet-hotfix"},next:"hotfix.build.execute"},{id:"hotfix.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"hotfix.build.complete"},{id:"hotfix.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"hotfix.verify.run"},{id:"hotfix.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"hotfix.verify.branch"},{id:"hotfix.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"hotfix.archive.confirm"},{id:"hotfix.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"hotfix.archive.execute"},{id:"hotfix.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"tweak.open",action:{type:"invoke_skill",ref:"comet-tweak"},next:"tweak.build.execute"},{id:"tweak.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"tweak.build.complete"},{id:"tweak.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"tweak.verify.run"},{id:"tweak.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"tweak.verify.branch"},{id:"tweak.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"tweak.archive.confirm"},{id:"tweak.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"tweak.archive.execute"},{id:"tweak.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"completed",action:{type:"checkpoint"},completionEvals:["classic-completed"]}]},skills:[{id:"comet-open"},{id:"comet-design"},{id:"comet-build"},{id:"comet-verify"},{id:"comet-archive"},{id:"comet-hotfix"},{id:"comet-tweak"}],agents:[],tools:[]},guardrails:{allowedSkills:["comet-open","comet-design","comet-build","comet-verify","comet-archive","comet-hotfix","comet-tweak"],allowedAgents:[],allowedTools:[],maxIterations:500,maxRetriesPerAction:3,confirmationRequiredFor:[]},evals:[{id:"classic-completed",scope:"completion",type:"state_equals",field:"status",equals:"completed"}]}}async function ab(){let t=ce.dirname(Ud(import.meta.url)),e=[process.env.COMET_RUNTIME_CLASSIC_ROOT,ce.resolve(t,"..","runtime","classic"),ce.resolve(t,"..","..","comet","runtime","classic"),ce.resolve(t,"..","..","assets","skills","comet","runtime","classic"),ce.resolve("assets","skills","comet","runtime","classic"),process.env.COMET_CLASSIC_SKILL_ROOT,ce.resolve(t,"..","..","comet-classic"),ce.resolve(t,"..","..","assets","skills","comet-classic"),ce.resolve("assets","skills","comet-classic")].filter(n=>!!n);for(let n of e)if(await ob(n))return n;return null}async function cb(t){return await Zi(ce.join(t,"skill.yaml"))?Od(t):Pd(t)}async function Kd(t){let e=await ab();return Fd(t,{skillPackage:e?await cb(e):sb(ce.dirname(Ud(import.meta.url)))})}async function Gd(t,e,n,r){return Re(t,()=>lb(t,e,n,r))}async function lb(t,e,n,r){let i=await Pe(t);if(!i.classic||!i.run)throw new Error("Classic transition requires synchronized Classic and Run projections");if(i.run.runId!==n.runId||i.run.iteration!==n.iteration||(e.checkEpoch??0)<(i.classic.checkEpoch??0))throw new Error("Classic transition became stale; reload the current state");let o=await Xt(t,{classic:e,run:n,unknownKeys:i.unknownKeys}),s=Oi(e,o),a={...n,currentStep:s,iteration:n.iteration+1,status:s==="completed"?"completed":"running"};await Et(t,{classic:e,run:a,unknownKeys:i.unknownKeys});let c=await or(t,a.trajectoryRef);return await on(t,a.trajectoryRef,{sequence:c.length+1,timestamp:new Date().toISOString(),type:"state_transitioned",runId:a.runId,data:{kind:"classic",fromStep:n.currentStep,toStep:s,...r}}),a}Bi();import ub from"path";var fb=ub.join(".comet","state-events.jsonl"),db=Number.MAX_SAFE_INTEGER;async function Hd(t,e){let n={schemaVersion:1,timestamp:new Date().toISOString(),...e};return await Mi(t,fb,`${JSON.stringify(n)}
|
|
169
|
+
`,db,"Classic state event log"),n}var zd=["open-complete","design-complete","build-complete","verify-pass","verify-fail","archive-confirm","archive-reopen","archived","preset-escalate"],mb={"open-complete":{event:"open-complete",from:"open",guardRefs:["open-artifacts-present"]},"design-complete":{event:"design-complete",from:"design",guardRefs:["design-evidence-present"]},"build-complete":{event:"build-complete",from:"build",guardRefs:["build-decisions-selected"]},"verify-pass":{event:"verify-pass",from:"verify",guardRefs:["verification-report-present"]},"verify-fail":{event:"verify-fail",from:"verify",guardRefs:["verification-failed"]},"archive-confirm":{event:"archive-confirm",from:"archive",guardRefs:["archive-final-confirmation"]},"archive-reopen":{event:"archive-reopen",from:"archive",guardRefs:["archive-not-finalized"]},archived:{event:"archived",from:"archive",guardRefs:["verify-result-pass","archive-confirmed"]},"preset-escalate":{event:"preset-escalate",from:"build",guardRefs:["preset-workflow"]}};function pb(t){return t.toISOString().slice(0,10)}function _(t,e,n,r){let i=t[n];t[n]=r,i!==r&&e.push({field:n,from:i,to:r})}function Jd(t,e,n={}){let r=mb[e];if(t.phase!==r.from)throw new Error(`Cannot apply ${e}: phase is '${t.phase}', expected '${r.from}'`);let i={...t},o=[],s=t.checkEpoch??0;if(!Number.isSafeInteger(s)||s<0||s===Number.MAX_SAFE_INTEGER)throw new Error("Invalid Classic check epoch");_(i,o,"checkEpoch",s+1);let a=n.now??new Date;if(e==="open-complete")_(i,o,"phase",i.workflow==="full"?"design":"build");else if(e==="design-complete")_(i,o,"phase","build");else if(e==="build-complete"){let c=i.verifyResult==="fail";_(i,o,"phase","verify"),_(i,o,"verifyResult","pending"),_(i,o,"branchStatus","pending"),c||_(i,o,"verificationReport",null)}else if(e==="verify-pass")_(i,o,"verifyResult","pass"),_(i,o,"verifyFailures",0),_(i,o,"phase","archive"),_(i,o,"verifiedAt",pb(a)),_(i,o,"archiveConfirmation","pending"),_(i,o,"branchStatus","pending");else if(e==="verify-fail")_(i,o,"verifyResult","fail"),_(i,o,"verifyFailures",i.verifyFailures+1),_(i,o,"phase","build"),_(i,o,"branchStatus","pending");else if(e==="preset-escalate"){if(i.workflow!=="hotfix"&&i.workflow!=="tweak")throw new Error(`Cannot apply ${e}: workflow must be hotfix or tweak, got '${i.workflow}'`);_(i,o,"workflow","full"),_(i,o,"classicProfile","full"),_(i,o,"phase","design"),_(i,o,"designDoc",null),_(i,o,"buildPause",null),_(i,o,"buildMode",null),_(i,o,"subagentDispatch",null),_(i,o,"tddMode",null),_(i,o,"reviewMode",null),_(i,o,"isolation",null),_(i,o,"boundBranch",null),_(i,o,"verifyMode",null),_(i,o,"directOverride",null)}else if(e==="archive-confirm"){if(i.verifyResult!=="pass")throw new Error(`Cannot apply ${e}: verifyResult must be pass`);if(i.archived)throw new Error(`Cannot apply ${e}: already archived`);_(i,o,"archiveConfirmation","confirmed")}else if(e==="archive-reopen"){if(i.archived)throw new Error(`Cannot apply ${e}: already archived`);_(i,o,"verifyResult","pending"),_(i,o,"verifyFailures",0),_(i,o,"phase","verify"),_(i,o,"verifiedAt",null),_(i,o,"archiveConfirmation",null),_(i,o,"branchStatus","pending")}else{if(i.verifyResult!=="pass")throw new Error(`Cannot apply ${e}: verifyResult must be pass`);if(i.archiveConfirmation!=="confirmed")throw new Error(`Cannot apply ${e}: archiveConfirmation must be confirmed`);_(i,o,"archived",!0)}return{classic:i,effects:o,definition:r}}Ra();Li();Vn();import{execFileSync as Yd}from"child_process";var hb=ve(pe(),1);Li();Ee();J();function gb(t){try{let e=bt(()=>Yd("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim());return e&&e!=="HEAD"?e:null}catch{return null}}var RP=Ea("liveGitBranch",t=>gb(t));function wb(t){try{return bt(()=>Yd("git",["rev-parse","--is-inside-work-tree"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim())==="true"}catch{return!1}}var PP=Ea("isGitWorkTree",t=>wb(t));var em=ve(pe(),1);Qn();import Ne from"node:path";import{createHash as no,randomUUID as jP}from"node:crypto";var yb=new Set(["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_GRAFT_FILE","GIT_SHALLOW_FILE","GIT_PREFIX","GIT_IMPLICIT_WORK_TREE","GIT_NO_REPLACE_OBJECTS","GIT_REPLACE_REF_BASE","GIT_CONFIG","GIT_CONFIG_PARAMETERS","GIT_CONFIG_COUNT"]);function vb(t=process.env){return Object.fromEntries(Object.entries(t).filter(([e])=>{let n=e.toUpperCase();return!yb.has(n)&&!/^GIT_CONFIG_(KEY|VALUE)_\d+$/u.test(n)}))}function Vd(t){return{...vb(t.environment),...t.authentication?{}:{GIT_CONFIG_GLOBAL:process.platform==="win32"?"NUL":"/dev/null",GIT_CONFIG_NOSYSTEM:"1"},GIT_TERMINAL_PROMPT:"0",GCM_INTERACTIVE:"never",SSH_ASKPASS_REQUIRE:"never",GIT_NO_REPLACE_OBJECTS:"1",GH_PROMPT_DISABLED:"1"}}function _t(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Classic progress requires a JSON object");return t}function Ba(t,e){let n=Object.keys(t).filter(r=>!e.includes(r));if(n.length)throw new Error(`Unknown Classic progress field(s): ${n.join(", ")}; allowed fields: ${e.join(", ")}`)}function Ae(t,e){if(typeof t!="string"||!t.trim()||t.length>4096||[...t].some(n=>n.charCodeAt(0)<32||n.charCodeAt(0)===127))throw new Error(`Invalid Classic progress ${e}`);return t}async function kb(t,e,n){let r=Ne.join(e,".comet",n);if(await Y(t,r,{label:"Classic progress",expected:"file"}))return JSON.parse(await V(t,r,{label:"Classic progress"}))}function bb(t,e){let n=no("sha256").update(e).digest("hex");return Ne.join(t,".comet","runtime","classic-delivery",`${n}.json`)}async function Cb(t,e){let n=bb(t,e);if(!await Y(t,n,{label:"Classic delivery reauthorization",expected:"file"}))return null;let r=_t(JSON.parse(await V(t,n,{label:"Classic delivery reauthorization"})));if(Ba(r,["schemaVersion","changeIdentity","previousAuthorizationId","authorizationId","action","targetBranch","remote","authorizedRemoteUrl"]),r.schemaVersion!==1||r.changeIdentity!==e)throw new Error("Classic delivery reauthorization identity is invalid");let i=Ua({action:r.action,targetBranch:r.targetBranch,...r.remote===void 0?{}:{remote:r.remote}},!0);if(i.commit!==void 0||i.prUrl!==void 0)throw new Error("Classic delivery reauthorization cannot change sealed commit or PR evidence");return{schemaVersion:1,changeIdentity:e,previousAuthorizationId:Ae(r.previousAuthorizationId,"previousAuthorizationId"),authorizationId:Ae(r.authorizationId,"authorizationId"),...i,...r.authorizedRemoteUrl===void 0?{}:{authorizedRemoteUrl:Ae(r.authorizedRemoteUrl,"authorizedRemoteUrl")}}}function Ua(t,e=!1){let n=_t(t);if(Ba(n,["action","targetBranch","remote","commit","prUrl",...e?["schemaVersion","changeIdentity","authorizedRemoteUrl","authorizationId"]:[]]),!["local","push","pr"].includes(n.action))throw new Error(`Invalid Classic delivery action '${String(n.action)}'; actions: local|push|pr`);let r=Ae(n.targetBranch,"targetBranch");if(r.startsWith("-")||/[~^:?*[\\\s]/u.test(r)||r.includes("..")||r.includes("@{"))throw new Error("Invalid Classic delivery targetBranch");let i={action:n.action,targetBranch:r};if(n.remote!==void 0){let o=Ae(n.remote,"remote");if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}$/u.test(o))throw new Error("Classic delivery remote must be a name, not a URL");i.remote=o}if(n.commit!==void 0){let o=Ae(n.commit,"commit");if(!/^(?:[a-fA-F0-9]{40}|[a-fA-F0-9]{64})$/u.test(o))throw new Error("Classic delivery commit must be a full object ID");i.commit=o.toLowerCase()}if(n.prUrl!==void 0){let o=Ae(n.prUrl,"prUrl"),s=new URL(o);if(s.protocol!=="https:"||s.username||s.password)throw new Error("Invalid Classic delivery prUrl");i.prUrl=o}return i}function tm(t){let e=(0,em.parseDocument)(t,{uniqueKeys:!0});if(e.errors.length)throw new Error("Invalid Classic delivery change state");return _t(e.toJS())}function nm(t,e){if(typeof t.run_id=="string"&&t.run_id)return`run:${t.run_id}`;let n=t.archived===!0?Ne.basename(e).replace(/^\d{4}-\d{2}-\d{2}-/u,""):Ne.basename(e);if(typeof t.created_at!="string"||typeof t.base_ref!="string")throw new Error("Classic delivery requires stable change identity");return`legacy:${no("sha256").update(JSON.stringify([n,t.created_at,t.base_ref])).digest("hex")}`}async function Sb(t,e){return tm(await V(t,Ne.join(e,".comet.yaml"),{label:"Classic delivery state"}))}var to=class extends Error{constructor(e,n){super(`Classic delivery git command timed out: ${[e,...n].join(" ")}`)}};function Fa(t,e,n,r){return If(e,n,{cwd:t,timeoutMs:5e3,env:Vd({authentication:r})}).trim()}function cr(t,e,n,r=!1){try{return Fa(t,e,n,r)}catch{return null}}function Eb(t,e,n,r=!1){try{return Fa(t,e,n,r)}catch(i){if(!(i instanceof Me)||!i.timedOut)return null;try{return Fa(t,e,n,r)}catch(o){if(o instanceof Me&&o.timedOut)throw new to(e,n);return null}}}function sr(t,e){return cr(t,"git",["-C",t,...e])}function ar(t,e){return Eb(t,"git",["-C",t,...e])}function Xd(t,e,n=!1){return cr(t,"git",["-C",t,"remote","get-url",...n?["--push"]:[],e],!0)}function xb(t,e){let n=Ne.relative(t,e).replaceAll("\\","/");return[`:(literal)${n}`,...[".comet-state.lock",".comet-state-transaction.json"].map(r=>`:(exclude,literal)${n}/${r}`)]}function Qd(t,e,n,r){let i=Ne.relative(t,e).replaceAll("\\","/"),o=xb(t,e),s=ar(t,["show",`${n}:${i}/.comet.yaml`]);if(!s)return!1;try{let a=tm(s);return a.archived===!0&&nm(a,e)===r&&ar(t,["merge-base","--is-ancestor",n,"HEAD"])!==null&&ar(t,["diff","--quiet","--no-ext-diff","--no-textconv",n,"--",...o])!==null&&ar(t,["ls-files","--others","--exclude-standard","--",...o])===""}catch(a){if(a instanceof to)throw a;return!1}}function _b(t,e){let n=`${no("sha256").update(e).digest("hex")}.json`,r=ar(t,["rev-parse","--path-format=absolute","--git-common-dir"]);return[{root:t,file:Ne.join(t,".comet","classic-deliveries",n)},...r?[{root:r,file:Ne.join(r,"comet","classic-deliveries",n)}]:[]]}async function Rb(t,e){let n=null;for(let r of _b(t,e)){if(!await Y(r.root,r.file,{label:"Classic delivery receipt",expected:"file"}))continue;let i=_t(JSON.parse(await V(r.root,r.file,{label:"Classic delivery receipt"})));if(Ba(i,["schemaVersion","changeIdentity","authorizationId","invalidated","commit","prUrl"]),i.schemaVersion!==1||i.changeIdentity!==e)throw new Error("Invalid Classic delivery receipt schema or identity");if(i.invalidated!==void 0&&typeof i.invalidated!="boolean")throw new Error("Invalid Classic delivery receipt invalidation");let o=Ua({action:"local",targetBranch:"main",...i.commit!==void 0?{commit:i.commit}:{},...i.prUrl!==void 0?{prUrl:i.prUrl}:{}}),s={schemaVersion:1,changeIdentity:e,authorizationId:Ae(i.authorizationId,"authorizationId"),...i.invalidated===!0?{invalidated:!0}:{},...o.commit?{commit:o.commit}:{},...o.prUrl?{prUrl:o.prUrl}:{}};if(n&&JSON.stringify(n)!==JSON.stringify(s))throw new Error("Conflicting Classic delivery receipts");n=s}return n}function Pb(t){return t.authorizationId===void 0?`legacy:${no("sha256").update(JSON.stringify(t)).digest("hex")}`:Ae(t.authorizationId,"authorizationId")}function Zd(t,e,n){return e===n||sr(t,["merge-base","--is-ancestor",e,n])!==null}function Ob(t){let e=/^git@([^:/]+):([^/]+\/[^/]+)$/u.exec(t);try{let n=new URL(e?`ssh://git@${e[1]}/${e[2]}`:t);if(!["https:","ssh:"].includes(n.protocol)||n.password||n.search||n.hash||n.port||n.protocol==="https:"&&n.username)return null;let r=n.pathname.replace(/\.git\/?$/u,"").replace(/\/$/u,"").split("/").filter(Boolean);return r.length!==2||r.some(i=>!/^[a-zA-Z0-9_.-]+$/u.test(i))?null:`${n.hostname}/${r.join("/")}`.toLowerCase()}catch{return null}}function eo(t,e){try{let n=new URL(t);if(n.protocol!=="https:"||n.username||n.password||n.port||n.search||n.hash)return null;let r=/^\/([^/]+)\/([^/]+)\/pull\/([1-9]\d*)\/?$/u.exec(n.pathname);return r&&`${n.hostname}/${r[1]}/${r[2]}`.toLowerCase()===e?`https://${n.hostname}/${r[1]}/${r[2]}/pull/${r[3]}`:null}catch{return null}}async function ro(t,e,n={}){let r=await kb(t,e,"delivery.json");if(r===void 0)return{delivery:null,verification:{status:"needsAuthorization"}};let i=_t(r);if(i.schemaVersion!==1)throw new Error("Unsupported Classic delivery schemaVersion");let o=Ua(i,!0),s=await Sb(t,e),a=nm(s,e);if(i.changeIdentity!==a)throw new Error("Classic delivery change identity mismatch");let c=Pb(i),l=await Cb(t,a);if(l&&l.previousAuthorizationId!==c)throw new Error("Classic delivery reauthorization is stale for the sealed authorization");let u=l?{action:l.action,targetBranch:l.targetBranch,...l.remote===void 0?{}:{remote:l.remote}}:o,f=l?.authorizationId??c,d=await Rb(t,a),p=d?.authorizationId===f?d:null;if(p?.invalidated)return{delivery:null,verification:{status:"needsAuthorization",invalidated:!0}};for(let U of["commit","prUrl"]){if(U==="commit"&&p?.[U]&&u[U]&&p[U]!==u[U])throw new Error("Classic delivery receipt conflicts with authorization evidence");p?.[U]&&(u[U]=p[U])}let g=i.authorizedRemoteUrl===void 0?void 0:Ae(i.authorizedRemoteUrl,"authorizedRemoteUrl"),m=l?.authorizedRemoteUrl??g,h={...u,schemaVersion:1,changeIdentity:a,authorizationId:f,...m?{authorizedRemoteUrl:m}:{}},w=sr(t,["symbolic-ref","--quiet","--short","HEAD"]),y=Ne.relative(t,e).replaceAll("\\","/"),C=null;!u.commit&&s.archived===!0&&(C=sr(t,["log","-20","--format=%H","HEAD","--",`:(literal)${y}/.comet.yaml`])?.split(/\r?\n/u).find(ye=>/^[a-f0-9]{40,64}$/u.test(ye)&&Qd(t,e,ye,a))??null);let b=u.commit??C,x=!!b&&sr(t,["cat-file","-t",b])==="commit",E=s.archived===!0&&x&&Qd(t,e,b,a),S=w===u.targetBranch&&(!s.bound_branch||l!==null||s.bound_branch===w)&&E,v=!1,R=!1,K=null,N=n.verifyRemote&&u.action!=="local"?"unavailable":"notChecked",A="notChecked";if(n.verifyRemote&&S&&u.action!=="local"&&u.remote&&m&&Xd(t,u.remote)===m&&Xd(t,u.remote,!0)===m){let U=`refs/heads/${u.targetBranch}`,ye=cr(t,"git",["-C",t,"-c","protocol.allow=never","-c","protocol.https.allow=always","-c","protocol.ssh.allow=always","-c","protocol.file.allow=always","ls-remote","--refs",u.remote,U],!0),an=ye?.split(/\r?\n/u)??[],Ja=an.length===1?/^([a-f0-9]{40}|[a-f0-9]{64})\t(.+)$/u.exec(an[0]):null,cn=Ja?.[2]===U?Ja[1]:null;v=!!b&&!!cn&&Zd(t,b,cn),N=v?"verified":ye===""?"missing":ye===null||!cn||sr(t,["cat-file","-t",cn])!=="commit"?"unavailable":"missing";let Ie=Ob(m),oo=Ie&&u.prUrl?eo(u.prUrl,Ie):null,so=v||ye==="",Ya=se=>se.headRefName===u.targetBranch&&typeof se.headRefOid=="string"&&/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(se.headRefOid)&&(v?se.headRefOid===cn&&["OPEN","MERGED"].includes(se.state):ye===""&&se.state==="MERGED"&&!!b&&Zd(t,b,se.headRefOid));if(so&&u.action==="pr"&&(A="unavailable"),so&&u.action==="pr"&&oo&&Ie){let se=cr(t,"gh",["pr","view",oo,"--repo",Ie,"--json","url,headRefName,headRefOid,state"],!0);try{let je=se?_t(JSON.parse(se)):null;R=!!je&&typeof je.url=="string"&&eo(je.url,Ie)===oo&&Ya(je),A=R?"verified":je?"missing":"unavailable"}catch{R=!1,A="unavailable"}}else if(so&&u.action==="pr"&&!u.prUrl&&Ie){let se=cr(t,"gh",["pr","list","--repo",Ie,"--head",u.targetBranch,"--state","all","--json","url,headRefName,headRefOid,state","--limit","100"],!0);try{let je=se===null?null:JSON.parse(se);if(!Array.isArray(je)||je.length>=100)throw new Error("Incomplete PR discovery");let ao=je.map(_t).filter(co=>typeof co.url=="string"&&eo(co.url,Ie)&&Ya(co));ao.length===1?(K=eo(ao[0].url,Ie),R=!0,A="verified"):A=ao.length===0?"missing":"unavailable"}catch{A="unavailable"}}}return{delivery:h,verification:{status:S&&(u.action==="local"||(u.action==="push"?v:R))?"complete":"needsVerification",currentBranch:w,commitExists:x,archiveCommitted:E,observedCommit:C,observedPrUrl:K,remoteVerified:v,prVerified:R,remoteStatus:N,prStatus:A}}}var Ab=ve(pe(),1);rm();Vn();Qn();import{AsyncLocalStorage as im}from"node:async_hooks";bi();var VP=new im,XP=new im;yt();ki();J();Se();Ee();var PO=$i("readCometCurrentSelection",t=>Di(t));async function om(t,e){return _a(t,"classic",e)}var Tb="\x1B[32m",Ib="\x1B[31m",jb="\x1B[33m",Ga="\x1B[0m";function fe(t){return`${Tb}${t}${Ga}`}function z(t){return`${Ib}${t}${Ga}`}function lr(t){return`${jb}${t}${Ga}`}var D=class extends Error{constructor(n,r=1){super(n);this.exitCode=r}exitCode},Ka=class{stderr=[];openSpecStdout=[];openSpecStderr=[];stepsOk=0;stepsTotal=0;envelope;captureOpenSpec(e){e.stdout&&this.openSpecStdout.push(e.stdout),e.stderr&&this.openSpecStderr.push(e.stderr)}finishEnvelope(e){this.envelope=Sf({name:e.name,stepsOk:this.stepsOk,stepsTotal:this.stepsTotal,dryRun:e.dryRun,locale:e.locale}),this.stderr.push(this.envelope.summary)}toResult(e=0){let n=this.stderr.length>0?this.stderr.join(`
|
|
157
170
|
`)+`
|
|
158
171
|
`:"",r=this.openSpecStderr.join(""),i=r&&n&&!r.endsWith(`
|
|
159
172
|
`)?`
|
|
160
|
-
`:"";return{exitCode:e,...this.openSpecStdout.length>0?{stdout:this.openSpecStdout.join("")}:{},...r||n?{stderr:`${r}${i}${n}`}:{},...this.envelope===void 0?{}:{envelope:this.envelope}}}};function
|
|
161
|
-
`)));let i=[["design_doc",n.classic.designDoc],["plan",n.classic.plan],["verification_report",n.classic.verificationReport],["handoff_context",n.classic.handoffContext]],o=await
|
|
162
|
-
`}function
|
|
173
|
+
`:"";return{exitCode:e,...this.openSpecStdout.length>0?{stdout:this.openSpecStdout.join("")}:{},...r||n?{stderr:`${r}${i}${n}`}:{},...this.envelope===void 0?{}:{envelope:this.envelope}}}};function $b(t){let e=pa(t);if(e)throw new D(z(`FATAL: ${e}`))}function am(t){return Nb("sha256").update(t).digest("hex")}function Lb(t){return am(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}function qb(t,e){let n=Te.relative(t,e);return n!==""&&!Te.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${Te.sep}`)}function Rt(t,e,n,r){if(!r)return r;let i=Te.resolve(t,r);return qb(e,i)?L(t,Te.join(n,Te.relative(e,i))):r}function Wb(t,e,n,r){let i={...r};for(let o of["handoff_context","handoff_markdown"]){let s=i[o];s&&(i[o]=Rt(t,e,n,s)??s)}return i}async function Db(t,e){let n=await Pe(e);if(!n.classic||!n.run||!n.classic.archived)throw new D(z(" [FAIL] Final archived state is incomplete"));let r=await bf(t,e);if(r.length)throw new D(z(r.join(`
|
|
174
|
+
`)));let i=[["design_doc",n.classic.designDoc],["plan",n.classic.plan],["verification_report",n.classic.verificationReport],["handoff_context",n.classic.handoffContext]],o=await $a(e,n.run.artifactsRef),s=[["artifacts.handoff_context",o.handoff_context],["artifacts.handoff_markdown",o.handoff_markdown]];for(let[a,c]of[...i,...s])if(c&&!await Y(t,Te.resolve(t,c),{label:`Classic archived ${a}`,expected:"file"}))throw new D(z(` [FAIL] Final archived ${a} does not exist: ${c}`))}function sm(t){return`${t.replace(/\n+$/u,"")}
|
|
175
|
+
`}function Mb(t,e,n){let r=t.replace(/\r\n/gu,`
|
|
163
176
|
`),i=r.split(`
|
|
164
|
-
`),o=i[0]==="---"?i.indexOf("---",1):-1,s=n.match(/^([^:\n]+):/u)?.[1]?.trim();if(o!==-1){let c=i.slice(1,o).filter(l=>{let u=l.match(/^([^:\n]+):/u)?.[1]?.trim();return u===void 0?!0:u!=="archived-with"&&u!==s});return c.push(`archived-with: ${e}`),n&&c.push(n),
|
|
165
|
-
`))}let a=["---",`archived-with: ${e}`];return n&&a.push(n),s!=="status"&&a.push("status: final"),a.push("---"),
|
|
166
|
-
`))}async function
|
|
177
|
+
`),o=i[0]==="---"?i.indexOf("---",1):-1,s=n.match(/^([^:\n]+):/u)?.[1]?.trim();if(o!==-1){let c=i.slice(1,o).filter(l=>{let u=l.match(/^([^:\n]+):/u)?.[1]?.trim();return u===void 0?!0:u!=="archived-with"&&u!==s});return c.push(`archived-with: ${e}`),n&&c.push(n),sm(["---",...c,"---",...i.slice(o+1)].join(`
|
|
178
|
+
`))}let a=["---",`archived-with: ${e}`];return n&&a.push(n),s!=="status"&&a.push("status: final"),a.push("---"),sm([...a,r].join(`
|
|
179
|
+
`))}async function Fb(t,e,n){let r=await or(t,e.trajectoryRef);r.some(i=>i.type==="recovery_reconciled"&&i.data.kind==="classic-archive"&&i.data.actionId===n)||await on(t,e.trajectoryRef,{sequence:r.length+1,timestamp:new Date().toISOString(),type:"recovery_reconciled",runId:e.runId,data:{kind:"classic-archive",actionId:n}})}async function io(t,e,n,r,i,o){if(!await Y(e,n,{label:"Classic archive annotation target",expected:"file"}))return;if(o){t.stderr.push(lr(` [DRY-RUN] Would annotate: ${n}`)),t.stepsOk+=1,t.stepsTotal+=1;return}let s=await V(e,n,{label:"Classic archive annotation target"}),a=Mb(s,r,i);await Ht(e,n,a,{label:"Classic archive annotation target"}),t.stderr.push(fe(` [OK] Annotated: ${n}`)),t.stepsOk+=1,t.stepsTotal+=1}async function Bb(t,e){if(!(await ge(t,e,{label:"Classic main specs directory",expected:"directory"})).exists)return;let r=!1;for(let i of await zt(t,e)){let s=(await V(t,i,{label:`Classic main spec ${i}`})).split(/\r?\n/u).map((a,c)=>({line:a,number:c+1})).filter(a=>/^## (ADDED|MODIFIED|REMOVED|RENAMED) Requirements$/u.test(a.line));if(s.length>0){r=!0,process.stderr.write(z(`FATAL: delta-only section heading leaked into main spec: ${i}`)+`
|
|
167
180
|
`);for(let a of s)process.stderr.write(`${a.number}:${a.line}
|
|
168
|
-
`)}}if(r)throw new D("")}var
|
|
169
|
-
`))e.stderr.push(o);return e.toResult(i.exitCode)}throw i}};var
|
|
181
|
+
`)}}if(r)throw new D("")}var Ha=async t=>{if(t.length<1||t.length>2||t[1]!==void 0&&t[1]!=="--dry-run")return{exitCode:64,stderr:"Usage: comet archive <change-name> [--dry-run]"};let e=new Ka,n=t[0],r=t[1]==="--dry-run";try{$b(n);let i=await xe(process.cwd()),o=await Kn(i),s=await Ri(n,o.projectRoot),a=s.directory,c=L(o.projectRoot,a),u=`${new Date().toISOString().slice(0,10)}-${n}`,f=Te.join(o.archiveDir,u);e.stderr.push(`=== Comet Archive: ${n} ===`);let d=s.stateExists,p=d?null:await Yt(n,o.projectRoot),g=d?a:p?.directory;if(!g||!await Y(o.projectRoot,`${g}/.comet.yaml`,{label:`Classic change ${n} state`,expected:"file"}))throw new D(z(`FATAL: .comet.yaml not found in ${c}/`));p&&(f=p.directory,u=Te.basename(p.directory));let m=await Pe(g);if(!m.classic)throw new D(z("FATAL: archive requires Classic state"));let h=m.classic,w=h.designDoc,y=h.plan;if(h.phase!=="archive")throw new D(z(`FATAL: phase is '${h.phase}', expected 'archive'`));if(h.verifyResult!=="pass")throw new D(z(`FATAL: verify_result is '${h.verifyResult}', expected 'pass'. Run comet-verify first.`));e.stderr.push(fe(" [OK] Entry state verified")),e.stepsOk+=1,e.stepsTotal+=1;let C=await ge(o.projectRoot,f,{label:`Classic archive target ${u}`,expected:"directory"});if(d&&C.exists)throw new D(z(`FATAL: archive target already exists: ${f}`));if(e.stderr.push(fe(" [OK] Archive target available")),e.stepsOk+=1,e.stepsTotal+=1,r)e.stderr.push(lr(` [DRY-RUN] Would run OpenSpec archive: ${n}`)),e.stepsOk+=1,e.stepsTotal+=1;else if(!h.archived||m.run?.pending){await Ei(o.projectRoot,`${g}/.comet`,"Classic change runtime directory");let b=`classic-archive:${n}`,x=await Re(g,async()=>{let S=await Kd(g);if(S.classic.phase!=="archive"||S.classic.verifyResult!=="pass")throw new D(z("FATAL: Archive state changed before preparing the pending action."));let v=await yd(g,S.run.pendingRef),R=!!p||v?.id===b&&v.type==="checkpoint"&&v.ref===n;if(S.run.pending&&S.run.pending!==b)throw new D(z(`FATAL: another action is pending: ${S.run.pending}`));if(!R&&!S.classic.archived&&S.classic.archiveConfirmation!=="confirmed")throw new D(z(`FATAL: archive_confirmation is '${h.archiveConfirmation??"null"}', expected 'confirmed'. Run final archive confirmation first.`));if(!R){await kf(o.projectRoot,g);let K={id:b,stepId:S.run.currentStep,type:"checkpoint",ref:n};await wd(g,S.run.pendingRef,K);let N=await Pe(g);if(!N.classic||!N.run||N.run.runId!==S.run.runId||N.classic.phase!=="archive"||N.classic.verifyResult!=="pass"||N.classic.archiveConfirmation!=="confirmed")throw new D(z("FATAL: Archive state changed while preparing the pending action."));await Et(g,{classic:N.classic,run:{...N.run,pending:b,status:"waiting"},unknownKeys:N.unknownKeys})}return R});if(!p){let S=await xi(["archive",n,"--yes"],o.projectRoot);if(e.captureOpenSpec(S),S.exitCode!==0)throw new D("",S.exitCode)}let E=await Yt(n,o.projectRoot,{preferredArchiveName:u});if(!E&&!p&&(E=await Yt(n,o.projectRoot,{skipExactCompatibility:!0})),!E)return e.stderr.push(z(" [FAIL] OpenSpec archive output not found")),e.stepsTotal+=1,e.stderr.push(""),e.finishEnvelope({name:n,dryRun:r,locale:ha(h.language)}),e.stderr.push(fe(`Archive complete. ${e.stepsOk}/${e.stepsTotal} steps succeeded.`)),e.toResult(1);f=E.directory,u=Te.basename(E.directory),e.stderr.push(fe(` [OK] OpenSpec archive completed: ${f}`)),e.stepsOk+=1,e.stepsTotal+=1,await Bb(o.projectRoot,o.specsDir),e.stderr.push(fe(" [OK] Main specs verified clean")),e.stepsOk+=1,e.stepsTotal+=1,w&&await io(e,o.projectRoot,Rt(o.projectRoot,a,f,w),u,"status: final",!1),y&&await io(e,o.projectRoot,Rt(o.projectRoot,a,f,y),u,"",!1),await Re(f,async()=>{let S=await Pe(f);if(!S.classic||!S.run)throw new D(z(" [FAIL] archived state projection is incomplete"));let v={...Wb(o.projectRoot,a,f,await $a(f,S.run.artifactsRef)),archive_directory:L(o.projectRoot,f)};await Ji(f,S.run.artifactsRef,v);let R=Jd(x&&S.classic.archiveConfirmation!=="confirmed"?{...S.classic,archiveConfirmation:"confirmed"}:S.classic,"archived"),K={...R.classic,designDoc:Rt(o.projectRoot,a,f,R.classic.designDoc),plan:Rt(o.projectRoot,a,f,R.classic.plan),verificationReport:Rt(o.projectRoot,a,f,R.classic.verificationReport),handoffContext:Rt(o.projectRoot,a,f,R.classic.handoffContext)},N=S.run;(S.run.currentStep!=="completed"||S.run.status!=="completed")&&(N=await Gd(f,K,S.run,{actionId:b,archiveDirectory:L(o.projectRoot,f),event:"archived",source:"comet-archive"})),x&&await Fb(f,N,b);let A=await or(f,N.trajectoryRef),U=await gd(f,N.contextRef),ye={runId:N.runId,stateVersion:N.iteration,trajectoryOffset:A.length,contextHash:U===null?null:am(U),artifactsHash:Lb(v),createdAt:new Date().toISOString()};await Yi(f,N.checkpointRef,ye);let an={...N,pending:null,status:"completed"};await Et(f,{classic:K,run:an,unknownKeys:S.unknownKeys}),await Hd(f,{change:u,event:"archived",source:"comet-archive",from:S.classic,to:K,effects:R.effects}),await vd(f,an.pendingRef)}),e.stderr.push(fe(" [OK] archived: true")),e.stepsOk+=1,e.stepsTotal+=1}else{if(!m.run)throw new D(z("FATAL: archived Classic state is missing its Run projection"));e.stderr.push(fe(` [OK] OpenSpec archive completed: ${f}`)),e.stepsOk+=1,e.stepsTotal+=1,e.stderr.push(fe(" [OK] Main specs verified clean")),e.stepsOk+=1,e.stepsTotal+=1,e.stderr.push(fe(" [OK] archived: true")),e.stepsOk+=1,e.stepsTotal+=1}if(r?(w&&await io(e,o.projectRoot,w,u,"status: final",!0),y&&await io(e,o.projectRoot,y,u,"",!0),e.stderr.push(lr(` [DRY-RUN] Would set archived: true in ${f}/.comet.yaml`)),e.stepsOk+=1,e.stepsTotal+=1,e.stderr.push(lr(" [DRY-RUN] Would verify final archive integrity")),e.stepsOk+=1,e.stepsTotal+=1):(await Db(o.projectRoot,f),e.stderr.push(fe(" [OK] Final archive integrity verified")),e.stepsOk+=1,e.stepsTotal+=1),!r){let b=await ro(o.projectRoot,f);["complete","local-verified"].includes(b.verification.status)&&await om(o.projectRoot,n)}return e.stderr.push(""),e.finishEnvelope({name:n,dryRun:r,locale:ha(h.language)}),e.stderr.push(r?lr(`Dry run complete. ${e.stepsOk}/${e.stepsTotal} steps would succeed.`):fe(`Archive complete. ${e.stepsOk}/${e.stepsTotal} steps succeeded.`)),e.toResult(e.stepsOk<e.stepsTotal?1:0)}catch(i){if(i instanceof D){if(i.message)for(let o of i.message.split(`
|
|
182
|
+
`))e.stderr.push(o);return e.toResult(i.exitCode)}throw i}};import{realpathSync as Gb}from"fs";import{pathToFileURL as um}from"url";var Ub=new Set([...rr,"archive_confirmation","verify_failures","check_epoch","classic_profile","classic_migration","bound_branch"]),cm=new Set(ct.filter(t=>!Ub.has(t))),za={workflow:["full","hotfix","tweak"],phase:["open","design","build","verify","archive"],context_compression:["off","beta"],build_mode:["subagent-driven-development","executing-plans","direct","autonomous"],build_pause:["null","plan-ready"],subagent_dispatch:["null","confirmed"],tdd_mode:["tdd","direct"],review_mode:["off","standard","thorough"],isolation:["current","branch","worktree"],verify_mode:["light","full"],auto_transition:["true","false"],verify_result:["pending","pass","fail"],branch_status:["pending","handled"],archive_confirmation:["pending","confirmed"],archived:["true","false"],direct_override:["true","false"],classic_profile:["full","hotfix","tweak"],classic_migration:["1"]};var Kb=`
|
|
170
183
|
Options: --json (machine-readable output), --help
|
|
171
184
|
JSON: one object with command and exitCode; data, stdout, stderr, summary and next are optional.
|
|
172
185
|
Use exitCode for success; do not parse human-readable stdout. Help text is in stdout in JSON mode.
|
|
173
|
-
`;function Bd(t,e){let n=e.indexOf("--"),r=n<0?e:e.slice(0,n);if(!r.includes("--help")&&!r.includes("-h"))return;let i={check:["comet check run <change> <build|verify> [--local] [--incremental] [--cwd <path>] [--timeout-ms <ms>] -- <program> [args...]","comet check rerun <change> <build|verify>","--local opts deterministic local checks into same-input reuse; other checks are single-use.","--incremental records phase-local evidence: guard previews accept it, --apply requires a full rerun.","Arguments after -- belong to the child. Windows batch arguments containing shell syntax are rejected.","","Executes a program for an active change and stores its log and input-bound evidence.","--local is not a location switch: all checks execute locally. It asserts deterministic inputs.","Use --local only when no network, external state or untracked ignored inputs affect the result.","Default evidence is single-use; reusable evidence requires matching inputs, environment and log.","--cwd: relative to the project root; default is the invocation directory; must stay inside the project.","Guard reuses evidence only when its cwd matches the guard invocation directory, or the command is declared with that cwd in a v2 check policy.","--timeout-ms: default 300000; integer range 1..3600000.","Place Comet options, including --json, before --. Child --help and --json after -- are forwarded.","","Result: data.scope, data.argv, data.cwd, data.exitCode, data.logRef, data.reusable; data.reused is optional.","Exit: 0 = success with stable inputs; child failures propagate; timeout = 124; invalid invocation/runtime error = 70.","A child exit of 0 with changed inputs returns exitCode 1. Use top-level exitCode, not data.exitCode.","On failure inspect data.logRef or stderr, fix the cause, then rerun. Recovery revalidates local evidence.","rerun repeats the latest Runtime-recorded argv, cwd, timeout and reuse tier without reconstructing shell syntax.","Optional .comet/check-policy.json binds declared deterministic commands by exact argv and cwd.",'A v1 single-command object stays valid; v2 {"commands":[...]} scopes each command separately.',"Editing one v2 command entry invalidates only that command's evidence; unmatched commands stay conservative.",'Default inputs are the working-tree files. Declare git: "all" for builds that read HEAD or the index,','env variable names whose values affect the result, and taskCheckboxes: "include" when completion marks matter.',"files accept literal paths and * ? ** globs; a new file matching a glob is checked without re-declaring.","Declare every real input; do not infer dependencies from the current diff.",'Policy example: {"version":2,"commands":[{"argv":["node","scripts/build.mjs"],"cwd":".","files":["src/**","package.json"],"git":"all"},{"argv":["node","--test"],"cwd":".","files":["src/**","test/**"],"taskCheckboxes":"ignore"}]}',"Build evidence does not substitute for verify evidence. A successful check does not advance the phase.","","Examples: (replace demo with your active change; these commands execute code)"," comet check run demo verify --json -- node --test"," comet check run demo build --local --cwd . -- npm run build"," comet check rerun demo build"],state:["comet state <command> [args]","init <change-name> <full|hotfix|tweak> [--isolation <current|branch|worktree>]","get <change-name> <field>","set <change-name> <field> <value> [<field> <value> ...]","complete-design <change-name> --design-doc <repo-relative-ref>","transition <change-name> <event>","check <change-name> <phase> [--recover] [--details]","scale <change-name>","artifacts <change-name>","record-check <change-name> <build|verify> --command <text> --exit-code <int> [--cwd <path>]","task-checkoff <file> <task-text>","tasks <change-name> [--assign-ids]","task-complete <change-name> <task-id> --expect <revision>","sync-plan <change-name>","checkpoint <change-name> [--file <json>]","delivery <change-name> [--file <json> | --verify]","select <change-name> | rebind <change-name> | next <change-name>","current | clear-selection","","Start with current or next <change-name> to inspect workflow guidance.","Advanced writes: init, set, transition, task-checkoff, select, rebind, clear-selection.","Use comet state <command> --help for details. --recover is for cold recovery, not normal progression.","After explicit design confirmation, complete-design registers the reference, refreshes handoff, and applies the guard; interrupted retries retain completed work.","Use data.artifactRefs for state references and task-authority markers; absolute paths are for file operations."],guard:["comet guard <change-name> <open|design|build|verify|archive> [--apply]","Validates phase requirements; --apply advances the phase after all checks pass.","Without --apply the phase stays unchanged, but this is NOT a read-only preview:","Build validation may execute a detected build and write evidence/logs.","Preview does not consume single-use evidence. Successful phase advancement consumes it atomically.","Failed or repeated previews preserve evidence; changed inputs still require a new check.","Do not poll guard for status. Use comet state next <change-name> for guidance.","On failure follow the reported next action; do not blindly retry side-effecting checks.","","Examples:"," comet guard demo build --apply --json"," comet state next demo --json"],handoff:["comet handoff <change-name> design --write [--full]","comet handoff <change-name> --hash-only"],archive:["comet archive <change-name> [--dry-run]"],validate:["comet classic validate <change-name>"],workspace:["comet classic workspace prepare <change-name> --isolation <current|branch|worktree> [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]","comet classic workspace resolve <change-name>"]},o={current:["comet state current","Reports the selected Classic change. Does not advance the phase."],next:["comet state next <change-name>","Reports the next workflow action. Does not execute build or verification checks."],select:["comet state select <change-name>","Writes the current change selection used by workflow routing."],rebind:["comet state rebind <change-name>","Updates the change branch binding to the current Git branch after validation."],"clear-selection":["comet state clear-selection","Clears the current change selection; does not delete change artifacts."],init:["comet state init <change-name> <full|hotfix|tweak> [--isolation <current|branch|worktree>]","Creates Classic workflow state. Follow the Open workflow for required user decisions."],scale:["comet state scale <change-name>","Reports a verification recommendation without changing verify_mode.","JSON: data.recommendation, data.selected and data.metrics. Scale is not a risk assessment.","Preserve an existing selection; record a new decision explicitly with state set when needed."],artifacts:["comet state artifacts <change-name>","Inspects the OpenSpec apply dependency closure, including dependencies of already-complete artifacts.","JSON: data.source, required, skipped, designRequired, files and problems. This does not execute implementation or verification.","Optional design is omitted only when the active schema excludes it from the required closure.","Skipped specs require explicit skip_specs: true, upstream support and no conflicting spec files.","Legacy changes without .openspec.yaml retain the existing Classic artifact requirements."],"task-checkoff":["comet state task-checkoff <file> <task-text>","Checks that exactly one matching task is already checked. Does not write the task file or execute the task."],tasks:["comet state tasks <change-name> [--assign-ids]","Reads tasks.md as the task completion authority. Fenced examples are excluded.","--assign-ids persists IDs for legacy/new tasks in Open, Design or Build; existing IDs remain unchanged.","Assign IDs before generating the design handoff and plan. ID assignment changes task requirements.","JSON: data.authority, data.revision, data.needsIds, data.tasks and data.progress.","Each task has id, text, completed and line. Never use line/order as task identity.","Example: comet state tasks demo --assign-ids --json"],"task-complete":["comet state task-complete <change-name> <task-id> --expect <revision>","Records accepted task completion during Build; does not execute or independently verify work.","Use the revision returned by state tasks. Changed requirements reject the write; refresh and reassess the task.","Writes tasks.md under the state lock and synchronizes explicitly ID-mapped legacy plan checkboxes. Retries repair interrupted projection writes.","Reconcile code, checks and review evidence before recording completion; unchecked does not mean unimplemented.","Unmapped legacy items are preserved and reported as mapping-required; never match tasks by position or wording."],"sync-plan":["comet state sync-plan <change-name>","Synchronizes legacy plan checkboxes from tasks.md by explicit comet-task IDs; does not execute or accept work.","Rejects missing or unknown plan IDs. Reconcile extra requirements into tasks.md before mapping.","New plans should reference task IDs without a second completion checklist."],checkpoint:["comet state checkpoint <change-name> [--file <json>]","Reads a structured coordination checkpoint, or records an explicitly bounded work package during Build.","Input: taskIds, revision, stage, sessionId, evidence, unresolved, reviewRounds.","Include schemaVersion: 1. JSON state is .comet/coordination.json, separate from the Engine checkpoint.","Stages: implementing|task-review|checkoff|done|blocked. Evidence is a coordination record, not automatic acceptance.","Runtime checks task IDs and revision and renders subagent-progress.md. Do not maintain its projection manually."],delivery:["comet state delivery <change-name> [--file <json> | --verify]","Reads delivery authorization and observed progress, or records the user-authorized local|push|pr action.","Input: action, targetBranch, optional remote, commit and prUrl. Recording never performs remote writes.","First authorization requires Archive with passing verification before archival. Missing legacy authorization is never inferred.","Resume only authorized unfinished steps; supplied commit or PR text alone does not prove delivery.","--verify performs bounded read-only remote/PR verification; normal entry never contacts the network."],get:["comet state get <change-name> <field>","Reads one stored field. The field value is returned in stdout, including in JSON mode.",`Fields: ${[...rt,...Hn].join(", ")}`,"Example: comet state get demo phase --json"],set:["comet state set <change-name> <field> <value> [<field> <value> ...]","Advanced: validates all fields, then commits one atomic state update and reconciles Runtime state.","Invalid values or duplicate fields reject the whole update. Do not bypass workflow confirmations.","JSON: data.change and data.updated contain the committed field values.","Writable fields (enum values shown where applicable):",...[...Md].map(c=>` ${c}${Ta[c]?`: ${Ta[c].join("|")}`:c==="language"?": en|zh-CN":""}`),"Other Runtime-owned fields cannot be set manually. Artifact paths must stay within the project.","Example: comet state set demo verify_mode full","Example: comet state set demo build_mode executing-plans tdd_mode direct review_mode standard --json"],check:["comet state check <change-name> <open|design|build|verify|archive> [--recover] [--details]","Checks phase entry requirements; this is not a build/test execution command.","--recover is for cold recovery after context loss, not normal phase progression.","Recovery revalidates reusable local evidence and invalidates stale, damaged or single-use evidence.","It preserves completed work; resume from the checkpoint and rerun required checks before progressing.","JSON entry data includes layout, configuration, configurationReadiness, nextAction, compact taskState, planMapping and checks.","--recover additionally revalidates evidence and includes checkpoint references; --details expands tasks and checkpoint content.","Reconcile existing implementation and acceptance before dispatching work; unchecked tasks are not proof of missing implementation.","Read fresh state after changing configuration or advancing phases; do not reuse an earlier entry snapshot.","","Examples:"," comet state check demo build --json"," comet state check demo build --recover --json"],"record-check":["comet state record-check <change> <build|verify> --command <text> --exit-code <int> [--cwd <path>]","Advanced: writes a manual attestation; does not execute the command.","A manual attestation cannot satisfy Runtime build/verify evidence requirements, even with exit code 0.","Use comet check run to execute a check and obtain evidence that guard can validate.","--cwd: relative to project root, defaults to .; must stay inside the project.","","Examples:",' comet state record-check demo verify --command "external test run" --exit-code 1'," comet check run demo verify --json -- node --test"],transition:["comet state transition <change-name> <event>",`Events: ${xd.join(", ")}`,"Advanced: applies a state-machine event and writes workflow state. Required confirmations still apply.","This is not a substitute for the workflow Skill or phase guard. Use state next for the next action."]},s=r.find(c=>!c.startsWith("-")),a=t==="state"&&s&&o[s]||i[t];return a?`Usage: ${a.join(`
|
|
186
|
+
`;function lm(t,e){let n=e.indexOf("--"),r=n<0?e:e.slice(0,n);if(!r.includes("--help")&&!r.includes("-h"))return;let i={check:["comet check run <change> <build|verify> [--local] [--incremental] [--cwd <path>] [--timeout-ms <ms>] -- <program> [args...]","comet check rerun <change> <build|verify>","--local opts deterministic local checks into same-input reuse; other checks are single-use.","--incremental records phase-local evidence: guard previews accept it, --apply requires a full rerun.","Arguments after -- belong to the child. Windows batch arguments containing shell syntax are rejected.","","Executes a program for an active change and stores its log and input-bound evidence.","--local is not a location switch: all checks execute locally. It asserts deterministic inputs.","Use --local only when no network, external state or untracked ignored inputs affect the result.","Default evidence is single-use; reusable evidence requires matching inputs, environment and log.","--cwd: relative to the project root; default is the invocation directory; must stay inside the project.","Guard reuses evidence only when its cwd matches the guard invocation directory, or the command is declared with that cwd in a v2 check policy.","--timeout-ms: default 300000; integer range 1..3600000.","Place Comet options, including --json, before --. Child --help and --json after -- are forwarded.","","Result: data.scope, data.argv, data.cwd, data.exitCode, data.logRef, data.reusable; data.reused is optional.","Exit: 0 = success with stable inputs; child failures propagate; timeout = 124; invalid invocation/runtime error = 70.","A child exit of 0 with changed inputs returns exitCode 1. Use top-level exitCode, not data.exitCode.","On failure inspect data.logRef or stderr, fix the cause, then rerun. Recovery revalidates local evidence.","rerun repeats the latest Runtime-recorded argv, cwd, timeout and reuse tier without reconstructing shell syntax.","Optional .comet/check-policy.json binds declared deterministic commands by exact argv and cwd.",'A v1 single-command object stays valid; v2 {"commands":[...]} scopes each command separately.',"Editing one v2 command entry invalidates only that command's evidence; unmatched commands stay conservative.",'Default inputs are the working-tree files. Declare git: "all" for builds that read HEAD or the index,','env variable names whose values affect the result, and taskCheckboxes: "include" when completion marks matter.',"files accept literal paths and * ? ** globs; a new file matching a glob is checked without re-declaring.","Declare every real input; do not infer dependencies from the current diff.",'Policy example: {"version":2,"commands":[{"argv":["node","scripts/build.mjs"],"cwd":".","files":["src/**","package.json"],"git":"all"},{"argv":["node","--test"],"cwd":".","files":["src/**","test/**"],"taskCheckboxes":"ignore"}]}',"Build evidence does not substitute for verify evidence. A successful check does not advance the phase.","","Examples: (replace demo with your active change; these commands execute code)"," comet check run demo verify --json -- node --test"," comet check run demo build --local --cwd . -- npm run build"," comet check rerun demo build"],state:["comet state <command> [args]","init <change-name> <full|hotfix|tweak> [--isolation <current|branch|worktree>]","get <change-name> <field>","set <change-name> <field> <value> [<field> <value> ...]","complete-design <change-name> --design-doc <repo-relative-ref>","transition <change-name> <event>","check <change-name> <phase> [--recover] [--details]","scale <change-name>","artifacts <change-name>","record-check <change-name> <build|verify> --command <text> --exit-code <int> [--cwd <path>]","task-checkoff <file> <task-text>","tasks <change-name> [--assign-ids]","task-complete <change-name> <task-id> --expect <revision>","sync-plan <change-name>","checkpoint <change-name> [--file <json>]","delivery <change-name> [--file <json> | --verify]","select <change-name> | rebind <change-name> | next <change-name>","current | clear-selection","","Start with current or next <change-name> to inspect workflow guidance.","Advanced writes: init, set, transition, task-checkoff, select, rebind, clear-selection.","Use comet state <command> --help for details. --recover is for cold recovery, not normal progression.","After explicit design confirmation, complete-design registers the reference, refreshes handoff, and applies the guard; interrupted retries retain completed work.","Use data.artifactRefs for state references and task-authority markers; absolute paths are for file operations."],guard:["comet guard <change-name> <open|design|build|verify|archive> [--apply]","Validates phase requirements; --apply advances the phase after all checks pass.","Without --apply the phase stays unchanged, but this is NOT a read-only preview:","Build validation may execute a detected build and write evidence/logs.","Preview does not consume single-use evidence. Successful phase advancement consumes it atomically.","Failed or repeated previews preserve evidence; changed inputs still require a new check.","Do not poll guard for status. Use comet state next <change-name> for guidance.","On failure follow the reported next action; do not blindly retry side-effecting checks.","","Examples:"," comet guard demo build --apply --json"," comet state next demo --json"],handoff:["comet handoff <change-name> design --write [--full]","comet handoff <change-name> --hash-only"],archive:["comet archive <change-name> [--dry-run]"],validate:["comet classic validate <change-name>"],workspace:["comet classic workspace prepare <change-name> --isolation <current|branch|worktree> [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]","comet classic workspace resolve <change-name>"]},o={current:["comet state current","Reports the selected Classic change. Does not advance the phase."],next:["comet state next <change-name>","Reports the next workflow action. Does not execute build or verification checks."],select:["comet state select <change-name>","Writes the current change selection used by workflow routing."],rebind:["comet state rebind <change-name>","Updates the change branch binding to the current Git branch after validation."],"clear-selection":["comet state clear-selection","Clears the current change selection; does not delete change artifacts."],init:["comet state init <change-name> <full|hotfix|tweak> [--isolation <current|branch|worktree>]","Creates Classic workflow state. Follow the Open workflow for required user decisions."],scale:["comet state scale <change-name>","Reports a verification recommendation without changing verify_mode.","JSON: data.recommendation, data.selected and data.metrics. Scale is not a risk assessment.","Preserve an existing selection; record a new decision explicitly with state set when needed."],artifacts:["comet state artifacts <change-name>","Inspects the OpenSpec apply dependency closure, including dependencies of already-complete artifacts.","JSON: data.source, required, skipped, designRequired, files and problems. This does not execute implementation or verification.","Optional design is omitted only when the active schema excludes it from the required closure.","Skipped specs require explicit skip_specs: true, upstream support and no conflicting spec files.","Legacy changes without .openspec.yaml retain the existing Classic artifact requirements."],"task-checkoff":["comet state task-checkoff <file> <task-text>","Checks that exactly one matching task is already checked. Does not write the task file or execute the task."],tasks:["comet state tasks <change-name> [--assign-ids]","Reads tasks.md as the task completion authority. Fenced examples are excluded.","--assign-ids persists IDs for legacy/new tasks in Open, Design or Build; existing IDs remain unchanged.","Assign IDs before generating the design handoff and plan. ID assignment changes task requirements.","JSON: data.authority, data.revision, data.needsIds, data.tasks and data.progress.","Each task has id, text, completed and line. Never use line/order as task identity.","Example: comet state tasks demo --assign-ids --json"],"task-complete":["comet state task-complete <change-name> <task-id> --expect <revision>","Records accepted task completion during Build; does not execute or independently verify work.","Use the revision returned by state tasks. Changed requirements reject the write; refresh and reassess the task.","Writes tasks.md under the state lock and synchronizes explicitly ID-mapped legacy plan checkboxes. Retries repair interrupted projection writes.","Reconcile code, checks and review evidence before recording completion; unchecked does not mean unimplemented.","Unmapped legacy items are preserved and reported as mapping-required; never match tasks by position or wording."],"sync-plan":["comet state sync-plan <change-name>","Synchronizes legacy plan checkboxes from tasks.md by explicit comet-task IDs; does not execute or accept work.","Rejects missing or unknown plan IDs. Reconcile extra requirements into tasks.md before mapping.","New plans should reference task IDs without a second completion checklist."],checkpoint:["comet state checkpoint <change-name> [--file <json>]","Reads a structured coordination checkpoint, or records an explicitly bounded work package during Build.","Input: taskIds, revision, stage, sessionId, evidence, unresolved, reviewRounds.","Include schemaVersion: 1. JSON state is .comet/coordination.json, separate from the Engine checkpoint.","Stages: implementing|task-review|checkoff|done|blocked. Evidence is a coordination record, not automatic acceptance.","Runtime checks task IDs and revision and renders subagent-progress.md. Do not maintain its projection manually."],delivery:["comet state delivery <change-name> [--file <json> | --verify]","Reads delivery authorization and observed progress, or records the user-authorized local|push|pr action.","Input: action, targetBranch, optional remote, commit and prUrl. Recording never performs remote writes.","First authorization requires Archive with passing verification before archival. Missing legacy authorization is never inferred.","Resume only authorized unfinished steps; supplied commit or PR text alone does not prove delivery.","--verify performs bounded read-only remote/PR verification; normal entry never contacts the network."],get:["comet state get <change-name> <field>","Reads one stored field. The field value is returned in stdout, including in JSON mode.",`Fields: ${[...ct,...rr].join(", ")}`,"Example: comet state get demo phase --json"],set:["comet state set <change-name> <field> <value> [<field> <value> ...]","Advanced: validates all fields, then commits one atomic state update and reconciles Runtime state.","Invalid values or duplicate fields reject the whole update. Do not bypass workflow confirmations.","JSON: data.change and data.updated contain the committed field values.","Writable fields (enum values shown where applicable):",...[...cm].map(c=>` ${c}${za[c]?`: ${za[c].join("|")}`:c==="language"?": en|zh-CN":""}`),"Other Runtime-owned fields cannot be set manually. Artifact paths must stay within the project.","Example: comet state set demo verify_mode full","Example: comet state set demo build_mode executing-plans tdd_mode direct review_mode standard --json"],check:["comet state check <change-name> <open|design|build|verify|archive> [--recover] [--details]","Checks phase entry requirements; this is not a build/test execution command.","--recover is for cold recovery after context loss, not normal phase progression.","Recovery revalidates reusable local evidence and invalidates stale, damaged or single-use evidence.","It preserves completed work; resume from the checkpoint and rerun required checks before progressing.","JSON entry data includes layout, configuration, configurationReadiness, nextAction, compact taskState, planMapping and checks.","--recover additionally revalidates evidence and includes checkpoint references; --details expands tasks and checkpoint content.","Reconcile existing implementation and acceptance before dispatching work; unchecked tasks are not proof of missing implementation.","Read fresh state after changing configuration or advancing phases; do not reuse an earlier entry snapshot.","","Examples:"," comet state check demo build --json"," comet state check demo build --recover --json"],"record-check":["comet state record-check <change> <build|verify> --command <text> --exit-code <int> [--cwd <path>]","Advanced: writes a manual attestation; does not execute the command.","A manual attestation cannot satisfy Runtime build/verify evidence requirements, even with exit code 0.","Use comet check run to execute a check and obtain evidence that guard can validate.","--cwd: relative to project root, defaults to .; must stay inside the project.","","Examples:",' comet state record-check demo verify --command "external test run" --exit-code 1'," comet check run demo verify --json -- node --test"],transition:["comet state transition <change-name> <event>",`Events: ${zd.join(", ")}`,"Advanced: applies a state-machine event and writes workflow state. Required confirmations still apply.","This is not a substitute for the workflow Skill or phase guard. Use state next for the next action."]},s=r.find(c=>!c.startsWith("-")),a=t==="state"&&s&&o[s]||i[t];return a?`Usage: ${a.join(`
|
|
174
187
|
`)}
|
|
175
|
-
${
|
|
176
|
-
`:void 0}function
|
|
177
|
-
`,...e.envelope===void 0?{}:{envelope:e.envelope}}}async function
|
|
188
|
+
${Kb}Command placeholders must be replaced with actual values.
|
|
189
|
+
`:void 0}function Hb(t,e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:t,exitCode:e.exitCode,agent:fa(e.data),...e.data===void 0?{}:{data:e.data},...e.envelope===void 0?{}:{summary:e.envelope.summary,...e.envelope.next===void 0?{}:{next:e.envelope.next},...e.envelope.user_message===void 0?{}:{user_message:e.envelope.user_message}},...e.stdout===void 0?{}:{stdout:e.stdout},...e.stderr===void 0?{}:{stderr:e.stderr}})+`
|
|
190
|
+
`,...e.envelope===void 0?{}:{envelope:e.envelope}}}async function fm(t,e,n,r={}){let i=n.indexOf("--"),o=l=>i<0||l<i,s=n.some((l,u)=>o(u)&&l==="--json"),a=n.filter((l,u)=>!o(u)||l!=="--json"),c;try{let l=lm(t,a);c=l?{exitCode:0,stdout:l}:await e(a,{json:s,invocationCwd:r.invocationCwd??process.cwd(),...r.projectRoot?{projectRoot:r.projectRoot}:{}})}catch(l){c={exitCode:70,stderr:l instanceof Error?l.message:String(l),data:{issues:[da(l)]}}}return s?Hb(t,c):c}function dm(t,e){return async(n,r={})=>n[0]!==t?{exitCode:64,stderr:`Expected Classic command: ${t}`}:fm(t,e,n.slice(1),r)}function mm(t){let e=process.argv[1];if(!e)return!1;if(t===um(e).href)return!0;try{return t===um(Gb(e)).href}catch{return!1}}async function pm(t,e,n=process.argv.slice(2)){let r=await fm(t,e,n);return r.stdout&&process.stdout.write(r.stdout),r.stderr&&process.stderr.write(r.stderr+(r.stderr.endsWith(`
|
|
178
191
|
`)?"":`
|
|
179
|
-
`)),
|
|
192
|
+
`)),r.exitCode}var sA=dm("archive",Ha);mm(import.meta.url)&&(process.exitCode=await pm("archive",Ha));export{sA as runClassicCli};
|