@rpamis/comet 0.4.3 → 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/README.md +332 -332
- 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 +1 -1
- package/assets/skills/comet-classic/reference/scripts.md +9 -1
- package/assets/skills/comet-design/SKILL.md +0 -2
- package/assets/skills/comet-hotfix/SKILL.md +1 -3
- package/assets/skills/comet-native/SKILL.md +8 -7
- 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 +15 -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 +1 -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 +1 -1
- package/assets/skills-zh/comet-classic/reference/scripts.md +9 -1
- package/assets/skills-zh/comet-design/SKILL.md +0 -2
- package/assets/skills-zh/comet-hotfix/SKILL.md +1 -3
- package/assets/skills-zh/comet-native/SKILL.md +8 -7
- 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 +16 -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 +1 -1
- package/assets/skills-zh/comet-verify/SKILL.md +0 -2
- package/bin/comet-daemon-router.js +23 -7
- 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 +13 -2
- package/dist/app/commands/daemon-server.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.map +1 -1
- package/dist/domains/comet-classic/classic-check-snapshot.js +68 -26
- 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 +14 -4
- package/dist/domains/comet-native/native-portable-checks.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-checks.js +159 -60
- 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/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 +8 -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 +1 -0
- package/dist/platform/process/windows-process-broker.d.ts.map +1 -1
- package/dist/platform/process/windows-process-broker.js +70 -11
- package/dist/platform/process/windows-process-broker.js.map +1 -1
- 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,167 +1,180 @@
|
|
|
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 Yd=Object.create;var Oi=Object.defineProperty;var Gd=Object.getOwnPropertyDescriptor;var zd=Object.getOwnPropertyNames;var Vd=Object.getPrototypeOf,Xd=Object.prototype.hasOwnProperty;var er=(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 W=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var C=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}},Qd=(t,e)=>{for(var n in e)Oi(t,n,{get:e[n],enumerable:!0})},Zd=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of zd(e))!Xd.call(t,i)&&i!==n&&Oi(t,i,{get:()=>e[i],enumerable:!(r=Gd(e,i))||r.enumerable});return t};var Vt=(t,e,n)=>(n=t!=null?Yd(Vd(t)):{},Zd(e||!t||!t.__esModule?Oi(n,"default",{value:t,enumerable:!0}):n,t));var A=C(z=>{"use strict";var Ti=Symbol.for("yaml.alias"),Oa=Symbol.for("yaml.document"),tr=Symbol.for("yaml.map"),Ta=Symbol.for("yaml.pair"),Ii=Symbol.for("yaml.scalar"),nr=Symbol.for("yaml.seq"),Ae=Symbol.for("yaml.node.type"),nm=t=>!!t&&typeof t=="object"&&t[Ae]===Ti,rm=t=>!!t&&typeof t=="object"&&t[Ae]===Oa,im=t=>!!t&&typeof t=="object"&&t[Ae]===tr,om=t=>!!t&&typeof t=="object"&&t[Ae]===Ta,Ia=t=>!!t&&typeof t=="object"&&t[Ae]===Ii,sm=t=>!!t&&typeof t=="object"&&t[Ae]===nr;function ja(t){if(t&&typeof t=="object")switch(t[Ae]){case tr:case nr:return!0}return!1}function am(t){if(t&&typeof t=="object")switch(t[Ae]){case Ti:case tr:case Ii:case nr:return!0}return!1}var cm=t=>(Ia(t)||ja(t))&&!!t.anchor;z.ALIAS=Ti;z.DOC=Oa;z.MAP=tr;z.NODE_TYPE=Ae;z.PAIR=Ta;z.SCALAR=Ii;z.SEQ=nr;z.hasAnchor=cm;z.isAlias=nm;z.isCollection=ja;z.isDocument=rm;z.isMap=im;z.isNode=am;z.isPair=om;z.isScalar=Ia;z.isSeq=sm});var Qt=C(ji=>{"use strict";var U=A(),oe=Symbol("break visit"),La=Symbol("skip children"),be=Symbol("remove node");function rr(t,e){let n=$a(e);U.isDocument(t)?_t(null,t.contents,n,Object.freeze([t]))===be&&(t.contents=null):_t(null,t,n,Object.freeze([]))}rr.BREAK=oe;rr.SKIP=La;rr.REMOVE=be;function _t(t,e,n,r){let i=qa(t,e,n,r);if(U.isNode(i)||U.isPair(i))return Ma(t,r,i),_t(t,i,n,r);if(typeof i!="symbol"){if(U.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let s=_t(o,e.items[o],n,r);if(typeof s=="number")o=s-1;else{if(s===oe)return oe;s===be&&(e.items.splice(o,1),o-=1)}}}else if(U.isPair(e)){r=Object.freeze(r.concat(e));let o=_t("key",e.key,n,r);if(o===oe)return oe;o===be&&(e.key=null);let s=_t("value",e.value,n,r);if(s===oe)return oe;s===be&&(e.value=null)}}return i}async function ir(t,e){let n=$a(e);U.isDocument(t)?await Pt(null,t.contents,n,Object.freeze([t]))===be&&(t.contents=null):await Pt(null,t,n,Object.freeze([]))}ir.BREAK=oe;ir.SKIP=La;ir.REMOVE=be;async function Pt(t,e,n,r){let i=await qa(t,e,n,r);if(U.isNode(i)||U.isPair(i))return Ma(t,r,i),Pt(t,i,n,r);if(typeof i!="symbol"){if(U.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let s=await Pt(o,e.items[o],n,r);if(typeof s=="number")o=s-1;else{if(s===oe)return oe;s===be&&(e.items.splice(o,1),o-=1)}}}else if(U.isPair(e)){r=Object.freeze(r.concat(e));let o=await Pt("key",e.key,n,r);if(o===oe)return oe;o===be&&(e.key=null);let s=await Pt("value",e.value,n,r);if(s===oe)return oe;s===be&&(e.value=null)}}return i}function $a(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 qa(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(U.isMap(e))return n.Map?.(t,e,r);if(U.isSeq(e))return n.Seq?.(t,e,r);if(U.isPair(e))return n.Pair?.(t,e,r);if(U.isScalar(e))return n.Scalar?.(t,e,r);if(U.isAlias(e))return n.Alias?.(t,e,r)}function Ma(t,e,n){let r=e[e.length-1];if(U.isCollection(r))r.items[t]=n;else if(U.isPair(r))t==="key"?r.key=n:r.value=n;else if(U.isDocument(r))r.contents=n;else{let i=U.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}ji.visit=rr;ji.visitAsync=ir});var Li=C(Da=>{"use strict";var Fa=A(),lm=Qt(),um={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},fm=t=>t.replace(/[!,[\]{}]/g,e=>um[e]),Zt=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+fm(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&&Fa.isNode(e.contents)){let o={};lm.visit(e.contents,(s,a)=>{Fa.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
|
+
`)}};Zt.defaultYaml={explicit:!1,version:"1.2"};Zt.defaultTags={"!!":"tag:yaml.org,2002:"};Da.Directives=Zt});var or=C(en=>{"use strict";var Wa=A(),dm=Qt();function mm(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 Ba(t){let e=new Set;return dm.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function Ka(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function pm(t,e){let n=[],r=new Map,i=null;return{onAnchor:o=>{n.push(o),i??(i=Ba(t));let s=Ka(e,i);return i.add(s),s},setAnchors:()=>{for(let o of n){let s=r.get(o);if(typeof s=="object"&&s.anchor&&(Wa.isScalar(s.node)||Wa.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}}en.anchorIsValid=mm;en.anchorNames=Ba;en.createNodeAnchors=pm;en.findNewAnchor=Ka});var $i=C(Ua=>{"use strict";function tn(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=tn(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=tn(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=tn(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=tn(t,r,i,o);s===void 0?delete r[i]:s!==o&&(r[i]=s)}return t.call(e,n,r)}Ua.applyReviver=tn});var qe=C(Ja=>{"use strict";var hm=A();function Ha(t,e,n){if(Array.isArray(t))return t.map((r,i)=>Ha(r,String(i),n));if(t&&typeof t.toJSON=="function"){if(!n||!hm.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}Ja.toJS=Ha});var sr=C(Ga=>{"use strict";var gm=$i(),Ya=A(),wm=qe(),qi=class{constructor(e){Object.defineProperty(this,Ya.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(!Ya.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=wm.toJS(this,"",s);if(typeof i=="function")for(let{count:c,res:l}of s.anchors.values())i(l,c);return typeof o=="function"?gm.applyReviver(o,{"":a},"",a):a}};Ga.NodeBase=qi});var nn=C(za=>{"use strict";var ym=or(),vm=Qt(),Rt=A(),km=sr(),bm=qe(),Mi=class extends km.NodeBase{constructor(e){super(Rt.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=[],vm.visit(e,{Node:(o,s)=>{(Rt.isAlias(s)||Rt.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||(bm.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=ar(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(ym.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 ar(t,e,n){if(Rt.isAlias(e)){let r=e.resolve(t),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Rt.isCollection(e)){let r=0;for(let i of e.items){let o=ar(t,i,n);o>r&&(r=o)}return r}else if(Rt.isPair(e)){let r=ar(t,e.key,n),i=ar(t,e.value,n);return Math.max(r,i)}return 1}za.Alias=Mi});var B=C(Fi=>{"use strict";var Cm=A(),Sm=sr(),Em=qe(),xm=t=>!t||typeof t!="function"&&typeof t!="object",Me=class extends Sm.NodeBase{constructor(e){super(Cm.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:Em.toJS(this.value,e,n)}toString(){return String(this.value)}};Me.BLOCK_FOLDED="BLOCK_FOLDED";Me.BLOCK_LITERAL="BLOCK_LITERAL";Me.PLAIN="PLAIN";Me.QUOTE_DOUBLE="QUOTE_DOUBLE";Me.QUOTE_SINGLE="QUOTE_SINGLE";Fi.Scalar=Me;Fi.isScalarValue=xm});var rn=C(Xa=>{"use strict";var _m=nn(),ct=A(),Va=B(),Pm="tag:yaml.org,2002:";function Rm(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 Nm(t,e,n){if(ct.isDocument(t)&&(t=t.contents),ct.isNode(t))return t;if(ct.isPair(t)){let f=n.schema[ct.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 _m.Alias(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=Pm+e.slice(2));let l=Rm(t,e,s.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let f=new Va.Scalar(t);return c&&(c.node=f),f}l=t instanceof Map?s[ct.MAP]:Symbol.iterator in Object(t)?s[ct.SEQ]:s[ct.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 Va.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}Xa.createNode=Nm});var lr=C(cr=>{"use strict";var Am=rn(),Ce=A(),Om=sr();function Di(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 Am.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 Qa=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Wi=class extends Om.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=>Ce.isNode(r)||Ce.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(Qa(e))this.add(n);else{let[r,...i]=e,o=this.get(r,!0);if(Ce.isCollection(o))o.addIn(i,n);else if(o===void 0&&this.schema)this.set(r,Di(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(Ce.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&&Ce.isScalar(o)?o.value:o:Ce.isCollection(o)?o.getIn(i,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!Ce.isPair(n))return!1;let r=n.value;return r==null||e&&Ce.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 Ce.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(Ce.isCollection(o))o.setIn(i,n);else if(o===void 0&&this.schema)this.set(r,Di(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};cr.Collection=Wi;cr.collectionFromPath=Di;cr.isEmptyPath=Qa});var on=C(ur=>{"use strict";var Tm=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Bi(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Im=(t,e,n)=>t.endsWith(`
|
|
6
|
+
`)?Bi(n,e):n.includes(`
|
|
7
7
|
`)?`
|
|
8
|
-
`+
|
|
9
|
-
`)n===
|
|
8
|
+
`+Bi(n,e):(t.endsWith(" ")?"":" ")+n;ur.indentComment=Bi;ur.lineComment=Im;ur.stringifyComment=Tm});var ec=C(sn=>{"use strict";var jm="flow",Ki="block",fr="quoted";function Lm(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,y=-1;n===Ki&&(m=Za(t,m,e.length),m!==-1&&(f=m+c));for(let k;k=t[m+=1];){if(n===fr&&k==="\\"){switch(h=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}y=m}if(k===`
|
|
9
|
+
`)n===Ki&&(m=Za(t,m,e.length)),f=m+e.length+c,d=void 0;else{if(k===" "&&p&&p!==" "&&p!==`
|
|
10
10
|
`&&p!==" "){let E=t[m+1];E&&E!==" "&&E!==`
|
|
11
|
-
`&&E!==" "&&(d=m)}if(m>=f)if(d)l.push(d),f=d+c,d=void 0;else if(n===
|
|
12
|
-
${e}${t.slice(0,
|
|
13
|
-
${e}${t.slice(E+1,
|
|
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
|
+
`&&E!==" "&&(d=m)}if(m>=f)if(d)l.push(d),f=d+c,d=void 0;else if(n===fr){for(;p===" "||p===" ";)p=k,k=t[m+=1],g=!0;let E=m>y+1?m-2:h-1;if(u[E])return t;l.push(E),u[E]=!0,f=E+c,d=void 0}else g=!0}p=k}if(g&&a&&a(),l.length===0)return t;s&&s();let v=t.slice(0,l[0]);for(let k=0;k<l.length;++k){let E=l[k],x=l[k+1]||t.length;E===0?v=`
|
|
12
|
+
${e}${t.slice(0,x)}`:(n===fr&&u[E]&&(v+=`${t[E]}\\`),v+=`
|
|
13
|
+
${e}${t.slice(E+1,x)}`)}return v}function Za(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}sn.FOLD_BLOCK=Ki;sn.FOLD_FLOW=jm;sn.FOLD_QUOTED=fr;sn.foldFlowLines=Lm});var cn=C(tc=>{"use strict";var we=B(),Fe=ec(),mr=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),pr=t=>/^(%|---|\.\.\.)/m.test(t);function $m(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 an(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,i=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(pr(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:Fe.foldFlowLines(s,o,Fe.FOLD_QUOTED,mr(e,!1))}function Ui(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
19
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return an(t,e);let n=e.indent||(pr(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
20
|
+
${n}`)+"'";return e.implicitKey?r:Fe.foldFlowLines(r,n,Fe.FOLD_FLOW,mr(e,!1))}function Nt(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=an;else{let i=t.includes('"'),o=t.includes("'");i&&!o?r=Ui:o&&!i?r=an:r=n?Ui:an}return r(t,e)}var Hi;try{Hi=new RegExp(`(^|(?<!
|
|
21
21
|
))
|
|
22
22
|
+(?!
|
|
23
|
-
|$)`,"g")}catch{
|
|
23
|
+
|$)`,"g")}catch{Hi=/\n+(?!\n|$)/g}function dr({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||pr(n)?" ":""),u=s==="literal"?!0:s==="folded"||e===we.Scalar.BLOCK_FOLDED?!1:e===we.Scalar.BLOCK_LITERAL?!0:!$m(n,c,l.length);if(!n)return u?`|
|
|
24
24
|
`:`>
|
|
25
|
-
`;let f,d;for(d=n.length;d>0;--d){let
|
|
26
|
-
`&&
|
|
25
|
+
`;let f,d;for(d=n.length;d>0;--d){let x=n[d-1];if(x!==`
|
|
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(
|
|
29
|
-
`)
|
|
30
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),
|
|
31
|
-
${l}${
|
|
32
|
-
${l}${
|
|
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+=
|
|
39
|
-
`:"",
|
|
40
|
-
${
|
|
41
|
-
`&&
|
|
28
|
+
`&&(p=p.slice(0,-1)),p=p.replace(Hi,`$&${l}`));let m=!1,h,y=-1;for(h=0;h<n.length;++h){let x=n[h];if(x===" ")m=!0;else if(x===`
|
|
29
|
+
`)y=h;else break}let v=n.substring(0,y<h?y+1:h);v&&(n=n.substring(v.length),v=v.replace(/\n+/g,`$&${l}`));let E=(m?l?"2":"1":"")+f;if(t&&(E+=" "+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}`),_=!1,O=mr(r,!0);s!=="folded"&&e!==we.Scalar.BLOCK_FOLDED&&(O.onOverflow=()=>{_=!0});let S=Fe.foldFlowLines(`${v}${x}${p}`,l,Fe.FOLD_BLOCK,O);if(!_)return`>${E}
|
|
31
|
+
${l}${S}`}return n=n.replace(/\n+/g,`$&${l}`),`|${E}
|
|
32
|
+
${l}${v}${n}${p}`}function qm(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):dr(t,e,n,r);if(!a&&!u&&i!==we.Scalar.PLAIN&&o.includes(`
|
|
35
|
+
`))return dr(t,e,n,r);if(pr(o)){if(c==="")return e.forceBlockIndent=!0,dr(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:Fe.foldFlowLines(f,c,Fe.FOLD_FLOW,mr(e,!1))}function Mm(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!==we.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=we.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case we.Scalar.BLOCK_FOLDED:case we.Scalar.BLOCK_LITERAL:return i||o?Nt(s.value,e):dr(s,e,n,r);case we.Scalar.QUOTE_DOUBLE:return an(s.value,e);case we.Scalar.QUOTE_SINGLE:return Ui(s.value,e);case we.Scalar.PLAIN:return qm(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}tc.stringifyString=Mm});var ln=C(Ji=>{"use strict";var Fm=or(),De=A(),Dm=on(),Wm=cn();function Bm(t,e){let n=Object.assign({blockQuote:!0,commentString:Dm.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 Km(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(De.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 Um(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let i=[],o=(De.isScalar(t)||De.isCollection(t))&&t.anchor;o&&Fm.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 Hm(t,e,n,r){if(De.isPair(t))return t.toString(e,n,r);if(De.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=De.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>i=c});i??(i=Km(e.doc.schema.tags,o));let s=Um(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):De.isScalar(o)?Wm.stringifyString(o,e,n,r):o.toString(e,n,r);return s?De.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
|
|
37
|
+
${e.indent}${a}`:a}Ji.createStringifyContext=Bm;Ji.stringify=Hm});var oc=C(ic=>{"use strict";var Oe=A(),nc=B(),rc=ln(),un=on();function Jm({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=Oe.isNode(t)&&t.comment||null;if(f){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Oe.isCollection(t)||!Oe.isNode(t)&&typeof t=="object"){let O="With simple keys, collection cannot be used as a key value";throw new Error(O)}}let p=!f&&(!t||d&&e==null&&!n.inFlow||Oe.isCollection(t)||(Oe.isScalar(t)?t.type===nc.Scalar.BLOCK_FOLDED||t.type===nc.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=rc.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+=un.lineComment(h,n.indent,l(d)):m&&i&&i(),h;g&&(d=null),p?(d&&(h+=un.lineComment(h,n.indent,l(d))),h=`? ${h}
|
|
38
|
+
${a}:`):(h=`${h}:`,d&&(h+=un.lineComment(h,n.indent,l(d))));let y,v,k;Oe.isNode(e)?(y=!!e.spaceBefore,v=e.commentBefore,k=e.comment):(y=!1,v=null,k=null,e&&typeof e=="object"&&(e=s.createNode(e))),n.implicitKey=!1,!p&&!d&&Oe.isScalar(e)&&(n.indentAtStart=h.length+1),m=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Oe.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let E=!1,x=rc.stringify(e,n,()=>E=!0,()=>m=!0),_=" ";if(d||y||v){if(_=y?`
|
|
39
|
+
`:"",v){let O=l(v);_+=`
|
|
40
|
+
${un.indentComment(O,n.indent)}`}x===""&&!n.inFlow?_===`
|
|
41
|
+
`&&k&&(_=`
|
|
42
42
|
|
|
43
|
-
`):
|
|
44
|
-
${n.indent}`}else if(!p&&
|
|
45
|
-
`),
|
|
46
|
-
${n.indent}`)}}else(
|
|
47
|
-
`)&&(
|
|
43
|
+
`):_+=`
|
|
44
|
+
${n.indent}`}else if(!p&&Oe.isCollection(e)){let O=x[0],S=x.indexOf(`
|
|
45
|
+
`),L=S!==-1,I=n.inFlow??e.flow??e.items.length===0;if(L||!I){let w=!1;if(L&&(O==="&"||O==="!")){let b=x.indexOf(" ");O==="&"&&b!==-1&&b<S&&x[b+1]==="!"&&(b=x.indexOf(" ",b+1)),(b===-1||S<b)&&(w=!0)}w||(_=`
|
|
46
|
+
${n.indent}`)}}else(x===""||x[0]===`
|
|
47
|
+
`)&&(_="");return h+=_+x,n.inFlow?E&&r&&r():k&&!E?h+=un.lineComment(h,n.indent,l(k)):m&&i&&i(),h}ic.stringifyPair=Jm});var Gi=C(Yi=>{"use strict";var sc=er("process");function Ym(t,...e){t==="debug"&&console.log(...e)}function Gm(t,e){(t==="debug"||t==="warn")&&(typeof sc.emitWarning=="function"?sc.emitWarning(e):console.warn(e))}Yi.debug=Ym;Yi.warn=Gm});var vr=C(yr=>{"use strict";var wr=A(),ac=B(),hr="<<",gr={identify:t=>t===hr||typeof t=="symbol"&&t.description===hr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ac.Scalar(Symbol(hr)),{addToJSMap:cc}),stringify:()=>hr},zm=(t,e)=>(gr.identify(e)||wr.isScalar(e)&&(!e.type||e.type===ac.Scalar.PLAIN)&&gr.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===gr.tag&&n.default);function cc(t,e,n){let r=lc(t,n);if(wr.isSeq(r))for(let i of r.items)zi(t,e,i);else if(Array.isArray(r))for(let i of r)zi(t,e,i);else zi(t,e,r)}function zi(t,e,n){let r=lc(t,n);if(!wr.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 lc(t,e){return t&&wr.isAlias(e)?e.resolve(t.doc,t):e}yr.addMergeToJSMap=cc;yr.isMergeKey=zm;yr.merge=gr});var Xi=C(dc=>{"use strict";var Vm=Gi(),uc=vr(),Xm=ln(),fc=A(),Vi=qe();function Qm(t,e,{key:n,value:r}){if(fc.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(uc.isMergeKey(t,n))uc.addMergeToJSMap(t,e,r);else{let i=Vi.toJS(n,"",t);if(e instanceof Map)e.set(i,Vi.toJS(r,i,t));else if(e instanceof Set)e.add(i);else{let o=Zm(n,i,t),s=Vi.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 Zm(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(fc.isNode(t)&&n?.doc){let r=Xm.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)+'..."'),Vm.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)}dc.addPairToJSMap=Qm});var We=C(Qi=>{"use strict";var mc=rn(),ep=oc(),tp=Xi(),kr=A();function np(t,e,n){let r=mc.createNode(t,void 0,n),i=mc.createNode(e,void 0,n);return new br(r,i)}var br=class t{constructor(e,n=null){Object.defineProperty(this,kr.NODE_TYPE,{value:kr.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return kr.isNode(n)&&(n=n.clone(e)),kr.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return tp.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?ep.stringifyPair(this,e,n,r):JSON.stringify(this)}};Qi.Pair=br;Qi.createPair=np});var Zi=C(hc=>{"use strict";var lt=A(),pc=ln(),Cr=on();function rp(t,e,n){return(e.inFlow??t.flow?op:ip)(t,e,n)}function ip({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(lt.isNode(m))!f&&m.spaceBefore&&d.push(""),Sr(n,d,m.commentBefore,f),m.comment&&(h=m.comment);else if(lt.isPair(m)){let v=lt.isNode(m.key)?m.key:null;v&&(!f&&v.spaceBefore&&d.push(""),Sr(n,d,v.commentBefore,f))}f=!1;let y=pc.stringify(m,u,()=>h=null,()=>f=!0);h&&(y+=Cr.lineComment(y,o,l(h))),f&&h&&(f=!1),d.push(r+y)}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?
|
|
50
|
+
`+Cr.indentComment(l(t),c),a&&a()):f&&s&&s(),p}function op({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(lt.isNode(m))m.spaceBefore&&f.push(""),Sr(e,f,m.commentBefore,!1),m.comment&&(h=m.comment);else if(lt.isPair(m)){let v=lt.isNode(m.key)?m.key:null;v&&(v.spaceBefore&&f.push(""),Sr(e,f,v.commentBefore,!1),v.comment&&(l=!0));let k=lt.isNode(m.value)?m.value:null;k?(k.comment&&(h=k.comment),k.commentBefore&&(l=!0)):m.value==null&&v?.comment&&(h=v.comment)}h&&(l=!0);let y=pc.stringify(m,c,()=>h=null);l||(l=f.length>u||y.includes(`
|
|
51
|
+
`)),g<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=f.reduce((v,k)=>v+k.length+2,2)+(y.length+2)>e.options.lineWidth)),l&&(y+=",")),h&&(y+=Cr.lineComment(y,r,a(h))),f.push(y),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 Sr({indent:t,options:{commentString:e}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,"")),r){let o=Cr.indentComment(e(r),t);n.push(o.trimStart())}}hc.stringifyCollection=rp});var Ke=C(to=>{"use strict";var sp=Zi(),ap=Xi(),cp=lr(),Be=A(),Er=We(),lp=B();function fn(t,e){let n=Be.isScalar(e)?e.value:e;for(let r of t)if(Be.isPair(r)&&(r.key===e||r.key===n||Be.isScalar(r.key)&&r.key.value===n))return r}var eo=class extends cp.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Be.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(Er.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;Be.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new Er.Pair(e,e?.value):r=new Er.Pair(e.key,e.value);let i=fn(this.items,r.key),o=this.schema?.sortMapEntries;if(i){if(!n)throw new Error(`Key ${r.key} already set`);Be.isScalar(i.value)&&lp.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=fn(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let i=fn(this.items,e)?.value;return(!n&&Be.isScalar(i)?i.value:i)??void 0}has(e){return!!fn(this.items,e)}set(e,n){this.add(new Er.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)ap.addPairToJSMap(n,i,o);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!Be.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})),sp.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};to.YAMLMap=eo;to.findPair=fn});var At=C(wc=>{"use strict";var up=A(),gc=Ke(),fp={collection:"map",default:!0,nodeClass:gc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return up.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>gc.YAMLMap.from(t,e,n)};wc.map=fp});var Ue=C(yc=>{"use strict";var dp=rn(),mp=Zi(),pp=lr(),_r=A(),hp=B(),gp=qe(),no=class extends pp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(_r.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=xr(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=xr(e);if(typeof r!="number")return;let i=this.items[r];return!n&&_r.isScalar(i)?i.value:i}has(e){let n=xr(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=xr(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let i=this.items[r];_r.isScalar(i)&&hp.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(gp.toJS(o,String(i++),n));return r}toString(e,n,r){return e?mp.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(dp.createNode(a,void 0,r))}}return o}};function xr(t){let e=_r.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}yc.YAMLSeq=no});var Ot=C(kc=>{"use strict";var wp=A(),vc=Ue(),yp={collection:"seq",default:!0,nodeClass:vc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return wp.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>vc.YAMLSeq.from(t,e,n)};kc.seq=yp});var dn=C(bc=>{"use strict";var vp=cn(),kp={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),vp.stringifyString(t,e,n,r)}};bc.string=kp});var Pr=C(Ec=>{"use strict";var Cc=B(),Sc={identify:t=>t==null,createNode:()=>new Cc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Cc.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Sc.test.test(t)?t:e.options.nullStr};Ec.nullTag=Sc});var ro=C(_c=>{"use strict";var bp=B(),xc={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new bp.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&xc.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};_c.boolTag=xc});var Tt=C(Pc=>{"use strict";function Cp({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}Pc.stringifyNumber=Cp});var oo=C(Rr=>{"use strict";var Sp=B(),io=Tt(),Ep={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:io.stringifyNumber},xp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():io.stringifyNumber(t)}},_p={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new Sp.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:io.stringifyNumber};Rr.float=_p;Rr.floatExp=xp;Rr.floatNaN=Ep});var ao=C(Ar=>{"use strict";var Rc=Tt(),Nr=t=>typeof t=="bigint"||Number.isInteger(t),so=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function Nc(t,e,n){let{value:r}=t;return Nr(r)&&r>=0?n+r.toString(e):Rc.stringifyNumber(t)}var Pp={identify:t=>Nr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>so(t,2,8,n),stringify:t=>Nc(t,8,"0o")},Rp={identify:Nr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>so(t,0,10,n),stringify:Rc.stringifyNumber},Np={identify:t=>Nr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>so(t,2,16,n),stringify:t=>Nc(t,16,"0x")};Ar.int=Rp;Ar.intHex=Np;Ar.intOct=Pp});var Oc=C(Ac=>{"use strict";var Ap=At(),Op=Pr(),Tp=Ot(),Ip=dn(),jp=ro(),co=oo(),lo=ao(),Lp=[Ap.map,Tp.seq,Ip.string,Op.nullTag,jp.boolTag,lo.intOct,lo.int,lo.intHex,co.floatNaN,co.floatExp,co.float];Ac.schema=Lp});var jc=C(Ic=>{"use strict";var $p=B(),qp=At(),Mp=Ot();function Tc(t){return typeof t=="bigint"||Number.isInteger(t)}var Or=({value:t})=>JSON.stringify(t),Fp=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Or},{identify:t=>t==null,createNode:()=>new $p.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Or},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Or},{identify:Tc,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})=>Tc(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:Or}],Dp={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Wp=[qp.map,Mp.seq].concat(Fp,Dp);Ic.schema=Wp});var fo=C(Lc=>{"use strict";var mn=er("buffer"),uo=B(),Bp=cn(),Kp={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof mn.Buffer=="function")return mn.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 mn.Buffer=="function")a=s instanceof mn.Buffer?s.toString("base64"):mn.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 Bp.stringifyString({comment:t,type:e,value:a},r,i,o)}};Lc.binary=Kp});var jr=C(Ir=>{"use strict";var Tr=A(),mo=We(),Up=B(),Hp=Ue();function $c(t,e){if(Tr.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!Tr.isPair(r)){if(Tr.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let i=r.items[0]||new mo.Pair(new Up.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]=br.isPair(r)?r:new Zi.Pair(r)}}else e("Expected a sequence for this tag");return t}function kc(t,e,n){let{replacer:r}=n,i=new kp.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(Zi.createPair(a,c,n))}return i}var bp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:vc,createNode:kc};Cr.createPairs=kc;Cr.pairs=bp;Cr.resolvePairs=vc});var no=C(to=>{"use strict";var bc=O(),eo=Ne(),rn=Le(),Cp=$e(),Cc=Sr(),it=class t extends Cp.YAMLSeq{constructor(){super(),this.add=rn.YAMLMap.prototype.add.bind(this),this.delete=rn.YAMLMap.prototype.delete.bind(this),this.get=rn.YAMLMap.prototype.get.bind(this),this.has=rn.YAMLMap.prototype.has.bind(this),this.set=rn.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=eo.toJS(i.key,"",n),s=eo.toJS(i.value,o,n)):o=eo.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=Cc.createPairs(e,n,r),o=new this;return o.items=i.items,o}};it.tag="tag:yaml.org,2002:omap";var Sp={collection:"seq",identify:t=>t instanceof Map,nodeClass:it,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Cc.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 it,n)},createNode:(t,e,n)=>it.from(t,e,n)};to.YAMLOMap=it;to.omap=Sp});var Pc=C(ro=>{"use strict";var Sc=M();function Ec({value:t,source:e},n){return e&&(t?xc:_c).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var xc={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 Sc.Scalar(!0),stringify:Ec},_c={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 Sc.Scalar(!1),stringify:Ec};ro.falseTag=_c;ro.trueTag=xc});var Rc=C(Er=>{"use strict";var Ep=M(),io=xt(),xp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:io.stringifyNumber},_p={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():io.stringifyNumber(t)}},Pp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new Ep.Scalar(parseFloat(t.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:io.stringifyNumber};Er.float=Pp;Er.floatExp=_p;Er.floatNaN=xp});var Ac=C(sn=>{"use strict";var Nc=xt(),on=t=>typeof t=="bigint"||Number.isInteger(t);function xr(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 oo(t,e,n){let{value:r}=t;if(on(r)){let i=r.toString(e);return r<0?"-"+n+i.substr(1):n+i}return Nc.stringifyNumber(t)}var Rp={identify:on,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>xr(t,2,2,n),stringify:t=>oo(t,2,"0b")},Np={identify:on,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>xr(t,1,8,n),stringify:t=>oo(t,8,"0")},Ap={identify:on,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>xr(t,0,10,n),stringify:Nc.stringifyNumber},Op={identify:on,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>xr(t,2,16,n),stringify:t=>oo(t,16,"0x")};sn.int=Ap;sn.intBin=Rp;sn.intHex=Op;sn.intOct=Np});var ao=C(so=>{"use strict";var Rr=O(),_r=Ie(),Pr=Le(),ot=class t extends Pr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;Rr.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new _r.Pair(e.key,null):n=new _r.Pair(e,null),Pr.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=Pr.findPair(this.items,e);return!n&&Rr.isPair(r)?Rr.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=Pr.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new _r.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(_r.createPair(s,null,r));return o}};ot.tag="tag:yaml.org,2002:set";var Tp={collection:"map",identify:t=>t instanceof Set,nodeClass:ot,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>ot.from(t,e,n),resolve(t,e){if(Rr.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new ot,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};so.YAMLSet=ot;so.set=Tp});var lo=C(Nr=>{"use strict";var Ip=xt();function co(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 Oc(t){let{value:e}=t,n=s=>s;if(typeof e=="bigint")n=s=>BigInt(s);else if(isNaN(e)||!isFinite(e))return Ip.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 jp={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>co(t,n),stringify:Oc},Lp={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=>co(t,!1),stringify:Oc},Tc={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(Tc.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=co(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$/,"")??""};Nr.floatTime=Lp;Nr.intTime=jp;Nr.timestamp=Tc});var Lc=C(jc=>{"use strict";var $p=St(),qp=gr(),Mp=Et(),Dp=tn(),Fp=Qi(),Ic=Pc(),uo=Rc(),Ar=Ac(),Wp=cr(),Bp=no(),Kp=Sr(),Up=ao(),fo=lo(),Hp=[$p.map,Mp.seq,Dp.string,qp.nullTag,Ic.trueTag,Ic.falseTag,Ar.intBin,Ar.intOct,Ar.int,Ar.intHex,uo.floatNaN,uo.floatExp,uo.float,Fp.binary,Wp.merge,Bp.omap,Kp.pairs,Up.set,fo.intTime,fo.floatTime,fo.timestamp];jc.schema=Hp});var Hc=C(ho=>{"use strict";var Dc=St(),Jp=gr(),Fc=Et(),Yp=tn(),zp=Ui(),mo=Ji(),po=zi(),Gp=pc(),Vp=wc(),Wc=Qi(),an=cr(),Bc=no(),Kc=Sr(),$c=Lc(),Uc=ao(),Or=lo(),qc=new Map([["core",Gp.schema],["failsafe",[Dc.map,Fc.seq,Yp.string]],["json",Vp.schema],["yaml11",$c.schema],["yaml-1.1",$c.schema]]),Mc={binary:Wc.binary,bool:zp.boolTag,float:mo.float,floatExp:mo.floatExp,floatNaN:mo.floatNaN,floatTime:Or.floatTime,int:po.int,intHex:po.intHex,intOct:po.intOct,intTime:Or.intTime,map:Dc.map,merge:an.merge,null:Jp.nullTag,omap:Bc.omap,pairs:Kc.pairs,seq:Fc.seq,set:Uc.set,timestamp:Or.timestamp},Xp={"tag:yaml.org,2002:binary":Wc.binary,"tag:yaml.org,2002:merge":an.merge,"tag:yaml.org,2002:omap":Bc.omap,"tag:yaml.org,2002:pairs":Kc.pairs,"tag:yaml.org,2002:set":Uc.set,"tag:yaml.org,2002:timestamp":Or.timestamp};function Qp(t,e,n){let r=qc.get(e);if(r&&!t)return n&&!r.includes(an.merge)?r.concat(an.merge):r.slice();let i=r;if(!i)if(Array.isArray(t))i=[];else{let o=Array.from(qc.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(an.merge)),i.reduce((o,s)=>{let a=typeof s=="string"?Mc[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(Mc).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},[])}ho.coreKnownTags=Xp;ho.getTags=Qp});var yo=C(Jc=>{"use strict";var go=O(),Zp=St(),eh=Et(),th=tn(),Tr=Hc(),nh=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,wo=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(e)?Tr.getTags(e,"compat"):e?Tr.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?Tr.coreKnownTags:{},this.tags=Tr.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,go.MAP,{value:Zp.map}),Object.defineProperty(this,go.SCALAR,{value:th.string}),Object.defineProperty(this,go.SEQ,{value:eh.seq}),this.sortMapEntries=typeof s=="function"?s:s===!0?nh:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Jc.Schema=wo});var zc=C(Yc=>{"use strict";var rh=O(),vo=Qt(),cn=zt();function ih(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=vo.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(rh.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=vo.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(vo.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]=Tr.isPair(r)?r:new mo.Pair(r)}}else e("Expected a sequence for this tag");return t}function qc(t,e,n){let{replacer:r}=n,i=new Hp.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(mo.createPair(a,c,n))}return i}var Jp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:$c,createNode:qc};Ir.createPairs=qc;Ir.pairs=Jp;Ir.resolvePairs=$c});var go=C(ho=>{"use strict";var Mc=A(),po=qe(),pn=Ke(),Yp=Ue(),Fc=jr(),ut=class t extends Yp.YAMLSeq{constructor(){super(),this.add=pn.YAMLMap.prototype.add.bind(this),this.delete=pn.YAMLMap.prototype.delete.bind(this),this.get=pn.YAMLMap.prototype.get.bind(this),this.has=pn.YAMLMap.prototype.has.bind(this),this.set=pn.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(Mc.isPair(i)?(o=po.toJS(i.key,"",n),s=po.toJS(i.value,o,n)):o=po.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=Fc.createPairs(e,n,r),o=new this;return o.items=i.items,o}};ut.tag="tag:yaml.org,2002:omap";var Gp={collection:"seq",identify:t=>t instanceof Map,nodeClass:ut,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Fc.resolvePairs(t,e),r=[];for(let{key:i}of n.items)Mc.isScalar(i)&&(r.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):r.push(i.value));return Object.assign(new ut,n)},createNode:(t,e,n)=>ut.from(t,e,n)};ho.YAMLOMap=ut;ho.omap=Gp});var Uc=C(wo=>{"use strict";var Dc=B();function Wc({value:t,source:e},n){return e&&(t?Bc:Kc).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Bc={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Dc.Scalar(!0),stringify:Wc},Kc={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Dc.Scalar(!1),stringify:Wc};wo.falseTag=Kc;wo.trueTag=Bc});var Hc=C(Lr=>{"use strict";var zp=B(),yo=Tt(),Vp={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:yo.stringifyNumber},Xp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():yo.stringifyNumber(t)}},Qp={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 zp.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:yo.stringifyNumber};Lr.float=Qp;Lr.floatExp=Xp;Lr.floatNaN=Vp});var Yc=C(gn=>{"use strict";var Jc=Tt(),hn=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 vo(t,e,n){let{value:r}=t;if(hn(r)){let i=r.toString(e);return r<0?"-"+n+i.substr(1):n+i}return Jc.stringifyNumber(t)}var Zp={identify:hn,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=>vo(t,2,"0b")},eh={identify:hn,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=>vo(t,8,"0")},th={identify:hn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>$r(t,0,10,n),stringify:Jc.stringifyNumber},nh={identify:hn,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=>vo(t,16,"0x")};gn.int=th;gn.intBin=Zp;gn.intHex=nh;gn.intOct=eh});var bo=C(ko=>{"use strict";var Fr=A(),qr=We(),Mr=Ke(),ft=class t extends Mr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;Fr.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new qr.Pair(e.key,null):n=new qr.Pair(e,null),Mr.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=Mr.findPair(this.items,e);return!n&&Fr.isPair(r)?Fr.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=Mr.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new qr.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(qr.createPair(s,null,r));return o}};ft.tag="tag:yaml.org,2002:set";var rh={collection:"map",identify:t=>t instanceof Set,nodeClass:ft,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>ft.from(t,e,n),resolve(t,e){if(Fr.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new ft,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};ko.YAMLSet=ft;ko.set=rh});var So=C(Dr=>{"use strict";var ih=Tt();function Co(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 Gc(t){let{value:e}=t,n=s=>s;if(typeof e=="bigint")n=s=>BigInt(s);else if(isNaN(e)||!isFinite(e))return ih.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 oh={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})=>Co(t,n),stringify:Gc},sh={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=>Co(t,!1),stringify:Gc},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=Co(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=sh;Dr.intTime=oh;Dr.timestamp=zc});var Qc=C(Xc=>{"use strict";var ah=At(),ch=Pr(),lh=Ot(),uh=dn(),fh=fo(),Vc=Uc(),Eo=Hc(),Wr=Yc(),dh=vr(),mh=go(),ph=jr(),hh=bo(),xo=So(),gh=[ah.map,lh.seq,uh.string,ch.nullTag,Vc.trueTag,Vc.falseTag,Wr.intBin,Wr.intOct,Wr.int,Wr.intHex,Eo.floatNaN,Eo.floatExp,Eo.float,fh.binary,dh.merge,mh.omap,ph.pairs,hh.set,xo.intTime,xo.floatTime,xo.timestamp];Xc.schema=gh});var cl=C(Ro=>{"use strict";var nl=At(),wh=Pr(),rl=Ot(),yh=dn(),vh=ro(),_o=oo(),Po=ao(),kh=Oc(),bh=jc(),il=fo(),wn=vr(),ol=go(),sl=jr(),Zc=Qc(),al=bo(),Br=So(),el=new Map([["core",kh.schema],["failsafe",[nl.map,rl.seq,yh.string]],["json",bh.schema],["yaml11",Zc.schema],["yaml-1.1",Zc.schema]]),tl={binary:il.binary,bool:vh.boolTag,float:_o.float,floatExp:_o.floatExp,floatNaN:_o.floatNaN,floatTime:Br.floatTime,int:Po.int,intHex:Po.intHex,intOct:Po.intOct,intTime:Br.intTime,map:nl.map,merge:wn.merge,null:wh.nullTag,omap:ol.omap,pairs:sl.pairs,seq:rl.seq,set:al.set,timestamp:Br.timestamp},Ch={"tag:yaml.org,2002:binary":il.binary,"tag:yaml.org,2002:merge":wn.merge,"tag:yaml.org,2002:omap":ol.omap,"tag:yaml.org,2002:pairs":sl.pairs,"tag:yaml.org,2002:set":al.set,"tag:yaml.org,2002:timestamp":Br.timestamp};function Sh(t,e,n){let r=el.get(e);if(r&&!t)return n&&!r.includes(wn.merge)?r.concat(wn.merge):r.slice();let i=r;if(!i)if(Array.isArray(t))i=[];else{let o=Array.from(el.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(wn.merge)),i.reduce((o,s)=>{let a=typeof s=="string"?tl[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(tl).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},[])}Ro.coreKnownTags=Ch;Ro.getTags=Sh});var Oo=C(ll=>{"use strict";var No=A(),Eh=At(),xh=Ot(),_h=dn(),Kr=cl(),Ph=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Ao=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(e)?Kr.getTags(e,"compat"):e?Kr.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?Kr.coreKnownTags:{},this.tags=Kr.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,No.MAP,{value:Eh.map}),Object.defineProperty(this,No.SCALAR,{value:_h.string}),Object.defineProperty(this,No.SEQ,{value:xh.seq}),this.sortMapEntries=typeof s=="function"?s:s===!0?Ph:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};ll.Schema=Ao});var fl=C(ul=>{"use strict";var Rh=A(),To=ln(),yn=on();function Nh(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=To.createStringifyContext(t,e),{commentString:o}=i.options;if(t.commentBefore){n.length!==1&&n.unshift("");let c=o(t.commentBefore);n.unshift(yn.indentComment(c,""))}let s=!1,a=null;if(t.contents){if(Rh.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let u=o(t.contents.commentBefore);n.push(yn.indentComment(u,""))}i.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>s=!0,l=To.stringify(t.contents,i,()=>a=null,c);a&&(l+=yn.lineComment(l,"",o(a))),(l[0]==="|"||l[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${l}`:n.push(l)}else n.push(To.stringify(t.contents,i));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
|
|
58
|
+
`)?(n.push("..."),n.push(yn.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(yn.indentComment(o(c),"")))}return n.join(`
|
|
59
59
|
`)+`
|
|
60
|
-
`}
|
|
60
|
+
`}ul.stringifyDocument=Nh});var vn=C(dl=>{"use strict";var Ah=nn(),It=lr(),pe=A(),Oh=We(),Th=qe(),Ih=Oo(),jh=fl(),Io=or(),Lh=$i(),$h=rn(),jo=Li(),Lo=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,pe.NODE_TYPE,{value:pe.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 jo.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,{[pe.NODE_TYPE]:{value:pe.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=pe.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){jt(this.contents)&&this.contents.add(e)}addIn(e,n){jt(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=Io.anchorNames(this);e.anchor=!n||r.has(n)?Io.findNewAnchor(n||"a",r):n}return new Ah.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=v=>typeof v=="number"||v instanceof String||v instanceof Number,y=n.filter(h).map(String);y.length>0&&(n=n.concat(y)),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}=Io.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:o??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:p},m=$h.createNode(e,u,g);return a&&pe.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 Oh.Pair(i,o)}delete(e){return jt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return It.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):jt(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return pe.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return It.isEmptyPath(e)?!n&&pe.isScalar(this.contents)?this.contents.value:this.contents:pe.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return pe.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return It.isEmptyPath(e)?this.contents!==void 0:pe.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=It.collectionFromPath(this.schema,[e],n):jt(this.contents)&&this.contents.set(e,n)}setIn(e,n){It.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=It.collectionFromPath(this.schema,Array.from(e),n):jt(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 jo.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 jo.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 Ih.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=Th.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"?Lh.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 jh.stringifyDocument(this,e)}};function jt(t){if(pe.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}dl.Document=Lo});var Cn=C(bn=>{"use strict";var kn=class extends Error{constructor(e,n,r,i){super(),this.name=e,this.code=r,this.message=i,this.pos=n}},$o=class extends kn{constructor(e,n,r){super("YAMLParseError",e,n,r)}},qo=class extends kn{constructor(e,n,r){super("YAMLWarning",e,n,r)}},qh=(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
|
-
`+
|
|
69
|
-
`+
|
|
70
|
-
`+S
|
|
71
|
-
`+
|
|
72
|
-
`+h.comment:l.comment=h.comment),l.range=[r.offset,m,h.offset]}else l.range=[r.offset,m,m];return l}
|
|
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,
|
|
74
|
-
`;for(let m=u;m<a;++m){let[h,
|
|
75
|
-
`):h.length>c||
|
|
65
|
+
`}};bn.YAMLError=kn;bn.YAMLParseError=$o;bn.YAMLWarning=qo;bn.prettifyError=qh});var Sn=C(ml=>{"use strict";function Mh(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,y=null,v=null,k=null,E=null,x=null;for(let S of t)switch(g&&(S.type!=="space"&&S.type!=="newline"&&S.type!=="comma"&&o(S.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),m&&(l&&S.type!=="comment"&&S.type!=="newline"&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),S.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&S.source.includes(" ")&&(m=S),u=!0;break;case"comment":{u||o(S,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=S.source.substring(1)||" ";f?f+=d+L:f=L,d="",l=!1;break}case"newline":l?f?f+=S.source:(!E||n!=="seq-item-ind")&&(c=!0):d+=S.source,l=!0,p=!0,(h||y)&&(v=S),u=!0;break;case"anchor":h&&o(S,"MULTIPLE_ANCHORS","A node can have at most one anchor"),S.source.endsWith(":")&&o(S.offset+S.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=S,x??(x=S.offset),l=!1,u=!1,g=!0;break;case"tag":{y&&o(S,"MULTIPLE_TAGS","A node can have at most one tag"),y=S,x??(x=S.offset),l=!1,u=!1,g=!0;break}case n:(h||y)&&o(S,"BAD_PROP_ORDER",`Anchors and tags must be after the ${S.source} indicator`),E&&o(S,"UNEXPECTED_TOKEN",`Unexpected ${S.source} in ${e??"collection"}`),E=S,l=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(e){k&&o(S,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=S,l=!1,u=!1;break}default:o(S,"UNEXPECTED_TOKEN",`Unexpected ${S.type} token`),l=!1,u=!1}let _=t[t.length-1],O=_?_.offset+_.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:k,found:E,spaceBefore:c,comment:f,hasNewline:p,anchor:h,tag:y,newlineAfterProp:v,end:O,start:x??O}}ml.resolveProps=Mh});var Ur=C(pl=>{"use strict";function Mo(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(Mo(e.key)||Mo(e.value))return!0}return!1;default:return!0}}pl.containsNewline=Mo});var Fo=C(hl=>{"use strict";var Fh=Ur();function Dh(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&Fh.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}hl.flowIndentCheck=Dh});var Do=C(wl=>{"use strict";var gl=A();function Wh(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let i=typeof r=="function"?r:(o,s)=>o===s||gl.isScalar(o)&&gl.isScalar(s)&&o.value===s.value;return e.some(o=>i(o.key,n))}wl.mapIncludes=Wh});var Sl=C(Cl=>{"use strict";var yl=We(),Bh=Ke(),vl=Sn(),Kh=Ur(),kl=Fo(),Uh=Do(),bl="All mapping items must start at the same column";function Hh({composeNode:t,composeEmptyNode:e},n,r,i,o){let s=o?.nodeClass??Bh.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=vl.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",bl)),!m.anchor&&!m.tag&&!p){l=m.end,m.comment&&(a.comment?a.comment+=`
|
|
67
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||Kh.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",bl);n.atKey=!0;let y=m.end,v=d?t(n,d,m,i):e(n,y,f,null,m,i);n.schema.compat&&kl.flowIndentCheck(r.indent,d,i),n.atKey=!1,Uh.mapIncludes(n,a.items,v)&&i(y,"DUPLICATE_KEY","Map keys must be unique");let k=vl.resolveProps(p??[],{indicator:"map-value-ind",next:g,offset:v.range[2],onError:i,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=k.end,k.found){h&&(g?.type==="block-map"&&!k.hasNewline&&i(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<k.found.offset-1024&&i(v.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let E=g?t(n,g,k,i):e(n,c,p,null,k,i);n.schema.compat&&kl.flowIndentCheck(r.indent,g,i),c=E.range[2];let x=new yl.Pair(v,E);n.options.keepSourceTokens&&(x.srcToken=u),a.items.push(x)}else{h&&i(v.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(v.comment?v.comment+=`
|
|
68
|
+
`+k.comment:v.comment=k.comment);let E=new yl.Pair(v);n.options.keepSourceTokens&&(E.srcToken=u),a.items.push(E)}}return l&&l<c&&i(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,l??c],a}Cl.resolveBlockMap=Hh});var xl=C(El=>{"use strict";var Jh=Ue(),Yh=Sn(),Gh=Fo();function zh({composeNode:t,composeEmptyNode:e},n,r,i,o){let s=o?.nodeClass??Jh.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=Yh.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&&Gh.flowIndentCheck(r.indent,f,i),c=p.range[2],a.items.push(p)}return a.range=[r.offset,c,l??c],a}El.resolveBlockSeq=zh});var Lt=C(_l=>{"use strict";function Vh(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}}_l.resolveEnd=Vh});var Al=C(Nl=>{"use strict";var Xh=A(),Qh=We(),Pl=Ke(),Zh=Ue(),eg=Lt(),Rl=Sn(),tg=Ur(),ng=Do(),Wo="Block collections are not allowed within flow collections",Bo=t=>t&&(t.type==="block-map"||t.type==="block-seq");function rg({composeNode:t,composeEmptyNode:e},n,r,i,o){let s=r.start.source==="{",a=s?"flow map":"flow sequence",c=o?.nodeClass??(s?Pl.YAMLMap:Zh.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 y=r.items[h],{start:v,key:k,sep:E,value:x}=y,_=Rl.resolveProps(v,{flow:a,indicator:"explicit-key-ind",next:k??E?.[0],offset:f,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!_.found){if(!_.anchor&&!_.tag&&!E&&!x){h===0&&_.comma?i(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):h<r.items.length-1&&i(_.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),_.comment&&(l.comment?l.comment+=`
|
|
69
|
+
`+_.comment:l.comment=_.comment),f=_.end;continue}!s&&n.options.strict&&tg.containsNewline(k)&&i(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)_.comma&&i(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(_.comma||i(_.start,"MISSING_CHAR",`Missing , between ${a} items`),_.comment){let O="";e:for(let S of v)switch(S.type){case"comma":case"space":break;case"comment":O=S.source.substring(1);break e;default:break e}if(O){let S=l.items[l.items.length-1];Xh.isPair(S)&&(S=S.value??S.key),S.comment?S.comment+=`
|
|
70
|
+
`+O:S.comment=O,_.comment=_.comment.substring(O.length+1)}}if(!s&&!E&&!_.found){let O=x?t(n,x,_,i):e(n,_.end,E,null,_,i);l.items.push(O),f=O.range[2],Bo(x)&&i(O.range,"BLOCK_IN_FLOW",Wo)}else{n.atKey=!0;let O=_.end,S=k?t(n,k,_,i):e(n,O,v,null,_,i);Bo(k)&&i(S.range,"BLOCK_IN_FLOW",Wo),n.atKey=!1;let L=Rl.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:x,offset:S.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(L.found){if(!s&&!_.found&&n.options.strict){if(E)for(let b of E){if(b===L.found)break;if(b.type==="newline"){i(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}_.start<L.found.offset-1024&&i(L.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(L.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let I=x?t(n,x,L,i):L.found?e(n,L.end,E,null,L,i):null;I?Bo(x)&&i(I.range,"BLOCK_IN_FLOW",Wo):L.comment&&(S.comment?S.comment+=`
|
|
71
|
+
`+L.comment:S.comment=L.comment);let w=new Qh.Pair(S,I);if(n.options.keepSourceTokens&&(w.srcToken=y),s){let b=l;ng.mapIncludes(n,b.items,S)&&i(O,"DUPLICATE_KEY","Map keys must be unique"),b.items.push(w)}else{let b=new Pl.YAMLMap(n.schema);b.flow=!0,b.items.push(w);let R=(I??S).range;b.range=[S.range[0],R[1],R[2]],l.items.push(b)}f=I?I.range[2]:L.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),y=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",y),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let h=eg.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}Nl.resolveFlowCollection=rg});var Tl=C(Ol=>{"use strict";var ig=A(),og=B(),sg=Ke(),ag=Ue(),cg=Sl(),lg=xl(),ug=Al();function Ko(t,e,n,r,i,o){let s=n.type==="block-map"?cg.resolveBlockMap(t,e,n,r,o):n.type==="block-seq"?lg.resolveBlockSeq(t,e,n,r,o):ug.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 fg(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===sg.YAMLMap.tagName&&a==="map"||s===ag.YAMLSeq.tagName&&a==="seq")return Ko(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),Ko(t,e,n,i,s)}let l=Ko(t,e,n,i,s,c),u=c.resolve?.(l,d=>i(o,"TAG_RESOLVE_FAILED",d),e.options)??l,f=ig.isNode(u)?u:new og.Scalar(u);return f.range=l.range,f.tag=s,c?.format&&(f.format=c.format),f}Ol.composeCollection=fg});var Ho=C(Il=>{"use strict";var Uo=B();function dg(t,e,n){let r=e.offset,i=mg(e,t.options.strict,n);if(!i)return{value:"",type:null,comment:"",range:[r,r,r]};let o=i.mode===">"?Uo.Scalar.BLOCK_FOLDED:Uo.Scalar.BLOCK_LITERAL,s=e.source?pg(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
|
+
`.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,y]=s[m];if(y===""||y==="\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+y.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,y]=s[m];l+=h.length+y.length+1;let v=y[y.length-1]==="\r";if(v&&(y=y.slice(0,-1)),y&&h.length<c){let E=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;n(l-y.length-(v?2:1),"BAD_INDENT",E),h=""}o===Uo.Scalar.BLOCK_LITERAL?(f+=d+h.slice(c)+y,d=`
|
|
75
|
+
`):h.length>c||y[0]===" "?(d===" "?d=`
|
|
76
76
|
`:!p&&d===`
|
|
77
77
|
`&&(d=`
|
|
78
78
|
|
|
79
|
-
`),f+=d+h.slice(c)+
|
|
80
|
-
`,p=!0):
|
|
79
|
+
`),f+=d+h.slice(c)+y,d=`
|
|
80
|
+
`,p=!0):y===""?d===`
|
|
81
81
|
`?f+=`
|
|
82
82
|
`:d=`
|
|
83
|
-
`:(f+=d+
|
|
83
|
+
`:(f+=d+y,d=" ",p=!1)}switch(i.chomp){case"-":break;case"+":for(let m=a;m<s.length;++m)f+=`
|
|
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 mg({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 pg(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}Il.resolveBlockScalar=dg});var Yo=C(Ll=>{"use strict";var Jo=B(),hg=Lt();function gg(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=Jo.Scalar.PLAIN,c=wg(o,l);break;case"single-quoted-scalar":a=Jo.Scalar.QUOTE_SINGLE,c=yg(o,l);break;case"double-quoted-scalar":a=Jo.Scalar.QUOTE_DOUBLE,c=vg(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=hg.resolveEnd(s,u,e,n);return{value:c,type:a,comment:f.comment,range:[r,u,f.offset]}}function wg(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}`),jl(t)}function yg(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),jl(t.slice(1,-1)).replace(/''/g,"'")}function jl(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 vg(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}=kg(t,r);n+=o,r=s}else if(i==="\\"){let o=t[++r],s=bg[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+=Cg(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 kg(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 bg={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Cg(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}}Ll.resolveFlowScalar=gg});var Ml=C(ql=>{"use strict";var dt=A(),$l=B(),Sg=Ho(),Eg=Yo();function xg(t,e,n,r){let{value:i,type:o,comment:s,range:a}=e.type==="block-scalar"?Sg.resolveBlockScalar(t,e,r):Eg.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[dt.SCALAR]:c?l=_g(t.schema,i,c,n,r):e.type==="scalar"?l=Pg(t,i,e,r):l=t.schema[dt.SCALAR];let u;try{let f=l.resolve(i,d=>r(n??e,"TAG_RESOLVE_FAILED",d),t.options);u=dt.isScalar(f)?f:new $l.Scalar(f)}catch(f){let d=f instanceof Error?f.message:String(f);r(n??e,"TAG_RESOLVE_FAILED",d),u=new $l.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 _g(t,e,n,r,i){if(n==="!")return t[dt.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[dt.SCALAR])}function Pg({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[dt.SCALAR];if(n.compat){let a=n.compat.find(c=>c.default&&c.test?.test(r))??n[dt.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}ql.composeScalar=xg});var Dl=C(Fl=>{"use strict";function Rg(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}Fl.emptyScalarPosition=Rg});var Kl=C(zo=>{"use strict";var Ng=nn(),Ag=A(),Og=Tl(),Wl=Ml(),Tg=Lt(),Ig=Dl(),jg={composeNode:Bl,composeEmptyNode:Go};function Bl(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=Lg(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=Wl.composeScalar(t,e,c,r),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Og.composeCollection(jg,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=Go(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&&(!Ag.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 Go(t,e,n,r,{spaceBefore:i,comment:o,anchor:s,tag:a,end:c},l){let u={type:"scalar",offset:Ig.emptyScalarPosition(e,n,r),indent:-1,source:""},f=Wl.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 Lg({options:t},{offset:e,source:n,end:r},i){let o=new Ng.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=Tg.resolveEnd(r,s,t.strict,i);return o.range=[e,s,a.offset],a.comment&&(o.comment=a.comment),o}zo.composeEmptyNode=Go;zo.composeNode=Bl});var Jl=C(Hl=>{"use strict";var $g=vn(),Ul=Kl(),qg=Lt(),Mg=Sn();function Fg(t,e,{offset:n,start:r,value:i,end:o},s){let a=Object.assign({_directives:e},t),c=new $g.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=Mg.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?Ul.composeNode(l,i,u,s):Ul.composeEmptyNode(l,u.end,r,null,u,s);let f=c.contents.range[2],d=qg.resolveEnd(o,f,!1,s);return d.comment&&(c.comment=d.comment),c.range=[n,f,d.offset],c}Hl.composeDoc=Fg});var Xo=C(zl=>{"use strict";var Dg=er("process"),Wg=Li(),Bg=vn(),En=Cn(),Yl=A(),Kg=Jl(),Ug=Lt();function xn(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 Gl(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 Vo=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,i,o)=>{let s=xn(n);o?this.warnings.push(new En.YAMLWarning(s,r,i)):this.errors.push(new En.YAMLParseError(s,r,i))},this.directives=new Wg.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:i}=Gl(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(Yl.isCollection(o)&&!o.flow&&o.items.length>0){let s=o.items[0];Yl.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:Gl(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(Dg.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,i)=>{let o=xn(e);o[0]+=n,this.onError(o,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=Kg.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 En.YAMLParseError(xn(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 En.YAMLParseError(xn(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=Ug.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 En.YAMLParseError(xn(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 Bg.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}}};zl.Composer=Vo});var Ql=C(Hr=>{"use strict";var Hg=Ho(),Jg=Yo(),Yg=Cn(),Vl=cn();function Gg(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 Yg.YAMLParseError([a,a+1],o,s)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Jg.resolveFlowScalar(t,e,r);case"block-scalar":return Hg.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function zg(t,e){let{implicitKey:n=!1,indent:r,inFlow:i=!1,offset:o=-1,type:s="PLAIN"}=e,a=Vl.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 Xl(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 Vg(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=Vl.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">":Xg(t,c);break;case'"':Qo(t,c,"double-quoted-scalar");break;case"'":Qo(t,c,"single-quoted-scalar");break;default:Qo(t,c,"scalar")}}function Xg(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}];Xl(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 Xl(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 Qo(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})}}}Hr.createScalarToken=zg;Hr.resolveAsScalar=Gg;Hr.setScalarValue=Vg});var eu=C(Zl=>{"use strict";var Qg=t=>"type"in t?Yr(t):Jr(t);function Yr(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=Yr(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=Jr(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=Jr(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=Jr(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 Jr({start:t,key:e,sep:n,value:r}){let i="";for(let o of t)i+=o.source;if(e&&(i+=Yr(e)),n)for(let o of n)i+=o.source;return r&&(i+=Yr(r)),i}Zl.stringify=Qg});var iu=C(ru=>{"use strict";var Zo=Symbol("break visit"),Zg=Symbol("skip children"),tu=Symbol("remove item");function mt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),nu(Object.freeze([]),t,e)}mt.BREAK=Zo;mt.SKIP=Zg;mt.REMOVE=tu;mt.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};mt.parentCollection=(t,e)=>{let n=mt.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 nu(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=nu(Object.freeze(t.concat([[i,s]])),o.items[s],n);if(typeof a=="number")s=a-1;else{if(a===Zo)return Zo;a===tu&&(o.items.splice(s,1),s-=1)}}typeof r=="function"&&i==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}ru.visit=mt});var Gr=C(se=>{"use strict";var es=Ql(),ew=eu(),tw=iu(),ts="\uFEFF",ns="",rs="",is="",nw=t=>!!t&&"items"in t,rw=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function iw(t){switch(t){case ts:return"<BOM>";case ns:return"<DOC>";case rs:return"<FLOW_END>";case is:return"<SCALAR>";default:return JSON.stringify(t)}}function ow(t){switch(t){case ts:return"byte-order-mark";case ns:return"doc-mode";case rs:return"flow-error-end";case is: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}
|
|
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}se.createScalarToken=es.createScalarToken;se.resolveAsScalar=es.resolveAsScalar;se.setScalarValue=es.setScalarValue;se.stringify=ew.stringify;se.visit=tw.visit;se.BOM=ts;se.DOCUMENT=ns;se.FLOW_END=rs;se.SCALAR=is;se.isCollection=nw;se.isScalar=rw;se.prettyToken=iw;se.tokenType=ow});var as=C(su=>{"use strict";var _n=Gr();function ye(t){switch(t){case void 0:case" ":case`
|
|
120
|
+
`:case"\r":case" ":return!0;default:return!1}}var ou=new Set("0123456789ABCDEFabcdef"),sw=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),zr=new Set(",[]{}"),aw=new Set(` ,[]{}
|
|
121
|
+
\r `),os=t=>!t||aw.has(t),ss=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==="...")&&ye(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]===_n.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 _n.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==="...")&&ye(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&&!ye(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===":")&&ye(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(os),"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("..."))&&ye(i[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield _n.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(os),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let s=this.charAt(1);if(this.flowKey||ye(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=>ye(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 _n.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(ye(o)||e&&zr.has(o))break;n=r}else if(ye(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&&zr.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&&zr.has(i))break;n=r}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield _n.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(os),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,r=this.charAt(1);if(ye(r)||n&&zr.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(;!ye(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(sw.has(n))n=this.buffer[++e];else if(n==="%"&&ou.has(this.buffer[e+1])&&ou.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)}};su.Lexer=ss});var ls=C(au=>{"use strict";var cs=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}}}};au.LineCounter=cs});var fs=C(du=>{"use strict";var cw=er("process"),cu=Gr(),lw=as();function He(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function lu(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function fu(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 Vr(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 $t(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 Xr(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 uu(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!He(e.start,"explicit-key-ind")&&!He(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,fu(e.value)?e.value.end?Xr(e.value.end,e.sep):e.value.end=e.sep:Xr(e.start,e.sep),delete e.sep)}var us=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 lw.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,cw.env.LOG_TOKENS&&console.log("|",cu.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=cu.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"&&uu(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&&lu(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":{lu(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let 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=Vr(this.peek(2)),r=$t(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)){Xr(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(He(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(fu(n.key)&&!He(n.sep,"newline")){let s=$t(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(He(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let s=$t(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]}):He(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&&!He(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)){Xr(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||He(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=Vr(r),o=$t(i);uu(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=Dr(e),r=Nt(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=Dr(e),r=Nt(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())}}};Gl.Parser=Xo});var eu=C(yn=>{"use strict";var Vl=Mo(),Dg=ln(),wn=dn(),Fg=Li(),Wg=O(),Bg=Vo(),Xl=Qo();function Ql(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Bg.LineCounter||null,prettyErrors:e}}function Kg(t,e={}){let{lineCounter:n,prettyErrors:r}=Ql(e),i=new Xl.Parser(n?.addNewLine),o=new Vl.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 Zl(t,e={}){let{lineCounter:n,prettyErrors:r}=Ql(e),i=new Xl.Parser(n?.addNewLine),o=new Vl.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 Ug(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let i=Zl(t,n);if(!i)return null;if(i.warnings.forEach(o=>Fg.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 Hg(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 Wg.isDocument(t)&&!r?t.toString(n):new Dg.Document(t,r,n).toString(n)}yn.parse=Ug;yn.parseAllDocuments=Kg;yn.parseDocument=Zl;yn.stringify=Hg});var At=C(T=>{"use strict";var Jg=Mo(),Yg=ln(),zg=yo(),Zo=dn(),Gg=Jt(),Me=O(),Vg=Ie(),Xg=M(),Qg=Le(),Zg=$e(),ew=qr(),tw=zo(),nw=Vo(),rw=Qo(),Wr=eu(),tu=Bt();T.Composer=Jg.Composer;T.Document=Yg.Document;T.Schema=zg.Schema;T.YAMLError=Zo.YAMLError;T.YAMLParseError=Zo.YAMLParseError;T.YAMLWarning=Zo.YAMLWarning;T.Alias=Gg.Alias;T.isAlias=Me.isAlias;T.isCollection=Me.isCollection;T.isDocument=Me.isDocument;T.isMap=Me.isMap;T.isNode=Me.isNode;T.isPair=Me.isPair;T.isScalar=Me.isScalar;T.isSeq=Me.isSeq;T.Pair=Vg.Pair;T.Scalar=Xg.Scalar;T.YAMLMap=Qg.YAMLMap;T.YAMLSeq=Zg.YAMLSeq;T.CST=ew;T.Lexer=tw.Lexer;T.LineCounter=nw.LineCounter;T.Parser=rw.Parser;T.parse=Wr.parse;T.parseAllDocuments=Wr.parseAllDocuments;T.parseDocument=Wr.parseDocument;T.stringify=Wr.stringify;T.visit=tu.visit;T.visitAsync=tu.visitAsync});import De from"path";function cw(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||De.posix.isAbsolute(n)||De.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 kn(t){let e=cw(t,"native.artifact_root");return e.length===0?".":e.join("/")}function uu(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 G(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||De.posix.isAbsolute(r)||De.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 xe(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function fu(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 bn(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>es)throw new Error(`${e} exceeds ${es} 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>ts)throw new Error(`${e} contains more than ${ts} wildcard tokens`);return t}function su(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=>bn(r,e)))].sort((r,i)=>r.localeCompare(i,"en"))}function vn(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 au(t,e,n){let r=vn(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 lw(t){if(t===void 0)return{...ie,include:[...ie.include],exclude:[...ie.exclude]};let e=xe(t,"native.snapshot");return{include:su(e.include,"native.snapshot.include",ie.include),exclude:su(e.exclude,"native.snapshot.exclude",ie.exclude),max_files:vn(e.max_files,ie.max_files,"native.snapshot.max_files"),max_total_bytes:vn(e.max_total_bytes,ie.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:vn(e.max_duration_ms,ie.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:vn(e.max_selection_records,ie.max_selection_records,"native.snapshot.max_selection_records")}}function uw(t){if(t===void 0)return;let e=xe(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=xe(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:kn(r),toArtifactRoot:kn(i),stage:o,...s?{cleanup:s}:{}}}function fw(t){if(t===void 0)return;let e=xe(t,"native.finish");if(e.pull_request===void 0)return{};let n=xe(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(De.posix.isAbsolute(r[0])||De.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??iw;if(!Number.isSafeInteger(i)||i<1||i>ou)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${ou}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:i}}}function dw(t,e={}){let n=xe(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??cu;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=uw(n.pending_root_move),l=fw(n.finish);return{artifact_root:kn(r),language:fu(n.language,"en","native.language"),clarification_mode:i,archive_confirmation:o,max_verify_failures:s,...a==="revert"?{document_writes:a}:{},snapshot:lw(n.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function mw(t){let e=xe(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:uu(e.artifact_layout),language:fu(e.language,"zh-CN","classic.language"),context_compression:n,review_mode:r,auto_transition:i,...o==="strict"?{document_evidence:o}:{}}}function pw(t){let n=xe(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)=>G(r,`hook.allow_paths[${i}]`)))]}}function hw(t){if(t===void 0)return{...Br};let e=xe(t,"memory"),n=e.learning??Br.learning,r=e.retrieval??Br.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 rs(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function gw(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")||De.posix.isAbsolute(n)||De.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>nu)throw new Error(`${e} exceeds ${nu} 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>ru)throw new Error(`${e} contains more than ${ru} wildcard tokens`);return n}function ww(t){let e=rs(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)=>gw(i,`knowledge.local.include[${o}]`)))],max_file_mb:au(e.max_file_mb,iu.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:au(e.max_total_mb,iu.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 yw(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 vw(t){let e=rs(t,"knowledge.remote"),n=yw(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{...lu};let e=rs(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:ww(e.local);if(n==="local")return{provider:n,...r?{local:r}:{}};let i=e.remote===void 0?void 0:vw(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 bw(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function Cw(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 Fe(t,e={}){let n=(0,ns.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=bw(i.ambient_resume),s=i.hook===void 0?void 0:pw(i.hook),a=hw(i.memory),c=kw(i.knowledge),l=i.native===void 0?void 0:dw(i.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=i.classic===void 0?void 0:mw(i.classic),f=Cw(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}:{}}}function is(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Br},knowledge:{...lu},native:{artifact_root:kn(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:cu,snapshot:{...ie,include:[...ie.include],exclude:[...ie.exclude]}}}}var ns,Ot,es,ts,nu,ru,cu,Br,iu,lu,iw,ou,ow,sw,aw,ie,ye=q(()=>{"use strict";ns=Ft(At(),1),Ot=Number.MAX_SAFE_INTEGER,es=1024,ts=64,nu=1024,ru=64,cu=5,Br={learning:!0,retrieval:!0},iu={include:[],max_file_mb:1,max_total_mb:32},lu={provider:"local"},iw=12e4,ou=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/**"],sw=["**/.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"],aw=[...ow,...sw].sort((t,e)=>t.localeCompare(e,"en")),ie={include:["**/*"],exclude:[...aw],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});function We(t){return t!==0&&t!==0n&&t!=="0"}function du(t,e){return We(t.dev)&&We(e.dev)&&We(t.ino)&&We(e.ino)}function Be(t,e){let n=We(t.dev)&&We(e.dev);if(n&&t.dev!==e.dev)return!1;let r=We(t.ino)&&We(e.ino);return r&&t.ino!==e.ino?!1:n&&r?!0:t.birthtime===e.birthtime}var Kr=q(()=>{"use strict"});import{constants as Ke,promises as ne}from"fs";import{createHash as Sw}from"node:crypto";function os(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function mu(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function He(t){return{dev:t.dev,ino:t.ino,birthtime:os(t)}}function Ue(t,e){let n=He(t),r=He(e);return du(n,r)?Be(n,r):Be(n,r)&&os(t)===os(e)&&mu(t)===mu(e)&&t.size===e.size}async function ss(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 ne.lstat(t,{bigint:i});if(!o.isFile()||o.isSymbolicLink())throw new le("not-regular-file",`${r} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new le("too-large",`${r} exceeds ${e} bytes`);let s=await ne.realpath(t);await n.verify?.("pre-open",{realPath:s,identity:He(o)});let a=process.platform==="win32"?Ke.O_RDONLY:Ke.O_RDONLY|Ke.O_NOFOLLOW|Ke.O_NONBLOCK,c;try{c=await ne.open(t,a)}catch(l){throw l.code==="ELOOP"?new le("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,f]=await Promise.all([c.stat({bigint:i}),ne.lstat(t,{bigint:i}),ne.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||f!==s||!Ue(o,l)||!Ue(o,u))throw new le("changed",`${r} changed while opening`);await n.verify?.("post-open",{realPath:f,identity:He(l)}),await n.hooks?.afterOpen?.();let d=[],p=0,g=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let k=e+1-p,{bytesRead:b}=await c.read(g,0,Math.min(g.length,k),null);if(b===0)break;if(p+=b,p>e)throw new le("too-large",`${r} exceeds ${e} bytes`);d.push(Buffer.from(g.subarray(0,b)))}await n.hooks?.beforeFinalCheck?.();let[m,h,v]=await Promise.all([c.stat({bigint:i}),ne.lstat(t,{bigint:i}),ne.realpath(t)]);if(!h.isFile()||h.isSymbolicLink()||v!==s||!Ue(o,m)||!Ue(o,h))throw new le("changed",`${r} changed while reading`);return await n.verify?.("post-read",{realPath:v,identity:He(m)}),{bytes:Buffer.concat(d,p),stat:m,realPath:v}}finally{await c.close()}}async function pu(t,e={}){let n=e.label??"file",r=e.bigint===!0,i=await ne.lstat(t,{bigint:r});if(!i.isFile()||i.isSymbolicLink())throw new le("not-regular-file",`${n} must be a regular file`);let o=await ne.realpath(t);await e.verify?.("pre-open",{realPath:o,identity:He(i)});let s=process.platform==="win32"?Ke.O_RDONLY:Ke.O_RDONLY|Ke.O_NOFOLLOW|Ke.O_NONBLOCK,a;try{a=await ne.open(t,s)}catch(c){throw c.code==="ELOOP"?new le("not-regular-file",`${n} must be a regular file`,{cause:c}):c}try{let[c,l,u]=await Promise.all([a.stat({bigint:r}),ne.lstat(t,{bigint:r}),ne.realpath(t)]);if(!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!Ue(i,c)||!Ue(i,l))throw new le("changed",`${n} changed while opening`);await e.verify?.("post-open",{realPath:u,identity:He(c)}),await e.hooks?.afterOpen?.();let f=Sw(e.algorithm??"sha256"),d=Buffer.allocUnsafe(64*1024);for(;;){let{bytesRead:h}=await a.read(d,0,d.length,null);if(h===0)break;f.update(d.subarray(0,h))}await e.hooks?.beforeFinalCheck?.();let[p,g,m]=await Promise.all([a.stat({bigint:r}),ne.lstat(t,{bigint:r}),ne.realpath(t)]);if(!g.isFile()||g.isSymbolicLink()||m!==o||!Ue(i,p)||!Ue(i,g))throw new le("changed",`${n} changed while reading`);return await e.verify?.("post-read",{realPath:m,identity:He(p)}),{digest:f.digest("hex"),stat:p,realPath:m}}finally{await a.close()}}var le,as=q(()=>{"use strict";Kr();le=class extends Error{reason;constructor(e,n,r){super(n,r),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Ur}from"fs";import Je from"path";async function hu(t,e,n){let r=await L(t,e,{label:n.label,expected:"file"});if(!r.exists){let o=new Error(`${n.label} does not exist`);throw o.code="ENOENT",o}let i=await cs(r.projectRoot,n.label);return pu(r.target,{...n,verify:async(o,s)=>{if(!Hr(i,s.realPath))throw new Error(`${n.label} resolves outside the project root`);await ls(r.projectRoot,i,r.relative.split("/"),{label:n.label,expected:"file"})}})}function Ew(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Hr(t,e){let n=Je.relative(t,e);return n===""||!Je.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${Je.sep}`)}async function cs(t,e){let n=Je.resolve(t),r=await Ur.lstat(n);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Ur.realpath(n)}async function ls(t,e,n,r){let i=t;for(let o=0;o<n.length;o++){i=Je.join(i,n[o]);let s;try{s=await Ur.lstat(i)}catch(u){if(Ew(u))return{exists:!1,kind:"missing"};throw u}let a=Je.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 Ur.realpath(i);if(!Hr(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 L(t,e,n){let r=G(e,n.label),i=Je.resolve(t),o=await cs(i,n.label),s=r.split("/"),a=Je.resolve(i,...s);if(!Hr(i,a))throw new Error(`${n.label} must stay inside the project root`);let c=await ls(i,o,s,n);return{projectRoot:i,target:a,relative:r,exists:c.exists,kind:c.kind}}async function us(t,e,n){return(await L(t,e,{...n,expected:"file"})).exists}async function W(t,e,n,r){let i=await L(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 cs(i.projectRoot,r.label);return ss(i.target,n,{...r,verify:async(s,a)=>{if(!Hr(o,a.realPath))throw new Error(`${r.label} resolves outside the project root`);await ls(i.projectRoot,o,i.relative.split("/"),{label:r.label,expected:"file"})}})}var V=q(()=>{"use strict";as();ye()});import{createHash as xw}from"crypto";function _w(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function ct(t,e={}){return(await Jr(t,e)).document}async function Pw(t){try{return(await W(t,Cn,Ot,{label:Cn})).bytes}catch(e){if(_w(e))return null;throw e}}function Rw(t){return t?{exists:!0,sha256:xw("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Jr(t,e={}){let n=await Pw(t);return{document:n?Fe(n.toString("utf8"),e):null,identity:Rw(n)}}async function fs(t){return(await ct(t))?.config??null}var Cn,lt=q(()=>{"use strict";ye();V();Cn=".comet/config.yaml"});import{promises as ms}from"node:fs";async function ps(t,e){let n;for(let r=0;r<=ds.length;r+=1)try{return await t()}catch(i){n=i;let o=i.code;if(r===ds.length||!Nw.has(o??""))throw i;await new Promise(s=>setTimeout(s,ds[r]))}throw n}async function gu(t,e){await ps(()=>ms.rename(t,e),`rename ${e}`)}async function Yr(t){await ps(()=>ms.unlink(t),`unlink ${t}`)}async function wu(t,e){await ps(()=>ms.link(t,e),`link ${e}`)}var Nw,ds,hs=q(()=>{"use strict";Nw=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),ds=[50,100,200]});import{randomUUID as Aw}from"crypto";import{constants as Ow,promises as B}from"fs";import Y from"path";async function gs(t,e){try{return await wu(t,e),{linked:!0}}catch(n){let r=n.code;if(r!=="ENOTSUP"&&r!=="EOPNOTSUPP")throw n}return await B.copyFile(t,e,Ow.COPYFILE_EXCL),{linked:!1}}function ut(t,e){let n=Y.relative(t,e);return n===""||!Y.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${Y.sep}`)}function zr(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Tw(t,e){return Be(t,zr(e))}function Gr(t,e){return Be(zr(t),zr(e))}function yu(t,e){return Gr(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Vr(t){let e=await B.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 B.realpath(t),...zr(e)}}async function _e(t){for(let e of t){let n=await B.lstat(e.path);if(!n.isDirectory()||n.isSymbolicLink()||!Tw(e,n)||await B.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function Iw(t,e,n){let[r,i]=await Promise.all([B.lstat(t),B.realpath(t),_e(n)]);if(!r.isFile()||r.isSymbolicLink()||!Gr(r,e)||!ut(n[0].realPath,i))throw new Error("Contained atomic write temporary file changed after close");return r}async function jw(t,e){let n=Y.resolve(t),r=Y.resolve(e);if(!ut(n,r))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let i=[await Vr(n)],o=Y.relative(n,r).split(Y.sep).filter(Boolean),s=n;for(let a of o){await _e(i),s=Y.join(s,a);try{await B.mkdir(s)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Vr(s);if(!ut(i[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${s}`);i.push(c)}return await _e(i),i}async function Lw(t,e){let n=Y.resolve(t),r=Y.resolve(e);if(!ut(n,r))throw new Error(`Contained file parent is outside its managed root: ${e}`);let i=[await Vr(n)],o=Y.relative(n,r).split(Y.sep).filter(Boolean),s=n;for(let a of o){s=Y.join(s,a);try{let c=await Vr(s);if(!ut(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 _e(i),i}async function vu(t){let e;try{e=await B.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 $w(t,e,n){let r=Y.dirname(t),i=await jw(n.containedRoot,r),o=Y.join(r,`.${Y.basename(t)}.${Aw()}.tmp`),s,a,c;try{await n.beforeTemporaryOpen?.(),s=await B.open(o,"wx"),a=await s.stat();let[l,u]=await Promise.all([B.lstat(o),B.realpath(o)]);if(await _e(i),!l.isFile()||l.isSymbolicLink()||!Gr(a,l)||!ut(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(),!Gr(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 Iw(o,c,i),await n.beforeCommit?.(),await _e(i);let f=await B.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!c||!yu(f,c))throw new Error("Contained atomic write temporary file changed before commit");n.exclusive?(await gs(o,t),await B.unlink(o)):await gu(o,t),await vu(r)}catch(l){await s?.close();try{await _e(i),await B.rm(o,{force:!0})}catch{}throw l}}async function oe(t,e,n){await $w(t,e,n)}async function Tt(t,e){let n=Y.dirname(t),r=await Lw(e.containedRoot,n);if(!r)return!1;let i,o;try{i=await B.lstat(t),o=await B.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!i.isFile()||i.isSymbolicLink()||!ut(r[0].realPath,o))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await _e(r);let[s,a]=await Promise.all([B.lstat(t),B.realpath(t)]);if(!s.isFile()||s.isSymbolicLink()||!yu(i,s)||a!==o)throw new Error("Contained file removal target changed before removal");return await Yr(t),await _e(r),await vu(n),!0}var Ye=q(()=>{"use strict";hs();Kr()});var AC,ws=q(()=>{"use strict";Ye();lt();V();AC=16*1024});var vs=q(()=>{"use strict";Ye();ye();lt();V();ws()});var ii=q(()=>{"use strict"});var zu=q(()=>{"use strict"});var Ms=q(()=>{"use strict";ii()});var Gu=q(()=>{"use strict";ii();Ms()});function Uy(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Hy(t){let e=(0,Vu.parseDocument)(t,{uniqueKeys:!0});if(e.errors.length>0)throw new Error(`Invalid global Comet config: ${e.errors[0].message}`);let n=e.toJS();if(n==null)return{};if(typeof n!="object"||Array.isArray(n))throw new Error("Invalid global Comet config: root must be a mapping");return n}function Qu(t){if(t.native?.pending_root_move)throw new Error("Global Comet config cannot contain native.pending_root_move");let e=t.native?(({pending_root_move:n,...r})=>r)(t.native):void 0;return{...t,schema:"comet.global.v1",...e?{native:e}:{}}}function Jy(t){let e=Fe(JSON.stringify({...t,schema:"comet.project.v1"})).config;if(!e)throw new Error("Invalid global Comet config: workflow template is incomplete");return Qu(e)}function Yy(t){let e=Fe(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e.native&&!e.classic)return null;let n=e.native?"native":"classic",r=e.native?.language??e.classic?.language??"en",i=is(e.native?.artifact_root??"docs",r);return{schema:"comet.global.v1",default_workflow:n,workflows:[n],ambient_resume:e.ambient_resume,...e.native?{native:{...i.native,...e.native}}:{},...e.classic?{classic:e.classic}:{}}}function Zu(t){let e=Hy(t);if(Object.keys(e).length===0)return null;if(e.schema===void 0)return Yy(t);if(e.schema!=="comet.global.v1")throw new Error("Unsupported Comet global schema");return Jy(e)}async function Ds(t){try{let e=await W(t,Xu,Ot,{label:"global Comet config"});return Zu(e.bytes.toString("utf8"))}catch(e){if(Uy(e))return null;throw e}}var Vu,Xu,Fs=q(()=>{"use strict";Vu=Ft(At(),1);Ye();ye();V();Xu=".comet/config.yaml"});var dE,ef=q(()=>{"use strict";Ye();V();dE=4*1024*1024});function Gy(t,e){let n=t;for(let r of e)n+="\0"+(typeof r=="string"?r:JSON.stringify(r));return n}function tf(t,e){return(...n)=>{let r=zy;if(r===null)return e(...n);let i=Gy(`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}}var zy,nf=q(()=>{"use strict";zy=null});var wE,rf=q(()=>{"use strict";nf();lt();wE=tf("hookWritePolicy",async t=>(await fs(t))?.hook??{allow_paths:[]})});var Vy,of=q(()=>{"use strict";as();Vy=16*1024});var sf=q(()=>{"use strict";ii();Ye();zu();Gu();ye();Fs();V();lt();vs();ef();rf();of();ws();Ms()});import{TextDecoder as Xy}from"util";function af(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Qy(t,e){try{return new Xy("utf-8",{fatal:!0}).decode(t.bytes)}catch(n){throw new Error(`${e} is not valid UTF-8`,{cause:n})}}async function Ws(t,e,n,r,i={}){try{let o=await W(t,e,n,{label:r,hooks:i.hooks});return{result:o,text:Qy(o,r)}}catch(o){let s=o.code;if(s==="ENOENT"||s==="ENOTDIR")return null;throw o}}async function An(t,e,n,r,i={}){return(await Ws(t,e,n,r,i))?.text??null}async function ht(t,e,n,r,i,o={}){if(Buffer.byteLength(n,"utf8")>r)throw new Error(`${i} exceeds ${r} bytes`);let s=await Ws(t,e,r,i),a=await L(t,e,{label:i,expected:"file"});await oe(a.target,n,{containedRoot:a.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await Ws(t,e,r,i);if(!(!s&&!c)){if(!s||!c)throw new Error(`${i} changed before commit`);if(s.result.realPath!==c.result.realPath||!Be(af(s.result.stat),af(c.result.stat))||s.text!==c.text)throw new Error(`${i} changed before commit`)}}})}async function cf(t,e,n,r,i,o={}){let s=await An(t,e,r,i);await ht(t,e,`${s??""}${n}`,r,i,o)}async function Bs(t,e,n,r={}){let i=await L(t,e,{label:n,expected:"file"});return i.exists?Tt(i.target,{containedRoot:i.projectRoot,beforeRemove:r.beforeRemove}):!1}var Ks=q(()=>{"use strict";sf();Kr()});var ff={};Pd(ff,{RUN_STATE_FILE:()=>oi,applyRunStateToDocument:()=>Us,readRunState:()=>si,removeRunState:()=>In,runStateFromDocument:()=>jt,writeRunState:()=>Lt});import Zy from"path";function Tn(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 On(t,e){let n=Tn(t,e);if(Zy.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 ev(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 jt(t){if(!t.run_id)return null;let e=Tn(t,"run_id"),n=Tn(t,"skill"),r=Tn(t,"skill_version"),i=Tn(t,"skill_hash"),o=On(t,"pending_ref"),s=On(t,"trajectory_ref"),a=On(t,"context_ref"),c=On(t,"artifacts_ref"),l=On(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:ev(t)}}function Us(t,e){e?t.run_id=e.runId:delete t.run_id}function tv(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 nv(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 jt(e)}async function si(t,e={}){let n=await An(t,oi,uf,"Run state",e);if(n===null)return null;let r=JSON.parse(n);return nv(r)}async function Lt(t,e,n={}){await ht(t,oi,JSON.stringify(tv(e),null,2),uf,"Run state",n)}async function In(t,e={}){await Bs(t,oi,"Run state",e)}var lf,oi,uf,ai=q(()=>{"use strict";Ks();lf=(t,e)=>{let n=t[e];return n==null?null:String(n)};oi=".comet/run-state.json",uf=Number.MAX_SAFE_INTEGER});import md from"node:path";import{AsyncLocalStorage as Hw}from"async_hooks";import{promises as _u}from"fs";import En from"path";import{promises as Su}from"fs";import $ from"path";import{promises as Nd}from"fs";async function Wt(t){try{return await Nd.access(t),!0}catch(e){if(Ad(e))return!1;throw e}}function Ad(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}ye();lt();vs();V();var Sn=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Cu=".comet/config.yaml";function Eu(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function xu(t){await L(t,Cu,{label:Cu,expected:"file"})}function Xr(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 Ww(t){await xu(t);let e=await ct(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new Sn;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new Sn("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function ks(t,e){return Xr(t,e??await Ww(t))}async function Bw(t){try{return await Su.lstat(t),!0}catch(e){if(Eu(e))return!1;throw e}}async function Kw(t,e){let n=await ks(t,e),r=n.artifactLayout==="legacy"?"docs":"legacy",i=Xr(t,r).openSpecRoot,[o,s]=await Promise.all([L(n.projectRoot,z(n.projectRoot,n.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),Bw(i)]),a=o.exists;return{paths:n,configuredRootExists:a,alternateRoot:i,alternateRootExists:s,dualRoots:a&&s}}async function Uw(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=z(t.projectRoot,n);await L(t.projectRoot,r,{label:`Classic managed physical path ${r}`,expected:"directory"})}}async function ve(t,e){let n=await Kw(t,e);if(await Uw(n.paths),!n.configuredRootExists){let r=z(n.paths.projectRoot,n.paths.openSpecRoot),i=z(n.paths.projectRoot,n.alternateRoot);throw new Sn(`Configured Classic OpenSpec root is missing: ${r} (alternate ${i} is ${n.alternateRootExists?"present":"missing"})`)}return n.paths}async function bs(t,e){let n=$.join($.resolve(t),".comet","classic-root-move.json");if(await Wt(n))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let r=await ve(t,e);if(!await Wt(r.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${z(r.projectRoot,r.openSpecRoot)}`);return r}async function ft(t){let e=$.resolve(t),n=null;try{(await Su.lstat(e)).isDirectory()||(e=$.dirname(e))}catch(r){if(!Eu(r))throw r}for(;;){$.basename(e)==="openspec"&&(n=$.dirname(e));let r=$.join(e,".comet","config.yaml"),i=!1;if(await Wt(r))try{await xu(e);let s=(await ct(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 Wt($.join(e,".git")))return e;let o=$.dirname(e);if(o===e)return n??$.resolve(t);e=o}}function z(t,e){return $.relative($.resolve(t),e).replaceAll("\\","/")}var Qr=new Hw;function Jw(t,e){let n=En.relative(t,e);return n===""||!En.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${En.sep}`)}async function Yw(t){let e=En.resolve(t.invocationCwd??process.cwd()),n=En.resolve(t.projectRoot??await ft(e)),[r,i]=await Promise.all([_u.realpath(e),_u.realpath(n)]);if(!Jw(i,r))throw new Error(`Classic command invocation cwd is outside the discovered project: ${e}`);return{invocationCwd:e,projectRoot:n,observations:new Map}}async function zw(t,e){let n=Qr.getStore();if(n)return e(n);let r=await Yw(t);return Qr.run(r,()=>e(r))}function Pu(){let t=Qr.getStore();if(!t)throw new Error("Classic command project context is unavailable");return t.projectRoot}function Ru(){let t=Qr.getStore();if(!t)throw new Error("Classic command invocation context is unavailable");return t.invocationCwd}function Nu(t){return(e,n)=>zw(n,()=>t(e,n))}import{promises as xs}from"fs";import ei from"path";Ye();ye();V();import xn from"path";var Vw=Number.MAX_SAFE_INTEGER;function Cs(t,e,n){let r=xn.resolve(t),i=xn.isAbsolute(e)?xn.resolve(e):xn.resolve(r,e),o=xn.relative(r,i).replaceAll("\\","/");return{root:r,relative:G(o,n),target:i}}async function ke(t,e,n){let r=Cs(t,e,n.label);return L(r.root,r.relative,n)}async function Zr(t,e,n){return(await ke(t,e,{label:n.label,expected:n.expected??"any"})).exists}async function Pe(t,e,n){return(await Ss(t,e,n)).toString("utf8")}async function Ss(t,e,n){let r=Cs(t,e,n.label);return(await W(r.root,r.relative,n.maxBytes??Vw,{label:n.label,hooks:n.hooks})).bytes}async function Es(t,e,n,r){let i=Cs(t,e,r.label);await L(i.root,i.relative,{label:r.label,expected:"file"}),await oe(i.target,n,{containedRoot:i.root,beforeTemporaryOpen:r.beforeTemporaryOpen,beforeCommit:r.beforeCommit,exclusive:r.exclusive})}async function Au(t,e){let n=[],r=new Set;async function i(o,s){let a=await ke(t,o,{label:"Classic capability directory",expected:"directory"});if(!a.exists)return;let c=await xs.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 ke(t,u,{label:"Classic capability spec",expected:"file"})).exists&&n.push(u)}let l=(await xs.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 Xw(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}'
|
|
143
|
-
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function Ps(t){let e=Xw(t);if(e)throw new Error(e)}function Qw(t,e){return{label:z(t,e),directory:e}}async function _s(t,e,n){let r=Qw(t,e);if(!(await ke(t,e,{label:n,expected:"directory"})).exists)return{change:r,exists:!1,stateExists:!1};let o=await ke(t,ei.join(e,".comet.yaml"),{label:`${n} state`,expected:"file"});return{change:r,exists:!0,stateExists:o.exists}}function Zw(t,e){let n=e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`^\\d{4}-\\d{2}-\\d{2}-${n}$`,"u").test(t)}async function ey(t,e,n,r={}){if(!r.skipExactCompatibility){let s=await _s(t,ei.join(e,n),`Classic archived change ${n}`);if(s.exists)return s.change}if(!(await ke(t,e,{label:"Classic archive directory",expected:"directory"})).exists)return null;let o=[];for(let s of await xs.readdir(e,{withFileTypes:!0})){if(!Zw(s.name,n))continue;let a=await _s(t,ei.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 Ou(t,e=process.cwd()){Ps(t);let n=await ve(e),r=await _s(n.projectRoot,ei.join(n.changesDir,t),`Classic active change ${t}`);if(r.exists)return r.change;let i=await ey(n.projectRoot,n.archiveDir,t);return i||r.change}import{promises as Hf}from"fs";import se from"path";import{fileURLToPath as Jf}from"url";import ze from"path";function Tu(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 Iu(t){let e=Tu(t);return e.missingFields.length===0&&e.invalidFields.length===0}var ty=Ft(At(),1);import dt from"node:path";async function ju(t,e,n={}){if(!e||e==="null")return{status:"missing",recordedPath:null};let r=await ve(t),i=dt.resolve(t,e),o=dt.relative(r.superpowersPlansDir,i);return dt.isAbsolute(e)||!o||o.startsWith(`..${dt.sep}`)||dt.isAbsolute(o)||o.includes(dt.sep)||dt.extname(o).toLowerCase()!==".md"?{status:"broken",recordedPath:e}:await Zr(t,e,{label:`Classic build plan ${e}`,expected:"file"})&&(!n.requireNonempty||(await Pe(t,e,{label:`Classic build plan ${e}`})).trim().length>0)?{status:"ready",recordedPath:e}:{status:"broken",recordedPath:e}}var ny=/^(\s*[-*]\s+\[)([ xX])(\]\s+)(.*)$/u,ry=/\s*<!-- comet-task:([a-zA-Z0-9][a-zA-Z0-9_-]{0,79}) -->\s*$/u;function Rs(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=ny.exec(o);if(!a)continue;let c=ry.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}function Lu(t){let e=t.split(/(?<=\n)/u);for(let n of Rs(t))e[n.line-1]=e[n.line-1].replace(/^(\s*[-*]\s+\[)[ xX](\])/u,"$1 $2");return e.join("")}V();ye();import _n from"path";function iy(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function $u(t,e,n,r){let i=G(n,"Classic handoff artifact pointer");if((await L(t,i,{label:"Classic handoff artifact",expected:"file"})).exists)return null;let s=await ve(t),a=`${z(t,s.changesDir)}/`,l=(s.artifactLayout==="docs"?[a,"openspec/changes/"]:[a]).find(k=>i.startsWith(k));if(!l)return null;let u=i.slice(l.length).split("/");if(u.length<4||u[1]!==".comet"||u.slice(2).some(k=>k.length===0))return null;let f=u[0];Ps(f);let d=u.slice(2),p=_n.resolve(e);if(_n.dirname(p)!==_n.resolve(s.archiveDir))return null;let g=_n.basename(p),m=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(g);if(g!==f&&m?.[1]!==f)return null;await L(t,z(t,p),{label:"Classic archived change directory",expected:"directory"});let h=_n.join(p,".comet",...d),v=z(t,h);try{return await W(t,v,r,{label:"Historical Classic archived handoff artifact"}),v}catch(k){if(iy(k))return null;throw k}}V();function Ns(t,e){return ze.relative(t,e).split(ze.sep).join("/")}async function Pn(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=z(t,Xr(t,a).openSpecRoot);if((o===c||o.startsWith(`${c}/`))&&(await L(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 us(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 oy(t,e,n,r){try{r??=await ve(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 Pn(t,"design.handoff",n,r);if(!n||i.satisfied||i.detail)return i;try{let o=await $u(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 ti(t,e,n){return Pn(t,e,Ns(t,n))}async function sy(t,e){let n=ze.join(e,"specs"),r;try{r=await Au(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]?Ns(t,r[0]):void 0,detail:`${r.length} delta spec${r.length===1?"":"s"}`}}async function ay(t,e){let n,r=Ns(t,e);try{n=(await W(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=Rs(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 It(t,e){return t.some(n=>n.code===e&&n.satisfied)}async function Rn(t,e){let n=await ft(t),r=e.classic,i=ze.join(t,"proposal.md"),o=ze.join(t,"design.md"),s=ze.join(t,"tasks.md"),a=e.run?ze.resolve(t,e.run.checkpointRef):ze.join(t,".comet","checkpoint.json"),c,l;try{c=await ve(n)}catch(d){l=d}let u=await Promise.all([ti(n,"openspec.proposal",i),ti(n,"openspec.design",o),ti(n,"openspec.tasks",s),sy(n,t),Pn(n,"design.document",r?.designDoc??null,c,l),(async()=>{let d=await Pn(n,"build.plan",r?.plan??null,c,l);if(!d.satisfied)return d;try{let p=await ju(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)}}})(),ay(n,s),Pn(n,"verification.report",r?.verificationReport??null,c,l),oy(n,t,r?.handoffContext??null,c),ti(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 Vv,randomUUID as Xv}from"crypto";import{promises as na}from"fs";import Re from"path";function cy(t){return t.classicProfile??t.workflow}function ly(t){return t.isolation!==null&&Iu(t)}function uy(t){return(t.buildMode==="direct"||t.buildMode==="autonomous")&&t.tddMode==="direct"&&t.isolation!==null&&t.verifyMode==="light"}function fy(t,e,n){if(t!=="full"&&e.verifyResult==="fail")return`${t}.build.execute`;if(t==="full"){if(It(n,"build.plan")&&e.buildPause==="plan-ready")return"full.build.plan-ready";if(!ly(e))return"full.build.configure";if(!It(n,"build.plan"))return"full.build.plan";if(e.verifyResult==="fail")return"full.build.fix"}else if(!uy(e))throw new Error(`${t} build configuration is incomplete`);return It(n,"build.tasks-complete")?`${t}.build.complete`:`${t}.build.execute`}function dy(t,e,n){return e.verifyResult!=="pass"||!It(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 As(t,e){let n=cy(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 It(e,"design.handoff")?"full.design.document":"full.design.handoff";case"build":return fy(n,t,e);case"verify":return dy(n,t,e);case"archive":return my(n,t)}}import Ve from"path";import{AsyncLocalStorage as bv}from"node:async_hooks";hs();import{randomUUID as Ty}from"node:crypto";import{promises as pt}from"node:fs";import Hu from"node:os";import Uu from"node:path";import{promises as Fu}from"node:fs";import Wu from"node:path";import{execFileSync as Cy}from"node:child_process";import Du from"node:path";import{spawn as Os}from"node:child_process";import{existsSync as qu}from"node:fs";import mt from"node:path";var py=new Set([".bat",".cmd",".ps1"]),hy=new Set([".bat",".cmd"]),gy=/[&|<>()^%"!\r\n]/u,wy=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");function Ts(t,e){let n=e.toLowerCase();return Object.entries(t).find(([r,i])=>r.toLowerCase()===n&&i!==void 0)?.[1]}function yy(t){let e=(Ts(t,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").map(n=>n.trim().toLowerCase()).filter(Boolean);return[...new Set([...e,".ps1"])]}function vy(t,e,n){let i=mt.win32.isAbsolute(t)||/[\\/]/u.test(t)?[""]:(Ts(e,"PATH")??"").split(mt.delimiter).map(a=>a.trim().replace(/^"(.*)"$/u,"$1")).filter(Boolean),s=mt.win32.extname(t)?[t]:yy(e).map(a=>`${t}${a}`);return i.flatMap(a=>s.map(c=>a?mt.join(a,c):mt.resolve(n,c)))}function Nn(t,e,n){return vy(t,e,n).find(r=>qu(r))??t}function ky(t){let e=Ts(t,"SystemRoot");if(e){let n=mt.join(e,"System32","WindowsPowerShell","v1.0","powershell.exe");if(qu(n))return n}return"powershell.exe"}function Is(t){if(t.some(e=>gy.test(e)))throw new Error("Windows batch check arguments must not contain shell syntax")}function by(t,e,n){let r=Buffer.from(JSON.stringify({command:t,arguments:[...e]}),"utf8").toString("base64"),i=Buffer.from(wy,"utf16le").toString("base64");return Os(ky(n.env),["-NoLogo","-NoProfile","-NonInteractive","-InputFormat","None","-OutputFormat","Text","-ExecutionPolicy","Bypass","-EncodedCommand",i],{cwd:n.cwd,env:{...n.env,COMET_COMMAND_PAYLOAD:r},shell:!1,windowsHide:!0,detached:!1,stdio:["ignore","pipe","pipe"]})}function Mu(t,e,n){let r=n.env??process.env;if(process.platform!=="win32")return Os(t,[...e],{cwd:n.cwd,env:r,shell:!1,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});let i=Nn(t,r,n.cwd),o=mt.win32.extname(i).toLowerCase();return hy.has(o)&&Is(e),py.has(o)?by(i,e,{cwd:n.cwd,env:r}):Os(i,[...e],{cwd:n.cwd,env:r,shell:!1,windowsHide:!0,detached:!1,stdio:["ignore","pipe","pipe"]})}var Sy=6e4,Ey=8*1024*1024,js=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};function xy(t){return t instanceof Error&&(t.code==="ETIMEDOUT"||t.killed===!0&&t.signal==="SIGTERM")}function ni(t,e,n={}){let r=n.timeoutMs??Sy,i=n.maxBufferBytes??Ey;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=Du.resolve(n.cwd??process.cwd()),s=n.env??process.env,a=process.platform==="win32"?Nn(t,s,o):t,c=Du.win32.extname(a).toLowerCase(),l=c===".bat"||c===".cmd";process.platform==="win32"&&l&&Is(e);try{return Cy(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 js(t,e,f,{cause:u,timedOut:xy(u)})}}var Ls=null,_y=6e4,Py=1e4,$s=new Map;function Ry(t){let e=$s.get(t);if(!e)return;let n=e.value===null?Py:_y;if(Date.now()-e.at>n){$s.delete(t);return}return e.value}async function qs(t){if(t===process.pid&&Ls!==null)return Ls;let e=Ry(t);if(e!==void 0)return e;let n=await Ny(t);return t===process.pid&&n!==null&&(Ls=n),t!==process.pid&&$s.set(t,{value:n,at:Date.now()}),n}async function Ny(t){if(!Number.isSafeInteger(t)||t<=0)return null;try{if(process.platform==="linux"){let[e,n]=await Promise.all([Fu.readFile(`/proc/${t}/stat`,"utf8"),Fu.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 Oy(t);if(process.platform==="darwin"){let e=ni("/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 Ay(t){let e=t.trim();return/^\d+$/u.test(e)?`win32-ps:${e}`:null}async function Oy(t){try{let i=ni(Wu.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=Wu.win32.join(e,"System32","WindowsPowerShell","v1.0","powershell.exe"),r=ni(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${t} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`],{timeoutMs:8e3,maxBufferBytes:4096}).trim();return Ay(r)}var Bu=new Set(["win32-wmic","win32-ps"]);function ri(t){let e=t.indexOf(":");return e===-1?"":t.slice(0,e)}async function Ku(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 qs(t);return n===e?"alive":n===null||ri(n)!==ri(e)&&Bu.has(ri(n))&&Bu.has(ri(e))?"unknown":"dead"}var Iy=3e4,jy=20,Ly=5*6e4,$y=1e4;async function Ju(t,e,n={}){let r=Uu.resolve(t);await pt.mkdir(Uu.dirname(r),{recursive:!0});let i=Date.now(),o=n.timeoutMs??Iy,s=n.retryMs??jy,a=n.malformedLockStaleMs??Ly,c=await qs(process.pid),l={pid:process.pid,nonce:Ty(),createdAt:Date.now(),hostname:Hu.hostname(),...c===null?{}:{processIdentity:c}},u=!1;for(;!u;){let f;try{f=await pt.open(r,"wx"),await f.writeFile(JSON.stringify(l),"utf8"),u=!0}catch(d){if(d.code!=="EEXIST")throw d;if(await qy(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 My(r,l.nonce)}}async function qy(t,e){let n,r;try{[n,r]=await Promise.all([pt.readFile(t,"utf8"),pt.stat(t)])}catch(o){return o.code==="ENOENT"}let i=Yu(n);if(i!==null&&(i.hostname!==void 0&&i.hostname!==Hu.hostname()||await Ku(i.pid,i.processIdentity)!=="dead"))return!1;if(i===null){let o=n.trim().length===0?$y:e;if(Date.now()-Number(r.mtimeMs)<o)return!1}try{return await pt.readFile(t,"utf8")!==n?!1:(await pt.rm(t),!0)}catch(o){return o.code==="ENOENT"}}async function My(t,e){try{if(Yu(await pt.readFile(t,"utf8"))?.nonce!==e)return;await Yr(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
|
|
144
|
-
`)}}function Yu(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}}V();var li=Ft(At(),1);Ye();V();ai();var df=["full","hotfix","tweak"],gt=1,rv=["open","design","build","verify","archive"],iv=["en","zh-CN"],ov=["off","beta"],sv=["subagent-driven-development","executing-plans","direct","autonomous"],av=["plan-ready"],cv=["confirmed"],lv=["tdd","direct"],uv=["off","standard","thorough"],fv=["current","branch","worktree"],dv=["light","full"],mv=["pending","pass","fail"],pv=["pending","handled"],hv=["pending","confirmed"],Ge=["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"],jn=["run_id"],gv=new Set([...Ge,...jn]),wv=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function Hs(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function $t(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 X(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 Js(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 mf(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 ci(t,e){let n=$t(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 yv(t,e){let n=$t(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 vv(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==gt)throw new Error(`Invalid Classic state: classic_migration must be ${gt}`);return e}function kv(t){if(!Ge.some(n=>Hs(t,n)))return null;for(let n of wv)if(!Hs(t,n))return null;return{workflow:X(t,"workflow",df,!1),language:X(t,"language",iv),phase:X(t,"phase",rv,!1),contextCompression:X(t,"context_compression",ov),buildMode:X(t,"build_mode",sv),buildPause:X(t,"build_pause",av),subagentDispatch:X(t,"subagent_dispatch",cv),tddMode:X(t,"tdd_mode",lv),reviewMode:X(t,"review_mode",uv),isolation:X(t,"isolation",fv),boundBranch:$t(t,"bound_branch"),verifyMode:X(t,"verify_mode",dv),autoTransition:Js(t,"auto_transition"),baseRef:$t(t,"base_ref"),designDoc:ci(t,"design_doc"),plan:ci(t,"plan"),verifyResult:X(t,"verify_result",mv,!1),verifyFailures:mf(t,"verify_failures"),...Hs(t,"check_epoch")?{checkEpoch:mf(t,"check_epoch")}:{},verificationReport:ci(t,"verification_report"),branchStatus:X(t,"branch_status",pv),createdAt:$t(t,"created_at"),verifiedAt:$t(t,"verified_at"),archiveConfirmation:X(t,"archive_confirmation",hv),archived:Js(t,"archived",!1),directOverride:Js(t,"direct_override"),handoffContext:ci(t,"handoff_context"),handoffHash:yv(t,"handoff_hash"),classicProfile:X(t,"classic_profile",df),classicMigration:vv(t)}}function Ys(t,e){let n=e??null;if(n===null&&e===void 0&&t.run_id&&t.skill)try{n=jt(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:kv(t),run:n,unknownKeys:Object.keys(t).filter(r=>!gv.has(r))}}function pf(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}}ai();var hf=new bv,zs=".comet-state-transaction.json";async function Xe(t,e){let n=Ve.resolve(t);return hf.getStore()===n?e():(await L(n,".comet-state.lock",{label:"Classic state lock",expected:"file"}),Ju(Ve.join(n,".comet-state.lock"),()=>hf.run(n,async()=>(await wf(n),e()))))}async function Gs(t,e){try{return(await W(t,e,Number.MAX_SAFE_INTEGER,{label:"Classic state transaction"})).bytes.toString("utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}}function Cv(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=jt({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 wf(t){let e=await Gs(t,zs);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 Gs(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=Cv(r===n.afterYaml?n.afterRun:n.beforeRun);i?await Lt(t,i):await In(t),await Tt(Ve.join(t,zs),{containedRoot:t})}function Ln(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 gf(t,e,n){t.get(e)!==n&&t.set(e,n)}function Sv(t,e){if(e.classic)for(let[n,r]of Object.entries(pf(e.classic)))n==="auto_transition"&&r===null&&!t.has(n)||gf(t,n,r);else for(let n of Ge)t.delete(n);Us(t.toJS(),e.run),e.run?gf(t,"run_id",e.run.runId):t.delete("run_id")}function Ev(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 xv(t){let e=!1;for(let n of["build_command","verify_command"])t.has(n)&&(t.delete(n),e=!0);return e}async function yf(t){let e;try{e=(await W(Ve.dirname(t),Ve.basename(t),Number.MAX_SAFE_INTEGER,{label:"Classic state document"})).bytes.toString("utf8")}catch(r){if(r.code!=="ENOENT")throw r;return new li.Document({})}let n=(0,li.parseDocument)(e);if(n.errors.length>0)throw new Error(`Invalid Classic state document: ${n.errors[0].message}`);return Ln(n),n}async function be(t,e={}){return Xe(t,()=>_v(t,e))}async function _v(t,e){let n=e.migrate!==!1,r=Ve.join(t,".comet.yaml"),i=await yf(r),o=Ln(i),s=xv(i);s&&(o=Ln(i));let a=await si(t);if(!a&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(ai(),ff));a=c(o),a&&n&&(await Lt(t,a),Ev(i),s=!0)}return s&&n&&await oe(r,i.toString(),{containedRoot:t}),Ys(Ln(i),a)}async function Vs(t,e,n={}){return Xe(t,()=>Pv(t,e,n))}async function Pv(t,e,n){let r=Ve.join(t,".comet.yaml"),i=await yf(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");Sv(i,{...e,unknownKeys:e.unknownKeys??[]}),Ys(Ln(i),e.run??null);let s=await Gs(t,".comet.yaml"),a=i.toString();if(s===a){await n.beforeCommit?.(),e.run?await Lt(t,e.run):await In(t);return}let c=Ve.join(t,zs);await oe(c,JSON.stringify({schema:"comet.classic.state-transaction.v1",beforeYaml:s,afterYaml:a,beforeRun:await si(t),afterRun:e.run}),{containedRoot:t});try{e.run?await Lt(t,e.run):await In(t),await oe(r,a,{containedRoot:t,beforeCommit:n.beforeCommit})}catch(l){throw await wf(t).catch(()=>{}),l}await Tt(c,{containedRoot:t}).catch(()=>{})}function vf(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:{}}}Ks();import ui from"path";var $n={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 qn(t,e){if(ui.isAbsolute(e))throw new Error("Run path must stay inside the change directory");let n=ui.resolve(t),r=ui.resolve(n,e);if(r!==n&&!r.startsWith(n+ui.sep))throw new Error("Run path must stay inside the change directory")}async function Mn(t,e,n,r={}){qn(t,e),await cf(t,e,`${JSON.stringify(n)}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
`));let l=await mi(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 Bf(t){try{return await na.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Kf(t){return Vv("sha256").update(t).digest("hex")}function Qv(t){return Kf(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}function Zv(t){return t.replaceAll(".","_").replaceAll("-","_")}async function ek(t,e){let n=await ft(t),r=Object.fromEntries(e.filter(s=>s.satisfied&&s.source).map(s=>[Zv(s.code),s.source])),i=Re.join(t,"subagent-progress.md");await Bf(i)&&(r.subagent_progress=Re.relative(n,i).split(Re.sep).join("/"));let o=e.find(s=>s.code==="design.handoff"&&s.satisfied);return o?.source&&(r.handoff_context=o.source),r}function tk(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:gt,profile:e,source:"pre-migration"}}]}async function nk(t){await Promise.all(t.map(e=>na.rm(e,{recursive:!0,force:!0})))}async function Uf(t,e){return Xe(t,()=>rk(t,e))}async function rk(t,e){let n=await be(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!==gt)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 mi(e.skillPackage)!==n.run.skillHash)return await ta(t,n.run.skillHash),{classic:r,run:n.run,evidence:await Rn(t,n),migrated:!1,snapshotDir:Re.join(t,".comet","skill-snapshots",n.run.skillHash)};let d=await ea(e.skillPackage,t);return{classic:r,run:n.run,evidence:await Rn(t,n),migrated:!1,snapshotDir:d.snapshotDir}}let o=await Rn(t,n),s=As(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 mi(e.skillPackage),c=Re.join(t,".comet","skill-snapshots",a),l=await Bf(c),u=[];try{let f=await ea(e.skillPackage,t),d=vf(e.skillPackage,e.runId?.()??Xv(),f.hash);d.currentStep=s,s==="completed"&&(d.status="completed");let p={...r,classicProfile:i,classicMigration:gt},g=await ek(t,o),m=await ft(t),h=o.find(E=>E.code==="design.handoff"&&E.satisfied),v=null;h?.source&&(v=await Pe(m,h.resolvedSource??h.source,{label:"Classic migration handoff context",hooks:e.handoffReadHooks}),await bf(t,d.contextRef,v),u.push(Re.resolve(t,d.contextRef))),await kf(t,d.artifactsRef,g),u.push(Re.resolve(t,d.artifactsRef));let k=(e.now?.()??new Date).toISOString(),b={runId:d.runId,stateVersion:1,trajectoryOffset:2,contextHash:v===null?null:Kf(v),artifactsHash:Qv(g),createdAt:k};await Cf(t,d.checkpointRef,b),u.push(Re.resolve(t,d.checkpointRef)),u.push(Re.resolve(t,d.trajectoryRef));for(let E of tk(d,i,k))await Mn(t,d.trajectoryRef,E);return await Vs(t,{classic:p,run:d,unknownKeys:n.unknownKeys}),{classic:p,run:d,evidence:o,migrated:!0,snapshotDir:f.snapshotDir}}catch(f){throw await nk(u),l||await na.rm(c,{recursive:!0,force:!0}),f}}async function ik(t){try{return(await Hf.stat(t)).isDirectory()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function pi(t){try{return(await Hf.stat(t)).isFile()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function ok(t){return await ik(t)?await pi(se.join(t,"skill.yaml"))?!0:await pi(se.join(t,"SKILL.md"))&&await pi(se.join(t,"comet","skill.yaml")):!1}function sk(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 ak(){let t=se.dirname(Jf(import.meta.url)),e=[process.env.COMET_RUNTIME_CLASSIC_ROOT,se.resolve(t,"..","runtime","classic"),se.resolve(t,"..","..","comet","runtime","classic"),se.resolve(t,"..","..","assets","skills","comet","runtime","classic"),se.resolve("assets","skills","comet","runtime","classic"),process.env.COMET_CLASSIC_SKILL_ROOT,se.resolve(t,"..","..","comet-classic"),se.resolve(t,"..","..","assets","skills","comet-classic"),se.resolve("assets","skills","comet-classic")].filter(n=>!!n);for(let n of e)if(await ok(n))return n;return null}async function ck(t){return await pi(se.join(t,"skill.yaml"))?Tf(t):Of(t)}async function Yf(t){let e=await ak();return Uf(t,{skillPackage:e?await ck(e):sk(se.dirname(Jf(import.meta.url)))})}import Z from"path";import{createHash as ld,randomUUID as ad}from"node:crypto";import{promises as gi}from"node:fs";import{spawn as lk}from"node:child_process";import ra from"node:path";var uk=1e3,fk=2;async function zf(t){let e=t.pid;if(e===void 0){t.kill("SIGKILL");return}if(process.platform==="win32"){let n=process.env.SystemRoot??process.env.WINDIR,r=n&&ra.win32.isAbsolute(n)?ra.win32.resolve(n):"C:\\Windows",i=ra.win32.join(r,"System32","taskkill.exe"),o=()=>new Promise(s=>{let a=!1,c=null,l=null,u=(f,d=!1)=>{a||(a=!0,l&&clearTimeout(l),d&&c?.kill("SIGKILL"),s(f))};try{c=lk(i,["/pid",String(e),"/t","/f"],{stdio:"ignore",windowsHide:!0}),c.once("error",()=>u(!1)),c.once("close",f=>u(f===0)),l=setTimeout(()=>u(!1,!0),uk)}catch{u(!1)}});for(let s=0;s<fk;s+=1)if(await o()){t.kill("SIGKILL");return}t.kill("SIGKILL"),t.stdin?.destroy(),t.stdout?.destroy(),t.stderr?.destroy();return}try{process.kill(-e,"SIGKILL")}catch(n){if(n.code!=="ESRCH")throw n}t.kill("SIGKILL")}import{spawnSync as gk}from"node:child_process";import{createHash as aa}from"node:crypto";import{promises as pe}from"node:fs";import N from"node:path";V();ye();import{createHash as Zf}from"node:crypto";import{createHash as dk}from"node:crypto";function Gf(t){return[...t].sort((e,n)=>e.p<n.p?-1:e.p>n.p?1:0).map(e=>JSON.stringify({p:e.p,h:e.h,s:e.s??null,m:e.m??null})).join(`
|
|
151
|
-
|
|
152
|
-
`)){if(!n)continue;let r=JSON.parse(n);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Invalid check manifest entry");let{p:i,h:o,s,m:a}=r;if(typeof i!="string"||!i||typeof o!="string"||!o)throw new Error("Invalid check manifest entry");if(s!==null&&typeof s!="number")throw new Error("Invalid check manifest entry");if(a!==null&&typeof a!="string")throw new Error("Invalid check manifest entry");e.push({p:i,h:o,s,m:a})}return e}function oa(t,e){let n=new Map(t.map(o=>[o.p,o])),r=new Map(e.map(o=>[o.p,o])),i=o=>[...o].sort();return{added:i([...r.keys()].filter(o=>!n.has(o))),removed:i([...n.keys()].filter(o=>!r.has(o))),changed:i([...n.keys()].filter(o=>r.has(o)&&n.get(o).h!==r.get(o).h))}}function Mt(t){return/[*?]/u.test(t)}function sa(t){let e=[];for(let r=0;r<t.length;r+=1){let i=t[r];i==="*"&&t[r+1]==="*"?(r+=1,t[r+1]==="/"?(r+=1,e.push({kind:"globstar-slash"})):e.push({kind:"globstar"})):i==="*"?e.push({kind:"star"}):i==="?"?e.push({kind:"question"}):e.push({kind:"literal",value:i})}let n=r=>{let i=new Set(r),o=[...r];for(;o.length>0;){let s=o.pop(),a=e[s];a&&(a.kind==="star"||a.kind==="globstar"||a.kind==="globstar-slash")&&!i.has(s+1)&&(i.add(s+1),o.push(s+1))}return i};return r=>{let i=n(new Set([0]));for(let o of r){let s=new Set;for(let a of i){let c=e[a];c&&(c.kind==="literal"&&c.value===o||c.kind==="question"&&o!=="/"?s.add(a+1):c.kind==="star"&&o!=="/"||c.kind==="globstar"?s.add(a):c.kind==="globstar-slash"&&(s.add(a),o==="/"&&s.add(a+1)))}if(i=n(s),i.size===0)return!1}return n(i).has(e.length)}}var Xf=".comet/check-policy.json",mk=["argv","cwd","files","outputs","env","git","taskCheckboxes"];function pk(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);let n=t;if(Object.keys(n).some(o=>!mk.includes(o)))throw new Error(`${e} has unknown fields`);if(!Array.isArray(n.argv)||!n.argv.length||!n.argv[0]||n.argv.some(o=>typeof o!="string"||o.includes("\0")))throw new Error(`${e} argv must bind literal command arguments`);if(typeof n.cwd!="string"||!n.cwd)throw new Error(`${e} cwd must bind a project-relative directory`);let r=n.cwd==="."?".":G(n.cwd,`${e} cwd`),i={argv:[...n.argv],cwd:r,git:"none",taskCheckboxes:"ignore"};for(let o of["files","outputs","env"])if(n[o]!==void 0&&(!Array.isArray(n[o])||n[o].some(s=>typeof s!="string"||!s)))throw new Error(`${e} ${o} must be an array of nonempty strings`);if(n.files!==void 0&&(i.files=[...new Set(n.files.map(o=>Mt(o)?bn(o,`${e} file`):G(o,`${e} file`)))].sort((o,s)=>o.localeCompare(s,"en"))),n.outputs!==void 0&&(i.outputs=[...new Set(n.outputs.map(o=>Mt(o)?bn(o,`${e} output`):G(o,`${e} output`)))].sort((o,s)=>o.localeCompare(s,"en"))),n.env!==void 0){if(n.env.some(o=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)))throw new Error(`${e} has an invalid environment variable name`);i.env=[...new Set(n.env)].sort((o,s)=>o.localeCompare(s,"en"))}if(n.git!==void 0){if(!["all","none"].includes(n.git))throw new Error(`${e} has an invalid git binding`);i.git=n.git}if(n.taskCheckboxes!==void 0){if(!["include","ignore"].includes(n.taskCheckboxes))throw new Error(`${e} has an invalid taskCheckboxes mode`);i.taskCheckboxes=n.taskCheckboxes}return i}function hk(t){return Zf("sha256").update(JSON.stringify({argv:t.argv,cwd:t.cwd,files:t.files??null,outputs:t.outputs??null,env:t.env??null,git:t.git,taskCheckboxes:t.taskCheckboxes})).digest("hex")}function Qf(t,e){return e.cwd===t.cwd&&JSON.stringify(e.argv)===JSON.stringify(t.argv)}async function et(t,e,n=!1){let r=n?{digest:"",git:"all",taskCheckboxes:"include"}:{digest:"",git:"none",taskCheckboxes:"ignore"};if(!await Zr(t,Xf,{label:"Classic check policy",expected:"file"}))return r;let i=await Pe(t,Xf,{label:"Classic check policy"});try{let o=JSON.parse(i);if(!o||Array.isArray(o))throw new Error("Expected a policy object");let s=Zf("sha256").update(i).digest("hex");if(o.version===2){if(Object.keys(o).some(p=>p!=="version"&&p!=="commands"))throw new Error("version 2 allows only version and commands");if(!Array.isArray(o.commands)||!o.commands.length)throw new Error("commands must be a nonempty array");let u=o.commands.map((p,g)=>pk(p,`Classic check policy commands[${g}]`));if(new Set(u.map(p=>JSON.stringify([p.argv,p.cwd]))).size!==u.length)throw new Error("commands must not repeat an argv and cwd pair");if(!e||!u.some(p=>Qf(p,e)))return{...r,digest:s};let d=u.find(p=>Qf(p,e));return{digest:s,entryDigest:hk(d),declaredCwd:d.cwd,files:d.files,outputs:d.outputs,env:d.env,git:d.git,taskCheckboxes:d.taskCheckboxes}}if(o.version!==1||Object.keys(o).some(u=>!["version","argv","cwd","files","outputs","env","git","taskCheckboxes"].includes(u)))throw new Error("Expected version 1 or 2 with known fields");if(!Array.isArray(o.argv)||!o.argv.length||!o.argv[0]||o.argv.some(u=>typeof u!="string"||u.includes("\0")))throw new Error("argv must bind literal command arguments");if(typeof o.cwd!="string"||!o.cwd)throw new Error("cwd must bind a project-relative directory");let a=o.cwd==="."?".":G(o.cwd,"Classic check policy cwd");for(let u of["files","outputs","env"])if(o[u]!==void 0&&(!Array.isArray(o[u])||o[u].some(f=>typeof f!="string"||!f)))throw new Error(`${u} must be an array of nonempty strings`);let c=o.files?.map(u=>{if(/[?*[\]{}]/.test(u))throw new Error("files accepts literal paths, not globs");return G(u,"Classic check policy file")}),l=o.outputs?.map(u=>{if(/[?*[\]{}]/u.test(u))throw new Error("outputs accepts literal paths, not globs");return G(u,"Classic check policy output")});if(o.env?.some(u=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(u)))throw new Error("Invalid environment variable name");if(o.git!==void 0&&!["all","none"].includes(o.git))throw new Error("Invalid git binding");if(o.taskCheckboxes!==void 0&&!["include","ignore"].includes(o.taskCheckboxes))throw new Error("Invalid taskCheckboxes mode");return!e||e.cwd!==a||JSON.stringify(e.argv)!==JSON.stringify(o.argv)?{...r,digest:s}:{digest:s,files:c,outputs:l,env:o.env,git:o.git??r.git,taskCheckboxes:o.taskCheckboxes??r.taskCheckboxes}}catch(o){throw new Error(`Invalid Classic check policy: ${o instanceof Error?o.message:String(o)}`,{cause:o})}}function Ce(t,e){let n=gk("git",["-C",t,...e],{encoding:"utf8",windowsHide:!0,timeout:3e4,maxBuffer:268435456});return n.status===0?n.stdout:null}function wk(t,e){let n=new Map,r=32;for(let i=0;i<e.length;i+=r){let o=e.slice(i,i+r),s=Ce(t,["hash-object","--no-filters","--",...o]);if(s===null)return null;let a=s.trimEnd().split(/\r?\n/u);if(a.length!==o.length||a.some(c=>!/^[0-9a-f]+$/iu.test(c)))return null;o.forEach((c,l)=>n.set(c,a[l]))}return n}function Dn(t,e){return e?t?.digest??"":t?.entryDigest??t?.digest??""}var ed=new Map;async function yk(t,e){let n=`${t}\0${e}`,r=ed.get(n);if(r!==void 0)return r;let i=process.platform==="win32"?Nn(t,process.env,e):t.includes("/")?N.resolve(e,t):(await Promise.all((process.env.PATH??"").split(N.delimiter).map(async o=>{let s=N.resolve(e,o,t);return await pe.access(s,pe.constants.X_OK).then(()=>s,()=>null)}))).find(o=>o!==null)??null;return ed.set(n,i),i}async function Fn(t,e,n,r=!1){let i=await yk(t[0],e),o=i?await pe.realpath(i).catch(()=>null):null,s=o?await pe.stat(o):null,a=n?.env;return aa("sha256").update(JSON.stringify([process.platform,process.arch,process.execPath,process.version,t,e,o,s&&[s.size,s.mtimeMs,s.ctimeMs,s.ino],Object.entries(process.env).filter(([c])=>a?a.some(l=>process.platform==="win32"?l.toLowerCase()===c.toLowerCase():l===c):r).sort(([c],[l])=>c.localeCompare(l)),...Dn(n,r)?[Dn(n,r)]:[]])).digest("hex")}async function Wn(t,e,n,r={}){t=N.resolve(t),e=N.resolve(e);let i=r.legacy===!0,o=aa("sha256"),s=await et(t,n,i);o.update(Dn(s,i));let a=[],c=r.contentCache??new Map,u=(await be(e,{migrate:!1})).classic?.verificationReport,f=u&&u.endsWith(".md")?N.resolve(t,u):null,d=(s.outputs??[]).map(w=>sa(w)),p=[t,await pe.realpath(t).catch(()=>t)],g=(w,S=t)=>{let y=N.relative(S,w);return y===""||y!==".."&&!y.startsWith(`..${N.sep}`)&&!N.isAbsolute(y)},m=[process.env.HOME,process.env.USERPROFILE].filter(w=>!!w),h=[...new Set((await Promise.all(m.map(async w=>{let S=N.resolve(w);return[S,await pe.realpath(S).catch(()=>S)]}))).flat())].filter(w=>p.some(S=>w!==S&&g(w,S))),v=w=>d.some(S=>S(N.relative(t,w).replaceAll("\\","/")))||h.some(S=>w===S||w.startsWith(S+N.sep))||w===N.join(e,".comet.yaml")||w===N.join(e,".comet-state.lock")||w===N.join(e,".comet-state-transaction.json")||w.startsWith(N.join(e,".comet")+N.sep)||w===f||w===N.join(t,".comet","current-change.json"),k=w=>N.relative(t,w).replaceAll("\\","/")||".";async function b(w){let S=[];async function y(x){let A=x===w||await pe.lstat(N.join(x,".git")).then(()=>!0,()=>!1)?Ce(x,["ls-files","-z","--cached","--others","--exclude-standard"]):null,_=N.relative(w,x).replaceAll("\\","/");if(A!==null){for(let I of[...new Set(A.split("\0").filter(Boolean))].sort())S.push(_?`${_}/${I}`:I);return}for(let I of(await pe.readdir(x,{withFileTypes:!0})).sort((U,tt)=>U.name.localeCompare(tt.name))){if(I.name===".git"||I.name==="node_modules")continue;let U=_?`${_}/${I.name}`:I.name;I.isDirectory()?await y(N.join(x,I.name)):S.push(U)}}return await y(w),S}async function E(w,S){if(v(w))return;let y=N.relative(t,w).replaceAll("\\","/"),x=await pe.lstat(w,{bigint:!0}).catch(I=>{if(I.code==="ENOENT")return null;throw I});if(o.update(JSON.stringify([y,x?x.isFile()?Number(x.size):null:"missing"])),!x){a.push({p:y,h:"missing",s:null,m:null}),await ke(t,w,{label:"Classic check input",expected:"any"});return}if(x.isSymbolicLink())throw new Error(`Check input is a symbolic link: ${y}. Symbolic links cannot be check inputs; either remove the link, or bind this command's inputs in .comet/check-policy.json (version 2) with a files list that excludes it`);if(x.isDirectory()){await ke(t,w,{label:"Classic check input",expected:"directory"}),await P(w);return}let R=`${y}|${x.size}|${x.mtimeNs}|${x.mode}`,A=s.taskCheckboxes==="ignore"&&w===N.join(e,"tasks.md"),_=i?void 0:A?c.get(R):S??c.get(R);if(_===void 0)if(!i&&!A)_=(await hu(t,y,{label:"Classic check input"})).digest;else{let I=await Ss(t,w,{label:"Classic check input",maxBytes:Number.MAX_SAFE_INTEGER}),U=I;if(A)try{U=Buffer.from(Lu(I.toString("utf8")),"utf8")}catch{U=I}i?o.update(U):_=aa("sha256").update(U).digest("hex")}_!==void 0&&(c.set(R,_),i||o.update(_)),a.push({p:y,h:_,s:Number(x.size),m:x.mtimeNs.toString()})}async function P(w){let y=w===t||await pe.lstat(N.join(w,".git")).then(()=>!0,()=>!1)?Ce(w,["ls-files","-z","--cached","--others","--exclude-standard"]):null;if(y!==null){if(s.git==="all"){let j=Ce(w,["rev-parse","HEAD"])??"unborn";o.update(j),a.push({p:`\0git:${k(w)}:head`,h:j.trim(),s:null,m:null})}let x=s.git==="all"?Ce(w,["ls-files","--stage","-z"]):"",R=s.git==="all"?x:Ce(w,["ls-files","--stage","-z"]);if(R===null)throw new Error("Cannot inspect check input index");if(s.git==="all")for(let j of R.split("\0").filter(Boolean)){let H=j.slice(j.indexOf(" ")+1);v(N.resolve(w,H))||(o.update(j),a.push({p:`\0git:${k(w)}:index:${H}`,h:j.slice(0,j.indexOf(" ")).split(" ")[1],s:null,m:null}))}let A=[...new Set(y.split("\0").filter(Boolean))].sort(),_=new Map(R.split("\0").filter(Boolean).map(j=>{let H=j.indexOf(" "),ae=j.slice(0,H).split(" ");return[j.slice(H+1),ae[1]??""]})),I=Ce(w,["status","--porcelain=v1","-z","--untracked-files=all","--ignore-submodules=none"]),U=new Set;if(I!==null){let j=I.split("\0");for(let H=0;H<j.length;H+=1){let ae=j[H];if(!(ae.length<4)&&(U.add(ae.slice(3)),/^[RC]/u.test(ae.slice(0,1))||/[RC]$/u.test(ae.slice(1,2)))){let ma=j[H+1];ma&&(U.add(ma),H+=1)}}}let tt=A.filter(j=>!_.has(j)||U.has(j)),he=wk(w,tt);for(let j of A){let H=_.get(j),ae=H&&!U.has(j)?H:he?.get(j)??(he===null?Ce(w,["hash-object","--no-filters","--",j])?.trim()??void 0:void 0);await E(N.resolve(w,j),ae?`git:${ae}`:void 0)}return}for(let x of(await pe.readdir(w,{withFileTypes:!0})).sort((R,A)=>R.name.localeCompare(A.name)))x.name===".git"||x.name==="node_modules"||await E(N.join(w,x.name))}if(s.files){if(s.git==="all"){let S=Ce(t,["rev-parse","HEAD"])??"unborn";o.update(S),a.push({p:"\0git:.:head",h:S.trim(),s:null,m:null});let y=Ce(t,["ls-files","--stage","-z"]);if(y!==null)for(let x of y.split("\0").filter(Boolean))v(N.resolve(t,x.slice(x.indexOf(" ")+1)))||(o.update(x),a.push({p:`\0git:.:index:${x.slice(x.indexOf(" ")+1)}`,h:x.slice(0,x.indexOf(" ")).split(" ")[1],s:null,m:null}))}let w=s.files.filter(S=>Mt(S)).map(S=>sa(S));if(w.length){let S=new Set(s.files.filter(R=>!Mt(R))),y=new Set,x=await b(t);for(let R of x){let A=N.resolve(t,R);v(A)||(S.has(R)||w.some(_=>_(R)))&&y.add(R)}for(let R of[...S].sort())await E(N.resolve(t,R));for(let R of[...y].sort())await E(N.resolve(t,R))}else for(let S of[...new Set(s.files)].sort())await E(N.resolve(t,S));await E(N.join(t,".comet","config.yaml"))}else await P(t);if(Dn(await et(t,n,i),i)!==Dn(s,i))throw new Error("Classic check policy changed during snapshot");for(let w of["node_modules/.package-lock.json","node_modules/.modules.yaml","node_modules/.pnpm/lock.yaml"])await E(N.join(t,w));return{digest:o.digest("hex"),entries:a,manifest:Gf(a)}}async function ca(t,e,n){return(await Wn(t,e,n,{legacy:!0})).digest}import{promises as vk}from"node:fs";V();var yt=new Map,kk=16;async function td(t,e){let n=await L(t,e,{label:"Classic check trajectory",expected:"file"});if(!n.exists)return{target:n.target,stamp:"missing",cacheable:!1};let r=await vk.lstat(n.target,{bigint:!0});if(!r.isFile()||r.isSymbolicLink())throw new Error("Classic check trajectory changed");return{target:n.target,cacheable:r.ino!==0n&&r.ctimeNs>0n,stamp:[r.dev,r.ino,r.birthtimeNs,r.ctimeNs,r.mtimeNs,r.size].join(":")}}async function Dt(t,e){for(let n=0;n<3;n++){let r=await td(t,e),i=yt.get(r.target),o;if(r.cacheable&&i?.stamp===r.stamp)o=i.index;else{let a=await Xs(t,e);if(a.some(c=>!c||typeof c.type!="string"||!Number.isSafeInteger(c.sequence)||c.sequence<0))throw new Error("Invalid Trajectory event in Classic check index");o={maximumSequence:a.reduce((c,l)=>Math.max(c,l.sequence),0),events:a.filter(c=>c.type.startsWith("command_check"))}}let s=await td(t,e);if(r.stamp!==s.stamp){yt.delete(r.target);continue}return yt.delete(r.target),yt.size>=kk&&yt.delete(yt.keys().next().value),yt.set(r.target,{stamp:r.stamp,index:o}),structuredClone(o)}throw new Error("Classic check trajectory changed during index read")}var bk=new Set([".md",".markdown"]),Ck=new Set([".md",".markdown",".rst",".txt"]),Sk=new Set(["docs","doc","documentation",".github"]),Ek=[/^LICENSE(?:[.-]|$)/u,/^NOTICE$/u,/^AUTHORS$/u];function nd(t){return t.replaceAll("\\","/").replace(/^\.\//u,"")}function xk(t,e){for(let n of e){let r=nd(n).replace(/\/+$/u,"");if(r&&(t===r||t.startsWith(`${r}/`)))return!0}return!1}function rd(t,e=[]){let n=nd(t);if(!n||n.endsWith("/")||xk(n,e))return!1;let r=n.split("/"),i=r[r.length-1],o=i.lastIndexOf("."),s=o===-1?"":i.slice(o).toLowerCase();return r.length===1?bk.has(s)||Ek.some(a=>a.test(i)):Sk.has(r[0])&&Ck.has(s)}Fs();lt();import _k from"os";import hi from"path";function Pk(t={}){let e=t.cwd??process.cwd(),n=t.homeDir??_k.homedir(),r=[{file:hi.resolve(e,".comet","config.yaml"),source:".comet/config.yaml",scope:"project"},{file:hi.resolve(n,".comet","config.yaml"),source:"~/.comet/config.yaml",scope:"global"}];return r.filter((i,o)=>r.findIndex(s=>s.file===i.file)===o)}async function id(t,e={}){for(let n of Pk(e)){let r=hi.dirname(hi.dirname(n.file)),i=n.scope==="global"?(await Ds(r))?.classic:(await ct(r,{allowPartialProject:!0}))?.value.classic;if(!i||typeof i!="object"||Array.isArray(i))continue;let o=i[t];if(o!=null)return{value:String(o),source:n.source}}return null}async function od(t){let e=await id("document_evidence",{cwd:t});if(!e)return"neutral";if(e.value==="neutral"||e.value==="strict")return e.value;throw new Error(`classic.document_evidence must be neutral or strict, got '${e.value}' (${e.source})`)}function Rk(t,e){return[z(t,e.openSpecRoot),z(t,e.superpowersRoot)]}async function sd(t,e){let n;try{let o=await ks(t);n=Rk(t,o)}catch{n=["openspec","docs/openspec","docs/superpowers"]}let r=[],i=[];for(let o of e)rd(o,n)?i.push(o):r.push(o);return{material:r,neutral:i}}function ua(t){if(t!=="build"&&t!=="verify")throw new Error(`Invalid command check scope: '${String(t)}'`)}function wi(t,e="."){if(e.trim().length===0)throw new Error("Command check cwd cannot be blank");let n=Z.resolve(t),r=Z.resolve(n,e);if(r!==n&&!r.startsWith(n+Z.sep))throw new Error(`Command check cwd must resolve within the project root: '${e}'`);return Z.relative(n,r).replaceAll("\\","/")||"."}function ud(t,e){if(e.type!=="command_check_recorded"&&e.type!=="command_check_executed")return null;let n=e.data;if(typeof n!="object"||n===null||Array.isArray(n))return null;let{scope:r,command:i,exitCode:o,cwd:s}=n;if(r!=="build"&&r!=="verify"||typeof i!="string"||i.trim().length===0||!Number.isInteger(o)||typeof s!="string")return null;let a;try{a=wi(t,s)}catch{return null}return{sequence:e.sequence,timestamp:e.timestamp,runId:e.runId,scope:r,command:i,exitCode:o,cwd:a,...e.type==="command_check_executed"?{provenance:"runtime",argv:n.argv,timeoutMs:typeof n.timeoutMs=="number"?n.timeoutMs:void 0,inputBefore:n.inputBefore,inputAfter:n.inputAfter,changedDuringExecution:Array.isArray(n.changedDuringExecution)?n.changedDuringExecution?.filter(c=>typeof c=="string"):void 0,environment:n.environment,logRef:n.logRef,logHash:n.logHash,logSize:typeof n.logSize=="number"?n.logSize:void 0,logMtimeNs:typeof n.logMtimeNs=="string"?n.logMtimeNs:void 0,manifestRef:typeof n.manifestRef=="string"?n.manifestRef:void 0,manifestHash:typeof n.manifestHash=="string"?n.manifestHash:void 0,tier:n.tier==="incremental"?"incremental":void 0,reusable:n.reusable,checkEpoch:n.checkEpoch}:{}}}async function Bn(t,e,n,r){ua(r);let i=(await Dt(e,n.trajectoryRef)).events;for(let o=i.length-1;o>=0;o-=1){let s=i[o];if(s.runId!==n.runId)continue;if(s.type==="command_checks_invalidated"&&(!Array.isArray(s.data?.scopes)||s.data.scopes.includes(r))||s.type==="command_check_started"&&s.data?.scope===r||s.type==="command_check_consumed"&&s.data?.scope===r)return null;let a=ud(t,s);if(a?.scope===r)return a}return null}function Nk(t,e){if(e.type!=="command_check_started")return null;let n=e.data;if(typeof n!="object"||n===null||Array.isArray(n))return null;let{scope:r,argv:i,cwd:o,timeoutMs:s,reusable:a,tier:c}=n;if(r!=="build"&&r!=="verify"||!Array.isArray(i)||i.length===0||i.some(u=>typeof u!="string"||u.includes("\0"))||typeof o!="string"||!Number.isInteger(s)||Number(s)<1||typeof a!="boolean"||c!=="full"&&c!=="incremental")return null;let l;try{l=wi(t,o)}catch{return null}return{sequence:e.sequence,timestamp:e.timestamp,runId:e.runId,scope:r,argv:[...i],cwd:l,timeoutMs:Number(s),reusable:a,tier:c}}async function fd(t,e,n,r){ua(r);let i=(await Dt(e,n.trajectoryRef)).events;for(let o=i.length-1;o>=0;o-=1){let s=i[o];if(s.runId!==n.runId||!(s.data?.scope===r||Array.isArray(s.data?.scopes)&&s.data.scopes.includes(r)))continue;if(s.type==="command_check_started")return Nk(t,s);let c=ud(t,s);if(c?.scope===r&&c.provenance==="runtime"&&c.argv?.length)return{sequence:c.sequence,timestamp:c.timestamp,runId:c.runId,scope:c.scope,argv:[...c.argv],cwd:c.cwd,timeoutMs:c.timeoutMs??3e5,reusable:c.reusable===!0,tier:c.tier??"full"};if(s.type!=="command_checks_invalidated")return null}return null}async function Ak(t,e,n){let r=(await Dt(t,e.trajectoryRef)).events;for(let i=r.length-1;i>=0;i-=1){let o=r[i];if(!(o.runId!==e.runId||!(o.data?.scope===n||Array.isArray(o.data?.scopes)&&o.data.scopes.includes(n))))return o.type==="command_check_started"?`a previous ${n} check attempt started at ${o.timestamp} never completed (interrupted or failed during launch); rerun the check`:null}return null}async function la(t,e,n,r){return Xe(t,async()=>{let o={sequence:(await Dt(t,e.trajectoryRef)).maximumSequence+1,timestamp:new Date().toISOString(),runId:e.runId,type:n,data:r};return await Mn(t,e.trajectoryRef,o),o})}async function fa(t,e,n,r){if(ua(r.scope),!r.argv.length||r.argv.some(R=>typeof R!="string"||R.includes("\0")))throw new Error("Check requires literal program arguments");let i=wi(t,r.cwd),o=await gi.realpath(t);wi(o,await gi.realpath(Z.resolve(t,i)));let s=r.tier==="incremental"?"incremental":"full",a=await Bn(t,e,n,r.scope);if(r.reusable){if(a&&a.reusable&&(a.tier??"full")===s&&a.cwd===i&&JSON.stringify(a.argv)===JSON.stringify(r.argv)){let R=await cd(t,e,n,r.scope);if(R?.sequence===a.sequence&&R.timestamp===a.timestamp)return{...R,reused:!0}}if(!a){let R=r.scope==="build"?"verify":"build",A=await cd(t,e,n,R);if(A?.reusable&&(A.tier??"full")===s&&A.cwd===i&&JSON.stringify(A.argv)===JSON.stringify(r.argv)){let{sequence:_,timestamp:I,runId:U,scope:tt,reused:he,...j}=A,H=(await be(e,{migrate:!1})).classic?.checkEpoch??0,ae=await la(e,n,"command_check_executed",{...j,scope:r.scope,checkEpoch:H});return{...j,scope:r.scope,checkEpoch:H,sequence:ae.sequence,timestamp:ae.timestamp,runId:n.runId,reused:!0}}}}let c=r.timeoutMs??3e5,l=await la(e,n,"command_check_started",{scope:r.scope,argv:[...r.argv],cwd:i,timeoutMs:c,reusable:r.reusable===!0,tier:s}),u=(await be(e,{migrate:!1})).classic?.checkEpoch??0,f={argv:r.argv,cwd:i},d=a?.manifestRef?await dd(t,a).catch(()=>null):null,p=await Wn(t,e,f,d?{baseline:d}:{}),g=p.digest,m=await Fn(r.argv,Z.resolve(t,i),await et(t,f)),h=Z.join(e,".comet","checks",`${ad()}.log`),v=await new Promise(R=>{let A=Mu(r.argv[0],r.argv.slice(1),{cwd:Z.resolve(t,i)}),_="",I=!1,U=he=>{_=(_+he.toString()).slice(-2*1024*1024)};A.stdout.on("data",U),A.stderr.on("data",U),A.on("error",he=>{_+=`
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
`,...g.inputBefore!==g.inputAfter?{stderr:pd(g)}:{}}});var gd=["open-complete","design-complete","build-complete","verify-pass","verify-fail","archive-confirm","archive-reopen","archived","preset-escalate"];var Tk=new Set([...jn,"archive_confirmation","verify_failures","check_epoch","classic_profile","classic_migration","bound_branch"]),wd=new Set(Ge.filter(t=>!Tk.has(t))),da={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 Ik=`
|
|
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=Vr(e),r=$t(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=Vr(e),r=$t(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())}}};du.Parser=us});var wu=C(Rn=>{"use strict";var mu=Xo(),uw=vn(),Pn=Cn(),fw=Gi(),dw=A(),mw=ls(),pu=fs();function hu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new mw.LineCounter||null,prettyErrors:e}}function pw(t,e={}){let{lineCounter:n,prettyErrors:r}=hu(e),i=new pu.Parser(n?.addNewLine),o=new mu.Composer(e),s=Array.from(o.compose(i.parse(t)));if(r&&n)for(let a of s)a.errors.forEach(Pn.prettifyError(t,n)),a.warnings.forEach(Pn.prettifyError(t,n));return s.length>0?s:Object.assign([],{empty:!0},o.streamInfo())}function gu(t,e={}){let{lineCounter:n,prettyErrors:r}=hu(e),i=new pu.Parser(n?.addNewLine),o=new mu.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 Pn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(s.errors.forEach(Pn.prettifyError(t,n)),s.warnings.forEach(Pn.prettifyError(t,n))),s}function hw(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let i=gu(t,n);if(!i)return null;if(i.warnings.forEach(o=>fw.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 gw(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 dw.isDocument(t)&&!r?t.toString(n):new uw.Document(t,r,n).toString(n)}Rn.parse=hw;Rn.parseAllDocuments=pw;Rn.parseDocument=gu;Rn.stringify=gw});var qt=C(j=>{"use strict";var ww=Xo(),yw=vn(),vw=Oo(),ds=Cn(),kw=nn(),Je=A(),bw=We(),Cw=B(),Sw=Ke(),Ew=Ue(),xw=Gr(),_w=as(),Pw=ls(),Rw=fs(),Qr=wu(),yu=Qt();j.Composer=ww.Composer;j.Document=yw.Document;j.Schema=vw.Schema;j.YAMLError=ds.YAMLError;j.YAMLParseError=ds.YAMLParseError;j.YAMLWarning=ds.YAMLWarning;j.Alias=kw.Alias;j.isAlias=Je.isAlias;j.isCollection=Je.isCollection;j.isDocument=Je.isDocument;j.isMap=Je.isMap;j.isNode=Je.isNode;j.isPair=Je.isPair;j.isScalar=Je.isScalar;j.isSeq=Je.isSeq;j.Pair=bw.Pair;j.Scalar=Cw.Scalar;j.YAMLMap=Sw.YAMLMap;j.YAMLSeq=Ew.YAMLSeq;j.CST=xw;j.Lexer=_w.Lexer;j.LineCounter=Pw.LineCounter;j.Parser=Rw.Parser;j.parse=Qr.parse;j.parseAllDocuments=Qr.parseAllDocuments;j.parseDocument=Qr.parseDocument;j.stringify=Qr.stringify;j.visit=yu.visit;j.visitAsync=yu.visitAsync});import Ye from"path";function Iw(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 An(t){let e=Iw(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Pu(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 Z(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 Te(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ru(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 On(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>ms)throw new Error(`${e} exceeds ${ms} 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>ps)throw new Error(`${e} contains more than ${ps} wildcard tokens`);return t}function Su(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=>On(r,e)))].sort((r,i)=>r.localeCompare(i,"en"))}function Nn(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 Eu(t,e,n){let r=Nn(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 jw(t){if(t===void 0)return{...ue,include:[...ue.include],exclude:[...ue.exclude]};let e=Te(t,"native.snapshot");return{include:Su(e.include,"native.snapshot.include",ue.include),exclude:Su(e.exclude,"native.snapshot.exclude",ue.exclude),max_files:Nn(e.max_files,ue.max_files,"native.snapshot.max_files"),max_total_bytes:Nn(e.max_total_bytes,ue.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Nn(e.max_duration_ms,ue.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:Nn(e.max_selection_records,ue.max_selection_records,"native.snapshot.max_selection_records")}}function Lw(t){if(t===void 0)return;let e=Te(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=Te(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:An(r),toArtifactRoot:An(i),stage:o,...s?{cleanup:s}:{}}}function $w(t){if(t===void 0)return;let e=Te(t,"native.finish");if(e.pull_request===void 0)return{};let n=Te(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??Nw;if(!Number.isSafeInteger(i)||i<1||i>Cu)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Cu}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:i}}}function qw(t,e={}){let n=Te(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??xu;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=Lw(n.pending_root_move),l=$w(n.finish);return{artifact_root:An(r),language:Ru(n.language,"en","native.language"),clarification_mode:i,archive_confirmation:o,max_verify_failures:s,...a==="revert"?{document_writes:a}:{},snapshot:jw(n.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function Mw(t){let e=Te(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:Pu(e.artifact_layout),language:Ru(e.language,"zh-CN","classic.language"),context_compression:n,review_mode:r,auto_transition:i,...o==="strict"?{document_evidence:o}:{}}}function Fw(t){let n=Te(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)=>Z(r,`hook.allow_paths[${i}]`)))]}}function Dw(t){if(t===void 0)return{...Zr};let e=Te(t,"memory"),n=e.learning??Zr.learning,r=e.retrieval??Zr.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 gs(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ww(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>vu)throw new Error(`${e} exceeds ${vu} 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>ku)throw new Error(`${e} contains more than ${ku} wildcard tokens`);return n}function Bw(t){let e=gs(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)=>Ww(i,`knowledge.local.include[${o}]`)))],max_file_mb:Eu(e.max_file_mb,bu.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Eu(e.max_total_mb,bu.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 Kw(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=gs(t,"knowledge.remote"),n=Kw(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 Hw(t){if(t===void 0)return{..._u};let e=gs(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:Bw(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 Jw(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function Yw(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 Ge(t,e={}){let n=(0,hs.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=Jw(i.ambient_resume),s=i.hook===void 0?void 0:Fw(i.hook),a=Dw(i.memory),c=Hw(i.knowledge),l=i.native===void 0?void 0:qw(i.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=i.classic===void 0?void 0:Mw(i.classic),f=Yw(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}:{}}}function ws(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Zr},knowledge:{..._u},native:{artifact_root:An(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:xu,snapshot:{...ue,include:[...ue.include],exclude:[...ue.exclude]}}}}var hs,Mt,ms,ps,vu,ku,xu,Zr,bu,_u,Nw,Cu,Aw,Ow,Tw,ue,Se=W(()=>{"use strict";hs=Vt(qt(),1),Mt=Number.MAX_SAFE_INTEGER,ms=1024,ps=64,vu=1024,ku=64,xu=5,Zr={learning:!0,retrieval:!0},bu={include:[],max_file_mb:1,max_total_mb:32},_u={provider:"local"},Nw=12e4,Cu=6e5,Aw=[".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/**"],Ow=["**/.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"],Tw=[...Aw,...Ow].sort((t,e)=>t.localeCompare(e,"en")),ue={include:["**/*"],exclude:[...Tw],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});function ze(t){return t!==0&&t!==0n&&t!=="0"}function Nu(t,e){return ze(t.dev)&&ze(e.dev)&&ze(t.ino)&&ze(e.ino)}function Ve(t,e){let n=ze(t.dev)&&ze(e.dev);if(n&&t.dev!==e.dev)return!1;let r=ze(t.ino)&&ze(e.ino);return r&&t.ino!==e.ino?!1:n&&r?!0:t.birthtime===e.birthtime}var ei=W(()=>{"use strict"});import{constants as Xe,promises as ae}from"fs";import{createHash as Gw}from"node:crypto";function ys(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Au(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function Ze(t){return{dev:t.dev,ino:t.ino,birthtime:ys(t)}}function Qe(t,e){let n=Ze(t),r=Ze(e);return Nu(n,r)?Ve(n,r):Ve(n,r)&&ys(t)===ys(e)&&Au(t)===Au(e)&&t.size===e.size}async function vs(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 ae.lstat(t,{bigint:i});if(!o.isFile()||o.isSymbolicLink())throw new he("not-regular-file",`${r} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new he("too-large",`${r} exceeds ${e} bytes`);let s=await ae.realpath(t);await n.verify?.("pre-open",{realPath:s,identity:Ze(o)});let a=process.platform==="win32"?Xe.O_RDONLY:Xe.O_RDONLY|Xe.O_NOFOLLOW|Xe.O_NONBLOCK,c;try{c=await ae.open(t,a)}catch(l){throw l.code==="ELOOP"?new he("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,f]=await Promise.all([c.stat({bigint:i}),ae.lstat(t,{bigint:i}),ae.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||f!==s||!Qe(o,l)||!Qe(o,u))throw new he("changed",`${r} changed while opening`);await n.verify?.("post-open",{realPath:f,identity:Ze(l)}),await n.hooks?.afterOpen?.();let d=[],p=0,g=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let v=e+1-p,{bytesRead:k}=await c.read(g,0,Math.min(g.length,v),null);if(k===0)break;if(p+=k,p>e)throw new he("too-large",`${r} exceeds ${e} bytes`);d.push(Buffer.from(g.subarray(0,k)))}await n.hooks?.beforeFinalCheck?.();let[m,h,y]=await Promise.all([c.stat({bigint:i}),ae.lstat(t,{bigint:i}),ae.realpath(t)]);if(!h.isFile()||h.isSymbolicLink()||y!==s||!Qe(o,m)||!Qe(o,h))throw new he("changed",`${r} changed while reading`);return await n.verify?.("post-read",{realPath:y,identity:Ze(m)}),{bytes:Buffer.concat(d,p),stat:m,realPath:y}}finally{await c.close()}}async function Ou(t,e={}){let n=e.label??"file",r=e.bigint===!0,i=await ae.lstat(t,{bigint:r});if(!i.isFile()||i.isSymbolicLink())throw new he("not-regular-file",`${n} must be a regular file`);let o=await ae.realpath(t);await e.verify?.("pre-open",{realPath:o,identity:Ze(i)});let s=process.platform==="win32"?Xe.O_RDONLY:Xe.O_RDONLY|Xe.O_NOFOLLOW|Xe.O_NONBLOCK,a;try{a=await ae.open(t,s)}catch(c){throw c.code==="ELOOP"?new he("not-regular-file",`${n} must be a regular file`,{cause:c}):c}try{let[c,l,u]=await Promise.all([a.stat({bigint:r}),ae.lstat(t,{bigint:r}),ae.realpath(t)]);if(!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!Qe(i,c)||!Qe(i,l))throw new he("changed",`${n} changed while opening`);await e.verify?.("post-open",{realPath:u,identity:Ze(c)}),await e.hooks?.afterOpen?.();let f=Gw(e.algorithm??"sha256"),d=Buffer.allocUnsafe(64*1024);for(;;){let{bytesRead:h}=await a.read(d,0,d.length,null);if(h===0)break;f.update(d.subarray(0,h))}await e.hooks?.beforeFinalCheck?.();let[p,g,m]=await Promise.all([a.stat({bigint:r}),ae.lstat(t,{bigint:r}),ae.realpath(t)]);if(!g.isFile()||g.isSymbolicLink()||m!==o||!Qe(i,p)||!Qe(i,g))throw new he("changed",`${n} changed while reading`);return await e.verify?.("post-read",{realPath:m,identity:Ze(p)}),{digest:f.digest("hex"),stat:p,realPath:m}}finally{await a.close()}}var he,ks=W(()=>{"use strict";ei();he=class extends Error{reason;constructor(e,n,r){super(n,r),this.name="RaceSafeReadError",this.reason=e}}});import{promises as ti}from"fs";import et from"path";async function Tu(t,e,n){let r=await $(t,e,{label:n.label,expected:"file"});if(!r.exists){let o=new Error(`${n.label} does not exist`);throw o.code="ENOENT",o}let i=await bs(r.projectRoot,n.label);return Ou(r.target,{...n,verify:async(o,s)=>{if(!ni(i,s.realPath))throw new Error(`${n.label} resolves outside the project root`);await Cs(r.projectRoot,i,r.relative.split("/"),{label:n.label,expected:"file"})}})}function zw(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function ni(t,e){let n=et.relative(t,e);return n===""||!et.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${et.sep}`)}async function bs(t,e){let n=et.resolve(t),r=await ti.lstat(n);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return ti.realpath(n)}async function Cs(t,e,n,r){let i=t;for(let o=0;o<n.length;o++){i=et.join(i,n[o]);let s;try{s=await ti.lstat(i)}catch(u){if(zw(u))return{exists:!1,kind:"missing"};throw u}let a=et.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 ti.realpath(i);if(!ni(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 $(t,e,n){let r=Z(e,n.label),i=et.resolve(t),o=await bs(i,n.label),s=r.split("/"),a=et.resolve(i,...s);if(!ni(i,a))throw new Error(`${n.label} must stay inside the project root`);let c=await Cs(i,o,s,n);return{projectRoot:i,target:a,relative:r,exists:c.exists,kind:c.kind}}async function Ss(t,e,n){return(await $(t,e,{...n,expected:"file"})).exists}async function H(t,e,n,r){let i=await $(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 bs(i.projectRoot,r.label);return vs(i.target,n,{...r,verify:async(s,a)=>{if(!ni(o,a.realPath))throw new Error(`${r.label} resolves outside the project root`);await Cs(i.projectRoot,o,i.relative.split("/"),{label:r.label,expected:"file"})}})}var ee=W(()=>{"use strict";ks();Se()});import{createHash as Vw}from"crypto";function Xw(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function pt(t,e={}){return(await ri(t,e)).document}async function Qw(t){try{return(await H(t,Tn,Mt,{label:Tn})).bytes}catch(e){if(Xw(e))return null;throw e}}function Zw(t){return t?{exists:!0,sha256:Vw("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function ri(t,e={}){let n=await Qw(t);return{document:n?Ge(n.toString("utf8"),e):null,identity:Zw(n)}}async function Es(t){return(await pt(t))?.config??null}var Tn,ht=W(()=>{"use strict";Se();ee();Tn=".comet/config.yaml"});import{promises as _s}from"node:fs";async function Ps(t,e){let n;for(let r=0;r<=xs.length;r+=1)try{return await t()}catch(i){n=i;let o=i.code;if(r===xs.length||!ey.has(o??""))throw i;await new Promise(s=>setTimeout(s,xs[r]))}throw n}async function Iu(t,e){await Ps(()=>_s.rename(t,e),`rename ${e}`)}async function ii(t){await Ps(()=>_s.unlink(t),`unlink ${t}`)}async function ju(t,e){await Ps(()=>_s.link(t,e),`link ${e}`)}var ey,xs,Rs=W(()=>{"use strict";ey=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),xs=[50,100,200]});import{randomUUID as ty}from"crypto";import{constants as ny,promises as J}from"fs";import V from"path";async function Ns(t,e){try{return await ju(t,e),{linked:!0}}catch(n){let r=n.code;if(r!=="ENOTSUP"&&r!=="EOPNOTSUPP")throw n}return await J.copyFile(t,e,ny.COPYFILE_EXCL),{linked:!1}}function gt(t,e){let n=V.relative(t,e);return n===""||!V.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${V.sep}`)}function oi(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function ry(t,e){return Ve(t,oi(e))}function si(t,e){return Ve(oi(t),oi(e))}function Lu(t,e){return si(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function ai(t){let e=await J.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 J.realpath(t),...oi(e)}}async function Ie(t){for(let e of t){let n=await J.lstat(e.path);if(!n.isDirectory()||n.isSymbolicLink()||!ry(e,n)||await J.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function iy(t,e,n){let[r,i]=await Promise.all([J.lstat(t),J.realpath(t),Ie(n)]);if(!r.isFile()||r.isSymbolicLink()||!si(r,e)||!gt(n[0].realPath,i))throw new Error("Contained atomic write temporary file changed after close");return r}async function oy(t,e){let n=V.resolve(t),r=V.resolve(e);if(!gt(n,r))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let i=[await ai(n)],o=V.relative(n,r).split(V.sep).filter(Boolean),s=n;for(let a of o){await Ie(i),s=V.join(s,a);try{await J.mkdir(s)}catch(l){if(l.code!=="EEXIST")throw l}let c=await ai(s);if(!gt(i[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${s}`);i.push(c)}return await Ie(i),i}async function sy(t,e){let n=V.resolve(t),r=V.resolve(e);if(!gt(n,r))throw new Error(`Contained file parent is outside its managed root: ${e}`);let i=[await ai(n)],o=V.relative(n,r).split(V.sep).filter(Boolean),s=n;for(let a of o){s=V.join(s,a);try{let c=await ai(s);if(!gt(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 Ie(i),i}async function $u(t){let e;try{e=await J.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 ay(t,e,n){let r=V.dirname(t),i=await oy(n.containedRoot,r),o=V.join(r,`.${V.basename(t)}.${ty()}.tmp`),s,a,c;try{await n.beforeTemporaryOpen?.(),s=await J.open(o,"wx"),a=await s.stat();let[l,u]=await Promise.all([J.lstat(o),J.realpath(o)]);if(await Ie(i),!l.isFile()||l.isSymbolicLink()||!si(a,l)||!gt(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(),!si(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 iy(o,c,i),await n.beforeCommit?.(),await Ie(i);let f=await J.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!c||!Lu(f,c))throw new Error("Contained atomic write temporary file changed before commit");n.exclusive?(await Ns(o,t),await J.unlink(o)):await Iu(o,t),await $u(r)}catch(l){await s?.close();try{await Ie(i),await J.rm(o,{force:!0})}catch{}throw l}}async function fe(t,e,n){await ay(t,e,n)}async function Ft(t,e){let n=V.dirname(t),r=await sy(e.containedRoot,n);if(!r)return!1;let i,o;try{i=await J.lstat(t),o=await J.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!i.isFile()||i.isSymbolicLink()||!gt(r[0].realPath,o))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await Ie(r);let[s,a]=await Promise.all([J.lstat(t),J.realpath(t)]);if(!s.isFile()||s.isSymbolicLink()||!Lu(i,s)||a!==o)throw new Error("Contained file removal target changed before removal");return await ii(t),await Ie(r),await $u(n),!0}var tt=W(()=>{"use strict";Rs();ei()});var mS,As=W(()=>{"use strict";tt();ht();ee();mS=16*1024});var Ts=W(()=>{"use strict";tt();Se();ht();ee();As()});var yi=W(()=>{"use strict"});var wf=W(()=>{"use strict"});var Zs=W(()=>{"use strict";yi()});var yf=W(()=>{"use strict";yi();Zs()});function Cv(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Sv(t){let e=(0,vf.parseDocument)(t,{uniqueKeys:!0});if(e.errors.length>0)throw new Error(`Invalid global Comet config: ${e.errors[0].message}`);let n=e.toJS();if(n==null)return{};if(typeof n!="object"||Array.isArray(n))throw new Error("Invalid global Comet config: root must be a mapping");return n}function bf(t){if(t.native?.pending_root_move)throw new Error("Global Comet config cannot contain native.pending_root_move");let e=t.native?(({pending_root_move:n,...r})=>r)(t.native):void 0;return{...t,schema:"comet.global.v1",...e?{native:e}:{}}}function Ev(t){let e=Ge(JSON.stringify({...t,schema:"comet.project.v1"})).config;if(!e)throw new Error("Invalid global Comet config: workflow template is incomplete");return bf(e)}function xv(t){let e=Ge(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e.native&&!e.classic)return null;let n=e.native?"native":"classic",r=e.native?.language??e.classic?.language??"en",i=ws(e.native?.artifact_root??"docs",r);return{schema:"comet.global.v1",default_workflow:n,workflows:[n],ambient_resume:e.ambient_resume,...e.native?{native:{...i.native,...e.native}}:{},...e.classic?{classic:e.classic}:{}}}function Cf(t){let e=Sv(t);if(Object.keys(e).length===0)return null;if(e.schema===void 0)return xv(t);if(e.schema!=="comet.global.v1")throw new Error("Unsupported Comet global schema");return Ev(e)}async function ea(t){try{let e=await H(t,kf,Mt,{label:"global Comet config"});return Cf(e.bytes.toString("utf8"))}catch(e){if(Cv(e))return null;throw e}}var vf,kf,ta=W(()=>{"use strict";vf=Vt(qt(),1);tt();Se();ee();kf=".comet/config.yaml"});var sx,Sf=W(()=>{"use strict";tt();ee();sx=4*1024*1024});import{AsyncLocalStorage as _v}from"node:async_hooks";function Rv(){let t=Pv.getStore();return t?.active?t:null}function Nv(t,e){let n=t;for(let r of e)n+="\0"+(typeof r=="string"?r:JSON.stringify(r));return n}function Ef(t,e){return(...n)=>{let r=Rv();if(r===null)return e(...n);let i=Nv(`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}}var Pv,xf=W(()=>{"use strict";Pv=new _v});var dx,_f=W(()=>{"use strict";xf();ht();dx=Ef("hookWritePolicy",async t=>(await Es(t))?.hook??{allow_paths:[]})});var Av,Pf=W(()=>{"use strict";ks();Av=16*1024});var Rf=W(()=>{"use strict";yi();tt();wf();yf();Se();ta();ee();ht();Ts();Sf();_f();Pf();As();Zs()});import{TextDecoder as Ov}from"util";function Nf(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Tv(t,e){try{return new Ov("utf-8",{fatal:!0}).decode(t.bytes)}catch(n){throw new Error(`${e} is not valid UTF-8`,{cause:n})}}async function na(t,e,n,r,i={}){try{let o=await H(t,e,n,{label:r,hooks:i.hooks});return{result:o,text:Tv(o,r)}}catch(o){let s=o.code;if(s==="ENOENT"||s==="ENOTDIR")return null;throw o}}async function Dn(t,e,n,r,i={}){return(await na(t,e,n,r,i))?.text??null}async function Ct(t,e,n,r,i,o={}){if(Buffer.byteLength(n,"utf8")>r)throw new Error(`${i} exceeds ${r} bytes`);let s=await na(t,e,r,i),a=await $(t,e,{label:i,expected:"file"});await fe(a.target,n,{containedRoot:a.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await na(t,e,r,i);if(!(!s&&!c)){if(!s||!c)throw new Error(`${i} changed before commit`);if(s.result.realPath!==c.result.realPath||!Ve(Nf(s.result.stat),Nf(c.result.stat))||s.text!==c.text)throw new Error(`${i} changed before commit`)}}})}async function Af(t,e,n,r,i,o={}){let s=await Dn(t,e,r,i);await Ct(t,e,`${s??""}${n}`,r,i,o)}async function ra(t,e,n,r={}){let i=await $(t,e,{label:n,expected:"file"});return i.exists?Ft(i.target,{containedRoot:i.projectRoot,beforeRemove:r.beforeRemove}):!1}var ia=W(()=>{"use strict";Rf();ei()});var If={};Qd(If,{RUN_STATE_FILE:()=>Bt,applyRunStateToDocument:()=>oa,readRunState:()=>Kn,removeRunState:()=>Un,runStateFromDocument:()=>Wt,writeRunState:()=>Kt});import Iv from"path";function Bn(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 Wn(t,e){let n=Bn(t,e);if(Iv.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 jv(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 Wt(t){if(!t.run_id)return null;let e=Bn(t,"run_id"),n=Bn(t,"skill"),r=Bn(t,"skill_version"),i=Bn(t,"skill_hash"),o=Wn(t,"pending_ref"),s=Wn(t,"trajectory_ref"),a=Wn(t,"context_ref"),c=Wn(t,"artifacts_ref"),l=Wn(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:Of(t,"current_step"),iteration:u,pending:Of(t,"pending"),pendingRef:o,trajectoryRef:s,contextRef:a,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:jv(t)}}function oa(t,e){e?t.run_id=e.runId:delete t.run_id}function Lv(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 $v(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 Wt(e)}async function Kn(t,e={}){let n=await Dn(t,Bt,Tf,"Run state",e);if(n===null)return null;let r=JSON.parse(n);return $v(r)}async function Kt(t,e,n={}){await Ct(t,Bt,JSON.stringify(Lv(e),null,2),Tf,"Run state",n)}async function Un(t,e={}){await ra(t,Bt,"Run state",e)}var Of,Bt,Tf,vi=W(()=>{"use strict";ia();Of=(t,e)=>{let n=t[e];return n==null?null:String(n)};Bt=".comet/run-state.json",Tf=Number.MAX_SAFE_INTEGER});import jd from"node:path";import{AsyncLocalStorage as gy}from"async_hooks";import{promises as Ku}from"fs";import jn from"path";import{promises as Du}from"fs";import D from"path";import{promises as em}from"fs";async function Xt(t){try{return await em.access(t),!0}catch(e){if(tm(e))return!1;throw e}}function tm(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}Se();ht();Ts();ee();var In=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Fu=".comet/config.yaml";function Wu(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Bu(t){await $(t,Fu,{label:Fu,expected:"file"})}function ci(t,e){let n=D.resolve(t),r=e==="docs"?D.join(n,"docs"):n,i=D.join(r,"openspec"),o=D.join(n,"docs","superpowers");return{projectRoot:n,artifactLayout:e,openSpecBase:r,openSpecRoot:i,changesDir:D.join(i,"changes"),archiveDir:D.join(i,"changes","archive"),specsDir:D.join(i,"specs"),superpowersRoot:o,superpowersSpecsDir:D.join(o,"specs"),superpowersPlansDir:D.join(o,"plans"),superpowersReportsDir:D.join(o,"reports")}}async function dy(t){await Bu(t);let e=await pt(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new In;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new In("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function Is(t,e){return ci(t,e??await dy(t))}async function my(t){try{return await Du.lstat(t),!0}catch(e){if(Wu(e))return!1;throw e}}async function py(t,e){let n=await Is(t,e),r=n.artifactLayout==="legacy"?"docs":"legacy",i=ci(t,r).openSpecRoot,[o,s]=await Promise.all([$(n.projectRoot,Q(n.projectRoot,n.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),my(i)]),a=o.exists;return{paths:n,configuredRootExists:a,alternateRoot:i,alternateRootExists:s,dualRoots:a&&s}}async function hy(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=Q(t.projectRoot,n);await $(t.projectRoot,r,{label:`Classic managed physical path ${r}`,expected:"directory"})}}async function Ee(t,e){let n=await py(t,e);if(await hy(n.paths),!n.configuredRootExists){let r=Q(n.paths.projectRoot,n.paths.openSpecRoot),i=Q(n.paths.projectRoot,n.alternateRoot);throw new In(`Configured Classic OpenSpec root is missing: ${r} (alternate ${i} is ${n.alternateRootExists?"present":"missing"})`)}return n.paths}async function js(t,e){let n=D.join(D.resolve(t),".comet","classic-root-move.json");if(await Xt(n))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let r=await Ee(t,e);if(!await Xt(r.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${Q(r.projectRoot,r.openSpecRoot)}`);return r}async function wt(t){let e=D.resolve(t),n=null;try{(await Du.lstat(e)).isDirectory()||(e=D.dirname(e))}catch(r){if(!Wu(r))throw r}for(;;){D.basename(e)==="openspec"&&(n=D.dirname(e));let r=D.join(e,".comet","config.yaml"),i=!1;if(await Xt(r))try{await Bu(e);let s=(await pt(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 Xt(D.join(e,".git")))return e;let o=D.dirname(e);if(o===e)return n??D.resolve(t);e=o}}function Q(t,e){return D.relative(D.resolve(t),e).replaceAll("\\","/")}var li=new gy;function wy(t,e){let n=jn.relative(t,e);return n===""||!jn.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${jn.sep}`)}async function yy(t){let e=jn.resolve(t.invocationCwd??process.cwd()),n=jn.resolve(t.projectRoot??await wt(e)),[r,i]=await Promise.all([Ku.realpath(e),Ku.realpath(n)]);if(!wy(i,r))throw new Error(`Classic command invocation cwd is outside the discovered project: ${e}`);return{invocationCwd:e,projectRoot:n,observations:new Map}}async function vy(t,e){let n=li.getStore();if(n)return e(n);let r=await yy(t);return li.run(r,()=>e(r))}function Uu(){let t=li.getStore();if(!t)throw new Error("Classic command project context is unavailable");return t.projectRoot}function Hu(){let t=li.getStore();if(!t)throw new Error("Classic command invocation context is unavailable");return t.invocationCwd}function Ju(t){return(e,n)=>vy(n,()=>t(e,n))}import{promises as Ms}from"fs";import fi from"path";tt();Se();ee();import Ln from"path";var by=Number.MAX_SAFE_INTEGER;function Ls(t,e,n){let r=Ln.resolve(t),i=Ln.isAbsolute(e)?Ln.resolve(e):Ln.resolve(r,e),o=Ln.relative(r,i).replaceAll("\\","/");return{root:r,relative:Z(o,n),target:i}}async function xe(t,e,n){let r=Ls(t,e,n.label);return $(r.root,r.relative,n)}async function ui(t,e,n){return(await xe(t,e,{label:n.label,expected:n.expected??"any"})).exists}async function je(t,e,n){return(await $s(t,e,n)).toString("utf8")}async function $s(t,e,n){let r=Ls(t,e,n.label);return(await H(r.root,r.relative,n.maxBytes??by,{label:n.label,hooks:n.hooks})).bytes}async function qs(t,e,n,r){let i=Ls(t,e,r.label);await $(i.root,i.relative,{label:r.label,expected:"file"}),await fe(i.target,n,{containedRoot:i.root,beforeTemporaryOpen:r.beforeTemporaryOpen,beforeCommit:r.beforeCommit,exclusive:r.exclusive})}async function Yu(t,e){let n=[],r=new Set;async function i(o,s){let a=await xe(t,o,{label:"Classic capability directory",expected:"directory"});if(!a.exists)return;let c=await Ms.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 xe(t,u,{label:"Classic capability spec",expected:"file"})).exists&&n.push(u)}let l=(await Ms.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 Cy(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}'
|
|
143
|
+
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function Ds(t){let e=Cy(t);if(e)throw new Error(e)}function Sy(t,e){return{label:Q(t,e),directory:e}}async function Fs(t,e,n){let r=Sy(t,e);if(!(await xe(t,e,{label:n,expected:"directory"})).exists)return{change:r,exists:!1,stateExists:!1};let o=await xe(t,fi.join(e,".comet.yaml"),{label:`${n} state`,expected:"file"});return{change:r,exists:!0,stateExists:o.exists}}function Ey(t,e){let n=e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`^\\d{4}-\\d{2}-\\d{2}-${n}$`,"u").test(t)}async function xy(t,e,n,r={}){if(!r.skipExactCompatibility){let s=await Fs(t,fi.join(e,n),`Classic archived change ${n}`);if(s.exists)return s.change}if(!(await xe(t,e,{label:"Classic archive directory",expected:"directory"})).exists)return null;let o=[];for(let s of await Ms.readdir(e,{withFileTypes:!0})){if(!Ey(s.name,n))continue;let a=await Fs(t,fi.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 Gu(t,e=process.cwd()){Ds(t);let n=await Ee(e),r=await Fs(n.projectRoot,fi.join(n.changesDir,t),`Classic active change ${t}`);if(r.exists)return r.change;let i=await xy(n.projectRoot,n.archiveDir,t);return i||r.change}import{promises as dd}from"fs";import me from"path";import{fileURLToPath as md}from"url";import nt from"path";function zu(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 Vu(t){let e=zu(t);return e.missingFields.length===0&&e.invalidFields.length===0}var _y=Vt(qt(),1);import yt from"node:path";async function Xu(t,e,n={}){if(!e||e==="null")return{status:"missing",recordedPath:null};let r=await Ee(t),i=yt.resolve(t,e),o=yt.relative(r.superpowersPlansDir,i);return yt.isAbsolute(e)||!o||o.startsWith(`..${yt.sep}`)||yt.isAbsolute(o)||o.includes(yt.sep)||yt.extname(o).toLowerCase()!==".md"?{status:"broken",recordedPath:e}:await ui(t,e,{label:`Classic build plan ${e}`,expected:"file"})&&(!n.requireNonempty||(await je(t,e,{label:`Classic build plan ${e}`})).trim().length>0)?{status:"ready",recordedPath:e}:{status:"broken",recordedPath:e}}var Py=/^(\s*[-*]\s+\[)([ xX])(\]\s+)(.*)$/u,Ry=/\s*<!-- comet-task:([a-zA-Z0-9][a-zA-Z0-9_-]{0,79}) -->\s*$/u;function Ws(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=Py.exec(o);if(!a)continue;let c=Ry.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}function Qu(t){let e=t.split(/(?<=\n)/u);for(let n of Ws(t))e[n.line-1]=e[n.line-1].replace(/^(\s*[-*]\s+\[)[ xX](\])/u,"$1 $2");return e.join("")}ee();Se();import $n from"path";function Ny(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Zu(t,e,n,r){let i=Z(n,"Classic handoff artifact pointer");if((await $(t,i,{label:"Classic handoff artifact",expected:"file"})).exists)return null;let s=await Ee(t),a=`${Q(t,s.changesDir)}/`,l=(s.artifactLayout==="docs"?[a,"openspec/changes/"]:[a]).find(v=>i.startsWith(v));if(!l)return null;let u=i.slice(l.length).split("/");if(u.length<4||u[1]!==".comet"||u.slice(2).some(v=>v.length===0))return null;let f=u[0];Ds(f);let d=u.slice(2),p=$n.resolve(e);if($n.dirname(p)!==$n.resolve(s.archiveDir))return null;let g=$n.basename(p),m=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(g);if(g!==f&&m?.[1]!==f)return null;await $(t,Q(t,p),{label:"Classic archived change directory",expected:"directory"});let h=$n.join(p,".comet",...d),y=Q(t,h);try{return await H(t,y,r,{label:"Historical Classic archived handoff artifact"}),y}catch(v){if(Ny(v))return null;throw v}}ee();function Bs(t,e){return nt.relative(t,e).split(nt.sep).join("/")}async function qn(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=Q(t,ci(t,a).openSpecRoot);if((o===c||o.startsWith(`${c}/`))&&(await $(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 Ss(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 Ay(t,e,n,r){try{r??=await Ee(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 qn(t,"design.handoff",n,r);if(!n||i.satisfied||i.detail)return i;try{let o=await Zu(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 di(t,e,n){return qn(t,e,Bs(t,n))}async function Oy(t,e){let n=nt.join(e,"specs"),r;try{r=await Yu(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]?Bs(t,r[0]):void 0,detail:`${r.length} delta spec${r.length===1?"":"s"}`}}async function Ty(t,e){let n,r=Bs(t,e);try{n=(await H(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=Ws(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 Dt(t,e){return t.some(n=>n.code===e&&n.satisfied)}async function Mn(t,e){let n=await wt(t),r=e.classic,i=nt.join(t,"proposal.md"),o=nt.join(t,"design.md"),s=nt.join(t,"tasks.md"),a=e.run?nt.resolve(t,e.run.checkpointRef):nt.join(t,".comet","checkpoint.json"),c,l;try{c=await Ee(n)}catch(d){l=d}let u=await Promise.all([di(n,"openspec.proposal",i),di(n,"openspec.design",o),di(n,"openspec.tasks",s),Oy(n,t),qn(n,"design.document",r?.designDoc??null,c,l),(async()=>{let d=await qn(n,"build.plan",r?.plan??null,c,l);if(!d.satisfied)return d;try{let p=await Xu(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)}}})(),Ty(n,s),qn(n,"verification.report",r?.verificationReport??null,c,l),Ay(n,t,r?.handoffContext??null,c),di(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 Tk,randomUUID as Ik}from"crypto";import{promises as wa}from"fs";import Le from"path";function Iy(t){return t.classicProfile??t.workflow}function jy(t){return t.isolation!==null&&Vu(t)}function Ly(t){return(t.buildMode==="direct"||t.buildMode==="autonomous")&&t.tddMode==="direct"&&t.isolation!==null&&t.verifyMode==="light"}function $y(t,e,n){if(t!=="full"&&e.verifyResult==="fail")return`${t}.build.execute`;if(t==="full"){if(Dt(n,"build.plan")&&e.buildPause==="plan-ready")return"full.build.plan-ready";if(!jy(e))return"full.build.configure";if(!Dt(n,"build.plan"))return"full.build.plan";if(e.verifyResult==="fail")return"full.build.fix"}else if(!Ly(e))throw new Error(`${t} build configuration is incomplete`);return Dt(n,"build.tasks-complete")?`${t}.build.complete`:`${t}.build.execute`}function qy(t,e,n){return e.verifyResult!=="pass"||!Dt(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 Ks(t,e){let n=Iy(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 Dt(e,"design.handoff")?"full.design.document":"full.design.handoff";case"build":return $y(n,t,e);case"verify":return qy(n,t,e);case"archive":return My(n,t)}}import _e from"path";import{promises as tk}from"node:fs";import{AsyncLocalStorage as nk}from"node:async_hooks";Rs();import{randomUUID as uv}from"node:crypto";import{promises as bt}from"node:fs";import pf from"node:os";import mf from"node:path";import{promises as uf}from"node:fs";import{execFile as Xy,execFileSync as xE}from"node:child_process";import of from"node:path";import{AsyncLocalStorage as Fy}from"node:async_hooks";import{performance as mi}from"node:perf_hooks";var Dy=0,Wy=0,By=new Fy;function ef(t=0){Dy+=1,Wy+=t;let e=By.getStore();e&&(e.gitCommands+=1,e.gitDurationMs+=t)}function Us(t){let e=mi.now();try{return t()}finally{ef(mi.now()-e)}}async function tf(t){let e=mi.now();try{return await t()}finally{ef(mi.now()-e)}}import{spawn as Hs}from"node:child_process";import{existsSync as nf}from"node:fs";import vt from"node:path";var Ky=new Set([".bat",".cmd",".ps1"]),Uy=new Set([".bat",".cmd"]),Hy=/[&|<>()^%"!\r\n]/u,Jy=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");function Js(t,e){let n=e.toLowerCase();return Object.entries(t).find(([r,i])=>r.toLowerCase()===n&&i!==void 0)?.[1]}function Yy(t){let e=(Js(t,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").map(n=>n.trim().toLowerCase()).filter(Boolean);return[...new Set([...e,".ps1"])]}function Gy(t,e,n){let i=vt.win32.isAbsolute(t)||/[\\/]/u.test(t)?[""]:(Js(e,"PATH")??"").split(vt.delimiter).map(a=>a.trim().replace(/^"(.*)"$/u,"$1")).filter(Boolean),s=vt.win32.extname(t)?[t]:Yy(e).map(a=>`${t}${a}`);return i.flatMap(a=>s.map(c=>a?vt.join(a,c):vt.resolve(n,c)))}function Fn(t,e,n){return Gy(t,e,n).find(r=>nf(r))??t}function zy(t){let e=Js(t,"SystemRoot");if(e){let n=vt.join(e,"System32","WindowsPowerShell","v1.0","powershell.exe");if(nf(n))return n}return"powershell.exe"}function Ys(t){if(t.some(e=>Hy.test(e)))throw new Error("Windows batch check arguments must not contain shell syntax")}function Vy(t,e,n){let r=Buffer.from(JSON.stringify({command:t,arguments:[...e]}),"utf8").toString("base64"),i=Buffer.from(Jy,"utf16le").toString("base64");return Hs(zy(n.env),["-NoLogo","-NoProfile","-NonInteractive","-InputFormat","None","-OutputFormat","Text","-ExecutionPolicy","Bypass","-EncodedCommand",i],{cwd:n.cwd,env:{...n.env,COMET_COMMAND_PAYLOAD:r},shell:!1,windowsHide:!0,detached:!1,stdio:["ignore","pipe","pipe"]})}function rf(t,e,n){let r=n.env??process.env;if(process.platform!=="win32")return Hs(t,[...e],{cwd:n.cwd,env:r,shell:!1,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});let i=Fn(t,r,n.cwd),o=vt.win32.extname(i).toLowerCase();return Uy.has(o)&&Ys(e),Ky.has(o)?Vy(i,e,{cwd:n.cwd,env:r}):Hs(i,[...e],{cwd:n.cwd,env:r,shell:!1,windowsHide:!0,detached:!1,stdio:["ignore","pipe","pipe"]})}var Qy=6e4,Zy=8*1024*1024;async function kt(t,e,n={}){let r=n.timeoutMs??Qy,i=n.maxBufferBytes??Zy;if(!Number.isSafeInteger(r)||r<1||!Number.isSafeInteger(i)||i<1)throw new Error("External command limits must be positive integers");let o=of.resolve(n.cwd??process.cwd()),s=n.env??process.env,a=process.platform==="win32"?Fn(t,s,o):t,c=process.platform==="win32"&&/\.(?:bat|cmd)$/iu.test(a);c&&Ys(e);let l=()=>new Promise((u,f)=>{let d=!1,p=Xy(a,[...e],{cwd:o,env:s,encoding:"utf8",maxBuffer:i,windowsHide:!0,shell:c},(y,v,k)=>{d||(d=!0,clearTimeout(h),n.signal?.removeEventListener("abort",m),y?f(new pi(t,e,k.trim(),{cause:y,timedOut:ev(y)})):u(v))}),g=y=>{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 pi(t,e,"",{timedOut:y})))},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(of.win32.basename(t))?tf(l):l()}var pi=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};function ev(t){return t instanceof Error&&(t.code==="ETIMEDOUT"||t.killed===!0&&t.signal==="SIGTERM")}import{createHash as zs,randomUUID as tv}from"node:crypto";import{promises as de}from"node:fs";import nv from"node:os";import ce from"node:path";var af=`using System;
|
|
144
|
+
using System.Runtime.InteropServices;
|
|
145
|
+
class CometProcessIdentity {
|
|
146
|
+
[DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
|
|
147
|
+
[DllImport("kernel32.dll")] static extern bool GetProcessTimes(IntPtr process, out long creation, out long exit, out long kernel, out long user);
|
|
148
|
+
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
149
|
+
static int Main(string[] args) {
|
|
150
|
+
int pid; if(args.Length != 1 || !int.TryParse(args[0], out pid) || pid <= 0) return 1;
|
|
151
|
+
IntPtr handle=OpenProcess(0x1000, false, pid); if(handle == IntPtr.Zero) return 1;
|
|
152
|
+
try { long creation, exit, kernel, user; if(!GetProcessTimes(handle,out creation,out exit,out kernel,out user)) return 1;
|
|
153
|
+
Console.WriteLine(DateTime.FromFileTimeUtc(creation).Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); return 0;
|
|
154
|
+
} finally { CloseHandle(handle); }
|
|
155
|
+
}
|
|
156
|
+
}`,rv=zs("sha256").update(af).digest("hex"),iv=1e4,hi=new Map;async function Gs(t,e){let n=await de.lstat(t,{bigint:!0});if(!n.isFile()||n.isSymbolicLink()||n.size>BigInt(e))throw new Error("Invalid process probe cache");let r=await de.readFile(t),i=await de.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 cf(t){try{let e=JSON.parse((await Gs(ce.join(t,"probe.json"),4096)).toString("utf8"));if(!/^probe-[a-f0-9-]+\.exe$/u.test(e.file??""))return null;let n=ce.join(t,e.file),r=await Gs(n,65536);return zs("sha256").update(r).digest("hex")===e.hash?n:null}catch{return null}}async function ov(t,e){let n,r=tv(),i=ce.join(t,`probe-${r}.cs`),o=ce.join(t,`probe-${r}.exe`),s=ce.join(t,`probe-${r}.json`);try{if(await de.mkdir(t,{recursive:!0,mode:448}),(await de.lstat(t)).isSymbolicLink())return null;n=await de.open(ce.join(t,"prepare.lock"),"wx",384);let a=await cf(t);if(a)return a;await de.writeFile(i,af,{flag:"wx",mode:384});let c;for(let u of["Framework64","Framework"]){let f=ce.join(e,"Microsoft.NET",u,"v4.0.30319","csc.exe");try{await de.access(f),c=f;break}catch{}}if(!c)return null;await kt(c,["/nologo","/target:exe","/platform:anycpu",`/out:${o}`,i],{timeoutMs:1500,maxBufferBytes:4096});let l=zs("sha256").update(await Gs(o,65536)).digest("hex");return await de.writeFile(s,JSON.stringify({file:ce.basename(o),hash:l}),{flag:"wx",mode:384}),await de.rename(s,ce.join(t,"probe.json")),o}catch{return null}finally{await de.unlink(i).catch(()=>{}),await de.unlink(s).catch(()=>{}),n&&(await n.close().catch(()=>{}),await de.unlink(ce.join(t,"prepare.lock")).catch(()=>{}))}}async function sf(t,e,n){try{let r=await kt(ce.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 kt(ce.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 sv(t,e){let n=hi.get(t);if(n&&performance.now()<n.retryAfter)return n.promise;let r={promise:ov(t,e),retryAfter:1/0};return hi.set(t,r),r.promise.then(i=>{hi.get(t)===r&&(i?hi.delete(t):r.retryAfter=performance.now()+iv)}),r.promise}async function lf(t,e={}){if(!Number.isSafeInteger(t)||t<=0)return null;let n=e.systemRoot??process.env.SystemRoot??"C:\\Windows",r=ce.join(e.cacheRoot??ce.join(nv.tmpdir(),"comet-process-identity"),rv),i=async l=>{if(!l)return null;try{let f=(await kt(l,[String(t)],{timeoutMs:1e3,maxBufferBytes:4096})).trim();return/^\d+$/u.test(f)?`win32-ps:${f}`:null}catch{return null}},o=await cf(r);if(o){let l=await i(o);return l||sf(t,n,new AbortController().signal)}let s=sv(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),sf(t,n,a.signal).then(c)])}catch{return null}finally{a.abort()}}var Vs=null,av=1e4,Xs=new Map,gi=new Map;function cv(t){let e=Xs.get(t);if(e){if(Date.now()-e.at>av){Xs.delete(t);return}return e.value}}async function Qs(t){if(t===process.pid&&Vs!==null)return Vs;let e=cv(t);if(e!==void 0)return e;let n=gi.get(t);n||(n=lv(t),gi.set(t,n));let r=await n;return gi.get(t)===n&&gi.delete(t),t===process.pid&&r!==null&&(Vs=r),r===null&&Xs.set(t,{value:null,at:Date.now()}),r}async function lv(t){if(!Number.isSafeInteger(t)||t<=0)return null;try{if(process.platform==="linux"){let[e,n]=await Promise.all([uf.readFile(`/proc/${t}/stat`,"utf8"),uf.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 lf(t);if(process.platform==="darwin"){let e=(await kt("/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}var ff=new Set(["win32-wmic","win32-ps"]);function wi(t){let e=t.indexOf(":");return e===-1?"":t.slice(0,e)}async function df(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 Qs(t);return n===e?"alive":n===null||wi(n)!==wi(e)&&ff.has(wi(n))&&ff.has(wi(e))?"unknown":"dead"}var fv=3e4,dv=20,mv=5*6e4,pv=1e4;async function hf(t,e,n={}){let r=mf.resolve(t);await bt.mkdir(mf.dirname(r),{recursive:!0});let i=Date.now(),o=n.timeoutMs??fv,s=n.retryMs??dv,a=n.malformedLockStaleMs??mv,c=await Qs(process.pid),l={pid:process.pid,nonce:uv(),createdAt:Date.now(),hostname:pf.hostname(),...c===null?{}:{processIdentity:c}},u=!1;for(;!u;){let f;try{f=await bt.open(r,"wx"),await f.writeFile(JSON.stringify(l),"utf8"),u=!0}catch(d){if(d.code!=="EEXIST")throw d;if(await hv(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 gv(r,l.nonce)}}async function hv(t,e){let n,r;try{[n,r]=await Promise.all([bt.readFile(t,"utf8"),bt.stat(t)])}catch(o){return o.code==="ENOENT"}let i=gf(n);if(i!==null&&(i.hostname!==void 0&&i.hostname!==pf.hostname()||await df(i.pid,i.processIdentity)!=="dead"))return!1;if(i===null){let o=n.trim().length===0?pv:e;if(Date.now()-Number(r.mtimeMs)<o)return!1}try{return await bt.readFile(t,"utf8")!==n?!1:(await bt.rm(t),!0)}catch(o){return o.code==="ENOENT"}}async function gv(t,e){try{if(gf(await bt.readFile(t,"utf8"))?.nonce!==e)return;await ii(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
|
|
157
|
+
`)}}function gf(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}}ee();var Ci=Vt(qt(),1);tt();ee();vi();var jf=["full","hotfix","tweak"],St=1,qv=["open","design","build","verify","archive"],Mv=["en","zh-CN"],Fv=["off","beta"],Dv=["subagent-driven-development","executing-plans","direct","autonomous"],Wv=["plan-ready"],Bv=["confirmed"],Kv=["tdd","direct"],Uv=["off","standard","thorough"],Hv=["current","branch","worktree"],Jv=["light","full"],Yv=["pending","pass","fail"],Gv=["pending","handled"],zv=["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"],Vv=new Set([...rt,...Hn]),Xv=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function sa(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ut(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 te(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 aa(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 Lf(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=Ut(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 Qv(t,e){let n=Ut(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 Zv(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 ek(t){if(!rt.some(n=>sa(t,n)))return null;for(let n of Xv)if(!sa(t,n))return null;return{workflow:te(t,"workflow",jf,!1),language:te(t,"language",Mv),phase:te(t,"phase",qv,!1),contextCompression:te(t,"context_compression",Fv),buildMode:te(t,"build_mode",Dv),buildPause:te(t,"build_pause",Wv),subagentDispatch:te(t,"subagent_dispatch",Bv),tddMode:te(t,"tdd_mode",Kv),reviewMode:te(t,"review_mode",Uv),isolation:te(t,"isolation",Hv),boundBranch:Ut(t,"bound_branch"),verifyMode:te(t,"verify_mode",Jv),autoTransition:aa(t,"auto_transition"),baseRef:Ut(t,"base_ref"),designDoc:ki(t,"design_doc"),plan:ki(t,"plan"),verifyResult:te(t,"verify_result",Yv,!1),verifyFailures:Lf(t,"verify_failures"),...sa(t,"check_epoch")?{checkEpoch:Lf(t,"check_epoch")}:{},verificationReport:ki(t,"verification_report"),branchStatus:te(t,"branch_status",Gv),createdAt:Ut(t,"created_at"),verifiedAt:Ut(t,"verified_at"),archiveConfirmation:te(t,"archive_confirmation",zv),archived:aa(t,"archived",!1),directOverride:aa(t,"direct_override"),handoffContext:ki(t,"handoff_context"),handoffHash:Qv(t,"handoff_hash"),classicProfile:te(t,"classic_profile",jf),classicMigration:Zv(t)}}function bi(t,e){let n=e??null;if(n===null&&e===void 0&&t.run_id&&t.skill)try{n=Wt(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:ek(t),run:n,unknownKeys:Object.keys(t).filter(r=>!Vv.has(r))}}function $f(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}}vi();var ca=new nk,Jn=".comet-state-transaction.json";async function it(t,e){let n=_e.resolve(t);return ca.getStore()===n?e():(await $(n,".comet-state.lock",{label:"Classic state lock",expected:"file"}),hf(_e.join(n,".comet-state.lock"),()=>ca.run(n,async()=>(await Ff(n),e()))))}async function la(t,e){try{return(await H(t,e,Number.MAX_SAFE_INTEGER,{label:"Classic state transaction"})).bytes.toString("utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}}function rk(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=Wt({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 Ff(t){let e=await la(t,Jn);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 la(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=rk(r===n.afterYaml?n.afterRun:n.beforeRun);i?await Kt(t,i):await Un(t),await Ft(_e.join(t,Jn),{containedRoot:t})}function Jt(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 qf(t,e,n){t.get(e)!==n&&t.set(e,n)}function ik(t,e){if(e.classic)for(let[n,r]of Object.entries($f(e.classic)))n==="auto_transition"&&r===null&&!t.has(n)||qf(t,n,r);else for(let n of rt)t.delete(n);oa(t.toJS(),e.run),e.run?qf(t,"run_id",e.run.runId):t.delete("run_id")}function ok(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 sk(t){let e=!1;for(let n of["build_command","verify_command"])t.has(n)&&(t.delete(n),e=!0);return e}async function ua(t){let e;try{e=(await H(_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 Ci.Document({})}let n=(0,Ci.parseDocument)(e);if(n.errors.length>0)throw new Error(`Invalid Classic state document: ${n.errors[0].message}`);return Jt(n),n}async function Pe(t,e={}){if(ca.getStore()!==_e.resolve(t)){let n=await ak(t);if(n!==null)return n}return it(t,()=>ck(t,e))}async function Ht(t,e){let n=await $(t,e,{label:"Classic state snapshot",expected:"file"});if(!n.exists)return{stamp:"missing",comparable:!0};let r=await tk.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 Mf(t){if((await Ht(t,".comet-state.lock")).stamp!=="missing"||(await Ht(t,Jn)).stamp!=="missing")return null;let r=await Ht(t,".comet.yaml"),i=await Ht(t,Bt);return!r.comparable||!i.comparable?null:{yaml:r.stamp,run:i.stamp}}async function ak(t){try{let e=await Mf(t);if(e===null)return null;let n=await ua(_e.join(t,".comet.yaml")),r=Jt(n);if(n.has("build_command")||n.has("verify_command"))return null;let i=await Kn(t);if(!i&&r.run_id&&r.skill)return null;let o=bi(r,i),s=await Mf(t);return s===null||e.yaml!==s.yaml||e.run!==s.run||(await Ht(t,Jn)).stamp!=="missing"||(await Ht(t,".comet-state.lock")).stamp!=="missing"?null:o}catch{return null}}async function ck(t,e){let n=e.migrate!==!1,r=_e.join(t,".comet.yaml"),i=await ua(r),o=Jt(i),s=sk(i);s&&(o=Jt(i));let a=await Kn(t);if(!a&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(vi(),If));a=c(o),a&&n&&(await Kt(t,a),ok(i),s=!0)}return s&&n&&await fe(r,i.toString(),{containedRoot:t}),bi(Jt(i),a)}async function fa(t,e,n={}){return it(t,()=>lk(t,e,n))}async function lk(t,e,n){let r=_e.join(t,".comet.yaml"),i=await ua(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");ik(i,{...e,unknownKeys:e.unknownKeys??[]}),bi(Jt(i),e.run??null);let s=await la(t,".comet.yaml"),a=i.toString();if(s===a){await n.beforeCommit?.(),e.run?await Kt(t,e.run):await Un(t);return}let c=_e.join(t,Jn);await fe(c,JSON.stringify({schema:"comet.classic.state-transaction.v1",beforeYaml:s,afterYaml:a,beforeRun:await Kn(t),afterRun:e.run}),{containedRoot:t});try{e.run?await Kt(t,e.run):await Un(t),await fe(r,a,{containedRoot:t,beforeCommit:n.beforeCommit})}catch(l){throw await Ff(t).catch(()=>{}),l}await Ft(c,{containedRoot:t}).catch(()=>{})}function Df(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:{}}}ia();import Si from"path";var Yn={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 Gn(t,e){if(Si.isAbsolute(e))throw new Error("Run path must stay inside the change directory");let n=Si.resolve(t),r=Si.resolve(n,e);if(r!==n&&!r.startsWith(n+Si.sep))throw new Error("Run path must stay inside the change directory")}async function zn(t,e,n,r={}){Gn(t,e),await Af(t,e,`${JSON.stringify(n)}
|
|
158
|
+
`,Yn.trajectory,"Run trajectory",r)}async function da(t,e,n={}){Gn(t,e);let r=await Dn(t,e,Yn.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 Wf(t,e,n,r={}){Gn(t,e),await Ct(t,e,JSON.stringify(n,null,2)+`
|
|
159
|
+
`,Yn.artifacts,"Run artifacts",r)}async function Bf(t,e,n,r={}){Gn(t,e),await Ct(t,e,n,Yn.context,"Run context",r)}async function Kf(t,e,n,r={}){Gn(t,e),await Ct(t,e,JSON.stringify(n,null,2)+`
|
|
160
|
+
`,Yn.checkpoint,"Run checkpoint",r)}import{createHash as rd,randomUUID as Pk}from"crypto";import{promises as Y}from"fs";import K from"path";var Jf=Vt(qt(),1);import{promises as ma}from"fs";import ge from"path";var uk=["invoke_skill","call_tool","handoff","ask_user","checkpoint"],fk=["deterministic","adaptive"],dk=["function","mcp","script","agent"],mk=["none","read","write","external"],pk=["progress","step","completion"],hk=["artifact_exists","state_equals"];function Et(t,e,n){return new Error(`${t}: ${e} ${n}`)}function le(t,e,n="document"){if(t===null||typeof t!="object"||Array.isArray(t))throw Et(e,n,"must be an object")}function ot(t,e,n){if(!Array.isArray(t))throw Et(e,n,"must be an array")}function ne(t,e,n){if(typeof t!="string")throw Et(e,n,"must be a string")}function ve(t,e,n,r){e in t&&ne(t[e],n,`${r}.${e}`)}function Yf(t,e,n,r){if(e in t&&typeof t[e]!="boolean")throw Et(n,`${r}.${e}`,"must be a boolean")}function st(t,e,n,r){if(typeof t!="string"||!e.includes(t))throw Et(n,r,`must be one of ${e.join(", ")}`)}function Ei(t,e,n){ot(t,e,n),t.forEach((r,i)=>{ne(r,e,`${n}[${i}]`)})}function Uf(t,e,n){le(t,e,n),ne(t.name,e,`${n}.name`),ne(t.description,e,`${n}.description`),Yf(t,"required",e,n)}function gk(t,e,n){le(t,e,n),ne(t.id,e,`${n}.id`),ve(t,"source",e,n),ve(t,"version",e,n)}function wk(t,e,n){le(t,e,n),ne(t.id,e,`${n}.id`),ne(t.role,e,`${n}.role`),ve(t,"instructions",e,n)}function yk(t,e,n){le(t,e,n),ne(t.id,e,`${n}.id`),st(t.kind,dk,e,`${n}.kind`),ne(t.source,e,`${n}.source`),st(t.sideEffect,mk,e,`${n}.sideEffect`),Yf(t,"requiresConfirmation",e,n)}function vk(t,e,n){le(t,e,n),st(t.type,uk,e,`${n}.type`),ve(t,"ref",e,n),ve(t,"prompt",e,n),ve(t,"question",e,n),"options"in t&&Ei(t.options,e,`${n}.options`)}function kk(t,e,n){le(t,e,n),ne(t.id,e,`${n}.id`),vk(t.action,e,`${n}.action`),ve(t,"next",e,n),"completionEvals"in t&&Ei(t.completionEvals,e,`${n}.completionEvals`)}function bk(t,e){let n="goal";le(t,e,n),ne(t.statement,e,`${n}.statement`),ot(t.inputs,e,`${n}.inputs`),t.inputs.forEach((r,i)=>{Uf(r,e,`${n}.inputs[${i}]`)}),ot(t.outputs,e,`${n}.outputs`),t.outputs.forEach((r,i)=>{Uf(r,e,`${n}.outputs[${i}]`)}),Ei(t.success,e,`${n}.success`)}function Ck(t,e){let n="orchestration";le(t,e,n),st(t.mode,fk,e,`${n}.mode`),ve(t,"entry",e,n),"steps"in t&&(ot(t.steps,e,`${n}.steps`),t.steps.forEach((r,i)=>{kk(r,e,`${n}.steps[${i}]`)}))}function Gf(t,e){return le(t,e),st(t.apiVersion,["comet/v1alpha1"],e,"apiVersion"),st(t.kind,["Skill"],e,"kind"),le(t.metadata,e,"metadata"),ne(t.metadata.name,e,"metadata.name"),ne(t.metadata.version,e,"metadata.version"),ne(t.metadata.description,e,"metadata.description"),bk(t.goal,e),Ck(t.orchestration,e),ot(t.skills,e,"skills"),t.skills.forEach((n,r)=>{gk(n,e,`skills[${r}]`)}),ot(t.agents,e,"agents"),t.agents.forEach((n,r)=>{wk(n,e,`agents[${r}]`)}),ot(t.tools,e,"tools"),t.tools.forEach((n,r)=>{yk(n,e,`tools[${r}]`)}),t}function zf(t,e){le(t,e);for(let n of["allowedSkills","allowedAgents","allowedTools","confirmationRequiredFor"])n in t&&Ei(t[n],e,n);for(let n of["maxIterations","maxRetriesPerAction"])if(n in t&&(typeof t[n]!="number"||!Number.isFinite(t[n])))throw Et(e,n,"must be a finite number");return t}function Sk(t,e){return le(t,e),"runtime"in t&&Vf(t.runtime,e,"runtime"),t}function Vf(t,e,n){return ot(t,e,n),t.forEach((r,i)=>{let o=`${n}[${i}]`;le(r,e,o),ne(r.id,e,`${o}.id`),st(r.scope,pk,e,`${o}.scope`),st(r.type,hk,e,`${o}.type`),ve(r,"artifact",e,o),ve(r,"field",e,o),ve(r,"equals",e,o)}),t}async function pa(t){let e=await ma.readFile(t,"utf8");try{return(0,Jf.parse)(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw Et(t,"document",r)}}async function Ek(t){try{return await pa(t)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Hf(t){try{return await ma.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function xk(t){let e=ge.join(t,"checks.yaml"),n=ge.join(t,"evals.yaml"),[r,i]=await Promise.all([Hf(e),Hf(n)]);if(i)throw new Error(`${n}: evals.yaml is no longer supported; use checks.yaml`);return r?{document:Sk(await pa(e),e)}:{document:null}}async function Xf(t){let e=ge.resolve(t.root),n=ge.resolve(t.controlRoot);t.requireSkillMarkdown&&await ma.access(ge.join(e,"SKILL.md"));let r=ge.join(n,"skill.yaml"),i=ge.join(n,"guardrails.yaml"),o=Gf(await pa(r),r),s=await Ek(i),a=s===null?null:zf(s,i),c=await xk(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 Qf(t){let e=ge.resolve(t);return Xf({root:e,controlRoot:ge.join(e,"comet"),packageKind:"skill",requireSkillMarkdown:!0})}async function Zf(t){let e=ge.resolve(t);return Xf({root:e,controlRoot:e,packageKind:"runtime",requireSkillMarkdown:!1})}function ed(t,e,n=ge.join(e,"package.json")){le(t,n);let r=t.packageKind==="runtime"?"runtime":void 0,i=Gf(t.definition,n),o=zf(t.guardrails,n),s=Vf(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:ge.resolve(e),packageKind:r,definition:i,guardrails:{...a,...o},evals:s}}import td from"path";function _k(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 nd(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),_k(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=td.posix.normalize(s.source.replaceAll("\\","/"));(td.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 Rk(t){return xi({...t.packageKind==="runtime"?{packageKind:"runtime"}:{},definition:t.definition,guardrails:t.guardrails,evals:t.evals})}function Nk(t){return K.posix.normalize(t.replaceAll("\\","/"))}function Yt(t,e,n){let r=K.relative(t,e);if(!(r===""||!K.isAbsolute(r)&&!r.startsWith(`..${K.sep}`)))throw new Error(`${n} resolves outside the Skill package`)}async function id(t,e,n){let r=Nk(e);if(K.posix.isAbsolute(r)||r===".."||r.startsWith("../"))throw new Error(`${n} resolves outside the Skill package`);let i=K.resolve(t,...r.split("/"));Yt(t,i,n);let o;try{o=await Y.realpath(i)}catch(s){throw s.code==="ENOENT"?new Error(`${n} does not exist: ${e}`,{cause:s}):s}if(Yt(t,o,n),!(await Y.stat(o)).isFile())throw new Error(`${n} is not a file: ${e}`);return{path:r,content:await Y.readFile(o)}}async function Ak(t){let e=await Y.realpath(t.root),n=t.packageKind==="runtime"?[]:[await id(e,"SKILL.md","SKILL.md")];for(let r of t.definition.tools)r.kind==="script"&&n.push(await id(e,r.source,`Script tool ${r.id}`));return n.sort((r,i)=>r.path.localeCompare(i.path))}function Ok(t,e){let n=e.map(r=>({path:r.path,sha256:rd("sha256").update(r.content).digest("hex")}));return rd("sha256").update(JSON.stringify(xi({package:t,files:n}))).digest("hex")}function ad(t){return JSON.stringify(t,null,2)+`
|
|
161
|
+
`}async function cd(t){let e=Rk(t),n=await Ak(t);return{document:e,files:n,hash:Ok(e,n)}}async function _i(t){return(await cd(t)).hash}async function od(t){try{return await Y.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function sd(t,e){try{if((await Y.readFile(K.join(t,"sha256"),"utf8")).trim()!==e.hash)throw new Error("hash mismatch");if(await Y.readFile(K.join(t,"package.json"),"utf8")!==ad(e.document))throw new Error("package mismatch");for(let i of e.files)if(!(await Y.readFile(K.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 ha(t,e){let n=await cd(t),r=K.resolve(e,".comet","skill-snapshots"),i=K.join(r,n.hash);if(await Y.mkdir(r,{recursive:!0}),await od(i))return await sd(i,n),{hash:n.hash,snapshotDir:i};let o=K.join(r,`.tmp-${Pk()}`);Yt(r,o,"Temporary snapshot"),Yt(r,i,"Published snapshot");try{await Y.mkdir(o);for(let s of n.files){let a=K.join(o,...s.path.split("/"));Yt(o,a,`Snapshot file ${s.path}`),await Y.mkdir(K.dirname(a),{recursive:!0}),await Y.writeFile(a,s.content)}await Y.writeFile(K.join(o,"package.json"),ad(n.document)),await Y.writeFile(K.join(o,"sha256"),n.hash+`
|
|
162
|
+
`),await Y.rename(o,i)}catch(s){if(await od(i)){try{await sd(i,n)}finally{await Y.rm(o,{recursive:!0,force:!0})}return{hash:n.hash,snapshotDir:i}}throw await Y.rm(o,{recursive:!0,force:!0}),s}return{hash:n.hash,snapshotDir:i}}async function ga(t,e){if(!/^[a-f0-9]{64}$/u.test(e))throw new Error(`Invalid Skill snapshot hash: ${e}`);let n=K.resolve(t,".comet","skill-snapshots"),r=K.join(n,e);Yt(n,r,"Skill snapshot");try{let i=(await Y.readFile(K.join(r,"sha256"),"utf8")).trim();if(i!==e)throw new Error(`stored hash is ${i||"(empty)"}`);let o=K.join(r,"package.json"),s=JSON.parse(await Y.readFile(o,"utf8")),a=ed(s,r,o),c=nd(a);if(c.length>0)throw new Error(c.map(u=>` - ${u}`).join(`
|
|
163
|
+
`));let l=await _i(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 ld(t){try{return await wa.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function ud(t){return Tk("sha256").update(t).digest("hex")}function jk(t){return ud(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}function Lk(t){return t.replaceAll(".","_").replaceAll("-","_")}async function $k(t,e){let n=await wt(t),r=Object.fromEntries(e.filter(s=>s.satisfied&&s.source).map(s=>[Lk(s.code),s.source])),i=Le.join(t,"subagent-progress.md");await ld(i)&&(r.subagent_progress=Le.relative(n,i).split(Le.sep).join("/"));let o=e.find(s=>s.code==="design.handoff"&&s.satisfied);return o?.source&&(r.handoff_context=o.source),r}function qk(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 Mk(t){await Promise.all(t.map(e=>wa.rm(e,{recursive:!0,force:!0})))}async function fd(t,e){return it(t,()=>Fk(t,e))}async function Fk(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 _i(e.skillPackage)!==n.run.skillHash)return await ga(t,n.run.skillHash),{classic:r,run:n.run,evidence:await Mn(t,n),migrated:!1,snapshotDir:Le.join(t,".comet","skill-snapshots",n.run.skillHash)};let d=await ha(e.skillPackage,t);return{classic:r,run:n.run,evidence:await Mn(t,n),migrated:!1,snapshotDir:d.snapshotDir}}let o=await Mn(t,n),s=Ks(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 _i(e.skillPackage),c=Le.join(t,".comet","skill-snapshots",a),l=await ld(c),u=[];try{let f=await ha(e.skillPackage,t),d=Df(e.skillPackage,e.runId?.()??Ik(),f.hash);d.currentStep=s,s==="completed"&&(d.status="completed");let p={...r,classicProfile:i,classicMigration:St},g=await $k(t,o),m=await wt(t),h=o.find(E=>E.code==="design.handoff"&&E.satisfied),y=null;h?.source&&(y=await je(m,h.resolvedSource??h.source,{label:"Classic migration handoff context",hooks:e.handoffReadHooks}),await Bf(t,d.contextRef,y),u.push(Le.resolve(t,d.contextRef))),await Wf(t,d.artifactsRef,g),u.push(Le.resolve(t,d.artifactsRef));let v=(e.now?.()??new Date).toISOString(),k={runId:d.runId,stateVersion:1,trajectoryOffset:2,contextHash:y===null?null:ud(y),artifactsHash:jk(g),createdAt:v};await Kf(t,d.checkpointRef,k),u.push(Le.resolve(t,d.checkpointRef)),u.push(Le.resolve(t,d.trajectoryRef));for(let E of qk(d,i,v))await zn(t,d.trajectoryRef,E);return await fa(t,{classic:p,run:d,unknownKeys:n.unknownKeys}),{classic:p,run:d,evidence:o,migrated:!0,snapshotDir:f.snapshotDir}}catch(f){throw await Mk(u),l||await wa.rm(c,{recursive:!0,force:!0}),f}}async function Dk(t){try{return(await dd.stat(t)).isDirectory()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Pi(t){try{return(await dd.stat(t)).isFile()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Wk(t){return await Dk(t)?await Pi(me.join(t,"skill.yaml"))?!0:await Pi(me.join(t,"SKILL.md"))&&await Pi(me.join(t,"comet","skill.yaml")):!1}function Bk(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 Kk(){let t=me.dirname(md(import.meta.url)),e=[process.env.COMET_RUNTIME_CLASSIC_ROOT,me.resolve(t,"..","runtime","classic"),me.resolve(t,"..","..","comet","runtime","classic"),me.resolve(t,"..","..","assets","skills","comet","runtime","classic"),me.resolve("assets","skills","comet","runtime","classic"),process.env.COMET_CLASSIC_SKILL_ROOT,me.resolve(t,"..","..","comet-classic"),me.resolve(t,"..","..","assets","skills","comet-classic"),me.resolve("assets","skills","comet-classic")].filter(n=>!!n);for(let n of e)if(await Wk(n))return n;return null}async function Uk(t){return await Pi(me.join(t,"skill.yaml"))?Zf(t):Qf(t)}async function pd(t){let e=await Kk();return fd(t,{skillPackage:e?await Uk(e):Bk(me.dirname(md(import.meta.url)))})}import re from"path";import{createHash as Ad,randomUUID as Rd}from"node:crypto";import{promises as Ni}from"node:fs";import{spawn as Hk}from"node:child_process";import ya from"node:path";var Jk=1e3,Yk=2;async function hd(t){let e=t.pid;if(e===void 0){t.kill("SIGKILL");return}if(process.platform==="win32"){let n=process.env.SystemRoot??process.env.WINDIR,r=n&&ya.win32.isAbsolute(n)?ya.win32.resolve(n):"C:\\Windows",i=ya.win32.join(r,"System32","taskkill.exe"),o=()=>new Promise(s=>{let a=!1,c=null,l=null,u=(f,d=!1)=>{a||(a=!0,l&&clearTimeout(l),d&&c?.kill("SIGKILL"),s(f))};try{c=Hk(i,["/pid",String(e),"/t","/f"],{stdio:"ignore",windowsHide:!0}),c.once("error",()=>u(!1)),c.once("close",f=>u(f===0)),l=setTimeout(()=>u(!1,!0),Jk)}catch{u(!1)}});for(let s=0;s<Yk;s+=1)if(await o()){t.kill("SIGKILL");return}t.kill("SIGKILL"),t.stdin?.destroy(),t.stdout?.destroy(),t.stderr?.destroy();return}try{process.kill(-e,"SIGKILL")}catch(n){if(n.code!=="ESRCH")throw n}t.kill("SIGKILL")}import{spawnSync as Qk}from"node:child_process";import{createHash as Ca}from"node:crypto";import{promises as ke}from"node:fs";import N from"node:path";ee();Se();import{createHash as kd}from"node:crypto";import{createHash as Gk}from"node:crypto";function gd(t){return[...t].sort((e,n)=>e.p<n.p?-1:e.p>n.p?1:0).map(e=>JSON.stringify({p:e.p,h:e.h,s:e.s??null,m:e.m??null})).join(`
|
|
164
|
+
`)}function va(t){return Gk("sha256").update(t).digest("hex")}function wd(t){let e=[];for(let n of t.split(`
|
|
165
|
+
`)){if(!n)continue;let r=JSON.parse(n);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Invalid check manifest entry");let{p:i,h:o,s,m:a}=r;if(typeof i!="string"||!i||typeof o!="string"||!o)throw new Error("Invalid check manifest entry");if(s!==null&&typeof s!="number")throw new Error("Invalid check manifest entry");if(a!==null&&typeof a!="string")throw new Error("Invalid check manifest entry");e.push({p:i,h:o,s,m:a})}return e}function ka(t,e){let n=new Map(t.map(o=>[o.p,o])),r=new Map(e.map(o=>[o.p,o])),i=o=>[...o].sort();return{added:i([...r.keys()].filter(o=>!n.has(o))),removed:i([...n.keys()].filter(o=>!r.has(o))),changed:i([...n.keys()].filter(o=>r.has(o)&&n.get(o).h!==r.get(o).h))}}function Gt(t){return/[*?]/u.test(t)}function ba(t){let e=[];for(let r=0;r<t.length;r+=1){let i=t[r];i==="*"&&t[r+1]==="*"?(r+=1,t[r+1]==="/"?(r+=1,e.push({kind:"globstar-slash"})):e.push({kind:"globstar"})):i==="*"?e.push({kind:"star"}):i==="?"?e.push({kind:"question"}):e.push({kind:"literal",value:i})}let n=r=>{let i=new Set(r),o=[...r];for(;o.length>0;){let s=o.pop(),a=e[s];a&&(a.kind==="star"||a.kind==="globstar"||a.kind==="globstar-slash")&&!i.has(s+1)&&(i.add(s+1),o.push(s+1))}return i};return r=>{let i=n(new Set([0]));for(let o of r){let s=new Set;for(let a of i){let c=e[a];c&&(c.kind==="literal"&&c.value===o||c.kind==="question"&&o!=="/"?s.add(a+1):c.kind==="star"&&o!=="/"||c.kind==="globstar"?s.add(a):c.kind==="globstar-slash"&&(s.add(a),o==="/"&&s.add(a+1)))}if(i=n(s),i.size===0)return!1}return n(i).has(e.length)}}var yd=".comet/check-policy.json",zk=["argv","cwd","files","outputs","env","git","taskCheckboxes"];function Vk(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);let n=t;if(Object.keys(n).some(o=>!zk.includes(o)))throw new Error(`${e} has unknown fields`);if(!Array.isArray(n.argv)||!n.argv.length||!n.argv[0]||n.argv.some(o=>typeof o!="string"||o.includes("\0")))throw new Error(`${e} argv must bind literal command arguments`);if(typeof n.cwd!="string"||!n.cwd)throw new Error(`${e} cwd must bind a project-relative directory`);let r=n.cwd==="."?".":Z(n.cwd,`${e} cwd`),i={argv:[...n.argv],cwd:r,git:"none",taskCheckboxes:"ignore"};for(let o of["files","outputs","env"])if(n[o]!==void 0&&(!Array.isArray(n[o])||n[o].some(s=>typeof s!="string"||!s)))throw new Error(`${e} ${o} must be an array of nonempty strings`);if(n.files!==void 0&&(i.files=[...new Set(n.files.map(o=>Gt(o)?On(o,`${e} file`):Z(o,`${e} file`)))].sort((o,s)=>o.localeCompare(s,"en"))),n.outputs!==void 0&&(i.outputs=[...new Set(n.outputs.map(o=>Gt(o)?On(o,`${e} output`):Z(o,`${e} output`)))].sort((o,s)=>o.localeCompare(s,"en"))),n.env!==void 0){if(n.env.some(o=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)))throw new Error(`${e} has an invalid environment variable name`);i.env=[...new Set(n.env)].sort((o,s)=>o.localeCompare(s,"en"))}if(n.git!==void 0){if(!["all","none"].includes(n.git))throw new Error(`${e} has an invalid git binding`);i.git=n.git}if(n.taskCheckboxes!==void 0){if(!["include","ignore"].includes(n.taskCheckboxes))throw new Error(`${e} has an invalid taskCheckboxes mode`);i.taskCheckboxes=n.taskCheckboxes}return i}function Xk(t){return kd("sha256").update(JSON.stringify({argv:t.argv,cwd:t.cwd,files:t.files??null,outputs:t.outputs??null,env:t.env??null,git:t.git,taskCheckboxes:t.taskCheckboxes})).digest("hex")}function vd(t,e){return e.cwd===t.cwd&&JSON.stringify(e.argv)===JSON.stringify(t.argv)}async function at(t,e,n=!1){let r=n?{digest:"",git:"all",taskCheckboxes:"include"}:{digest:"",git:"none",taskCheckboxes:"ignore"};if(!await ui(t,yd,{label:"Classic check policy",expected:"file"}))return r;let i=await je(t,yd,{label:"Classic check policy"});try{let o=JSON.parse(i);if(!o||Array.isArray(o))throw new Error("Expected a policy object");let s=kd("sha256").update(i).digest("hex");if(o.version===2){if(Object.keys(o).some(p=>p!=="version"&&p!=="commands"))throw new Error("version 2 allows only version and commands");if(!Array.isArray(o.commands)||!o.commands.length)throw new Error("commands must be a nonempty array");let u=o.commands.map((p,g)=>Vk(p,`Classic check policy commands[${g}]`));if(new Set(u.map(p=>JSON.stringify([p.argv,p.cwd]))).size!==u.length)throw new Error("commands must not repeat an argv and cwd pair");if(!e||!u.some(p=>vd(p,e)))return{...r,digest:s};let d=u.find(p=>vd(p,e));return{digest:s,entryDigest:Xk(d),declaredCwd:d.cwd,files:d.files,outputs:d.outputs,env:d.env,git:d.git,taskCheckboxes:d.taskCheckboxes}}if(o.version!==1||Object.keys(o).some(u=>!["version","argv","cwd","files","outputs","env","git","taskCheckboxes"].includes(u)))throw new Error("Expected version 1 or 2 with known fields");if(!Array.isArray(o.argv)||!o.argv.length||!o.argv[0]||o.argv.some(u=>typeof u!="string"||u.includes("\0")))throw new Error("argv must bind literal command arguments");if(typeof o.cwd!="string"||!o.cwd)throw new Error("cwd must bind a project-relative directory");let a=o.cwd==="."?".":Z(o.cwd,"Classic check policy cwd");for(let u of["files","outputs","env"])if(o[u]!==void 0&&(!Array.isArray(o[u])||o[u].some(f=>typeof f!="string"||!f)))throw new Error(`${u} must be an array of nonempty strings`);let c=o.files?.map(u=>{if(/[?*[\]{}]/.test(u))throw new Error("files accepts literal paths, not globs");return Z(u,"Classic check policy file")}),l=o.outputs?.map(u=>{if(/[?*[\]{}]/u.test(u))throw new Error("outputs accepts literal paths, not globs");return Z(u,"Classic check policy output")});if(o.env?.some(u=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(u)))throw new Error("Invalid environment variable name");if(o.git!==void 0&&!["all","none"].includes(o.git))throw new Error("Invalid git binding");if(o.taskCheckboxes!==void 0&&!["include","ignore"].includes(o.taskCheckboxes))throw new Error("Invalid taskCheckboxes mode");return!e||e.cwd!==a||JSON.stringify(e.argv)!==JSON.stringify(o.argv)?{...r,digest:s}:{digest:s,files:c,outputs:l,env:o.env,git:o.git??r.git,taskCheckboxes:o.taskCheckboxes??r.taskCheckboxes}}catch(o){throw new Error(`Invalid Classic check policy: ${o instanceof Error?o.message:String(o)}`,{cause:o})}}function Re(t,e){let n=Us(()=>Qk("git",["-C",t,...e],{encoding:"utf8",windowsHide:!0,timeout:3e4,maxBuffer:268435456}));return n.status===0?n.stdout:null}function Zk(t,e){let n=new Map,r=32;for(let i=0;i<e.length;i+=r){let o=e.slice(i,i+r),s=Re(t,["hash-object","--no-filters","--",...o]);if(s===null)return null;let a=s.trimEnd().split(/\r?\n/u);if(a.length!==o.length||a.some(c=>!/^[0-9a-f]+$/iu.test(c)))return null;o.forEach((c,l)=>n.set(c,a[l]))}return n}function Vn(t,e){return e?t?.digest??"":t?.entryDigest??t?.digest??""}var bd=new Map;async function eb(t,e){let n=`${t}\0${e}`,r=bd.get(n);if(r!==void 0)return r;let i=process.platform==="win32"?Fn(t,process.env,e):t.includes("/")?N.resolve(e,t):(await Promise.all((process.env.PATH??"").split(N.delimiter).map(async o=>{let s=N.resolve(e,o,t);return await ke.access(s,ke.constants.X_OK).then(()=>s,()=>null)}))).find(o=>o!==null)??null;return bd.set(n,i),i}async function Xn(t,e,n,r=!1){let i=await eb(t[0],e),o=i?await ke.realpath(i).catch(()=>null):null,s=o?await ke.stat(o):null,a=n?.env;return Ca("sha256").update(JSON.stringify([process.platform,process.arch,process.execPath,process.version,t,e,o,s&&[s.size,s.mtimeMs,s.ctimeMs,s.ino],Object.entries(process.env).filter(([c])=>a?a.some(l=>process.platform==="win32"?l.toLowerCase()===c.toLowerCase():l===c):r).sort(([c],[l])=>c.localeCompare(l)),...Vn(n,r)?[Vn(n,r)]:[]])).digest("hex")}async function Qn(t,e,n,r={}){t=N.resolve(t),e=N.resolve(e);let i=r.legacy===!0,o=Ca("sha256"),s=await at(t,n,i);o.update(Vn(s,i));let a=[],c=r.contentCache??new Map,u=(await Pe(e,{migrate:!1})).classic?.verificationReport,f=u&&u.endsWith(".md")?N.resolve(t,u):null,d=(s.outputs??[]).map(w=>ba(w)),p=[t,await ke.realpath(t).catch(()=>t)],g=(w,b=t)=>{let R=N.relative(b,w);return R===""||R!==".."&&!R.startsWith(`..${N.sep}`)&&!N.isAbsolute(R)},m=[process.env.HOME,process.env.USERPROFILE].filter(w=>!!w),h=[...new Set((await Promise.all(m.map(async w=>{let b=N.resolve(w);return[b,await ke.realpath(b).catch(()=>b)]}))).flat())].filter(w=>p.some(b=>w!==b&&g(w,b))),y=w=>d.some(b=>b(N.relative(t,w).replaceAll("\\","/")))||h.some(b=>w===b||w.startsWith(b+N.sep))||w===N.join(e,".comet.yaml")||w===N.join(e,".comet-state.lock")||w===N.join(e,".comet-state-transaction.json")||w.startsWith(N.join(e,".comet")+N.sep)||w===f||w===N.join(t,".comet","current-change.json"),v=w=>N.relative(t,w).replaceAll("\\","/")||".";async function k(w){let b=[];async function R(P){let M=P===w||await ke.lstat(N.join(P,".git")).then(()=>!0,()=>!1)?Re(P,["ls-files","-z","--cached","--others","--exclude-standard"]):null,X=N.relative(w,P).replaceAll("\\","/");if(M!==null){for(let F of[...new Set(M.split("\0").filter(Boolean))].sort())b.push(X?`${X}/${F}`:F);return}for(let F of(await ke.readdir(P,{withFileTypes:!0})).sort((G,$e)=>G.name.localeCompare($e.name))){if(F.name===".git"||F.name==="node_modules")continue;let G=X?`${X}/${F.name}`:F.name;F.isDirectory()?await R(N.join(P,F.name)):b.push(G)}}return await R(w),b}let E=new Set,x=w=>process.platform==="win32"?w.toLowerCase():w;async function _(w,b){if(y(w)||!i&&E.has(x(w)))return null;let R=N.relative(t,w).replaceAll("\\","/"),P=await ke.lstat(w,{bigint:!0}).catch(G=>{if(G.code==="ENOENT")return null;throw G}),T=[JSON.stringify([R,P?P.isFile()?Number(P.size):null:"missing"])];if(!P)return await xe(t,w,{label:"Classic check input",expected:"any"}),{absolute:w,binding:T,entry:{p:R,h:"missing",s:null,m:null}};if(P.isSymbolicLink())throw new Error(`Check input is a symbolic link: ${R}. Symbolic links cannot be check inputs; either remove the link, or bind this command's inputs in .comet/check-policy.json (version 2) with a files list that excludes it`);if(P.isDirectory())return await xe(t,w,{label:"Classic check input",expected:"directory"}),{absolute:w,binding:T,directory:w};let M=`${R}|${P.size}|${P.mtimeNs}|${P.mode}`,X=s.taskCheckboxes==="ignore"&&w===N.join(e,"tasks.md"),F=i?void 0:X?c.get(M):b??c.get(M);if(F===void 0)if(!i&&!X)F=(await Tu(t,R,{label:"Classic check input"})).digest;else{let G=await $s(t,w,{label:"Classic check input",maxBytes:Number.MAX_SAFE_INTEGER}),$e=G;if(X)try{$e=Buffer.from(Qu(G.toString("utf8")),"utf8")}catch{$e=G}i?T.push($e):F=Ca("sha256").update($e).digest("hex")}return F!==void 0&&(c.set(M,F),i||T.push(F)),{absolute:w,binding:T,entry:{p:R,h:F,s:Number(P.size),m:P.mtimeNs.toString()}}}async function O(w){if(!w)return;let b=x(w.absolute);if(!(!i&&E.has(b))){E.add(b);for(let R of w.binding)o.update(R);w.directory&&await I(w.directory),w.entry&&a.push(w.entry)}}async function S(w,b){await O(await _(w,b))}async function L(w){let b=i?1:4;for(let R=0;R<w.length;R+=b){let P=await Promise.allSettled(w.slice(R,R+b).map(({absolute:T,contentHash:M})=>_(T,M)));for(let T of P){if(T.status==="rejected")throw T.reason;await O(T.value)}}}async function I(w){let R=w===t||await ke.lstat(N.join(w,".git")).then(()=>!0,()=>!1)?Re(w,["ls-files","-z","--cached","--others","--exclude-standard"]):null;if(R!==null){if(s.git==="all"){let q=Re(w,["rev-parse","HEAD"])??"unborn";o.update(q),a.push({p:`\0git:${v(w)}:head`,h:q.trim(),s:null,m:null})}let P=s.git==="all"?Re(w,["ls-files","--stage","-z"]):"",T=s.git==="all"?P:Re(w,["ls-files","--stage","-z"]);if(T===null)throw new Error("Cannot inspect check input index");if(s.git==="all")for(let q of T.split("\0").filter(Boolean)){let ie=q.slice(q.indexOf(" ")+1);y(N.resolve(w,ie))||(o.update(q),a.push({p:`\0git:${v(w)}:index:${ie}`,h:q.slice(0,q.indexOf(" ")).split(" ")[1],s:null,m:null}))}let M=[...new Set(R.split("\0").filter(Boolean))].sort(),X=new Map(T.split("\0").filter(Boolean).map(q=>{let ie=q.indexOf(" "),Ne=q.slice(0,ie).split(" ");return[q.slice(ie+1),Ne[1]??""]})),F=Re(w,["status","--porcelain=v1","-z","--untracked-files=all","--ignore-submodules=none"]),G=new Set;if(F!==null){let q=F.split("\0");for(let ie=0;ie<q.length;ie+=1){let Ne=q[ie];if(!(Ne.length<4)&&(G.add(Ne.slice(3)),/^[RC]/u.test(Ne.slice(0,1))||/[RC]$/u.test(Ne.slice(1,2)))){let Aa=q[ie+1];Aa&&(G.add(Aa),ie+=1)}}}let $e=M.filter(q=>!X.has(q)||G.has(q)),Na=Zk(w,$e),Jd=M.map(q=>{let ie=X.get(q),Ne=ie&&!G.has(q)?ie:Na?.get(q)??(Na===null?Re(w,["hash-object","--no-filters","--",q])?.trim()??void 0:void 0);return{absolute:N.resolve(w,q),contentHash:Ne?`git:${Ne}`:void 0}});await L(Jd);return}for(let P of(await ke.readdir(w,{withFileTypes:!0})).sort((T,M)=>T.name.localeCompare(M.name)))P.name===".git"||P.name==="node_modules"||await S(N.join(w,P.name))}if(s.files){if(s.git==="all"){let b=Re(t,["rev-parse","HEAD"])??"unborn";o.update(b),a.push({p:"\0git:.:head",h:b.trim(),s:null,m:null});let R=Re(t,["ls-files","--stage","-z"]);if(R!==null)for(let P of R.split("\0").filter(Boolean))y(N.resolve(t,P.slice(P.indexOf(" ")+1)))||(o.update(P),a.push({p:`\0git:.:index:${P.slice(P.indexOf(" ")+1)}`,h:P.slice(0,P.indexOf(" ")).split(" ")[1],s:null,m:null}))}let w=s.files.filter(b=>Gt(b)).map(b=>ba(b));if(!w.length)await L([...new Set(s.files)].sort().map(b=>({absolute:N.resolve(t,b)})));else{let b=new Set(s.files.filter(T=>!Gt(T))),R=new Set,P=await k(t);for(let T of P){let M=N.resolve(t,T);y(M)||(b.has(T)||w.some(X=>X(T)))&&R.add(T)}await L([...b].sort().map(T=>({absolute:N.resolve(t,T)}))),await L([...R].sort().map(T=>({absolute:N.resolve(t,T)})))}await S(N.join(t,".comet","config.yaml"))}else await I(t);if(Vn(await at(t,n,i),i)!==Vn(s,i))throw new Error("Classic check policy changed during snapshot");for(let w of["node_modules/.package-lock.json","node_modules/.modules.yaml","node_modules/.pnpm/lock.yaml"])await S(N.join(t,w));return{digest:o.digest("hex"),entries:a,manifest:gd(a)}}async function Sa(t,e,n){return(await Qn(t,e,n,{legacy:!0})).digest}import{promises as tb}from"node:fs";ee();var xt=new Map,nb=16;async function Cd(t,e){let n=await $(t,e,{label:"Classic check trajectory",expected:"file"});if(!n.exists)return{target:n.target,stamp:"missing",cacheable:!1};let r=await tb.lstat(n.target,{bigint:!0});if(!r.isFile()||r.isSymbolicLink())throw new Error("Classic check trajectory changed");return{target:n.target,cacheable:r.ino!==0n&&r.ctimeNs>0n,stamp:[r.dev,r.ino,r.birthtimeNs,r.ctimeNs,r.mtimeNs,r.size].join(":")}}async function zt(t,e){for(let n=0;n<3;n++){let r=await Cd(t,e),i=xt.get(r.target),o;if(r.cacheable&&i?.stamp===r.stamp)o=i.index;else{let a=await da(t,e);if(a.some(c=>!c||typeof c.type!="string"||!Number.isSafeInteger(c.sequence)||c.sequence<0))throw new Error("Invalid Trajectory event in Classic check index");o={maximumSequence:a.reduce((c,l)=>Math.max(c,l.sequence),0),events:a.filter(c=>c.type.startsWith("command_check"))}}let s=await Cd(t,e);if(r.stamp!==s.stamp){xt.delete(r.target);continue}return xt.delete(r.target),xt.size>=nb&&xt.delete(xt.keys().next().value),xt.set(r.target,{stamp:r.stamp,index:o}),structuredClone(o)}throw new Error("Classic check trajectory changed during index read")}var rb=new Set([".md",".markdown"]),ib=new Set([".md",".markdown",".rst",".txt"]),ob=new Set(["docs","doc","documentation",".github"]),sb=[/^LICENSE(?:[.-]|$)/u,/^NOTICE$/u,/^AUTHORS$/u];function Sd(t){return t.replaceAll("\\","/").replace(/^\.\//u,"")}function ab(t,e){for(let n of e){let r=Sd(n).replace(/\/+$/u,"");if(r&&(t===r||t.startsWith(`${r}/`)))return!0}return!1}function Ed(t,e=[]){let n=Sd(t);if(!n||n.endsWith("/")||ab(n,e))return!1;let r=n.split("/"),i=r[r.length-1],o=i.lastIndexOf("."),s=o===-1?"":i.slice(o).toLowerCase();return r.length===1?rb.has(s)||sb.some(a=>a.test(i)):ob.has(r[0])&&ib.has(s)}ta();ht();import cb from"os";import Ri from"path";function lb(t={}){let e=t.cwd??process.cwd(),n=t.homeDir??cb.homedir(),r=[{file:Ri.resolve(e,".comet","config.yaml"),source:".comet/config.yaml",scope:"project"},{file:Ri.resolve(n,".comet","config.yaml"),source:"~/.comet/config.yaml",scope:"global"}];return r.filter((i,o)=>r.findIndex(s=>s.file===i.file)===o)}async function xd(t,e={}){for(let n of lb(e)){let r=Ri.dirname(Ri.dirname(n.file)),i=n.scope==="global"?(await ea(r))?.classic:(await pt(r,{allowPartialProject:!0}))?.value.classic;if(!i||typeof i!="object"||Array.isArray(i))continue;let o=i[t];if(o!=null)return{value:String(o),source:n.source}}return null}async function _d(t){let e=await xd("document_evidence",{cwd:t});if(!e)return"neutral";if(e.value==="neutral"||e.value==="strict")return e.value;throw new Error(`classic.document_evidence must be neutral or strict, got '${e.value}' (${e.source})`)}function ub(t,e){return[Q(t,e.openSpecRoot),Q(t,e.superpowersRoot)]}async function Pd(t,e){let n;try{let o=await Is(t);n=ub(t,o)}catch{n=["openspec","docs/openspec","docs/superpowers"]}let r=[],i=[];for(let o of e)Ed(o,n)?i.push(o):r.push(o);return{material:r,neutral:i}}function xa(t){if(t!=="build"&&t!=="verify")throw new Error(`Invalid command check scope: '${String(t)}'`)}function Ai(t,e="."){if(e.trim().length===0)throw new Error("Command check cwd cannot be blank");let n=re.resolve(t),r=re.resolve(n,e);if(r!==n&&!r.startsWith(n+re.sep))throw new Error(`Command check cwd must resolve within the project root: '${e}'`);return re.relative(n,r).replaceAll("\\","/")||"."}function Od(t,e){if(e.type!=="command_check_recorded"&&e.type!=="command_check_executed")return null;let n=e.data;if(typeof n!="object"||n===null||Array.isArray(n))return null;let{scope:r,command:i,exitCode:o,cwd:s}=n;if(r!=="build"&&r!=="verify"||typeof i!="string"||i.trim().length===0||!Number.isInteger(o)||typeof s!="string")return null;let a;try{a=Ai(t,s)}catch{return null}return{sequence:e.sequence,timestamp:e.timestamp,runId:e.runId,scope:r,command:i,exitCode:o,cwd:a,...e.type==="command_check_executed"?{provenance:"runtime",argv:n.argv,timeoutMs:typeof n.timeoutMs=="number"?n.timeoutMs:void 0,inputBefore:n.inputBefore,inputAfter:n.inputAfter,changedDuringExecution:Array.isArray(n.changedDuringExecution)?n.changedDuringExecution?.filter(c=>typeof c=="string"):void 0,environment:n.environment,logRef:n.logRef,logHash:n.logHash,logSize:typeof n.logSize=="number"?n.logSize:void 0,logMtimeNs:typeof n.logMtimeNs=="string"?n.logMtimeNs:void 0,manifestRef:typeof n.manifestRef=="string"?n.manifestRef:void 0,manifestHash:typeof n.manifestHash=="string"?n.manifestHash:void 0,tier:n.tier==="incremental"?"incremental":void 0,reusable:n.reusable,checkEpoch:n.checkEpoch}:{}}}async function Zn(t,e,n,r){xa(r);let i=(await zt(e,n.trajectoryRef)).events;for(let o=i.length-1;o>=0;o-=1){let s=i[o];if(s.runId!==n.runId)continue;if(s.type==="command_checks_invalidated"&&(!Array.isArray(s.data?.scopes)||s.data.scopes.includes(r))||s.type==="command_check_started"&&s.data?.scope===r||s.type==="command_check_consumed"&&s.data?.scope===r)return null;let a=Od(t,s);if(a?.scope===r)return a}return null}function fb(t,e){if(e.type!=="command_check_started")return null;let n=e.data;if(typeof n!="object"||n===null||Array.isArray(n))return null;let{scope:r,argv:i,cwd:o,timeoutMs:s,reusable:a,tier:c}=n;if(r!=="build"&&r!=="verify"||!Array.isArray(i)||i.length===0||i.some(u=>typeof u!="string"||u.includes("\0"))||typeof o!="string"||!Number.isInteger(s)||Number(s)<1||typeof a!="boolean"||c!=="full"&&c!=="incremental")return null;let l;try{l=Ai(t,o)}catch{return null}return{sequence:e.sequence,timestamp:e.timestamp,runId:e.runId,scope:r,argv:[...i],cwd:l,timeoutMs:Number(s),reusable:a,tier:c}}async function Td(t,e,n,r){xa(r);let i=(await zt(e,n.trajectoryRef)).events;for(let o=i.length-1;o>=0;o-=1){let s=i[o];if(s.runId!==n.runId||!(s.data?.scope===r||Array.isArray(s.data?.scopes)&&s.data.scopes.includes(r)))continue;if(s.type==="command_check_started")return fb(t,s);let c=Od(t,s);if(c?.scope===r&&c.provenance==="runtime"&&c.argv?.length)return{sequence:c.sequence,timestamp:c.timestamp,runId:c.runId,scope:c.scope,argv:[...c.argv],cwd:c.cwd,timeoutMs:c.timeoutMs??3e5,reusable:c.reusable===!0,tier:c.tier??"full"};if(s.type!=="command_checks_invalidated")return null}return null}async function db(t,e,n){let r=(await zt(t,e.trajectoryRef)).events;for(let i=r.length-1;i>=0;i-=1){let o=r[i];if(!(o.runId!==e.runId||!(o.data?.scope===n||Array.isArray(o.data?.scopes)&&o.data.scopes.includes(n))))return o.type==="command_check_started"?`a previous ${n} check attempt started at ${o.timestamp} never completed (interrupted or failed during launch); rerun the check`:null}return null}async function Ea(t,e,n,r){return it(t,async()=>{let o={sequence:(await zt(t,e.trajectoryRef)).maximumSequence+1,timestamp:new Date().toISOString(),runId:e.runId,type:n,data:r};return await zn(t,e.trajectoryRef,o),o})}async function _a(t,e,n,r){if(xa(r.scope),!r.argv.length||r.argv.some(I=>typeof I!="string"||I.includes("\0")))throw new Error("Check requires literal program arguments");let i=Ai(t,r.cwd),o=await Ni.realpath(t);Ai(o,await Ni.realpath(re.resolve(t,i)));let s=r.tier==="incremental"?"incremental":"full",a=await Zn(t,e,n,r.scope);if(r.reusable){if(a&&a.reusable&&(a.tier??"full")===s&&a.cwd===i&&JSON.stringify(a.argv)===JSON.stringify(r.argv)){let I=await Nd(t,e,n,r.scope);if(I?.sequence===a.sequence&&I.timestamp===a.timestamp)return{...I,reused:!0}}if(!a){let I=r.scope==="build"?"verify":"build",w=await Nd(t,e,n,I);if(w?.reusable&&(w.tier??"full")===s&&w.cwd===i&&JSON.stringify(w.argv)===JSON.stringify(r.argv)){let{sequence:b,timestamp:R,runId:P,scope:T,reused:M,...X}=w,F=(await Pe(e,{migrate:!1})).classic?.checkEpoch??0,G=await Ea(e,n,"command_check_executed",{...X,scope:r.scope,checkEpoch:F});return{...X,scope:r.scope,checkEpoch:F,sequence:G.sequence,timestamp:G.timestamp,runId:n.runId,reused:!0}}}}let c=r.timeoutMs??3e5,l=await Ea(e,n,"command_check_started",{scope:r.scope,argv:[...r.argv],cwd:i,timeoutMs:c,reusable:r.reusable===!0,tier:s}),u=(await Pe(e,{migrate:!1})).classic?.checkEpoch??0,f={argv:r.argv,cwd:i},d=a?.manifestRef?await Id(t,a).catch(()=>null):null,p=await Qn(t,e,f,d?{baseline:d}:{}),g=p.digest,m=await Xn(r.argv,re.resolve(t,i),await at(t,f)),h=re.join(e,".comet","checks",`${Rd()}.log`),y=await new Promise(I=>{let w=rf(r.argv[0],r.argv.slice(1),{cwd:re.resolve(t,i)}),b="",R=!1,P=M=>{b=(b+M.toString()).slice(-2*1024*1024)};w.stdout.on("data",P),w.stderr.on("data",P),w.on("error",M=>{b+=`
|
|
166
|
+
${M.message}`});let T=setTimeout(()=>{R=!0,hd(w).catch(()=>w.kill("SIGKILL"))},c);w.on("close",M=>{clearTimeout(T),I({exitCode:R?124:M??1,output:(R?`Check timed out.
|
|
167
|
+
`:"")+b})})}),v=await Qn(t,e,f,{baseline:p.entries}).catch(()=>null),k=v?v.digest:"unavailable",E=v?(()=>{let I=ka(p.entries,v.entries);return[...I.added,...I.removed,...I.changed].slice(0,100)})():void 0,x,_;if(v){let I=re.join(e,".comet","checks",`${Rd()}.manifest`);await qs(t,I,v.manifest,{label:"Classic check manifest"}),x=re.relative(t,I).replaceAll("\\","/"),_=va(v.manifest)}u!==((await Pe(e,{migrate:!1})).classic?.checkEpoch??0)&&(k="phase-changed"),m!==await Xn(r.argv,re.resolve(t,i),await at(t,f))&&(k="environment-changed"),await qs(t,h,y.output,{label:"Classic check log"});let O=await Ni.stat(h,{bigint:!0}).catch(()=>null),S={scope:r.scope,command:JSON.stringify(r.argv),checkEpoch:u,argv:r.argv,timeoutMs:c,exitCode:y.exitCode,cwd:i,provenance:"runtime",inputBefore:g,inputAfter:k,changedDuringExecution:E,environment:m,logRef:re.relative(t,h).replaceAll("\\","/"),logHash:Ad("sha256").update(y.output).digest("hex"),...O?{logSize:Number(O.size),logMtimeNs:O.mtimeNs.toString()}:{},manifestRef:x,manifestHash:_,tier:s,reusable:r.reusable===!0&&g===k},L=await it(e,async()=>{if((await zt(e,n.trajectoryRef)).events.some(b=>b.runId===n.runId&&b.sequence>l.sequence&&(b.type==="command_checks_invalidated"&&(!Array.isArray(b.data?.scopes)||b.data.scopes.includes(r.scope))||b.data?.scope===r.scope)))throw new Error("Check superseded by a newer check or invalidation; rerun required");return Ea(e,n,"command_check_executed",S)});return{...S,sequence:L.sequence,timestamp:L.timestamp,runId:n.runId}}async function Id(t,e){if(typeof e.manifestHash!="string"||typeof e.manifestRef!="string")return null;let n=await je(t,e.manifestRef,{label:"Classic check manifest",maxBytes:Number.MAX_SAFE_INTEGER});return va(n)!==e.manifestHash?null:wd(n)}async function mb(t,e,n,r,i=(o,s)=>Sa(t,e,{argv:o,cwd:s})){let o=await Zn(t,e,n,r),s=u=>({record:null,reason:u});if(o&&!o.reusable&&(o.checkEpoch??0)!==((await Pe(e,{migrate:!1})).classic?.checkEpoch??0))return s("check evidence crossed a phase boundary");if(!o)return{record:null,reason:await db(e,n,r)??void 0};if(o.provenance!=="runtime")return s(`the latest record is a manual record-check declaration from ${o.timestamp}; manual declarations never satisfy the guard and shadow any earlier runtime record`);if(o.exitCode!==0)return s(`the last check failed with exit code ${o.exitCode}`);if(!Array.isArray(o.argv)||!o.argv.length||!o.inputBefore)return s("the latest record is incomplete");if(o.inputBefore!==o.inputAfter)return{record:null,reason:o.changedDuringExecution?.length?"inputs changed while the check ran; if these paths are generated artifacts, declare them in the matching command outputs in .comet/check-policy.json":"inputs changed while the check ran",...o.changedDuringExecution?.length?{changedPaths:o.changedDuringExecution,relevance:"execution-time command inputs"}:{}};let a={argv:o.argv,cwd:o.cwd},c;if(o.manifestRef){let u=await at(t,a);if(o.environment!==await Xn(o.argv,re.resolve(t,o.cwd),u))return s("the environment changed since execution (checks bind the resolved executable path and its file identity, the Node version, and declared policy environment variables; switching Node versions, package-manager shims, or PATH order invalidates evidence)");let f=await Id(t,o).catch(()=>null);if(!f)return s("the recorded input manifest is damaged or missing");let d=await Qn(t,e,a,{baseline:f}),p=ka(f,d.entries),g=[...p.added,...p.removed,...p.changed];if(g.length){let m=u.files?`declared inputs (${u.files.join(", ")})`:"default whole-tree inputs",h=u.files||await _d(t)==="strict"?g:(await Pd(t,g)).material;if(h.length)return{record:null,reason:"check inputs changed since execution",changedPaths:h,relevance:m};c=g}}else if(o.environment!==await Xn(o.argv,re.resolve(t,o.cwd),await at(t,a,!0),!0)||o.inputAfter!==await i(o.argv,o.cwd))return s("check inputs changed since execution");if(typeof o.logRef!="string"||typeof o.logHash!="string")return s("the evidence log record is incomplete");try{let u=await Ni.stat(re.resolve(t,o.logRef),{bigint:!0}).catch(()=>null);if(!(typeof o.logSize=="number"&&typeof o.logMtimeNs=="string"&&u!==null&&Number(u.size)===o.logSize&&u.mtimeNs.toString()===o.logMtimeNs)){let d=await je(t,o.logRef,{label:"Classic check evidence log"});if(Ad("sha256").update(d).digest("hex")!==o.logHash)return s("the evidence log is damaged")}}catch{return s("the evidence log is missing")}let l=await Zn(t,e,n,r);return l?.sequence!==o.sequence||l.timestamp!==o.timestamp||JSON.stringify(l)!==JSON.stringify(o)?s("the evidence was superseded by a newer check"):{record:o,...c?{documentChangesIgnored:c}:{}}}async function Nd(t,e,n,r,i=(o,s)=>Sa(t,e,{argv:o,cwd:s})){return(await mb(t,e,n,r,i)).record}function Ld(t){let e=t.changedDuringExecution??[];if(e.length===0)return"Inputs changed during check; rerun after the workspace is stable.";let n=e.slice(0,20),r=e.length-n.length;return["Inputs changed during check.",`Changed inputs: ${n.join(", ")}${r>0?` (+${r} more)`:""}.`,"If these paths are generated artifacts, add them to the matching command outputs in .comet/check-policy.json; otherwise stabilize the inputs before rerunning."].join(`
|
|
168
|
+
`)}var Pa=Ju(async t=>{let[e,n,r]=t,i=t.indexOf("--"),o=e==="rerun";if(e!=="run"&&!o||!n||!["build","verify"].includes(r)||(o?t.length!==3:i<3||!t[i+1]))throw new Error("Usage: comet check run <change> <build|verify> [--local] [--incremental] [--cwd <path>] [--timeout-ms <ms>] -- <program> [args...] | comet check rerun <change> <build|verify>");let s=Uu(),a=await js(s),c=await Gu(n,s);if(jd.dirname(c.directory)!==a.changesDir)throw new Error("Checks require an active change");let l=await pd(c.directory);if(o){let m=await Zn(s,c.directory,l.run,r),h=m?null:await Td(s,c.directory,l.run,r),y=m?.argv?.length&&m.provenance==="runtime"?m:h;if(!y)throw new Error(`No Runtime ${r} check is available to rerun`);let v=y.argv;if(!v?.length)throw new Error(`No Runtime ${r} check is available to rerun`);let k=await _a(s,c.directory,l.run,{scope:r,argv:v,cwd:y.cwd,timeoutMs:y.timeoutMs??3e5,reusable:y.reusable===!0,tier:y.tier??"full"});return{exitCode:k.exitCode||(k.inputBefore===k.inputAfter?0:1),data:k,stdout:`Check ${k.scope}: exit=${k.exitCode}; reused=${k.reused===!0}; tier=${k.tier??"full"}; log=${k.logRef}
|
|
169
|
+
`,...k.inputBefore!==k.inputAfter?{stderr:Ld(k)}:{}}}let u=jd.relative(s,Hu())||".",f=3e5,d=!1,p=!1;for(let m=3;m<i;m+=1){let h=t[m];if(h==="--local")d=!0;else if(h==="--incremental")p=!0;else if(h==="--cwd"&&m+1<i)u=t[++m];else if(h==="--timeout-ms"&&m+1<i)f=Number(t[++m]);else throw new Error(`Unknown or incomplete check option: ${h}`)}if(!Number.isInteger(f)||f<1||f>36e5)throw new Error("Check timeout must be 1..3600000 milliseconds");let g=await _a(s,c.directory,l.run,{scope:r,argv:t.slice(i+1),cwd:u,timeoutMs:f,reusable:d,tier:p?"incremental":"full"});return{exitCode:g.exitCode||(g.inputBefore===g.inputAfter?0:1),data:g,stdout:`Check ${g.scope}: exit=${g.exitCode}; reused=${g.reused===!0}; tier=${g.tier??"full"}; log=${g.logRef}
|
|
170
|
+
`,...g.inputBefore!==g.inputAfter?{stderr:Ld(g)}:{}}});import{realpathSync as wb}from"fs";import{pathToFileURL as Wd}from"url";var $d=["open-complete","design-complete","build-complete","verify-pass","verify-fail","archive-confirm","archive-reopen","archived","preset-escalate"];var pb=new Set([...Hn,"archive_confirmation","verify_failures","check_epoch","classic_profile","classic_migration","bound_branch"]),qd=new Set(rt.filter(t=>!pb.has(t))),Ra={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 hb=`
|
|
158
171
|
Options: --json (machine-readable output), --help
|
|
159
172
|
JSON: one object with command and exitCode; data, stdout, stderr, summary and next are optional.
|
|
160
173
|
Use exitCode for success; do not parse human-readable stdout. Help text is in stdout in JSON mode.
|
|
161
|
-
`;function yd(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: ${[...Ge,...jn].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):",...[...wd].map(c=>` ${c}${da[c]?`: ${da[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: ${gd.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
|
+
`;function Md(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):",...[...qd].map(c=>` ${c}${Ra[c]?`: ${Ra[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: ${$d.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(`
|
|
162
175
|
`)}
|
|
163
|
-
${
|
|
164
|
-
`:void 0}function
|
|
165
|
-
`,...e.envelope===void 0?{}:{envelope:e.envelope}}}async function
|
|
176
|
+
${hb}Command placeholders must be replaced with actual values.
|
|
177
|
+
`:void 0}function Fd(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 gb}from"node:util";function Dd(t,e={}){return{code:"CLASSIC_COMMAND_FAILED",message:gb(t instanceof Error?t.message:String(t)),...e}}function yb(t,e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:t,exitCode:e.exitCode,agent:Fd(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}})+`
|
|
178
|
+
`,...e.envelope===void 0?{}:{envelope:e.envelope}}}async function Bd(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=Md(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:[Dd(l)]}}}return s?yb(t,c):c}function Kd(t,e){return async(n,r={})=>n[0]!==t?{exitCode:64,stderr:`Expected Classic command: ${t}`}:Bd(t,e,n.slice(1),r)}function Ud(t){let e=process.argv[1];if(!e)return!1;if(t===Wd(e).href)return!0;try{return t===Wd(wb(e)).href}catch{return!1}}async function Hd(t,e,n=process.argv.slice(2)){let r=await Bd(t,e,n);return r.stdout&&process.stdout.write(r.stdout),r.stderr&&process.stderr.write(r.stderr+(r.stderr.endsWith(`
|
|
166
179
|
`)?"":`
|
|
167
|
-
`)),
|
|
180
|
+
`)),r.exitCode}var WR=Kd("check",Pa);Ud(import.meta.url)&&(process.exitCode=await Hd("check",Pa));export{WR as runClassicCli};
|