@rpamis/comet 0.4.0-beta.14 → 0.4.0-beta.16
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 +13 -1
- package/assets/manifest.json +1 -1
- package/assets/skills/comet/SKILL.md +6 -5
- package/assets/skills/comet/reference/subagent-dispatch.md +2 -4
- package/assets/skills/comet/rules/comet-phase-guard.en.md +4 -3
- package/assets/skills/comet/rules/comet-phase-guard.md +4 -3
- package/assets/skills/comet/rules/comet-workflow-guard.en.md +1 -1
- package/assets/skills/comet/rules/comet-workflow-guard.md +1 -1
- package/assets/skills/comet/scripts/comet-archive.mjs +88 -88
- package/assets/skills/comet/scripts/comet-guard.mjs +126 -126
- package/assets/skills/comet/scripts/comet-handoff.mjs +88 -88
- package/assets/skills/comet/scripts/comet-hook-guard.mjs +91 -89
- package/assets/skills/comet/scripts/comet-hook-router.mjs +124 -116
- package/assets/skills/comet/scripts/comet-resume-probe.mjs +72 -72
- package/assets/skills/comet/scripts/comet-runtime.mjs +188 -185
- package/assets/skills/comet/scripts/comet-state.mjs +108 -107
- package/assets/skills/comet/scripts/comet-yaml-validate.mjs +97 -97
- package/assets/skills/comet-any/SKILL.md +1 -1
- package/assets/skills/comet-any/reference/authoring-subagents.md +3 -11
- package/assets/skills/comet-any/reference/subagents/pause-points-author.md +1 -4
- package/assets/skills/comet-any/reference/subagents/reference-author.md +1 -4
- package/assets/skills/comet-any/reference/subagents/script-author.md +1 -4
- package/assets/skills/comet-any/reference/subagents/skill-core-author.md +1 -4
- package/assets/skills/comet-any/reference/subagents/skill-reviewer.md +1 -4
- package/assets/skills/comet-any/reference/subagents/workflow-entry-author.md +1 -4
- package/assets/skills/comet-build/SKILL.md +2 -2
- package/assets/skills/comet-native/SKILL.md +85 -11
- package/assets/skills/comet-native/reference/artifacts.md +3 -1
- package/assets/skills/comet-native/reference/commands.md +15 -6
- package/assets/skills/comet-native/reference/recovery.md +12 -1
- package/assets/skills/comet-native/scripts/comet-native-archive.mjs +124 -118
- package/assets/skills/comet-native/scripts/comet-native-check.mjs +116 -110
- package/assets/skills/comet-native/scripts/comet-native-checkpoint.mjs +110 -110
- package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +121 -121
- package/assets/skills/comet-native/scripts/comet-native-evidence.mjs +83 -83
- package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +88 -82
- package/assets/skills/comet-native/scripts/comet-native-init.mjs +85 -85
- package/assets/skills/comet-native/scripts/comet-native-new.mjs +114 -114
- package/assets/skills/comet-native/scripts/comet-native-next.mjs +122 -122
- package/assets/skills/comet-native/scripts/comet-native-receipt.mjs +124 -116
- package/assets/skills/comet-native/scripts/comet-native-root.mjs +110 -110
- package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +154 -152
- package/assets/skills/comet-native/scripts/comet-native-select.mjs +110 -110
- package/assets/skills/comet-native/scripts/comet-native-show.mjs +80 -80
- package/assets/skills/comet-native/scripts/comet-native-spec.mjs +112 -112
- package/assets/skills/comet-native/scripts/comet-native-status.mjs +107 -107
- package/assets/skills-zh/comet/SKILL.md +3 -3
- package/assets/skills-zh/comet/reference/subagent-dispatch.md +2 -4
- package/assets/skills-zh/comet-any/SKILL.md +1 -1
- package/assets/skills-zh/comet-any/reference/authoring-subagents.md +3 -14
- package/assets/skills-zh/comet-any/reference/subagents/pause-points-author.md +1 -4
- package/assets/skills-zh/comet-any/reference/subagents/reference-author.md +1 -4
- package/assets/skills-zh/comet-any/reference/subagents/script-author.md +1 -4
- package/assets/skills-zh/comet-any/reference/subagents/skill-core-author.md +1 -4
- package/assets/skills-zh/comet-any/reference/subagents/skill-reviewer.md +1 -4
- package/assets/skills-zh/comet-any/reference/subagents/workflow-entry-author.md +1 -4
- package/assets/skills-zh/comet-build/SKILL.md +2 -2
- package/assets/skills-zh/comet-native/SKILL.md +86 -12
- package/assets/skills-zh/comet-native/reference/artifacts.md +3 -1
- package/assets/skills-zh/comet-native/reference/commands.md +17 -8
- package/assets/skills-zh/comet-native/reference/recovery.md +14 -3
- package/bin/fast-runtime-router.js +1 -0
- package/dist/app/cli/index.js +1 -0
- package/dist/app/cli/index.js.map +1 -1
- package/dist/app/commands/doctor.d.ts.map +1 -1
- package/dist/app/commands/doctor.js +146 -39
- package/dist/app/commands/doctor.js.map +1 -1
- package/dist/app/commands/init.d.ts.map +1 -1
- package/dist/app/commands/init.js +43 -12
- package/dist/app/commands/init.js.map +1 -1
- package/dist/app/commands/update.d.ts.map +1 -1
- package/dist/app/commands/update.js +42 -9
- package/dist/app/commands/update.js.map +1 -1
- package/dist/app/commands/workflow.d.ts +1 -0
- package/dist/app/commands/workflow.d.ts.map +1 -1
- package/dist/app/commands/workflow.js +9 -2
- package/dist/app/commands/workflow.js.map +1 -1
- package/dist/domains/comet-classic/classic-evidence.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-evidence.js +45 -9
- package/dist/domains/comet-classic/classic-evidence.js.map +1 -1
- package/dist/domains/comet-classic/classic-hook-guard.d.ts +5 -1
- package/dist/domains/comet-classic/classic-hook-guard.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-hook-guard.js +104 -20
- package/dist/domains/comet-classic/classic-hook-guard.js.map +1 -1
- package/dist/domains/comet-classic/classic-layout-initialization.d.ts +4 -3
- package/dist/domains/comet-classic/classic-layout-initialization.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-layout-initialization.js +13 -9
- package/dist/domains/comet-classic/classic-layout-initialization.js.map +1 -1
- package/dist/domains/comet-classic/classic-layout.d.ts +2 -11
- package/dist/domains/comet-classic/classic-layout.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-layout.js +22 -28
- package/dist/domains/comet-classic/classic-layout.js.map +1 -1
- package/dist/domains/comet-classic/classic-plan-readiness.d.ts +12 -0
- package/dist/domains/comet-classic/classic-plan-readiness.d.ts.map +1 -0
- package/dist/domains/comet-classic/classic-plan-readiness.js +26 -0
- package/dist/domains/comet-classic/classic-plan-readiness.js.map +1 -0
- package/dist/domains/comet-classic/classic-project-config.d.ts +1 -0
- package/dist/domains/comet-classic/classic-project-config.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-project-config.js +13 -7
- package/dist/domains/comet-classic/classic-project-config.js.map +1 -1
- package/dist/domains/comet-classic/classic-root-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-root-command.js +6 -1
- package/dist/domains/comet-classic/classic-root-command.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 +58 -7
- package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
- package/dist/domains/comet-entry/hook-adapter.d.ts.map +1 -1
- package/dist/domains/comet-entry/hook-adapter.js +19 -2
- package/dist/domains/comet-entry/hook-adapter.js.map +1 -1
- package/dist/domains/comet-entry/hook-project-root.d.ts +3 -0
- package/dist/domains/comet-entry/hook-project-root.d.ts.map +1 -0
- package/dist/domains/comet-entry/hook-project-root.js +62 -0
- package/dist/domains/comet-entry/hook-project-root.js.map +1 -0
- package/dist/domains/comet-entry/hook-router-entry.d.ts +2 -1
- package/dist/domains/comet-entry/hook-router-entry.d.ts.map +1 -1
- package/dist/domains/comet-entry/hook-router-entry.js +6 -4
- package/dist/domains/comet-entry/hook-router-entry.js.map +1 -1
- package/dist/domains/comet-entry/hook-router.d.ts +2 -0
- package/dist/domains/comet-entry/hook-router.d.ts.map +1 -1
- package/dist/domains/comet-entry/hook-router.js +45 -9
- package/dist/domains/comet-entry/hook-router.js.map +1 -1
- package/dist/domains/comet-entry/hook-types.d.ts +1 -0
- package/dist/domains/comet-entry/hook-types.d.ts.map +1 -1
- package/dist/domains/comet-entry/project-activation.d.ts +12 -0
- package/dist/domains/comet-entry/project-activation.d.ts.map +1 -0
- package/dist/domains/comet-entry/project-activation.js +109 -0
- package/dist/domains/comet-entry/project-activation.js.map +1 -0
- package/dist/domains/comet-entry/resume-probe.d.ts.map +1 -1
- package/dist/domains/comet-entry/resume-probe.js +47 -26
- package/dist/domains/comet-entry/resume-probe.js.map +1 -1
- package/dist/domains/comet-entry/types.d.ts +1 -1
- package/dist/domains/comet-entry/types.d.ts.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 +43 -1
- package/dist/domains/comet-native/native-archive-command.js.map +1 -1
- package/dist/domains/comet-native/native-archive-inspection.d.ts.map +1 -1
- package/dist/domains/comet-native/native-archive-inspection.js +11 -0
- package/dist/domains/comet-native/native-archive-inspection.js.map +1 -1
- package/dist/domains/comet-native/native-archive-preflight.d.ts +10 -0
- package/dist/domains/comet-native/native-archive-preflight.d.ts.map +1 -1
- package/dist/domains/comet-native/native-archive-preflight.js +44 -0
- package/dist/domains/comet-native/native-archive-preflight.js.map +1 -1
- package/dist/domains/comet-native/native-change.d.ts +18 -1
- package/dist/domains/comet-native/native-change.d.ts.map +1 -1
- package/dist/domains/comet-native/native-change.js +72 -3
- package/dist/domains/comet-native/native-change.js.map +1 -1
- package/dist/domains/comet-native/native-check.d.ts.map +1 -1
- package/dist/domains/comet-native/native-check.js +13 -1
- package/dist/domains/comet-native/native-check.js.map +1 -1
- package/dist/domains/comet-native/native-cli-shared.d.ts +2 -2
- package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli-shared.js +24 -3
- package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
- package/dist/domains/comet-native/native-conflict-inspection.d.ts +3 -1
- package/dist/domains/comet-native/native-conflict-inspection.d.ts.map +1 -1
- package/dist/domains/comet-native/native-conflict-inspection.js +20 -10
- package/dist/domains/comet-native/native-conflict-inspection.js.map +1 -1
- package/dist/domains/comet-native/native-continuation.d.ts.map +1 -1
- package/dist/domains/comet-native/native-continuation.js +16 -0
- package/dist/domains/comet-native/native-continuation.js.map +1 -1
- package/dist/domains/comet-native/native-diagnostics.d.ts +2 -0
- package/dist/domains/comet-native/native-diagnostics.d.ts.map +1 -1
- package/dist/domains/comet-native/native-diagnostics.js +43 -32
- package/dist/domains/comet-native/native-diagnostics.js.map +1 -1
- package/dist/domains/comet-native/native-evidence-storage.d.ts +6 -0
- package/dist/domains/comet-native/native-evidence-storage.d.ts.map +1 -1
- package/dist/domains/comet-native/native-evidence-storage.js +24 -0
- package/dist/domains/comet-native/native-evidence-storage.js.map +1 -1
- package/dist/domains/comet-native/native-findings.d.ts.map +1 -1
- package/dist/domains/comet-native/native-findings.js +36 -0
- package/dist/domains/comet-native/native-findings.js.map +1 -1
- package/dist/domains/comet-native/native-hook-guard.js +2 -2
- package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
- package/dist/domains/comet-native/native-new-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-new-command.js +22 -7
- package/dist/domains/comet-native/native-new-command.js.map +1 -1
- package/dist/domains/comet-native/native-receipt-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-receipt-command.js +14 -1
- package/dist/domains/comet-native/native-receipt-command.js.map +1 -1
- package/dist/domains/comet-native/native-receipt-errors.d.ts +23 -0
- package/dist/domains/comet-native/native-receipt-errors.d.ts.map +1 -0
- package/dist/domains/comet-native/native-receipt-errors.js +9 -0
- package/dist/domains/comet-native/native-receipt-errors.js.map +1 -0
- package/dist/domains/comet-native/native-receipt-refresh.d.ts +3 -0
- package/dist/domains/comet-native/native-receipt-refresh.d.ts.map +1 -1
- package/dist/domains/comet-native/native-receipt-refresh.js +13 -2
- package/dist/domains/comet-native/native-receipt-refresh.js.map +1 -1
- package/dist/domains/comet-native/native-root-move.d.ts.map +1 -1
- package/dist/domains/comet-native/native-root-move.js +54 -1
- package/dist/domains/comet-native/native-root-move.js.map +1 -1
- package/dist/domains/comet-native/native-snapshot.d.ts.map +1 -1
- package/dist/domains/comet-native/native-snapshot.js +71 -14
- package/dist/domains/comet-native/native-snapshot.js.map +1 -1
- package/dist/domains/comet-native/native-transitions.d.ts.map +1 -1
- package/dist/domains/comet-native/native-transitions.js +74 -42
- package/dist/domains/comet-native/native-transitions.js.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt-runtime.d.ts +37 -4
- package/dist/domains/comet-native/native-verification-receipt-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt-runtime.js +192 -4
- package/dist/domains/comet-native/native-verification-receipt-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-verification-runtime.d.ts +27 -1
- package/dist/domains/comet-native/native-verification-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-runtime.js +29 -6
- package/dist/domains/comet-native/native-verification-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-workspace.d.ts +39 -3
- package/dist/domains/comet-native/native-workspace.d.ts.map +1 -1
- package/dist/domains/comet-native/native-workspace.js +200 -8
- package/dist/domains/comet-native/native-workspace.js.map +1 -1
- package/dist/domains/dashboard/collector.d.ts +26 -1
- package/dist/domains/dashboard/collector.d.ts.map +1 -1
- package/dist/domains/dashboard/collector.js +381 -1
- package/dist/domains/dashboard/collector.js.map +1 -1
- package/dist/domains/dashboard/native-adapter.d.ts +15 -0
- package/dist/domains/dashboard/native-adapter.d.ts.map +1 -1
- package/dist/domains/dashboard/native-adapter.js +1 -1
- package/dist/domains/dashboard/native-adapter.js.map +1 -1
- package/dist/domains/dashboard/native-collector.d.ts +26 -1
- package/dist/domains/dashboard/native-collector.d.ts.map +1 -1
- package/dist/domains/dashboard/native-collector.js +284 -5
- package/dist/domains/dashboard/native-collector.js.map +1 -1
- package/dist/domains/dashboard/server.d.ts.map +1 -1
- package/dist/domains/dashboard/server.js +92 -3
- package/dist/domains/dashboard/server.js.map +1 -1
- package/dist/domains/dashboard/types.d.ts +41 -1
- package/dist/domains/dashboard/types.d.ts.map +1 -1
- package/dist/domains/dashboard/verify-parser.d.ts +1 -0
- package/dist/domains/dashboard/verify-parser.d.ts.map +1 -1
- package/dist/domains/dashboard/verify-parser.js +8 -4
- package/dist/domains/dashboard/verify-parser.js.map +1 -1
- package/dist/domains/dashboard/web/assets/{arc-mNt_SS1l.js → arc-ClrSujVb.js} +1 -1
- package/dist/domains/dashboard/web/assets/{architectureDiagram-3BPJPVTR-Bc5akVD6.js → architectureDiagram-3BPJPVTR-B4A_t84A.js} +1 -1
- package/dist/domains/dashboard/web/assets/{blockDiagram-GPEHLZMM-C43zhVBe.js → blockDiagram-GPEHLZMM-D72u2953.js} +1 -1
- package/dist/domains/dashboard/web/assets/{c4Diagram-AAUBKEIU-dToETarK.js → c4Diagram-AAUBKEIU-Ca5zba3N.js} +1 -1
- package/dist/domains/dashboard/web/assets/channel-B_u-_i2t.js +1 -0
- package/dist/domains/dashboard/web/assets/{chunk-2J33WTMH-C0oO137R.js → chunk-2J33WTMH-CCVPBm0J.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-4BX2VUAB-CGms1fgI.js → chunk-4BX2VUAB-JYluRsP-.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-55IACEB6-Bugl8v6f.js → chunk-55IACEB6-DfYm7pN7.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-727SXJPM-8ATNMlBG.js → chunk-727SXJPM-CwghIMO9.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-AQP2D5EJ-BNYjSSqU.js → chunk-AQP2D5EJ-BA_zgMXZ.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-FMBD7UC4-_nJAqSbe.js → chunk-FMBD7UC4-BAJLB5V6.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-ND2GUHAM-lyxYm5NX.js → chunk-ND2GUHAM-Bj6HWRwi.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-QZHKN3VN-PUMVeWpd.js → chunk-QZHKN3VN-B1kXfg5N.js} +1 -1
- package/dist/domains/dashboard/web/assets/classDiagram-4FO5ZUOK-BpA7BPgX.js +1 -0
- package/dist/domains/dashboard/web/assets/classDiagram-v2-Q7XG4LA2-BpA7BPgX.js +1 -0
- package/dist/domains/dashboard/web/assets/{cose-bilkent-S5V4N54A-DzMqjexn.js → cose-bilkent-S5V4N54A-BBrkuiAU.js} +1 -1
- package/dist/domains/dashboard/web/assets/{cynefin-VYW2F7L2-B67ET0eq.js → cynefin-VYW2F7L2-DlFhgQHt.js} +1 -1
- package/dist/domains/dashboard/web/assets/{dagre-BM42HDAG-CQPMvRLK.js → dagre-BM42HDAG-B0Bk5oiP.js} +1 -1
- package/dist/domains/dashboard/web/assets/{demo-BuVau32v.js → demo-DZYPLZpF.js} +2 -2
- package/dist/domains/dashboard/web/assets/{diagram-2AECGRRQ-BRpLrFHM.js → diagram-2AECGRRQ-tvTUiBA2.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-5GNKFQAL-CPGWuGrE.js → diagram-5GNKFQAL-BZfcK29q.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-KO2AKTUF-D2wpX2iO.js → diagram-KO2AKTUF-BQahyP-C.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-LMA3HP47-D54mAbDu.js → diagram-LMA3HP47-D5bJnW2C.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-OG6HWLK6-ZGQDpSs_.js → diagram-OG6HWLK6-DTwWdzWJ.js} +1 -1
- package/dist/domains/dashboard/web/assets/{erDiagram-TEJ5UH35-C3qDo7sd.js → erDiagram-TEJ5UH35-BbvrdCp9.js} +1 -1
- package/dist/domains/dashboard/web/assets/{flowDiagram-I6XJVG4X-B7hStPd9.js → flowDiagram-I6XJVG4X-DgbR7Tcc.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ganttDiagram-6RSMTGT7-IqcLFbTK.js → ganttDiagram-6RSMTGT7-wWMOA7F4.js} +1 -1
- package/dist/domains/dashboard/web/assets/{gitGraphDiagram-PVQCEYII-YrMZpzUu.js → gitGraphDiagram-PVQCEYII-DCxvMAUJ.js} +1 -1
- package/dist/domains/dashboard/web/assets/index-Bk1o-4VO.css +1 -0
- package/dist/domains/dashboard/web/assets/{index-icxk8_BP.js → index-Blit0P5Z.js} +1 -1
- package/dist/domains/dashboard/web/assets/index-g8vyW0R_.js +257 -0
- package/dist/domains/dashboard/web/assets/{infoDiagram-5YYISTIA-CcIgGK_7.js → infoDiagram-5YYISTIA-9qXEkzDe.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ishikawaDiagram-YF4QCWOH-1x3rNjGP.js → ishikawaDiagram-YF4QCWOH-Dkf5othW.js} +1 -1
- package/dist/domains/dashboard/web/assets/{journeyDiagram-JHISSGLW-B2XiqMNP.js → journeyDiagram-JHISSGLW-C2_IkO4s.js} +1 -1
- package/dist/domains/dashboard/web/assets/{kanban-definition-UN3LZRKU-x46cGuo3.js → kanban-definition-UN3LZRKU-BxWgu4DL.js} +1 -1
- package/dist/domains/dashboard/web/assets/{linear-DFLqGZWl.js → linear-Dkr6p-Ro.js} +1 -1
- package/dist/domains/dashboard/web/assets/{mermaid.core-g3J6BACc.js → mermaid.core-DZUcsoG4.js} +4 -4
- package/dist/domains/dashboard/web/assets/{mindmap-definition-RKZ34NQL-CTdeKmcX.js → mindmap-definition-RKZ34NQL-C9xyxGfa.js} +1 -1
- package/dist/domains/dashboard/web/assets/{pieDiagram-4H26LBE5-C_obwjIf.js → pieDiagram-4H26LBE5-Dn67tdOF.js} +1 -1
- package/dist/domains/dashboard/web/assets/{quadrantDiagram-W4KKPZXB-B6Gnfz9M.js → quadrantDiagram-W4KKPZXB-Cy6iOcxc.js} +1 -1
- package/dist/domains/dashboard/web/assets/{requirementDiagram-4Y6WPE33-nX4PObnB.js → requirementDiagram-4Y6WPE33-B_gZONhx.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sankeyDiagram-5OEKKPKP-QjDwwHgl.js → sankeyDiagram-5OEKKPKP-C3u-4dOk.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sequenceDiagram-3UESZ5HK-BEEe0j6B.js → sequenceDiagram-3UESZ5HK-Xd3ByTVF.js} +1 -1
- package/dist/domains/dashboard/web/assets/{stateDiagram-AJRCARHV-CXfAaBgM.js → stateDiagram-AJRCARHV-CJGHL7Up.js} +1 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-BHNVJYJU-rKvBgr6I.js +1 -0
- package/dist/domains/dashboard/web/assets/{timeline-definition-PNZ67QCA-BOzX2EnD.js → timeline-definition-PNZ67QCA-DvONX2YQ.js} +1 -1
- package/dist/domains/dashboard/web/assets/{vennDiagram-CIIHVFJN-C40vhXRq.js → vennDiagram-CIIHVFJN-B-L4qWy4.js} +1 -1
- package/dist/domains/dashboard/web/assets/{wardleyDiagram-YWT4CUSO-B1rm89JH.js → wardleyDiagram-YWT4CUSO-cf39WX2o.js} +1 -1
- package/dist/domains/dashboard/web/assets/{xychartDiagram-2RQKCTM6-BlMr59qK.js → xychartDiagram-2RQKCTM6-Dk1vcm3u.js} +1 -1
- package/dist/domains/dashboard/web/index.html +2 -2
- package/dist/domains/factory/package.d.ts.map +1 -1
- package/dist/domains/factory/package.js +7 -22
- package/dist/domains/factory/package.js.map +1 -1
- package/dist/domains/skill/hook-lifecycle.d.ts +9 -0
- package/dist/domains/skill/hook-lifecycle.d.ts.map +1 -0
- package/dist/domains/skill/hook-lifecycle.js +48 -0
- package/dist/domains/skill/hook-lifecycle.js.map +1 -0
- package/dist/domains/skill/platform-inspect.d.ts +2 -0
- package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
- package/dist/domains/skill/platform-inspect.js +170 -32
- package/dist/domains/skill/platform-inspect.js.map +1 -1
- package/dist/domains/skill/platform-install.d.ts +21 -1
- package/dist/domains/skill/platform-install.d.ts.map +1 -1
- package/dist/domains/skill/platform-install.js +142 -31
- package/dist/domains/skill/platform-install.js.map +1 -1
- package/dist/domains/skill/project-hook-projection.d.ts +14 -0
- package/dist/domains/skill/project-hook-projection.d.ts.map +1 -0
- package/dist/domains/skill/project-hook-projection.js +41 -0
- package/dist/domains/skill/project-hook-projection.js.map +1 -0
- package/dist/domains/skill/project-instructions.d.ts +3 -0
- package/dist/domains/skill/project-instructions.d.ts.map +1 -1
- package/dist/domains/skill/project-instructions.js +8 -0
- package/dist/domains/skill/project-instructions.js.map +1 -1
- package/dist/domains/skill/uninstall.d.ts.map +1 -1
- package/dist/domains/skill/uninstall.js +50 -11
- package/dist/domains/skill/uninstall.js.map +1 -1
- package/dist/domains/workflow-contract/global-config.d.ts +10 -0
- package/dist/domains/workflow-contract/global-config.d.ts.map +1 -0
- package/dist/domains/workflow-contract/global-config.js +117 -0
- package/dist/domains/workflow-contract/global-config.js.map +1 -0
- package/dist/domains/workflow-contract/hook-target-scope.d.ts +6 -0
- package/dist/domains/workflow-contract/hook-target-scope.d.ts.map +1 -0
- package/dist/domains/workflow-contract/hook-target-scope.js +51 -0
- package/dist/domains/workflow-contract/hook-target-scope.js.map +1 -0
- package/dist/domains/workflow-contract/index.d.ts +1 -0
- package/dist/domains/workflow-contract/index.d.ts.map +1 -1
- package/dist/domains/workflow-contract/index.js +1 -0
- package/dist/domains/workflow-contract/index.js.map +1 -1
- package/dist/domains/workflow-contract/types.d.ts +3 -0
- package/dist/domains/workflow-contract/types.d.ts.map +1 -1
- package/dist/platform/paths/git-worktree.d.ts +4 -1
- package/dist/platform/paths/git-worktree.d.ts.map +1 -1
- package/dist/platform/paths/git-worktree.js +34 -1
- package/dist/platform/paths/git-worktree.js.map +1 -1
- package/eval/local/tests/scaffold/test_utils.py +74 -0
- package/eval/scaffold/shell/docker.sh +5 -0
- package/package.json +7 -5
- package/dist/domains/dashboard/web/assets/channel-b2wWDG4F.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-4FO5ZUOK-B9SWZywo.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-v2-Q7XG4LA2-B9SWZywo.js +0 -1
- package/dist/domains/dashboard/web/assets/index-DhtBssCt.js +0 -257
- package/dist/domains/dashboard/web/assets/index-pr3axVDI.css +0 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-BHNVJYJU-CD3nS4cC.js +0 -1
|
@@ -1,158 +1,166 @@
|
|
|
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 qf=Object.create;var kn=Object.defineProperty;var Hf=Object.getOwnPropertyDescriptor;var Gf=Object.getOwnPropertyNames;var zf=Object.getPrototypeOf,Vf=Object.prototype.hasOwnProperty;var ji=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var B=(t,e,i)=>()=>{if(i)throw i[0];try{return t&&(e=t(t=0)),e}catch(r){throw i=[r],r}};var v=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(i){throw e=0,i}},Kf=(t,e)=>{for(var i in e)kn(t,i,{get:e[i],enumerable:!0})},Jf=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Gf(e))!Vf.call(t,n)&&n!==i&&kn(t,n,{get:()=>e[n],enumerable:!(r=Hf(e,n))||r.enumerable});return t};var xt=(t,e,i)=>(i=t!=null?qf(zf(t)):{},Jf(e||!t||!t.__esModule?kn(i,"default",{value:t,enumerable:!0}):i,t));var C=v($=>{"use strict";var Sn=Symbol.for("yaml.alias"),Ja=Symbol.for("yaml.document"),Li=Symbol.for("yaml.map"),Ua=Symbol.for("yaml.pair"),En=Symbol.for("yaml.scalar"),$i=Symbol.for("yaml.seq"),he=Symbol.for("yaml.node.type"),Uf=t=>!!t&&typeof t=="object"&&t[he]===Sn,Yf=t=>!!t&&typeof t=="object"&&t[he]===Ja,Xf=t=>!!t&&typeof t=="object"&&t[he]===Li,Qf=t=>!!t&&typeof t=="object"&&t[he]===Ua,Ya=t=>!!t&&typeof t=="object"&&t[he]===En,Zf=t=>!!t&&typeof t=="object"&&t[he]===$i;function Xa(t){if(t&&typeof t=="object")switch(t[he]){case Li:case $i:return!0}return!1}function ed(t){if(t&&typeof t=="object")switch(t[he]){case Sn:case Li:case En:case $i:return!0}return!1}var td=t=>(Ya(t)||Xa(t))&&!!t.anchor;$.ALIAS=Sn;$.DOC=Ja;$.MAP=Li;$.NODE_TYPE=he;$.PAIR=Ua;$.SCALAR=En;$.SEQ=$i;$.hasAnchor=td;$.isAlias=Uf;$.isCollection=Xa;$.isDocument=Yf;$.isMap=Xf;$.isNode=ed;$.isPair=Qf;$.isScalar=Ya;$.isSeq=Zf});var Rt=v(Cn=>{"use strict";var L=C(),W=Symbol("break visit"),Qa=Symbol("skip children"),se=Symbol("remove node");function Di(t,e){let i=Za(e);L.isDocument(t)?rt(null,t.contents,i,Object.freeze([t]))===se&&(t.contents=null):rt(null,t,i,Object.freeze([]))}Di.BREAK=W;Di.SKIP=Qa;Di.REMOVE=se;function rt(t,e,i,r){let n=es(t,e,i,r);if(L.isNode(n)||L.isPair(n))return ts(t,r,n),rt(t,n,i,r);if(typeof n!="symbol"){if(L.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let a=rt(o,e.items[o],i,r);if(typeof a=="number")o=a-1;else{if(a===W)return W;a===se&&(e.items.splice(o,1),o-=1)}}}else if(L.isPair(e)){r=Object.freeze(r.concat(e));let o=rt("key",e.key,i,r);if(o===W)return W;o===se&&(e.key=null);let a=rt("value",e.value,i,r);if(a===W)return W;a===se&&(e.value=null)}}return n}async function Bi(t,e){let i=Za(e);L.isDocument(t)?await nt(null,t.contents,i,Object.freeze([t]))===se&&(t.contents=null):await nt(null,t,i,Object.freeze([]))}Bi.BREAK=W;Bi.SKIP=Qa;Bi.REMOVE=se;async function nt(t,e,i,r){let n=await es(t,e,i,r);if(L.isNode(n)||L.isPair(n))return ts(t,r,n),nt(t,n,i,r);if(typeof n!="symbol"){if(L.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let a=await nt(o,e.items[o],i,r);if(typeof a=="number")o=a-1;else{if(a===W)return W;a===se&&(e.items.splice(o,1),o-=1)}}}else if(L.isPair(e)){r=Object.freeze(r.concat(e));let o=await nt("key",e.key,i,r);if(o===W)return W;o===se&&(e.key=null);let a=await nt("value",e.value,i,r);if(a===W)return W;a===se&&(e.value=null)}}return n}function Za(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 es(t,e,i,r){if(typeof i=="function")return i(t,e,r);if(L.isMap(e))return i.Map?.(t,e,r);if(L.isSeq(e))return i.Seq?.(t,e,r);if(L.isPair(e))return i.Pair?.(t,e,r);if(L.isScalar(e))return i.Scalar?.(t,e,r);if(L.isAlias(e))return i.Alias?.(t,e,r)}function ts(t,e,i){let r=e[e.length-1];if(L.isCollection(r))r.items[t]=i;else if(L.isPair(r))t==="key"?r.key=i:r.value=i;else if(L.isDocument(r))r.contents=i;else{let n=L.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Cn.visit=Di;Cn.visitAsync=Bi});var Pn=v(rs=>{"use strict";var is=C(),id=Rt(),rd={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},nd=t=>t.replace(/[!,[\]{}]/g,e=>rd[e]),_t=class t{constructor(e,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,i)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,i){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2&&(i(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[o,a]=r;return this.tags[o]=a,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return i(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 a=/^\d+\.\d+$/.test(o);return i(6,`Unsupported YAML version ${o}`,a),!1}}default:return i(0,`Unknown directive ${n}`,!0),!1}}tagName(e,i){if(e==="!")return"!";if(e[0]!=="!")return i(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let a=e.slice(2,-1);return a==="!"||a==="!!"?(i(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&i("Verbatim tags must end with a >"),a)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||i(`The ${e} tag has no suffix`);let o=this.tags[r];if(o)try{return o+decodeURIComponent(n)}catch(a){return i(String(a)),null}return r==="!"?e:(i(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[i,r]of Object.entries(this.tags))if(e.startsWith(r))return i+nd(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&is.isNode(e.contents)){let o={};id.visit(e.contents,(a,s)=>{is.isNode(s)&&s.tag&&(o[s.tag]=!0)}),n=Object.keys(o)}else n=[];for(let[o,a]of r)o==="!!"&&a==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(a)))&&i.push(`%TAG ${o} ${a}`);return i.join(`
|
|
5
|
+
`)}};_t.defaultYaml={explicit:!1,version:"1.2"};_t.defaultTags={"!!":"tag:yaml.org,2002:"};rs.Directives=_t});var Mi=v(At=>{"use strict";var ns=C(),od=Rt();function ad(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(i)}return!0}function os(t){let e=new Set;return od.visit(t,{Value(i,r){r.anchor&&e.add(r.anchor)}}),e}function as(t,e){for(let i=1;;++i){let r=`${t}${i}`;if(!e.has(r))return r}}function sd(t,e){let i=[],r=new Map,n=null;return{onAnchor:o=>{i.push(o),n??(n=os(t));let a=as(e,n);return n.add(a),a},setAnchors:()=>{for(let o of i){let a=r.get(o);if(typeof a=="object"&&a.anchor&&(ns.isScalar(a.node)||ns.isCollection(a.node)))a.node.anchor=a.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=o,s}}},sourceObjects:r}}At.anchorIsValid=ad;At.anchorNames=os;At.createNodeAnchors=sd;At.findNewAnchor=as});var xn=v(ss=>{"use strict";function Tt(t,e,i,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let n=0,o=r.length;n<o;++n){let a=r[n],s=Tt(t,r,String(n),a);s===void 0?delete r[n]:s!==a&&(r[n]=s)}else if(r instanceof Map)for(let n of Array.from(r.keys())){let o=r.get(n),a=Tt(t,r,n,o);a===void 0?r.delete(n):a!==o&&r.set(n,a)}else if(r instanceof Set)for(let n of Array.from(r)){let o=Tt(t,r,n,n);o===void 0?r.delete(n):o!==n&&(r.delete(n),r.add(o))}else for(let[n,o]of Object.entries(r)){let a=Tt(t,r,n,o);a===void 0?delete r[n]:a!==o&&(r[n]=a)}return t.call(e,i,r)}ss.applyReviver=Tt});var Ne=v(ls=>{"use strict";var cd=C();function cs(t,e,i){if(Array.isArray(t))return t.map((r,n)=>cs(r,String(n),i));if(t&&typeof t.toJSON=="function"){if(!i||!cd.hasAnchor(t))return t.toJSON(e,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(t,r),i.onCreate=o=>{r.res=o,delete i.onCreate};let n=t.toJSON(e,i);return i.onCreate&&i.onCreate(n),n}return typeof t=="bigint"&&!i?.keep?Number(t):t}ls.toJS=cs});var Fi=v(fs=>{"use strict";var ld=xn(),us=C(),ud=Ne(),Rn=class{constructor(e){Object.defineProperty(this,us.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:r,onAnchor:n,reviver:o}={}){if(!us.isDocument(e))throw new TypeError("A document argument is required");let a={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=ud.toJS(this,"",a);if(typeof n=="function")for(let{count:c,res:l}of a.anchors.values())n(l,c);return typeof o=="function"?ld.applyReviver(o,{"":s},"",s):s}};fs.NodeBase=Rn});var Ot=v(ds=>{"use strict";var fd=Mi(),dd=Rt(),ot=C(),hd=Fi(),md=Ne(),_n=class extends hd.NodeBase{constructor(e){super(ot.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],dd.visit(e,{Node:(o,a)=>{(ot.isAlias(a)||ot.hasAnchor(a))&&r.push(a)}}),i&&(i.aliasResolveCache=r));let n;for(let o of r){if(o===this)break;o.anchor===this.source&&(n=o)}return n}toJSON(e,i){if(!i)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:o}=i,a=this.resolve(n,i);if(!a){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=r.get(a);if(s||(md.toJS(a,null,i),s=r.get(a)),s?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(o>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=Wi(n,a,r)),s.count*s.aliasCount>o)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,i,r){let n=`*${this.source}`;if(e){if(fd.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`${n} `}return n}};function Wi(t,e,i){if(ot.isAlias(e)){let r=e.resolve(t),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(ot.isCollection(e)){let r=0;for(let n of e.items){let o=Wi(t,n,i);o>r&&(r=o)}return r}else if(ot.isPair(e)){let r=Wi(t,e.key,i),n=Wi(t,e.value,i);return Math.max(r,n)}return 1}ds.Alias=_n});var O=v(An=>{"use strict";var pd=C(),gd=Fi(),wd=Ne(),vd=t=>!t||typeof t!="function"&&typeof t!="object",ke=class extends gd.NodeBase{constructor(e){super(pd.SCALAR),this.value=e}toJSON(e,i){return i?.keep?this.value:wd.toJS(this.value,e,i)}toString(){return String(this.value)}};ke.BLOCK_FOLDED="BLOCK_FOLDED";ke.BLOCK_LITERAL="BLOCK_LITERAL";ke.PLAIN="PLAIN";ke.QUOTE_DOUBLE="QUOTE_DOUBLE";ke.QUOTE_SINGLE="QUOTE_SINGLE";An.Scalar=ke;An.isScalarValue=vd});var It=v(ms=>{"use strict";var yd=Ot(),Le=C(),hs=O(),bd="tag:yaml.org,2002:";function Nd(t,e,i){if(e){let r=i.filter(o=>o.tag===e),n=r.find(o=>!o.format)??r[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return i.find(r=>r.identify?.(t)&&!r.format)}function kd(t,e,i){if(Le.isDocument(t)&&(t=t.contents),Le.isNode(t))return t;if(Le.isPair(t)){let u=i.schema[Le.MAP].createNode?.(i.schema,null,i);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:n,onTagObj:o,schema:a,sourceObjects:s}=i,c;if(r&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new yd.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=bd+e.slice(2));let l=Nd(t,e,a.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new hs.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?a[Le.MAP]:Symbol.iterator in Object(t)?a[Le.SEQ]:a[Le.MAP]}o&&(o(l),delete i.onTagObj);let f=l?.createNode?l.createNode(i.schema,t,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,t,i):new hs.Scalar(t);return e?f.tag=e:l.default||(f.tag=l.tag),c&&(c.node=f),f}ms.createNode=kd});var Hi=v(qi=>{"use strict";var Sd=It(),ce=C(),Ed=Fi();function Tn(t,e,i){let r=i;for(let n=e.length-1;n>=0;--n){let o=e[n];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let a=[];a[o]=r,r=a}else r=new Map([[o,r]])}return Sd.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 ps=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,On=class extends Ed.NodeBase{constructor(e,i){super(e),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(e){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(i.schema=e),i.items=i.items.map(r=>ce.isNode(r)||ce.isPair(r)?r.clone(e):r),this.range&&(i.range=this.range.slice()),i}addIn(e,i){if(ps(e))this.add(i);else{let[r,...n]=e,o=this.get(r,!0);if(ce.isCollection(o))o.addIn(n,i);else if(o===void 0&&this.schema)this.set(r,Tn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[i,...r]=e;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(ce.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(e,i){let[r,...n]=e,o=this.get(r,!0);return n.length===0?!i&&ce.isScalar(o)?o.value:o:ce.isCollection(o)?o.getIn(n,i):void 0}hasAllNullValues(e){return this.items.every(i=>{if(!ce.isPair(i))return!1;let r=i.value;return r==null||e&&ce.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[i,...r]=e;if(r.length===0)return this.has(i);let n=this.get(i,!0);return ce.isCollection(n)?n.hasIn(r):!1}setIn(e,i){let[r,...n]=e;if(n.length===0)this.set(r,i);else{let o=this.get(r,!0);if(ce.isCollection(o))o.setIn(n,i);else if(o===void 0&&this.schema)this.set(r,Tn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};qi.Collection=On;qi.collectionFromPath=Tn;qi.isEmptyPath=ps});var jt=v(Gi=>{"use strict";var Cd=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function In(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Pd=(t,e,i)=>t.endsWith(`
|
|
6
|
+
`)?In(i,e):i.includes(`
|
|
7
7
|
`)?`
|
|
8
|
-
`+
|
|
9
|
-
`)i===
|
|
10
|
-
`&&
|
|
11
|
-
`&&
|
|
12
|
-
${e}${t.slice(0,E)}`:(i===
|
|
13
|
-
${e}${t.slice(
|
|
14
|
-
`);
|
|
15
|
-
`){if(o-a>
|
|
8
|
+
`+In(i,e):(t.endsWith(" ")?"":" ")+i;Gi.indentComment=In;Gi.lineComment=Pd;Gi.stringifyComment=Cd});var ws=v(Lt=>{"use strict";var xd="flow",jn="block",zi="quoted";function Rd(t,e,i="flow",{indentAtStart:r,lineWidth:n=80,minContentWidth:o=20,onFold:a,onOverflow:s}={}){if(!n||n<0)return t;n<o&&(o=0);let c=Math.max(1+o,1+n-e.length);if(t.length<=c)return t;let l=[],f={},u=n-e.length;typeof r=="number"&&(r>n-Math.max(2,o)?l.push(0):u=n-r);let d,m,w=!1,h=-1,p=-1,y=-1;i===jn&&(h=gs(t,h,e.length),h!==-1&&(u=h+c));for(let k;k=t[h+=1];){if(i===zi&&k==="\\"){switch(p=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}y=h}if(k===`
|
|
9
|
+
`)i===jn&&(h=gs(t,h,e.length)),u=h+e.length+c,d=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
|
|
10
|
+
`&&m!==" "){let S=t[h+1];S&&S!==" "&&S!==`
|
|
11
|
+
`&&S!==" "&&(d=h)}if(h>=u)if(d)l.push(d),u=d+c,d=void 0;else if(i===zi){for(;m===" "||m===" ";)m=k,k=t[h+=1],w=!0;let S=h>y+1?h-2:p-1;if(f[S])return t;l.push(S),f[S]=!0,u=S+c,d=void 0}else w=!0}m=k}if(w&&s&&s(),l.length===0)return t;a&&a();let b=t.slice(0,l[0]);for(let k=0;k<l.length;++k){let S=l[k],E=l[k+1]||t.length;S===0?b=`
|
|
12
|
+
${e}${t.slice(0,E)}`:(i===zi&&f[S]&&(b+=`${t[S]}\\`),b+=`
|
|
13
|
+
${e}${t.slice(S+1,E)}`)}return b}function gs(t,e,i){let r=e,n=e+1,o=t[n];for(;o===" "||o===" ";)if(e<n+i)o=t[++e];else{do o=t[++e];while(o&&o!==`
|
|
14
|
+
`);r=e,n=e+1,o=t[n]}return r}Lt.FOLD_BLOCK=jn;Lt.FOLD_FLOW=xd;Lt.FOLD_QUOTED=zi;Lt.foldFlowLines=Rd});var Dt=v(vs=>{"use strict";var Z=O(),Se=ws(),Ki=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ji=t=>/^(%|---|\.\.\.)/m.test(t);function _d(t,e,i){if(!e||e<0)return!1;let r=e-i,n=t.length;if(n<=r)return!1;for(let o=0,a=0;o<n;++o)if(t[o]===`
|
|
15
|
+
`){if(o-a>r)return!0;if(a=o+1,n-a<=r)return!1}return!0}function $t(t,e){let i=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=e,n=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Ji(t)?" ":""),a="",s=0;for(let c=0,l=i[c];l;l=i[++c])if(l===" "&&i[c+1]==="\\"&&i[c+2]==="n"&&(a+=i.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(i[c+1]){case"u":{a+=i.slice(s,c);let f=i.substr(c+2,4);switch(f){case"0000":a+="\\0";break;case"0007":a+="\\a";break;case"000b":a+="\\v";break;case"001b":a+="\\e";break;case"0085":a+="\\N";break;case"00a0":a+="\\_";break;case"2028":a+="\\L";break;case"2029":a+="\\P";break;default:f.substr(0,2)==="00"?a+="\\x"+f.substr(2):a+=i.substr(c,6)}c+=5,s=c+1}break;case"n":if(r||i[c+2]==='"'||i.length<n)c+=1;else{for(a+=i.slice(s,c)+`
|
|
16
16
|
|
|
17
17
|
`;i[c+2]==="\\"&&i[c+3]==="n"&&i[c+4]!=='"';)a+=`
|
|
18
|
-
`,c+=2;a+=o,i[c+2]===" "&&(a+="\\"),c+=1,s=c+1}break;default:c+=1}return a=s?a+i.slice(s):i,
|
|
19
|
-
`)||/[ \t]\n|\n[ \t]/.test(t))return
|
|
20
|
-
${i}`)+"'";return e.implicitKey?
|
|
18
|
+
`,c+=2;a+=o,i[c+2]===" "&&(a+="\\"),c+=1,s=c+1}break;default:c+=1}return a=s?a+i.slice(s):i,r?a:Se.foldFlowLines(a,o,Se.FOLD_QUOTED,Ki(e,!1))}function Ln(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
19
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return $t(t,e);let i=e.indent||(Ji(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
20
|
+
${i}`)+"'";return e.implicitKey?r:Se.foldFlowLines(r,i,Se.FOLD_FLOW,Ki(e,!1))}function at(t,e){let{singleQuote:i}=e.options,r;if(i===!1)r=$t;else{let n=t.includes('"'),o=t.includes("'");n&&!o?r=Ln:o&&!n?r=$t:r=i?Ln:$t}return r(t,e)}var $n;try{$n=new RegExp(`(^|(?<!
|
|
21
21
|
))
|
|
22
22
|
+(?!
|
|
23
|
-
|$)`,"g")}catch{
|
|
23
|
+
|$)`,"g")}catch{$n=/\n+(?!\n|$)/g}function Vi({comment:t,type:e,value:i},r,n,o){let{blockQuote:a,commentString:s,lineWidth:c}=r.options;if(!a||/\n[\t ]+$/.test(i))return at(i,r);let l=r.indent||(r.forceBlockIndent||Ji(i)?" ":""),f=a==="literal"?!0:a==="folded"||e===Z.Scalar.BLOCK_FOLDED?!1:e===Z.Scalar.BLOCK_LITERAL?!0:!_d(i,c,l.length);if(!i)return f?`|
|
|
24
24
|
`:`>
|
|
25
25
|
`;let u,d;for(d=i.length;d>0;--d){let E=i[d-1];if(E!==`
|
|
26
|
-
`&&E!==" "&&E!==" ")break}let
|
|
27
|
-
`);w===-1?u="-":i===
|
|
28
|
-
`&&(
|
|
29
|
-
`)y=
|
|
30
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),g=!1,P=
|
|
31
|
-
${l}${N}`}return i=i.replace(/\n+/g,`$&${l}`),`|${
|
|
32
|
-
${l}${b}${i}${
|
|
33
|
-
`)||f&&/[[\]{},]/.test(o))return
|
|
34
|
-
`)?
|
|
35
|
-
`))return
|
|
36
|
-
${c}`);if(a){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:
|
|
37
|
-
${e.indent}${s}`:s}
|
|
38
|
-
${s}:`):(
|
|
26
|
+
`&&E!==" "&&E!==" ")break}let m=i.substring(d),w=m.indexOf(`
|
|
27
|
+
`);w===-1?u="-":i===m||w!==m.length-1?(u="+",o&&o()):u="",m&&(i=i.slice(0,-m.length),m[m.length-1]===`
|
|
28
|
+
`&&(m=m.slice(0,-1)),m=m.replace($n,`$&${l}`));let h=!1,p,y=-1;for(p=0;p<i.length;++p){let E=i[p];if(E===" ")h=!0;else if(E===`
|
|
29
|
+
`)y=p;else break}let b=i.substring(0,y<p?y+1:p);b&&(i=i.substring(b.length),b=b.replace(/\n+/g,`$&${l}`));let S=(h?l?"2":"1":"")+u;if(t&&(S+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let E=i.replace(/\n+/g,`
|
|
30
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),g=!1,P=Ki(r,!0);a!=="folded"&&e!==Z.Scalar.BLOCK_FOLDED&&(P.onOverflow=()=>{g=!0});let N=Se.foldFlowLines(`${b}${E}${m}`,l,Se.FOLD_BLOCK,P);if(!g)return`>${S}
|
|
31
|
+
${l}${N}`}return i=i.replace(/\n+/g,`$&${l}`),`|${S}
|
|
32
|
+
${l}${b}${i}${m}`}function Ad(t,e,i,r){let{type:n,value:o}=t,{actualString:a,implicitKey:s,indent:c,indentStep:l,inFlow:f}=e;if(s&&o.includes(`
|
|
33
|
+
`)||f&&/[[\]{},]/.test(o))return at(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return s||f||!o.includes(`
|
|
34
|
+
`)?at(o,e):Vi(t,e,i,r);if(!s&&!f&&n!==Z.Scalar.PLAIN&&o.includes(`
|
|
35
|
+
`))return Vi(t,e,i,r);if(Ji(o)){if(c==="")return e.forceBlockIndent=!0,Vi(t,e,i,r);if(s&&c===l)return at(o,e)}let u=o.replace(/\n+/g,`$&
|
|
36
|
+
${c}`);if(a){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:m,tags:w}=e.doc.schema;if(w.some(d)||m?.some(d))return at(o,e)}return s?u:Se.foldFlowLines(u,c,Se.FOLD_FLOW,Ki(e,!1))}function Td(t,e,i,r){let{implicitKey:n,inFlow:o}=e,a=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==Z.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(a.value)&&(s=Z.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case Z.Scalar.BLOCK_FOLDED:case Z.Scalar.BLOCK_LITERAL:return n||o?at(a.value,e):Vi(a,e,i,r);case Z.Scalar.QUOTE_DOUBLE:return $t(a.value,e);case Z.Scalar.QUOTE_SINGLE:return Ln(a.value,e);case Z.Scalar.PLAIN:return Ad(a,e,i,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=n&&f||u;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}vs.stringifyString=Td});var Bt=v(Dn=>{"use strict";var Od=Mi(),Ee=C(),Id=jt(),jd=Dt();function Ld(t,e){let i=Object.assign({blockQuote:!0,commentString:Id.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function $d(t,e){if(e.tag){let n=t.filter(o=>o.tag===e.tag);if(n.length>0)return n.find(o=>o.format===e.format)??n[0]}let i,r;if(Ee.isScalar(e)){r=e.value;let n=t.filter(o=>o.identify?.(r));if(n.length>1){let o=n.filter(a=>a.test);o.length>0&&(n=o)}i=n.find(o=>o.format===e.format)??n.find(o=>!o.format)}else r=e,i=t.find(n=>n.nodeClass&&r instanceof n.nodeClass);if(!i){let n=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${n} value`)}return i}function Dd(t,e,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],o=(Ee.isScalar(t)||Ee.isCollection(t))&&t.anchor;o&&Od.anchorIsValid(o)&&(i.add(o),n.push(`&${o}`));let a=t.tag??(e.default?null:e.tag);return a&&n.push(r.directives.tagString(a)),n.join(" ")}function Bd(t,e,i,r){if(Ee.isPair(t))return t.toString(e,i,r);if(Ee.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let n,o=Ee.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=$d(e.doc.schema.tags,o));let a=Dd(o,n,e);a.length>0&&(e.indentAtStart=(e.indentAtStart??0)+a.length+1);let s=typeof n.stringify=="function"?n.stringify(o,e,i,r):Ee.isScalar(o)?jd.stringifyString(o,e,i,r):o.toString(e,i,r);return a?Ee.isScalar(o)||s[0]==="{"||s[0]==="["?`${a} ${s}`:`${a}
|
|
37
|
+
${e.indent}${s}`:s}Dn.createStringifyContext=Ld;Dn.stringify=Bd});var ks=v(Ns=>{"use strict";var me=C(),ys=O(),bs=Bt(),Mt=jt();function Md({key:t,value:e},i,r,n){let{allNullValues:o,doc:a,indent:s,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:u}}=i,d=me.isNode(t)&&t.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(me.isCollection(t)||!me.isNode(t)&&typeof t=="object"){let P="With simple keys, collection cannot be used as a key value";throw new Error(P)}}let m=!u&&(!t||d&&e==null&&!i.inFlow||me.isCollection(t)||(me.isScalar(t)?t.type===ys.Scalar.BLOCK_FOLDED||t.type===ys.Scalar.BLOCK_LITERAL:typeof t=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!m&&(u||!o),indent:s+c});let w=!1,h=!1,p=bs.stringify(t,i,()=>w=!0,()=>h=!0);if(!m&&!i.inFlow&&p.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(i.inFlow){if(o||e==null)return w&&r&&r(),p===""?"?":m?`? ${p}`:p}else if(o&&!u||e==null&&m)return p=`? ${p}`,d&&!w?p+=Mt.lineComment(p,i.indent,l(d)):h&&n&&n(),p;w&&(d=null),m?(d&&(p+=Mt.lineComment(p,i.indent,l(d))),p=`? ${p}
|
|
38
|
+
${s}:`):(p=`${p}:`,d&&(p+=Mt.lineComment(p,i.indent,l(d))));let y,b,k;me.isNode(e)?(y=!!e.spaceBefore,b=e.commentBefore,k=e.comment):(y=!1,b=null,k=null,e&&typeof e=="object"&&(e=a.createNode(e))),i.implicitKey=!1,!m&&!d&&me.isScalar(e)&&(i.indentAtStart=p.length+1),h=!1,!f&&c.length>=2&&!i.inFlow&&!m&&me.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(i.indent=i.indent.substring(2));let S=!1,E=bs.stringify(e,i,()=>S=!0,()=>h=!0),g=" ";if(d||y||b){if(g=y?`
|
|
39
39
|
`:"",b){let P=l(b);g+=`
|
|
40
|
-
${
|
|
41
|
-
`&&
|
|
40
|
+
${Mt.indentComment(P,i.indent)}`}E===""&&!i.inFlow?g===`
|
|
41
|
+
`&&k&&(g=`
|
|
42
42
|
|
|
43
43
|
`):g+=`
|
|
44
|
-
${i.indent}`}else if(!
|
|
45
|
-
`),_=N!==-1,
|
|
44
|
+
${i.indent}`}else if(!m&&me.isCollection(e)){let P=E[0],N=E.indexOf(`
|
|
45
|
+
`),_=N!==-1,H=i.inFlow??e.flow??e.items.length===0;if(_||!H){let it=!1;if(_&&(P==="&"||P==="!")){let j=E.indexOf(" ");P==="&"&&j!==-1&&j<N&&E[j+1]==="!"&&(j=E.indexOf(" ",j+1)),(j===-1||N<j)&&(it=!0)}it||(g=`
|
|
46
46
|
${i.indent}`)}}else(E===""||E[0]===`
|
|
47
|
-
`)&&(g="");return
|
|
47
|
+
`)&&(g="");return p+=g+E,i.inFlow?S&&r&&r():k&&!S?p+=Mt.lineComment(p,i.indent,l(k)):h&&n&&n(),p}Ns.stringifyPair=Md});var Mn=v(Bn=>{"use strict";var Ss=ji("process");function Fd(t,...e){t==="debug"&&console.log(...e)}function Wd(t,e){(t==="debug"||t==="warn")&&(typeof Ss.emitWarning=="function"?Ss.emitWarning(e):console.warn(e))}Bn.debug=Fd;Bn.warn=Wd});var Zi=v(Qi=>{"use strict";var Xi=C(),Es=O(),Ui="<<",Yi={identify:t=>t===Ui||typeof t=="symbol"&&t.description===Ui,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Es.Scalar(Symbol(Ui)),{addToJSMap:Cs}),stringify:()=>Ui},qd=(t,e)=>(Yi.identify(e)||Xi.isScalar(e)&&(!e.type||e.type===Es.Scalar.PLAIN)&&Yi.identify(e.value))&&t?.doc.schema.tags.some(i=>i.tag===Yi.tag&&i.default);function Cs(t,e,i){let r=Ps(t,i);if(Xi.isSeq(r))for(let n of r.items)Fn(t,e,n);else if(Array.isArray(r))for(let n of r)Fn(t,e,n);else Fn(t,e,r)}function Fn(t,e,i){let r=Ps(t,i);if(!Xi.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.toJSON(null,t,Map);for(let[o,a]of n)e instanceof Map?e.has(o)||e.set(o,a):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:a,writable:!0,enumerable:!0,configurable:!0});return e}function Ps(t,e){return t&&Xi.isAlias(e)?e.resolve(t.doc,t):e}Qi.addMergeToJSMap=Cs;Qi.isMergeKey=qd;Qi.merge=Yi});var qn=v(_s=>{"use strict";var Hd=Mn(),xs=Zi(),Gd=Bt(),Rs=C(),Wn=Ne();function zd(t,e,{key:i,value:r}){if(Rs.isNode(i)&&i.addToJSMap)i.addToJSMap(t,e,r);else if(xs.isMergeKey(t,i))xs.addMergeToJSMap(t,e,r);else{let n=Wn.toJS(i,"",t);if(e instanceof Map)e.set(n,Wn.toJS(r,n,t));else if(e instanceof Set)e.add(n);else{let o=Vd(i,n,t),a=Wn.toJS(r,o,t);o in e?Object.defineProperty(e,o,{value:a,writable:!0,enumerable:!0,configurable:!0}):e[o]=a}}return e}function Vd(t,e,i){if(e===null)return"";if(typeof e!="object")return String(e);if(Rs.isNode(t)&&i?.doc){let r=Gd.createStringifyContext(i.doc,{});r.anchors=new Set;for(let o of i.anchors.keys())r.anchors.add(o.anchor);r.inFlow=!0,r.inStringifyKey=!0;let n=t.toString(r);if(!i.mapKeyWarned){let o=JSON.stringify(n);o.length>40&&(o=o.substring(0,36)+'..."'),Hd.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return n}return JSON.stringify(e)}_s.addPairToJSMap=zd});var Ce=v(Hn=>{"use strict";var As=It(),Kd=ks(),Jd=qn(),er=C();function Ud(t,e,i){let r=As.createNode(t,void 0,i),n=As.createNode(e,void 0,i);return new tr(r,n)}var tr=class t{constructor(e,i=null){Object.defineProperty(this,er.NODE_TYPE,{value:er.PAIR}),this.key=e,this.value=i}clone(e){let{key:i,value:r}=this;return er.isNode(i)&&(i=i.clone(e)),er.isNode(r)&&(r=r.clone(e)),new t(i,r)}toJSON(e,i){let r=i?.mapAsMap?new Map:{};return Jd.addPairToJSMap(i,r,this)}toString(e,i,r){return e?.doc?Kd.stringifyPair(this,e,i,r):JSON.stringify(this)}};Hn.Pair=tr;Hn.createPair=Ud});var Gn=v(Os=>{"use strict";var $e=C(),Ts=Bt(),ir=jt();function Yd(t,e,i){return(e.inFlow??t.flow?Qd:Xd)(t,e,i)}function Xd({comment:t,items:e},i,{blockItemPrefix:r,flowChars:n,itemIndent:o,onChompKeep:a,onComment:s}){let{indent:c,options:{commentString:l}}=i,f=Object.assign({},i,{indent:o,type:null}),u=!1,d=[];for(let w=0;w<e.length;++w){let h=e[w],p=null;if($e.isNode(h))!u&&h.spaceBefore&&d.push(""),rr(i,d,h.commentBefore,u),h.comment&&(p=h.comment);else if($e.isPair(h)){let b=$e.isNode(h.key)?h.key:null;b&&(!u&&b.spaceBefore&&d.push(""),rr(i,d,b.commentBefore,u))}u=!1;let y=Ts.stringify(h,f,()=>p=null,()=>u=!0);p&&(y+=ir.lineComment(y,o,l(p))),u&&p&&(u=!1),d.push(r+y)}let m;if(d.length===0)m=n.start+n.end;else{m=d[0];for(let w=1;w<d.length;++w){let h=d[w];m+=h?`
|
|
48
48
|
${c}${h}`:`
|
|
49
|
-
`}}return t?(
|
|
50
|
-
`+
|
|
51
|
-
`)),w<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((b,
|
|
52
|
-
${o}${
|
|
49
|
+
`}}return t?(m+=`
|
|
50
|
+
`+ir.indentComment(l(t),c),s&&s()):u&&a&&a(),m}function Qd({items:t},e,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:o,flowCollectionPadding:a,options:{commentString:s}}=e;r+=o;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,f=0,u=[];for(let w=0;w<t.length;++w){let h=t[w],p=null;if($e.isNode(h))h.spaceBefore&&u.push(""),rr(e,u,h.commentBefore,!1),h.comment&&(p=h.comment);else if($e.isPair(h)){let b=$e.isNode(h.key)?h.key:null;b&&(b.spaceBefore&&u.push(""),rr(e,u,b.commentBefore,!1),b.comment&&(l=!0));let k=$e.isNode(h.value)?h.value:null;k?(k.comment&&(p=k.comment),k.commentBefore&&(l=!0)):h.value==null&&b?.comment&&(p=b.comment)}p&&(l=!0);let y=Ts.stringify(h,c,()=>p=null);l||(l=u.length>f||y.includes(`
|
|
51
|
+
`)),w<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((b,k)=>b+k.length+2,2)+(y.length+2)>e.options.lineWidth)),l&&(y+=",")),p&&(y+=ir.lineComment(y,r,s(p))),u.push(y),f=u.length}let{start:d,end:m}=i;if(u.length===0)return d+m;if(!l){let w=u.reduce((h,p)=>h+p.length+2,2);l=e.options.lineWidth>0&&w>e.options.lineWidth}if(l){let w=d;for(let h of u)w+=h?`
|
|
52
|
+
${o}${n}${h}`:`
|
|
53
53
|
`;return`${w}
|
|
54
|
-
${
|
|
55
|
-
`:" ")}return
|
|
56
|
-
${
|
|
57
|
-
${o.comment}`:n.comment}n=r}t.items[i]=on.isPair(n)?n:new Gr.Pair(n)}}else e("Expected a sequence for this tag");return t}function Bs(t,e,i){let{replacer:n}=i,r=new ih.YAMLSeq(t);r.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let a of e){typeof n=="function"&&(a=n.call(e,String(o++),a));let s,c;if(Array.isArray(a))if(a.length===2)s=a[0],c=a[1];else throw new TypeError(`Expected [key, value] tuple: ${a}`);else if(a&&a instanceof Object){let l=Object.keys(a);if(l.length===1)s=l[0],c=a[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=a;r.items.push(Gr.createPair(s,c,i))}return r}var nh={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ms,createNode:Bs};an.createPairs=Bs;an.pairs=nh;an.resolvePairs=Ms});var Kr=v(Jr=>{"use strict";var Fs=C(),Vr=me(),jt=be(),rh=Ne(),qs=sn(),Ie=class t extends rh.YAMLSeq{constructor(){super(),this.add=jt.YAMLMap.prototype.add.bind(this),this.delete=jt.YAMLMap.prototype.delete.bind(this),this.get=jt.YAMLMap.prototype.get.bind(this),this.has=jt.YAMLMap.prototype.has.bind(this),this.set=jt.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,i){if(!i)return super.toJSON(e);let n=new Map;i?.onCreate&&i.onCreate(n);for(let r of this.items){let o,a;if(Fs.isPair(r)?(o=Vr.toJS(r.key,"",i),a=Vr.toJS(r.value,o,i)):o=Vr.toJS(r,"",i),n.has(o))throw new Error("Ordered maps must not include duplicate keys");n.set(o,a)}return n}static from(e,i,n){let r=qs.createPairs(e,i,n),o=new this;return o.items=r.items,o}};Ie.tag="tag:yaml.org,2002:omap";var oh={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ie,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let i=qs.resolvePairs(t,e),n=[];for(let{key:r}of i.items)Fs.isScalar(r)&&(n.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):n.push(r.value));return Object.assign(new Ie,i)},createNode:(t,e,i)=>Ie.from(t,e,i)};Jr.YAMLOMap=Ie;Jr.omap=oh});var Vs=v(Ur=>{"use strict";var Ws=O();function Hs({value:t,source:e},i){return e&&(t?zs:Gs).test.test(e)?e:t?i.options.trueStr:i.options.falseStr}var zs={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 Ws.Scalar(!0),stringify:Hs},Gs={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 Ws.Scalar(!1),stringify:Hs};Ur.falseTag=Gs;Ur.trueTag=zs});var Js=v(cn=>{"use strict";var ah=O(),Yr=nt(),sh={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:Yr.stringifyNumber},ch={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():Yr.stringifyNumber(t)}},lh={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 ah.Scalar(parseFloat(t.replace(/_/g,""))),i=t.indexOf(".");if(i!==-1){let n=t.substring(i+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:Yr.stringifyNumber};cn.float=lh;cn.floatExp=ch;cn.floatNaN=sh});var Us=v($t=>{"use strict";var Ks=nt(),Lt=t=>typeof t=="bigint"||Number.isInteger(t);function ln(t,e,i,{intAsBigInt:n}){let r=t[0];if((r==="-"||r==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),n){switch(i){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let a=BigInt(t);return r==="-"?BigInt(-1)*a:a}let o=parseInt(t,i);return r==="-"?-1*o:o}function Xr(t,e,i){let{value:n}=t;if(Lt(n)){let r=n.toString(e);return n<0?"-"+i+r.substr(1):i+r}return Ks.stringifyNumber(t)}var uh={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,i)=>ln(t,2,2,i),stringify:t=>Xr(t,2,"0b")},fh={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,i)=>ln(t,1,8,i),stringify:t=>Xr(t,8,"0")},dh={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,i)=>ln(t,0,10,i),stringify:Ks.stringifyNumber},hh={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,i)=>ln(t,2,16,i),stringify:t=>Xr(t,16,"0x")};$t.int=dh;$t.intBin=uh;$t.intHex=hh;$t.intOct=fh});var Zr=v(Qr=>{"use strict";var dn=C(),un=ve(),fn=be(),je=class t extends fn.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let i;dn.isPair(e)?i=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?i=new un.Pair(e.key,null):i=new un.Pair(e,null),fn.findPair(this.items,i.key)||this.items.push(i)}get(e,i){let n=fn.findPair(this.items,e);return!i&&dn.isPair(n)?dn.isScalar(n.key)?n.key.value:n.key:n}set(e,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let n=fn.findPair(this.items,e);n&&!i?this.items.splice(this.items.indexOf(n),1):!n&&i&&this.items.push(new un.Pair(e))}toJSON(e,i){return super.toJSON(e,i,Set)}toString(e,i,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),i,n);throw new Error("Set items must all have null values")}static from(e,i,n){let{replacer:r}=n,o=new this(e);if(i&&Symbol.iterator in Object(i))for(let a of i)typeof r=="function"&&(a=r.call(i,a,a)),o.items.push(un.createPair(a,null,n));return o}};je.tag="tag:yaml.org,2002:set";var mh={collection:"map",identify:t=>t instanceof Set,nodeClass:je,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,i)=>je.from(t,e,i),resolve(t,e){if(dn.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new je,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Qr.YAMLSet=je;Qr.set=mh});var to=v(hn=>{"use strict";var ph=nt();function eo(t,e){let i=t[0],n=i==="-"||i==="+"?t.substring(1):t,r=a=>e?BigInt(a):Number(a),o=n.replace(/_/g,"").split(":").reduce((a,s)=>a*r(60)+r(s),r(0));return i==="-"?r(-1)*o:o}function Ys(t){let{value:e}=t,i=a=>a;if(typeof e=="bigint")i=a=>BigInt(a);else if(isNaN(e)||!isFinite(e))return ph.stringifyNumber(t);let n="";e<0&&(n="-",e*=i(-1));let r=i(60),o=[e%r];return e<60?o.unshift(0):(e=(e-o[0])/r,o.unshift(e%r),e>=60&&(e=(e-o[0])/r,o.unshift(e))),n+o.map(a=>String(a).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var gh={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:i})=>eo(t,i),stringify:Ys},wh={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=>eo(t,!1),stringify:Ys},Xs={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(Xs.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,n,r,o,a,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(i,n-1,r,o||0,a||0,s||0,c),f=e[8];if(f&&f!=="Z"){let u=eo(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};hn.floatTime=wh;hn.intTime=gh;hn.timestamp=Xs});var ec=v(Zs=>{"use strict";var vh=tt(),yh=Zi(),bh=it(),Nh=Ot(),Sh=zr(),Qs=Vs(),io=Js(),mn=Us(),kh=Gi(),Eh=Kr(),Ch=sn(),Ph=Zr(),no=to(),xh=[vh.map,bh.seq,Nh.string,yh.nullTag,Qs.trueTag,Qs.falseTag,mn.intBin,mn.intOct,mn.int,mn.intHex,io.floatNaN,io.floatExp,io.float,Sh.binary,kh.merge,Eh.omap,Ch.pairs,Ph.set,no.intTime,no.floatTime,no.timestamp];Zs.schema=xh});var uc=v(ao=>{"use strict";var rc=tt(),Rh=Zi(),oc=it(),_h=Ot(),Ah=$r(),ro=Mr(),oo=Fr(),Th=Is(),Oh=$s(),ac=zr(),Dt=Gi(),sc=Kr(),cc=sn(),tc=ec(),lc=Zr(),pn=to(),ic=new Map([["core",Th.schema],["failsafe",[rc.map,oc.seq,_h.string]],["json",Oh.schema],["yaml11",tc.schema],["yaml-1.1",tc.schema]]),nc={binary:ac.binary,bool:Ah.boolTag,float:ro.float,floatExp:ro.floatExp,floatNaN:ro.floatNaN,floatTime:pn.floatTime,int:oo.int,intHex:oo.intHex,intOct:oo.intOct,intTime:pn.intTime,map:rc.map,merge:Dt.merge,null:Rh.nullTag,omap:sc.omap,pairs:cc.pairs,seq:oc.seq,set:lc.set,timestamp:pn.timestamp},Ih={"tag:yaml.org,2002:binary":ac.binary,"tag:yaml.org,2002:merge":Dt.merge,"tag:yaml.org,2002:omap":sc.omap,"tag:yaml.org,2002:pairs":cc.pairs,"tag:yaml.org,2002:set":lc.set,"tag:yaml.org,2002:timestamp":pn.timestamp};function jh(t,e,i){let n=ic.get(e);if(n&&!t)return i&&!n.includes(Dt.merge)?n.concat(Dt.merge):n.slice();let r=n;if(!r)if(Array.isArray(t))r=[];else{let o=Array.from(ic.keys()).filter(a=>a!=="yaml11").map(a=>JSON.stringify(a)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)r=r.concat(o);else typeof t=="function"&&(r=t(r.slice()));return i&&(r=r.concat(Dt.merge)),r.reduce((o,a)=>{let s=typeof a=="string"?nc[a]:a;if(!s){let c=JSON.stringify(a),l=Object.keys(nc).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(s)||o.push(s),o},[])}ao.coreKnownTags=Ih;ao.getTags=jh});var lo=v(fc=>{"use strict";var so=C(),Lh=tt(),$h=it(),Dh=Ot(),gn=uc(),Mh=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,co=class t{constructor({compat:e,customTags:i,merge:n,resolveKnownTags:r,schema:o,sortMapEntries:a,toStringDefaults:s}){this.compat=Array.isArray(e)?gn.getTags(e,"compat"):e?gn.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?gn.coreKnownTags:{},this.tags=gn.getTags(i,this.name,n),this.toStringOptions=s??null,Object.defineProperty(this,so.MAP,{value:Lh.map}),Object.defineProperty(this,so.SCALAR,{value:Dh.string}),Object.defineProperty(this,so.SEQ,{value:$h.seq}),this.sortMapEntries=typeof a=="function"?a:a===!0?Mh:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};fc.Schema=co});var hc=v(dc=>{"use strict";var Bh=C(),uo=_t(),Mt=Ct();function Fh(t,e){let i=[],n=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(i.push(c),n=!0):t.directives.docStart&&(n=!0)}n&&i.push("---");let r=uo.createStringifyContext(t,e),{commentString:o}=r.options;if(t.commentBefore){i.length!==1&&i.unshift("");let c=o(t.commentBefore);i.unshift(Mt.indentComment(c,""))}let a=!1,s=null;if(t.contents){if(Bh.isNode(t.contents)){if(t.contents.spaceBefore&&n&&i.push(""),t.contents.commentBefore){let f=o(t.contents.commentBefore);i.push(Mt.indentComment(f,""))}r.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>a=!0,l=uo.stringify(t.contents,r,()=>s=null,c);s&&(l+=Mt.lineComment(l,"",o(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(uo.stringify(t.contents,r));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
|
|
58
|
-
`)?(i.push("..."),i.push(
|
|
54
|
+
${n}${m}`}else return`${d}${a}${u.join(" ")}${a}${m}`}function rr({indent:t,options:{commentString:e}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let o=ir.indentComment(e(r),t);i.push(o.trimStart())}}Os.stringifyCollection=Yd});var xe=v(Vn=>{"use strict";var Zd=Gn(),eh=qn(),th=Hi(),Pe=C(),nr=Ce(),ih=O();function Ft(t,e){let i=Pe.isScalar(e)?e.value:e;for(let r of t)if(Pe.isPair(r)&&(r.key===e||r.key===i||Pe.isScalar(r.key)&&r.key.value===i))return r}var zn=class extends th.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Pe.MAP,e),this.items=[]}static from(e,i,r){let{keepUndefined:n,replacer:o}=r,a=new this(e),s=(c,l)=>{if(typeof o=="function")l=o.call(i,c,l);else if(Array.isArray(o)&&!o.includes(c))return;(l!==void 0||n)&&a.items.push(nr.createPair(c,l,r))};if(i instanceof Map)for(let[c,l]of i)s(c,l);else if(i&&typeof i=="object")for(let c of Object.keys(i))s(c,i[c]);return typeof e.sortMapEntries=="function"&&a.items.sort(e.sortMapEntries),a}add(e,i){let r;Pe.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new nr.Pair(e,e?.value):r=new nr.Pair(e.key,e.value);let n=Ft(this.items,r.key),o=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);Pe.isScalar(n.value)&&ih.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(o){let a=this.items.findIndex(s=>o(r,s)<0);a===-1?this.items.push(r):this.items.splice(a,0,r)}else this.items.push(r)}delete(e){let i=Ft(this.items,e);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(e,i){let n=Ft(this.items,e)?.value;return(!i&&Pe.isScalar(n)?n.value:n)??void 0}has(e){return!!Ft(this.items,e)}set(e,i){this.add(new nr.Pair(e,i),!0)}toJSON(e,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let o of this.items)eh.addPairToJSMap(i,n,o);return n}toString(e,i,r){if(!e)return JSON.stringify(this);for(let n of this.items)if(!Pe.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Zd.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:i})}};Vn.YAMLMap=zn;Vn.findPair=Ft});var st=v(js=>{"use strict";var rh=C(),Is=xe(),nh={collection:"map",default:!0,nodeClass:Is.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return rh.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,i)=>Is.YAMLMap.from(t,e,i)};js.map=nh});var Re=v(Ls=>{"use strict";var oh=It(),ah=Gn(),sh=Hi(),ar=C(),ch=O(),lh=Ne(),Kn=class extends sh.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ar.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let i=or(e);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(e,i){let r=or(e);if(typeof r!="number")return;let n=this.items[r];return!i&&ar.isScalar(n)?n.value:n}has(e){let i=or(e);return typeof i=="number"&&i<this.items.length}set(e,i){let r=or(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[r];ar.isScalar(n)&&ch.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(e,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let o of this.items)r.push(lh.toJS(o,String(n++),i));return r}toString(e,i,r){return e?ah.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(e,i,r){let{replacer:n}=r,o=new this(e);if(i&&Symbol.iterator in Object(i)){let a=0;for(let s of i){if(typeof n=="function"){let c=i instanceof Set?s:String(a++);s=n.call(i,c,s)}o.items.push(oh.createNode(s,void 0,r))}}return o}};function or(t){let e=ar.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Ls.YAMLSeq=Kn});var ct=v(Ds=>{"use strict";var uh=C(),$s=Re(),fh={collection:"seq",default:!0,nodeClass:$s.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return uh.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,i)=>$s.YAMLSeq.from(t,e,i)};Ds.seq=fh});var Wt=v(Bs=>{"use strict";var dh=Dt(),hh={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,i,r){return e=Object.assign({actualString:!0},e),dh.stringifyString(t,e,i,r)}};Bs.string=hh});var sr=v(Ws=>{"use strict";var Ms=O(),Fs={identify:t=>t==null,createNode:()=>new Ms.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ms.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Fs.test.test(t)?t:e.options.nullStr};Ws.nullTag=Fs});var Jn=v(Hs=>{"use strict";var mh=O(),qs={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new mh.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},i){if(t&&qs.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?i.options.trueStr:i.options.falseStr}};Hs.boolTag=qs});var lt=v(Gs=>{"use strict";function ph({format:t,minFractionDigits:e,tag:i,value:r}){if(typeof r=="bigint")return String(r);let n=typeof r=="number"?r:Number(r);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let o=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!i||i==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let a=o.indexOf(".");a<0&&(a=o.length,o+=".");let s=e-(o.length-a-1);for(;s-- >0;)o+="0"}return o}Gs.stringifyNumber=ph});var Yn=v(cr=>{"use strict";var gh=O(),Un=lt(),wh={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:Un.stringifyNumber},vh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Un.stringifyNumber(t)}},yh={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 gh.Scalar(parseFloat(t)),i=t.indexOf(".");return i!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-i-1),e},stringify:Un.stringifyNumber};cr.float=yh;cr.floatExp=vh;cr.floatNaN=wh});var Qn=v(ur=>{"use strict";var zs=lt(),lr=t=>typeof t=="bigint"||Number.isInteger(t),Xn=(t,e,i,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),i);function Vs(t,e,i){let{value:r}=t;return lr(r)&&r>=0?i+r.toString(e):zs.stringifyNumber(t)}var bh={identify:t=>lr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,i)=>Xn(t,2,8,i),stringify:t=>Vs(t,8,"0o")},Nh={identify:lr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,i)=>Xn(t,0,10,i),stringify:zs.stringifyNumber},kh={identify:t=>lr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,i)=>Xn(t,2,16,i),stringify:t=>Vs(t,16,"0x")};ur.int=Nh;ur.intHex=kh;ur.intOct=bh});var Js=v(Ks=>{"use strict";var Sh=st(),Eh=sr(),Ch=ct(),Ph=Wt(),xh=Jn(),Zn=Yn(),eo=Qn(),Rh=[Sh.map,Ch.seq,Ph.string,Eh.nullTag,xh.boolTag,eo.intOct,eo.int,eo.intHex,Zn.floatNaN,Zn.floatExp,Zn.float];Ks.schema=Rh});var Xs=v(Ys=>{"use strict";var _h=O(),Ah=st(),Th=ct();function Us(t){return typeof t=="bigint"||Number.isInteger(t)}var fr=({value:t})=>JSON.stringify(t),Oh=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:fr},{identify:t=>t==null,createNode:()=>new _h.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:fr},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:fr},{identify:Us,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:i})=>i?BigInt(t):parseInt(t,10),stringify:({value:t})=>Us(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:fr}],Ih={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},jh=[Ah.map,Th.seq].concat(Oh,Ih);Ys.schema=jh});var io=v(Qs=>{"use strict";var qt=ji("buffer"),to=O(),Lh=Dt(),$h={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof qt.Buffer=="function")return qt.Buffer.from(t,"base64");if(typeof atob=="function"){let i=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(i.length);for(let n=0;n<i.length;++n)r[n]=i.charCodeAt(n);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:i},r,n,o){if(!i)return"";let a=i,s;if(typeof qt.Buffer=="function")s=a instanceof qt.Buffer?a.toString("base64"):qt.Buffer.from(a.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<a.length;++l)c+=String.fromCharCode(a[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=to.Scalar.BLOCK_LITERAL),e!==to.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(s.length/c),f=new Array(l);for(let u=0,d=0;u<l;++u,d+=c)f[u]=s.substr(d,c);s=f.join(e===to.Scalar.BLOCK_LITERAL?`
|
|
55
|
+
`:" ")}return Lh.stringifyString({comment:t,type:e,value:s},r,n,o)}};Qs.binary=$h});var mr=v(hr=>{"use strict";var dr=C(),ro=Ce(),Dh=O(),Bh=Re();function Zs(t,e){if(dr.isSeq(t))for(let i=0;i<t.items.length;++i){let r=t.items[i];if(!dr.isPair(r)){if(dr.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let n=r.items[0]||new ro.Pair(new Dh.Scalar(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
|
|
56
|
+
${n.key.commentBefore}`:r.commentBefore),r.comment){let o=n.value??n.key;o.comment=o.comment?`${r.comment}
|
|
57
|
+
${o.comment}`:r.comment}r=n}t.items[i]=dr.isPair(r)?r:new ro.Pair(r)}}else e("Expected a sequence for this tag");return t}function ec(t,e,i){let{replacer:r}=i,n=new Bh.YAMLSeq(t);n.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let a of e){typeof r=="function"&&(a=r.call(e,String(o++),a));let s,c;if(Array.isArray(a))if(a.length===2)s=a[0],c=a[1];else throw new TypeError(`Expected [key, value] tuple: ${a}`);else if(a&&a instanceof Object){let l=Object.keys(a);if(l.length===1)s=l[0],c=a[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=a;n.items.push(ro.createPair(s,c,i))}return n}var Mh={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Zs,createNode:ec};hr.createPairs=ec;hr.pairs=Mh;hr.resolvePairs=Zs});var ao=v(oo=>{"use strict";var tc=C(),no=Ne(),Ht=xe(),Fh=Re(),ic=mr(),De=class t extends Fh.YAMLSeq{constructor(){super(),this.add=Ht.YAMLMap.prototype.add.bind(this),this.delete=Ht.YAMLMap.prototype.delete.bind(this),this.get=Ht.YAMLMap.prototype.get.bind(this),this.has=Ht.YAMLMap.prototype.has.bind(this),this.set=Ht.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,i){if(!i)return super.toJSON(e);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let o,a;if(tc.isPair(n)?(o=no.toJS(n.key,"",i),a=no.toJS(n.value,o,i)):o=no.toJS(n,"",i),r.has(o))throw new Error("Ordered maps must not include duplicate keys");r.set(o,a)}return r}static from(e,i,r){let n=ic.createPairs(e,i,r),o=new this;return o.items=n.items,o}};De.tag="tag:yaml.org,2002:omap";var Wh={collection:"seq",identify:t=>t instanceof Map,nodeClass:De,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let i=ic.resolvePairs(t,e),r=[];for(let{key:n}of i.items)tc.isScalar(n)&&(r.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new De,i)},createNode:(t,e,i)=>De.from(t,e,i)};oo.YAMLOMap=De;oo.omap=Wh});var sc=v(so=>{"use strict";var rc=O();function nc({value:t,source:e},i){return e&&(t?oc:ac).test.test(e)?e:t?i.options.trueStr:i.options.falseStr}var oc={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new rc.Scalar(!0),stringify:nc},ac={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 rc.Scalar(!1),stringify:nc};so.falseTag=ac;so.trueTag=oc});var cc=v(pr=>{"use strict";var qh=O(),co=lt(),Hh={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:co.stringifyNumber},Gh={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():co.stringifyNumber(t)}},zh={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 qh.Scalar(parseFloat(t.replace(/_/g,""))),i=t.indexOf(".");if(i!==-1){let r=t.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:co.stringifyNumber};pr.float=zh;pr.floatExp=Gh;pr.floatNaN=Hh});var uc=v(zt=>{"use strict";var lc=lt(),Gt=t=>typeof t=="bigint"||Number.isInteger(t);function gr(t,e,i,{intAsBigInt:r}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(i){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let a=BigInt(t);return n==="-"?BigInt(-1)*a:a}let o=parseInt(t,i);return n==="-"?-1*o:o}function lo(t,e,i){let{value:r}=t;if(Gt(r)){let n=r.toString(e);return r<0?"-"+i+n.substr(1):i+n}return lc.stringifyNumber(t)}var Vh={identify:Gt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,i)=>gr(t,2,2,i),stringify:t=>lo(t,2,"0b")},Kh={identify:Gt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,i)=>gr(t,1,8,i),stringify:t=>lo(t,8,"0")},Jh={identify:Gt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,i)=>gr(t,0,10,i),stringify:lc.stringifyNumber},Uh={identify:Gt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,i)=>gr(t,2,16,i),stringify:t=>lo(t,16,"0x")};zt.int=Jh;zt.intBin=Vh;zt.intHex=Uh;zt.intOct=Kh});var fo=v(uo=>{"use strict";var yr=C(),wr=Ce(),vr=xe(),Be=class t extends vr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let i;yr.isPair(e)?i=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?i=new wr.Pair(e.key,null):i=new wr.Pair(e,null),vr.findPair(this.items,i.key)||this.items.push(i)}get(e,i){let r=vr.findPair(this.items,e);return!i&&yr.isPair(r)?yr.isScalar(r.key)?r.key.value:r.key:r}set(e,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=vr.findPair(this.items,e);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new wr.Pair(e))}toJSON(e,i){return super.toJSON(e,i,Set)}toString(e,i,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(e,i,r){let{replacer:n}=r,o=new this(e);if(i&&Symbol.iterator in Object(i))for(let a of i)typeof n=="function"&&(a=n.call(i,a,a)),o.items.push(wr.createPair(a,null,r));return o}};Be.tag="tag:yaml.org,2002:set";var Yh={collection:"map",identify:t=>t instanceof Set,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,i)=>Be.from(t,e,i),resolve(t,e){if(yr.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Be,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};uo.YAMLSet=Be;uo.set=Yh});var mo=v(br=>{"use strict";var Xh=lt();function ho(t,e){let i=t[0],r=i==="-"||i==="+"?t.substring(1):t,n=a=>e?BigInt(a):Number(a),o=r.replace(/_/g,"").split(":").reduce((a,s)=>a*n(60)+n(s),n(0));return i==="-"?n(-1)*o:o}function fc(t){let{value:e}=t,i=a=>a;if(typeof e=="bigint")i=a=>BigInt(a);else if(isNaN(e)||!isFinite(e))return Xh.stringifyNumber(t);let r="";e<0&&(r="-",e*=i(-1));let n=i(60),o=[e%n];return e<60?o.unshift(0):(e=(e-o[0])/n,o.unshift(e%n),e>=60&&(e=(e-o[0])/n,o.unshift(e))),r+o.map(a=>String(a).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Qh={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:i})=>ho(t,i),stringify:fc},Zh={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=>ho(t,!1),stringify:fc},dc={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(dc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,o,a,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-1,n,o||0,a||0,s||0,c),f=e[8];if(f&&f!=="Z"){let u=ho(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};br.floatTime=Zh;br.intTime=Qh;br.timestamp=dc});var pc=v(mc=>{"use strict";var em=st(),tm=sr(),im=ct(),rm=Wt(),nm=io(),hc=sc(),po=cc(),Nr=uc(),om=Zi(),am=ao(),sm=mr(),cm=fo(),go=mo(),lm=[em.map,im.seq,rm.string,tm.nullTag,hc.trueTag,hc.falseTag,Nr.intBin,Nr.intOct,Nr.int,Nr.intHex,po.floatNaN,po.floatExp,po.float,nm.binary,om.merge,am.omap,sm.pairs,cm.set,go.intTime,go.floatTime,go.timestamp];mc.schema=lm});var Cc=v(yo=>{"use strict";var yc=st(),um=sr(),bc=ct(),fm=Wt(),dm=Jn(),wo=Yn(),vo=Qn(),hm=Js(),mm=Xs(),Nc=io(),Vt=Zi(),kc=ao(),Sc=mr(),gc=pc(),Ec=fo(),kr=mo(),wc=new Map([["core",hm.schema],["failsafe",[yc.map,bc.seq,fm.string]],["json",mm.schema],["yaml11",gc.schema],["yaml-1.1",gc.schema]]),vc={binary:Nc.binary,bool:dm.boolTag,float:wo.float,floatExp:wo.floatExp,floatNaN:wo.floatNaN,floatTime:kr.floatTime,int:vo.int,intHex:vo.intHex,intOct:vo.intOct,intTime:kr.intTime,map:yc.map,merge:Vt.merge,null:um.nullTag,omap:kc.omap,pairs:Sc.pairs,seq:bc.seq,set:Ec.set,timestamp:kr.timestamp},pm={"tag:yaml.org,2002:binary":Nc.binary,"tag:yaml.org,2002:merge":Vt.merge,"tag:yaml.org,2002:omap":kc.omap,"tag:yaml.org,2002:pairs":Sc.pairs,"tag:yaml.org,2002:set":Ec.set,"tag:yaml.org,2002:timestamp":kr.timestamp};function gm(t,e,i){let r=wc.get(e);if(r&&!t)return i&&!r.includes(Vt.merge)?r.concat(Vt.merge):r.slice();let n=r;if(!n)if(Array.isArray(t))n=[];else{let o=Array.from(wc.keys()).filter(a=>a!=="yaml11").map(a=>JSON.stringify(a)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)n=n.concat(o);else typeof t=="function"&&(n=t(n.slice()));return i&&(n=n.concat(Vt.merge)),n.reduce((o,a)=>{let s=typeof a=="string"?vc[a]:a;if(!s){let c=JSON.stringify(a),l=Object.keys(vc).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(s)||o.push(s),o},[])}yo.coreKnownTags=pm;yo.getTags=gm});var ko=v(Pc=>{"use strict";var bo=C(),wm=st(),vm=ct(),ym=Wt(),Sr=Cc(),bm=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,No=class t{constructor({compat:e,customTags:i,merge:r,resolveKnownTags:n,schema:o,sortMapEntries:a,toStringDefaults:s}){this.compat=Array.isArray(e)?Sr.getTags(e,"compat"):e?Sr.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=n?Sr.coreKnownTags:{},this.tags=Sr.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,bo.MAP,{value:wm.map}),Object.defineProperty(this,bo.SCALAR,{value:ym.string}),Object.defineProperty(this,bo.SEQ,{value:vm.seq}),this.sortMapEntries=typeof a=="function"?a:a===!0?bm:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Pc.Schema=No});var Rc=v(xc=>{"use strict";var Nm=C(),So=Bt(),Kt=jt();function km(t,e){let i=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(i.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&i.push("---");let n=So.createStringifyContext(t,e),{commentString:o}=n.options;if(t.commentBefore){i.length!==1&&i.unshift("");let c=o(t.commentBefore);i.unshift(Kt.indentComment(c,""))}let a=!1,s=null;if(t.contents){if(Nm.isNode(t.contents)){if(t.contents.spaceBefore&&r&&i.push(""),t.contents.commentBefore){let f=o(t.contents.commentBefore);i.push(Kt.indentComment(f,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>a=!0,l=So.stringify(t.contents,n,()=>s=null,c);s&&(l+=Kt.lineComment(l,"",o(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(So.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
|
|
58
|
+
`)?(i.push("..."),i.push(Kt.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=t.comment;c&&a&&(c=c.replace(/^\n+/,"")),c&&((!a||s)&&i[i.length-1]!==""&&i.push(""),i.push(Kt.indentComment(o(c),"")))}return i.join(`
|
|
59
59
|
`)+`
|
|
60
|
-
`}
|
|
61
|
-
`),a=s+a}if(/[^ ]/.test(a)){let s=1,c=i.linePos[1];c?.line===
|
|
60
|
+
`}xc.stringifyDocument=km});var Jt=v(_c=>{"use strict";var Sm=Ot(),ut=Hi(),V=C(),Em=Ce(),Cm=Ne(),Pm=ko(),xm=Rc(),Eo=Mi(),Rm=xn(),_m=It(),Co=Pn(),Po=class t{constructor(e,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,V.NODE_TYPE,{value:V.DOC});let n=null;typeof i=="function"||Array.isArray(i)?n=i:r===void 0&&i&&(r=i,i=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:a}=o;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new Co.Directives({version:a}),this.setSchema(a,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(t.prototype,{[V.NODE_TYPE]:{value:V.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=V.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){ft(this.contents)&&this.contents.add(e)}addIn(e,i){ft(this.contents)&&this.contents.addIn(e,i)}createAlias(e,i){if(!e.anchor){let r=Eo.anchorNames(this);e.anchor=!i||r.has(i)?Eo.findNewAnchor(i||"a",r):i}return new Sm.Alias(e.anchor)}createNode(e,i,r){let n;if(typeof i=="function")e=i.call({"":e},"",e),n=i;else if(Array.isArray(i)){let p=b=>typeof b=="number"||b instanceof String||b instanceof Number,y=i.filter(p).map(String);y.length>0&&(i=i.concat(y)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:o,anchorPrefix:a,flow:s,keepUndefined:c,onTagObj:l,tag:f}=r??{},{onAnchor:u,setAnchors:d,sourceObjects:m}=Eo.createNodeAnchors(this,a||"a"),w={aliasDuplicateObjects:o??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:m},h=_m.createNode(e,f,w);return s&&V.isCollection(h)&&(h.flow=!0),d(),h}createPair(e,i,r={}){let n=this.createNode(e,null,r),o=this.createNode(i,null,r);return new Em.Pair(n,o)}delete(e){return ft(this.contents)?this.contents.delete(e):!1}deleteIn(e){return ut.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):ft(this.contents)?this.contents.deleteIn(e):!1}get(e,i){return V.isCollection(this.contents)?this.contents.get(e,i):void 0}getIn(e,i){return ut.isEmptyPath(e)?!i&&V.isScalar(this.contents)?this.contents.value:this.contents:V.isCollection(this.contents)?this.contents.getIn(e,i):void 0}has(e){return V.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return ut.isEmptyPath(e)?this.contents!==void 0:V.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,i){this.contents==null?this.contents=ut.collectionFromPath(this.schema,[e],i):ft(this.contents)&&this.contents.set(e,i)}setIn(e,i){ut.isEmptyPath(e)?this.contents=i:this.contents==null?this.contents=ut.collectionFromPath(this.schema,Array.from(e),i):ft(this.contents)&&this.contents.setIn(e,i)}setSchema(e,i={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Co.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 Co.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new Pm.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:o,reviver:a}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=Cm.toJS(this.contents,i??"",s);if(typeof o=="function")for(let{count:l,res:f}of s.anchors.values())o(f,l);return typeof a=="function"?Rm.applyReviver(a,{"":c},"",c):c}toJSON(e,i){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:i})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let i=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return xm.stringifyDocument(this,e)}};function ft(t){if(V.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}_c.Document=Po});var Xt=v(Yt=>{"use strict";var Ut=class extends Error{constructor(e,i,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=i}},xo=class extends Ut{constructor(e,i,r){super("YAMLParseError",e,i,r)}},Ro=class extends Ut{constructor(e,i,r){super("YAMLWarning",e,i,r)}},Am=(t,e)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>e.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let o=n-1,a=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(o>=60&&a.length>80){let s=Math.min(o-39,a.length-79);a="…"+a.substring(s),o-=s-1}if(a.length>80&&(a=a.substring(0,79)+"…"),r>1&&/^ *$/.test(a.substring(0,o))){let s=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);s.length>80&&(s=s.substring(0,79)+`…
|
|
61
|
+
`),a=s+a}if(/[^ ]/.test(a)){let s=1,c=i.linePos[1];c?.line===r&&c.col>n&&(s=Math.max(1,Math.min(c.col-n,80-o)));let l=" ".repeat(o)+"^".repeat(s);i.message+=`:
|
|
62
62
|
|
|
63
63
|
${a}
|
|
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 i of e.start)if(i.type==="newline")return!0;if(e.sep){for(let i of e.sep)if(i.type==="newline")return!0}if(
|
|
67
|
-
`+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp
|
|
68
|
-
`+
|
|
69
|
-
`+g.comment:l.comment=g.comment),u=g.end;continue}!a&&i.options.strict&&
|
|
70
|
-
`+P:N.comment=P,g.comment=g.comment.substring(P.length+1)}}if(!a&&!
|
|
71
|
-
`+_.comment:N.comment=_.comment);let
|
|
72
|
-
`+
|
|
73
|
-
`.repeat(Math.max(1,a.length-1)):"",
|
|
74
|
-
`;for(let h=f;h<s;++h){let[
|
|
75
|
-
`):
|
|
76
|
-
`:!
|
|
65
|
+
`}};Yt.YAMLError=Ut;Yt.YAMLParseError=xo;Yt.YAMLWarning=Ro;Yt.prettifyError=Am});var Qt=v(Ac=>{"use strict";function Tm(t,{flow:e,indicator:i,next:r,offset:n,onError:o,parentIndent:a,startOnNewline:s}){let c=!1,l=s,f=s,u="",d="",m=!1,w=!1,h=null,p=null,y=null,b=null,k=null,S=null,E=null;for(let N of t)switch(w&&(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma"&&o(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),w=!1),h&&(l&&N.type!=="comment"&&N.type!=="newline"&&o(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),N.type){case"space":!e&&(i!=="doc-start"||r?.type!=="flow-collection")&&N.source.includes(" ")&&(h=N),f=!0;break;case"comment":{f||o(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=N.source.substring(1)||" ";u?u+=d+_:u=_,d="",l=!1;break}case"newline":l?u?u+=N.source:(!S||i!=="seq-item-ind")&&(c=!0):d+=N.source,l=!0,m=!0,(p||y)&&(b=N),f=!0;break;case"anchor":p&&o(N,"MULTIPLE_ANCHORS","A node can have at most one anchor"),N.source.endsWith(":")&&o(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),p=N,E??(E=N.offset),l=!1,f=!1,w=!0;break;case"tag":{y&&o(N,"MULTIPLE_TAGS","A node can have at most one tag"),y=N,E??(E=N.offset),l=!1,f=!1,w=!0;break}case i:(p||y)&&o(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`),S&&o(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${e??"collection"}`),S=N,l=i==="seq-item-ind"||i==="explicit-key-ind",f=!1;break;case"comma":if(e){k&&o(N,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=N,l=!1,f=!1;break}default:o(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),l=!1,f=!1}let g=t[t.length-1],P=g?g.offset+g.source.length:n;return w&&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"),h&&(l&&h.indent<=a||r?.type==="block-map"||r?.type==="block-seq")&&o(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:c,comment:u,hasNewline:m,anchor:p,tag:y,newlineAfterProp:b,end:P,start:E??P}}Ac.resolveProps=Tm});var Er=v(Tc=>{"use strict";function _o(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
|
|
66
|
+
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let i of e.start)if(i.type==="newline")return!0;if(e.sep){for(let i of e.sep)if(i.type==="newline")return!0}if(_o(e.key)||_o(e.value))return!0}return!1;default:return!0}}Tc.containsNewline=_o});var Ao=v(Oc=>{"use strict";var Om=Er();function Im(t,e,i){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&Om.containsNewline(e)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Oc.flowIndentCheck=Im});var To=v(jc=>{"use strict";var Ic=C();function jm(t,e,i){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let n=typeof r=="function"?r:(o,a)=>o===a||Ic.isScalar(o)&&Ic.isScalar(a)&&o.value===a.value;return e.some(o=>n(o.key,i))}jc.mapIncludes=jm});var Fc=v(Mc=>{"use strict";var Lc=Ce(),Lm=xe(),$c=Qt(),$m=Er(),Dc=Ao(),Dm=To(),Bc="All mapping items must start at the same column";function Bm({composeNode:t,composeEmptyNode:e},i,r,n,o){let a=o?.nodeClass??Lm.YAMLMap,s=new a(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let f of r.items){let{start:u,key:d,sep:m,value:w}=f,h=$c.resolveProps(u,{indicator:"explicit-key-ind",next:d??m?.[0],offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0}),p=!h.found;if(p){if(d&&(d.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==r.indent&&n(c,"BAD_INDENT",Bc)),!h.anchor&&!h.tag&&!m){l=h.end,h.comment&&(s.comment?s.comment+=`
|
|
67
|
+
`+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||$m.containsNewline(d))&&n(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",Bc);i.atKey=!0;let y=h.end,b=d?t(i,d,h,n):e(i,y,u,null,h,n);i.schema.compat&&Dc.flowIndentCheck(r.indent,d,n),i.atKey=!1,Dm.mapIncludes(i,s.items,b)&&n(y,"DUPLICATE_KEY","Map keys must be unique");let k=$c.resolveProps(m??[],{indicator:"map-value-ind",next:w,offset:b.range[2],onError:n,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=k.end,k.found){p&&(w?.type==="block-map"&&!k.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.options.strict&&h.start<k.found.offset-1024&&n(b.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=w?t(i,w,k,n):e(i,c,m,null,k,n);i.schema.compat&&Dc.flowIndentCheck(r.indent,w,n),c=S.range[2];let E=new Lc.Pair(b,S);i.options.keepSourceTokens&&(E.srcToken=f),s.items.push(E)}else{p&&n(b.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(b.comment?b.comment+=`
|
|
68
|
+
`+k.comment:b.comment=k.comment);let S=new Lc.Pair(b);i.options.keepSourceTokens&&(S.srcToken=f),s.items.push(S)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}Mc.resolveBlockMap=Bm});var qc=v(Wc=>{"use strict";var Mm=Re(),Fm=Qt(),Wm=Ao();function qm({composeNode:t,composeEmptyNode:e},i,r,n,o){let a=o?.nodeClass??Mm.YAMLSeq,s=new a(i.schema);i.atRoot&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let c=r.offset,l=null;for(let{start:f,value:u}of r.items){let d=Fm.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?n(d.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(s.comment=d.comment);continue}let m=u?t(i,u,d,n):e(i,d.end,f,null,d,n);i.schema.compat&&Wm.flowIndentCheck(r.indent,u,n),c=m.range[2],s.items.push(m)}return s.range=[r.offset,c,l??c],s}Wc.resolveBlockSeq=qm});var dt=v(Hc=>{"use strict";function Hm(t,e,i,r){let n="";if(t){let o=!1,a="";for(let s of t){let{source:c,type:l}=s;switch(l){case"space":o=!0;break;case"comment":{i&&!o&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";n?n+=a+f:n=f,a="";break}case"newline":n&&(a+=c),o=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}Hc.resolveEnd=Hm});var Kc=v(Vc=>{"use strict";var Gm=C(),zm=Ce(),Gc=xe(),Vm=Re(),Km=dt(),zc=Qt(),Jm=Er(),Um=To(),Oo="Block collections are not allowed within flow collections",Io=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Ym({composeNode:t,composeEmptyNode:e},i,r,n,o){let a=r.start.source==="{",s=a?"flow map":"flow sequence",c=o?.nodeClass??(a?Gc.YAMLMap:Vm.YAMLSeq),l=new c(i.schema);l.flow=!0;let f=i.atRoot;f&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let u=r.offset+r.start.source.length;for(let p=0;p<r.items.length;++p){let y=r.items[p],{start:b,key:k,sep:S,value:E}=y,g=zc.resolveProps(b,{flow:s,indicator:"explicit-key-ind",next:k??S?.[0],offset:u,onError:n,parentIndent:r.indent,startOnNewline:!1});if(!g.found){if(!g.anchor&&!g.tag&&!S&&!E){p===0&&g.comma?n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):p<r.items.length-1&&n(g.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),g.comment&&(l.comment?l.comment+=`
|
|
69
|
+
`+g.comment:l.comment=g.comment),u=g.end;continue}!a&&i.options.strict&&Jm.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(p===0)g.comma&&n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(g.comma||n(g.start,"MISSING_CHAR",`Missing , between ${s} items`),g.comment){let P="";e:for(let N of b)switch(N.type){case"comma":case"space":break;case"comment":P=N.source.substring(1);break e;default:break e}if(P){let N=l.items[l.items.length-1];Gm.isPair(N)&&(N=N.value??N.key),N.comment?N.comment+=`
|
|
70
|
+
`+P:N.comment=P,g.comment=g.comment.substring(P.length+1)}}if(!a&&!S&&!g.found){let P=E?t(i,E,g,n):e(i,g.end,S,null,g,n);l.items.push(P),u=P.range[2],Io(E)&&n(P.range,"BLOCK_IN_FLOW",Oo)}else{i.atKey=!0;let P=g.end,N=k?t(i,k,g,n):e(i,P,b,null,g,n);Io(k)&&n(N.range,"BLOCK_IN_FLOW",Oo),i.atKey=!1;let _=zc.resolveProps(S??[],{flow:s,indicator:"map-value-ind",next:E,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!a&&!g.found&&i.options.strict){if(S)for(let j of S){if(j===_.found)break;if(j.type==="newline"){n(j,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}g.start<_.found.offset-1024&&n(_.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?n(E,"MISSING_CHAR",`Missing space after : in ${s}`):n(_.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let H=E?t(i,E,_,n):_.found?e(i,_.end,S,null,_,n):null;H?Io(E)&&n(H.range,"BLOCK_IN_FLOW",Oo):_.comment&&(N.comment?N.comment+=`
|
|
71
|
+
`+_.comment:N.comment=_.comment);let it=new zm.Pair(N,H);if(i.options.keepSourceTokens&&(it.srcToken=y),a){let j=l;Um.mapIncludes(i,j.items,N)&&n(P,"DUPLICATE_KEY","Map keys must be unique"),j.items.push(it)}else{let j=new Gc.YAMLMap(i.schema);j.flow=!0,j.items.push(it);let Ka=(H??N).range;j.range=[N.range[0],Ka[1],Ka[2]],l.items.push(j)}u=H?H.range[2]:_.end}}let d=a?"}":"]",[m,...w]=r.end,h=u;if(m?.source===d)h=m.offset+m.source.length;else{let p=s[0].toUpperCase()+s.substring(1),y=f?`${p} must end with a ${d}`:`${p} in block collection must be sufficiently indented and end with a ${d}`;n(u,f?"MISSING_CHAR":"BAD_INDENT",y),m&&m.source.length!==1&&w.unshift(m)}if(w.length>0){let p=Km.resolveEnd(w,h,i.options.strict,n);p.comment&&(l.comment?l.comment+=`
|
|
72
|
+
`+p.comment:l.comment=p.comment),l.range=[r.offset,h,p.offset]}else l.range=[r.offset,h,h];return l}Vc.resolveFlowCollection=Ym});var Uc=v(Jc=>{"use strict";var Xm=C(),Qm=O(),Zm=xe(),ep=Re(),tp=Fc(),ip=qc(),rp=Kc();function jo(t,e,i,r,n,o){let a=i.type==="block-map"?tp.resolveBlockMap(t,e,i,r,o):i.type==="block-seq"?ip.resolveBlockSeq(t,e,i,r,o):rp.resolveFlowCollection(t,e,i,r,o),s=a.constructor;return n==="!"||n===s.tagName?(a.tag=s.tagName,a):(n&&(a.tag=n),a)}function np(t,e,i,r,n){let o=r.tag,a=o?e.directives.tagName(o.source,d=>n(o,"TAG_RESOLVE_FAILED",d)):null;if(i.type==="block-seq"){let{anchor:d,newlineAfterProp:m}=r,w=d&&o?d.offset>o.offset?d:o:d??o;w&&(!m||m.offset<w.offset)&&n(w,"MISSING_CHAR","Missing newline after block sequence props")}let s=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!o||!a||a==="!"||a===Zm.YAMLMap.tagName&&s==="map"||a===ep.YAMLSeq.tagName&&s==="seq")return jo(t,e,i,n,a);let c=e.schema.tags.find(d=>d.tag===a&&d.collection===s);if(!c){let d=e.schema.knownTags[a];if(d?.collection===s)e.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?n(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${s} collection, but expects ${d.collection??"scalar"}`,!0):n(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${a}`,!0),jo(t,e,i,n,a)}let l=jo(t,e,i,n,a,c),f=c.resolve?.(l,d=>n(o,"TAG_RESOLVE_FAILED",d),e.options)??l,u=Xm.isNode(f)?f:new Qm.Scalar(f);return u.range=l.range,u.tag=a,c?.format&&(u.format=c.format),u}Jc.composeCollection=np});var $o=v(Yc=>{"use strict";var Lo=O();function op(t,e,i){let r=e.offset,n=ap(e,t.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let o=n.mode===">"?Lo.Scalar.BLOCK_FOLDED:Lo.Scalar.BLOCK_LITERAL,a=e.source?sp(e.source):[],s=a.length;for(let h=a.length-1;h>=0;--h){let p=a[h][1];if(p===""||p==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&a.length>0?`
|
|
73
|
+
`.repeat(Math.max(1,a.length-1)):"",p=r+n.length;return e.source&&(p+=e.source.length),{value:h,type:o,comment:n.comment,range:[r,p,p]}}let c=e.indent+n.indent,l=e.offset+n.length,f=0;for(let h=0;h<s;++h){let[p,y]=a[h];if(y===""||y==="\r")n.indent===0&&p.length>c&&(c=p.length);else{p.length<c&&i(l+p.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=p.length),f=h,c===0&&!t.atRoot&&i(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=p.length+y.length+1}for(let h=a.length-1;h>=s;--h)a[h][0].length>c&&(s=h+1);let u="",d="",m=!1;for(let h=0;h<f;++h)u+=a[h][0].slice(c)+`
|
|
74
|
+
`;for(let h=f;h<s;++h){let[p,y]=a[h];l+=p.length+y.length+1;let b=y[y.length-1]==="\r";if(b&&(y=y.slice(0,-1)),y&&p.length<c){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;i(l-y.length-(b?2:1),"BAD_INDENT",S),p=""}o===Lo.Scalar.BLOCK_LITERAL?(u+=d+p.slice(c)+y,d=`
|
|
75
|
+
`):p.length>c||y[0]===" "?(d===" "?d=`
|
|
76
|
+
`:!m&&d===`
|
|
77
77
|
`&&(d=`
|
|
78
78
|
|
|
79
|
-
`),u+=d+
|
|
80
|
-
`,
|
|
79
|
+
`),u+=d+p.slice(c)+y,d=`
|
|
80
|
+
`,m=!0):y===""?d===`
|
|
81
81
|
`?u+=`
|
|
82
82
|
`:d=`
|
|
83
|
-
`:(u+=d+y,d=" ",
|
|
83
|
+
`:(u+=d+y,d=" ",m=!1)}switch(n.chomp){case"-":break;case"+":for(let h=s;h<a.length;++h)u+=`
|
|
84
84
|
`+a[h][0].slice(c);u[u.length-1]!==`
|
|
85
85
|
`&&(u+=`
|
|
86
86
|
`);break;default:u+=`
|
|
87
|
-
`}let w=n
|
|
87
|
+
`}let w=r+n.length+e.source.length;return{value:u,type:o,comment:n.comment,range:[r,w,w]}}function ap({offset:t,props:e},i,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],o=n[0],a=0,s="",c=-1;for(let d=1;d<n.length;++d){let m=n[d];if(!s&&(m==="-"||m==="+"))s=m;else{let w=Number(m);!a&&w?a=w:c===-1&&(c=t+d)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,f="",u=n.length;for(let d=1;d<e.length;++d){let m=e[d];switch(m.type){case"space":l=!0;case"newline":u+=m.source.length;break;case"comment":i&&!l&&r(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=m.source.length,f=m.source.substring(1);break;case"error":r(m,"UNEXPECTED_TOKEN",m.message),u+=m.source.length;break;default:{let w=`Unexpected token in block scalar header: ${m.type}`;r(m,"UNEXPECTED_TOKEN",w);let h=m.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:o,indent:a,chomp:s,comment:f,length:u}}function sp(t){let e=t.split(/\n( *)/),i=e[0],r=i.match(/^( *)/),o=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let a=1;a<e.length;a+=2)o.push([e[a],e[a+1]]);return o}Yc.resolveBlockScalar=op});var Bo=v(Qc=>{"use strict";var Do=O(),cp=dt();function lp(t,e,i){let{offset:r,type:n,source:o,end:a}=t,s,c,l=(d,m,w)=>i(r+d,m,w);switch(n){case"scalar":s=Do.Scalar.PLAIN,c=up(o,l);break;case"single-quoted-scalar":s=Do.Scalar.QUOTE_SINGLE,c=fp(o,l);break;case"double-quoted-scalar":s=Do.Scalar.QUOTE_DOUBLE,c=dp(o,l);break;default:return i(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+o.length,r+o.length]}}let f=r+o.length,u=cp.resolveEnd(a,f,e,i);return{value:c,type:s,comment:u.comment,range:[r,f,u.offset]}}function up(t,e){let i="";switch(t[0]){case" ":i="a tab character";break;case",":i="flow indicator character ,";break;case"%":i="directive indicator character %";break;case"|":case">":{i=`block scalar indicator ${t[0]}`;break}case"@":case"`":{i=`reserved character ${t[0]}`;break}}return i&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),Xc(t)}function fp(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Xc(t.slice(1,-1)).replace(/''/g,"'")}function Xc(t){let e,i;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
88
88
|
`,"sy"),i=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
89
|
-
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let
|
|
90
|
-
`?
|
|
91
|
-
`:(
|
|
92
|
-
`))if(
|
|
93
|
-
`){let{fold:o,offset:a}=
|
|
94
|
-
`)for(o=t[
|
|
95
|
-
`)for(o=t[++
|
|
96
|
-
`&&!(a==="\r"&&t[
|
|
97
|
-
`)&&(i+=
|
|
98
|
-
`||
|
|
99
|
-
`);)
|
|
89
|
+
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let n=r[1],o=" ",a=e.lastIndex;for(i.lastIndex=a;r=i.exec(t);)r[1]===""?o===`
|
|
90
|
+
`?n+=o:o=`
|
|
91
|
+
`:(n+=o+r[1],o=" "),a=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=a,r=s.exec(t),n+o+(r?.[1]??"")}function dp(t,e){let i="";for(let r=1;r<t.length-1;++r){let n=t[r];if(!(n==="\r"&&t[r+1]===`
|
|
92
|
+
`))if(n===`
|
|
93
|
+
`){let{fold:o,offset:a}=hp(t,r);i+=o,r=a}else if(n==="\\"){let o=t[++r],a=mp[o];if(a)i+=a;else if(o===`
|
|
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 s=o==="x"?2:o==="u"?4:8;i+=pp(t,r+1,s,e),r+=s}else{let s=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let o=r,a=t[r+1];for(;a===" "||a===" ";)a=t[++r+1];a!==`
|
|
96
|
+
`&&!(a==="\r"&&t[r+2]===`
|
|
97
|
+
`)&&(i+=r>o?t.slice(o,r+1):n)}else i+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),i}function hp(t,e){let i="",r=t[e+1];for(;(r===" "||r===" "||r===`
|
|
98
|
+
`||r==="\r")&&!(r==="\r"&&t[e+2]!==`
|
|
99
|
+
`);)r===`
|
|
100
100
|
`&&(i+=`
|
|
101
|
-
`),e+=1,
|
|
102
|
-
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
101
|
+
`),e+=1,r=t[e+1];return i||(i=" "),{fold:i,offset:e}}var mp={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function pp(t,e,i,r){let n=t.substr(e,i),a=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(a)}catch{let s=t.substr(e-2,i+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Qc.resolveFlowScalar=lp});var tl=v(el=>{"use strict";var Me=C(),Zc=O(),gp=$o(),wp=Bo();function vp(t,e,i,r){let{value:n,type:o,comment:a,range:s}=e.type==="block-scalar"?gp.resolveBlockScalar(t,e,r):wp.resolveFlowScalar(e,t.options.strict,r),c=i?t.directives.tagName(i.source,u=>r(i,"TAG_RESOLVE_FAILED",u)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Me.SCALAR]:c?l=yp(t.schema,n,c,i,r):e.type==="scalar"?l=bp(t,n,e,r):l=t.schema[Me.SCALAR];let f;try{let u=l.resolve(n,d=>r(i??e,"TAG_RESOLVE_FAILED",d),t.options);f=Me.isScalar(u)?u:new Zc.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);r(i??e,"TAG_RESOLVE_FAILED",d),f=new Zc.Scalar(n)}return f.range=s,f.source=n,o&&(f.type=o),c&&(f.tag=c),l.format&&(f.format=l.format),a&&(f.comment=a),f}function yp(t,e,i,r,n){if(i==="!")return t[Me.SCALAR];let o=[];for(let s of t.tags)if(!s.collection&&s.tag===i)if(s.default&&s.test)o.push(s);else return s;for(let s of o)if(s.test?.test(e))return s;let a=t.knownTags[i];return a&&!a.collection?(t.tags.push(Object.assign({},a,{default:!1,test:void 0})),a):(n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),t[Me.SCALAR])}function bp({atKey:t,directives:e,schema:i},r,n,o){let a=i.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(r))||i[Me.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[Me.SCALAR];if(a.tag!==s.tag){let c=e.tagString(a.tag),l=e.tagString(s.tag),f=`Value may be parsed as either ${c} or ${l}`;o(n,"TAG_RESOLVE_FAILED",f,!0)}}return a}el.composeScalar=vp});var rl=v(il=>{"use strict";function Np(t,e,i){if(e){i??(i=e.length);for(let r=i-1;r>=0;--r){let n=e[r];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++r];n?.type==="space";)t+=n.source.length,n=e[++r];break}}return t}il.emptyScalarPosition=Np});var al=v(Fo=>{"use strict";var kp=Ot(),Sp=C(),Ep=Uc(),nl=tl(),Cp=dt(),Pp=rl(),xp={composeNode:ol,composeEmptyNode:Mo};function ol(t,e,i,r){let n=t.atKey,{spaceBefore:o,comment:a,anchor:s,tag:c}=i,l,f=!0;switch(e.type){case"alias":l=Rp(t,e,r),(s||c)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=nl.composeScalar(t,e,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Ep.composeCollection(xp,t,e,i,r),s&&(l.anchor=s.source.substring(1))}catch(u){let d=u instanceof Error?u.message:String(u);r(e,"RESOURCE_EXHAUSTION",d)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",u),f=!1}}return l??(l=Mo(t,e.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!Sp.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),a&&(e.type==="scalar"&&e.source===""?l.comment=a:l.commentBefore=a),t.options.keepSourceTokens&&f&&(l.srcToken=e),l}function Mo(t,e,i,r,{spaceBefore:n,comment:o,anchor:a,tag:s,end:c},l){let f={type:"scalar",offset:Pp.emptyScalarPosition(e,i,r),indent:-1,source:""},u=nl.composeScalar(t,f,s,l);return a&&(u.anchor=a.source.substring(1),u.anchor===""&&l(a,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),o&&(u.comment=o,u.range[2]=c),u}function Rp({options:t},{offset:e,source:i,end:r},n){let o=new kp.Alias(i.substring(1));o.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&n(e+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let a=e+i.length,s=Cp.resolveEnd(r,a,t.strict,n);return o.range=[e,a,s.offset],s.comment&&(o.comment=s.comment),o}Fo.composeEmptyNode=Mo;Fo.composeNode=ol});var ll=v(cl=>{"use strict";var _p=Jt(),sl=al(),Ap=dt(),Tp=Qt();function Op(t,e,{offset:i,start:r,value:n,end:o},a){let s=Object.assign({_directives:e},t),c=new _p.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=Tp.resolveProps(r,{indicator:"doc-start",next:n??o?.[0],offset:i,onError:a,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&a(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?sl.composeNode(l,n,f,a):sl.composeEmptyNode(l,f.end,r,null,f,a);let u=c.contents.range[2],d=Ap.resolveEnd(o,u,!1,a);return d.comment&&(c.comment=d.comment),c.range=[i,u,d.offset],c}cl.composeDoc=Op});var qo=v(dl=>{"use strict";var Ip=ji("process"),jp=Pn(),Lp=Jt(),Zt=Xt(),ul=C(),$p=ll(),Dp=dt();function ei(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:i}=t;return[e,e+(typeof i=="string"?i.length:1)]}function fl(t){let e="",i=!1,r=!1;for(let n=0;n<t.length;++n){let o=t[n];switch(o[0]){case"#":e+=(e===""?"":r?`
|
|
103
103
|
|
|
104
104
|
`:`
|
|
105
|
-
`)+(o.substring(1)||" "),i=!0,
|
|
106
|
-
${
|
|
107
|
-
${s}`:
|
|
108
|
-
${a}`:
|
|
109
|
-
${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new
|
|
105
|
+
`)+(o.substring(1)||" "),i=!0,r=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:e,afterEmptyLine:r}}var Wo=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,o)=>{let a=ei(i);o?this.warnings.push(new Zt.YAMLWarning(a,r,n)):this.errors.push(new Zt.YAMLParseError(a,r,n))},this.directives=new jp.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,i){let{comment:r,afterEmptyLine:n}=fl(this.prelude);if(r){let o=e.contents;if(i)e.comment=e.comment?`${e.comment}
|
|
106
|
+
${r}`:r;else if(n||e.directives.docStart||!o)e.commentBefore=r;else if(ul.isCollection(o)&&!o.flow&&o.items.length>0){let a=o.items[0];ul.isPair(a)&&(a=a.key);let s=a.commentBefore;a.commentBefore=s?`${r}
|
|
107
|
+
${s}`:r}else{let a=o.commentBefore;o.commentBefore=a?`${r}
|
|
108
|
+
${a}`:r}}if(i){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:fl(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,i=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(i,r)}*next(e){switch(Ip.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(i,r,n)=>{let o=ei(e);o[0]+=i,this.onError(o,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let i=$p.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(i,!1),this.doc&&(yield this.doc),this.doc=i,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let i=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Zt.YAMLParseError(ei(e),"UNEXPECTED_TOKEN",i);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new Zt.YAMLParseError(ei(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=Dp.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),i.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
|
|
109
|
+
${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new Zt.YAMLParseError(ei(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new Lp.Document(void 0,r);this.atDirectives&&this.onError(i,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,i,i],this.decorate(n,!1),yield n}}};dl.Composer=Wo});var pl=v(Cr=>{"use strict";var Bp=$o(),Mp=Bo(),Fp=Xt(),hl=Dt();function Wp(t,e=!0,i){if(t){let r=(n,o,a)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(i)i(s,o,a);else throw new Fp.YAMLParseError([s,s+1],o,a)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Mp.resolveFlowScalar(t,e,r);case"block-scalar":return Bp.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function qp(t,e){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:o=-1,type:a="PLAIN"}=e,s=hl.stringifyString({type:a,value:t},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
|
|
110
110
|
`}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
|
|
111
111
|
`),f=s.substring(0,l),u=s.substring(l+1)+`
|
|
112
|
-
`,d=[{type:"block-scalar-header",offset:o,indent:
|
|
113
|
-
`}),{type:"block-scalar",offset:o,indent:
|
|
114
|
-
`),
|
|
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=
|
|
116
|
-
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:a,props:s,source:
|
|
117
|
-
`};delete t.items,Object.assign(t,{type:i,source:e,end:[
|
|
112
|
+
`,d=[{type:"block-scalar-header",offset:o,indent:r,source:f}];return ml(d,c)||d.push({type:"newline",offset:-1,indent:r,source:`
|
|
113
|
+
`}),{type:"block-scalar",offset:o,indent:r,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:o,indent:r,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:r,source:s,end:c};default:return{type:"scalar",offset:o,indent:r,source:s,end:c}}}function Hp(t,e,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:o=!1,type:a}=i,s="indent"in t?t.indent:null;if(r&&typeof s=="number"&&(s+=2),!a)switch(t.type){case"single-quoted-scalar":a="QUOTE_SINGLE";break;case"double-quoted-scalar":a="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:a="PLAIN"}let c=hl.stringifyString({type:a,value:e},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":Gp(t,c);break;case'"':Ho(t,c,"double-quoted-scalar");break;case"'":Ho(t,c,"single-quoted-scalar");break;default:Ho(t,c,"scalar")}}function Gp(t,e){let i=e.indexOf(`
|
|
114
|
+
`),r=e.substring(0,i),n=e.substring(i+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=n}else{let{offset:o}=t,a="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:o,indent:a,source:r}];ml(s,"end"in t?t.end:void 0)||s.push({type:"newline",offset:-1,indent:a,source:`
|
|
116
|
+
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:a,props:s,source:n})}}function ml(t,e){if(e)for(let i of e)switch(i.type){case"space":case"comment":t.push(i);break;case"newline":return t.push(i),!0}return!1}function Ho(t,e,i){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=i,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let o of r)o.offset+=n;delete t.props,Object.assign(t,{type:i,source:e,end:r});break}case"block-map":case"block-seq":{let n={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
|
|
117
|
+
`};delete t.items,Object.assign(t,{type:i,source:e,end:[n]});break}default:{let r="indent"in t?t.indent:-1,n="end"in t&&Array.isArray(t.end)?t.end.filter(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:i,indent:r,source:e,end:n})}}}Cr.createScalarToken=qp;Cr.resolveAsScalar=Wp;Cr.setScalarValue=Hp});var wl=v(gl=>{"use strict";var zp=t=>"type"in t?xr(t):Pr(t);function xr(t){switch(t.type){case"block-scalar":{let e="";for(let i of t.props)e+=xr(i);return e+t.source}case"block-map":case"block-seq":{let e="";for(let i of t.items)e+=Pr(i);return e}case"flow-collection":{let e=t.start.source;for(let i of t.items)e+=Pr(i);for(let i of t.end)e+=i.source;return e}case"document":{let e=Pr(t);if(t.end)for(let i of t.end)e+=i.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let i of t.end)e+=i.source;return e}}}function Pr({start:t,key:e,sep:i,value:r}){let n="";for(let o of t)n+=o.source;if(e&&(n+=xr(e)),i)for(let o of i)n+=o.source;return r&&(n+=xr(r)),n}gl.stringify=zp});var Nl=v(bl=>{"use strict";var Go=Symbol("break visit"),Vp=Symbol("skip children"),vl=Symbol("remove item");function Fe(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),yl(Object.freeze([]),t,e)}Fe.BREAK=Go;Fe.SKIP=Vp;Fe.REMOVE=vl;Fe.itemAtPath=(t,e)=>{let i=t;for(let[r,n]of e){let o=i?.[r];if(o&&"items"in o)i=o.items[n];else return}return i};Fe.parentCollection=(t,e)=>{let i=Fe.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function yl(t,e,i){let r=i(e,t);if(typeof r=="symbol")return r;for(let n of["key","value"]){let o=e[n];if(o&&"items"in o){for(let a=0;a<o.items.length;++a){let s=yl(Object.freeze(t.concat([[n,a]])),o.items[a],i);if(typeof s=="number")a=s-1;else{if(s===Go)return Go;s===vl&&(o.items.splice(a,1),a-=1)}}typeof r=="function"&&n==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}bl.visit=Fe});var Rr=v(q=>{"use strict";var zo=pl(),Kp=wl(),Jp=Nl(),Vo="\uFEFF",Ko="",Jo="",Uo="",Up=t=>!!t&&"items"in t,Yp=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function Xp(t){switch(t){case Vo:return"<BOM>";case Ko:return"<DOC>";case Jo:return"<FLOW_END>";case Uo:return"<SCALAR>";default:return JSON.stringify(t)}}function Qp(t){switch(t){case Vo:return"byte-order-mark";case Ko:return"doc-mode";case Jo:return"flow-error-end";case Uo: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}q.createScalarToken=zo.createScalarToken;q.resolveAsScalar=zo.resolveAsScalar;q.setScalarValue=zo.setScalarValue;q.stringify=Kp.stringify;q.visit=Jp.visit;q.BOM=Vo;q.DOCUMENT=Ko;q.FLOW_END=Jo;q.SCALAR=Uo;q.isCollection=Up;q.isScalar=Yp;q.prettyToken=Xp;q.tokenType=Qp});var Qo=v(Sl=>{"use strict";var ti=Rr();function ee(t){switch(t){case void 0:case" ":case`
|
|
120
|
+
`:case"\r":case" ":return!0;default:return!1}}var kl=new Set("0123456789ABCDEFabcdef"),Zp=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),_r=new Set(",[]{}"),eg=new Set(` ,[]{}
|
|
121
|
+
\r `),Yo=t=>!t||eg.has(t),Xo=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,i=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,i=this.buffer[e];for(;i===" "||i===" ";)i=this.buffer[++e];return!i||i==="#"||i===`
|
|
122
122
|
`?!0:i==="\r"?this.buffer[e+1]===`
|
|
123
|
-
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let i=this.buffer[e];if(this.indentNext>0){let
|
|
124
|
-
`||!
|
|
125
|
-
`||
|
|
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]===
|
|
127
|
-
`,this.pos);if(
|
|
128
|
-
`,o)}
|
|
123
|
+
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let i=this.buffer[e];if(this.indentNext>0){let r=0;for(;i===" ";)i=this.buffer[++r+e];if(i==="\r"){let n=this.buffer[r+e+1];if(n===`
|
|
124
|
+
`||!n&&!this.atEnd)return e+r+1}return i===`
|
|
125
|
+
`||r>=this.indentNext||!i&&!this.atEnd?e+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&ee(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]===ti.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let i=e.length,r=e.indexOf("#");for(;r!==-1;){let o=e[r-1];if(o===" "||o===" "){i=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let o=e[i-1];if(o===" "||o===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-i),yield*this.pushNewline(),"stream"}return yield ti.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let i=this.peek(3);if((i==="---"||i==="...")&&ee(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,i==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ee(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ee(i)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(e[i]){case"#":yield*this.pushCount(e.length-i);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Yo),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,i,r=-1;do e=yield*this.pushNewline(),e>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(e+i>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&ee(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield ti.FLOW_END,yield*this.parseLineStart();let o=0;for(;n[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),n[o]){case void 0:return"flow";case"#":return yield*this.pushCount(n.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(Yo),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let a=this.charAt(1);if(this.flowKey||ee(a)||a===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),i=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;i!==-1&&this.buffer[i+1]==="'";)i=this.buffer.indexOf("'",i+2);else for(;i!==-1;){let o=0;for(;this.buffer[i-1-o]==="\\";)o+=1;if(o%2===0)break;i=this.buffer.indexOf('"',i+1)}let r=this.buffer.substring(0,i),n=r.indexOf(`
|
|
127
|
+
`,this.pos);if(n!==-1){for(;n!==-1;){let o=this.continueScalar(n+1);if(o===-1)break;n=r.indexOf(`
|
|
128
|
+
`,o)}n!==-1&&(i=n-(r[n-1]==="\r"?2:1))}if(i===-1){if(!this.atEnd)return this.setNext("quoted-scalar");i=this.buffer.length}return yield*this.pushToIndex(i+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let i=this.buffer[++e];if(i==="+")this.blockScalarKeep=!0;else if(i>"0"&&i<="9")this.blockScalarIndent=Number(i)-1;else if(i!=="-")break}return yield*this.pushUntil(i=>ee(i)||i==="#")}*parseBlockScalar(){let e=this.pos-1,i=0,r;e:for(let o=this.pos;r=this.buffer[o];++o)switch(r){case" ":i+=1;break;case`
|
|
129
129
|
`:e=o,i=0;break;case"\r":{let a=this.buffer[o+1];if(!a&&!this.atEnd)return this.setNext("block-scalar");if(a===`
|
|
130
|
-
`)break}default:break e}if(!
|
|
131
|
-
`,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let
|
|
132
|
-
`;)
|
|
133
|
-
`&&o>=this.pos&&o+1+i>s)e=o;else break}while(!0);return yield
|
|
134
|
-
`?(
|
|
135
|
-
`,o=this.buffer[
|
|
136
|
-
`){let a=this.continueScalar(
|
|
130
|
+
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(i>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=i:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(e+1);if(o===-1)break;e=this.buffer.indexOf(`
|
|
131
|
+
`,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(r=this.buffer[n];r===" ";)r=this.buffer[++n];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
|
|
132
|
+
`;)r=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let o=e-1,a=this.buffer[o];a==="\r"&&(a=this.buffer[--o]);let s=o;for(;a===" ";)a=this.buffer[--o];if(a===`
|
|
133
|
+
`&&o>=this.pos&&o+1+i>s)e=o;else break}while(!0);return yield ti.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,i=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let o=this.buffer[r+1];if(ee(o)||e&&_r.has(o))break;i=r}else if(ee(n)){let o=this.buffer[r+1];if(n==="\r"&&(o===`
|
|
134
|
+
`?(r+=1,n=`
|
|
135
|
+
`,o=this.buffer[r+1]):i=r),o==="#"||e&&_r.has(o))break;if(n===`
|
|
136
|
+
`){let a=this.continueScalar(r+1);if(a===-1)break;r=Math.max(r,a-2)}}else{if(e&&_r.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield ti.SCALAR,yield*this.pushToIndex(i+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,i){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(i&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Yo),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let i=this.flowLevel>0,r=this.charAt(1);if(ee(r)||i&&_r.has(r)){i?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,i=this.buffer[e];for(;!ee(i)&&i!==">";)i=this.buffer[++e];return yield*this.pushToIndex(i===">"?e+1:e,!1)}else{let e=this.pos+1,i=this.buffer[e];for(;i;)if(Zp.has(i))i=this.buffer[++e];else if(i==="%"&&kl.has(this.buffer[e+1])&&kl.has(this.buffer[e+2]))i=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
137
137
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
138
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let i=this.pos-1,
|
|
138
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||e&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(e){let i=this.pos,r=this.buffer[i];for(;!e(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};Sl.Lexer=Xo});var ea=v(El=>{"use strict";var Zo=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let i=0,r=this.lineStarts.length;for(;i<r;){let o=i+r>>1;this.lineStarts[o]<e?i=o+1:r=o}if(this.lineStarts[i]===e)return{line:i+1,col:1};if(i===0)return{line:0,col:e};let n=this.lineStarts[i-1];return{line:i,col:e-n+1}}}};El.LineCounter=Zo});var ia=v(_l=>{"use strict";var tg=ji("process"),Cl=Rr(),ig=Qo();function _e(t,e){for(let i=0;i<t.length;++i)if(t[i].type===e)return!0;return!1}function Pl(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 Rl(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 Ar(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 ht(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 Tr(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let i=0;i<e.length;++i)t.push(e[i])}function xl(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!_e(e.start,"explicit-key-ind")&&!_e(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Rl(e.value)?e.value.end?Tr(e.value.end,e.sep):e.value.end=e.sep:Tr(e.start,e.sep),delete e.sep)}var ta=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 ig.Lexer,this.onNewLine=e}*parse(e,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,i))yield*this.next(r);i||(yield*this.end())}*next(e){if(this.source=e,tg.env.LOG_TOKENS&&console.log("|",Cl.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let i=Cl.tokenType(e);if(i)if(i==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=i,yield*this.step(),i){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let i=e??this.stack.pop();if(!i)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield i;else{let r=this.peek(1);switch(i.type==="block-scalar"?i.indent="indent"in r?r.indent:0:i.type==="flow-collection"&&r.type==="document"&&(i.indent=0),i.type==="flow-collection"&&xl(i),r.type){case"document":r.value=i;break;case"block-scalar":r.props.push(i);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:i,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=i;else{Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];n.value?r.items.push({start:[],value:i}):n.value=i;break}case"flow-collection":{let n=r.items[r.items.length-1];!n||n.value?r.items.push({start:[],key:i,sep:[]}):n.sep?n.value=i:Object.assign(n,{key:i,sep:[]});return}default:yield*this.pop(),yield*this.pop(i)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(i.type==="block-map"||i.type==="block-seq")){let n=i.items[i.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Pl(n.start)===-1&&(i.indent===0||n.start.every(o=>o.type!=="comment"||o.indent<i.indent))&&(r.type==="document"?r.end=n.start:r.items.push({start:n.start}),i.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Pl(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let i=Ar(this.peek(2)),r=ht(i),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=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 i=this.source.indexOf(`
|
|
139
139
|
`)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
|
|
140
|
-
`,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){let
|
|
140
|
+
`,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Tr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind",o=[];if(n&&i.sep&&!i.value){let a=[];for(let s=0;s<i.sep.length;++s){let c=i.sep[s];switch(c.type){case"newline":a.push(s);break;case"space":break;case"comment":c.indent>e.indent&&(a.length=0);break;default:a.length=0}}a.length>=2&&(o=i.sep.splice(a[1]))}switch(this.type){case"anchor":case"tag":n||i.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):n||i.value?(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(i.explicitKey)if(i.sep)if(i.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(_e(i.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(Rl(i.key)&&!_e(i.sep,"newline")){let a=ht(i.start),s=i.key,c=i.sep;c.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:s,sep:c}]})}else o.length>0?i.sep=i.sep.concat(o,this.sourceToken):i.sep.push(this.sourceToken);else if(_e(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let a=ht(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||n?e.items.push({start:o,key:null,sep:[this.sourceToken]}):_e(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let a=this.flowScalar(this.type);n||i.value?(e.items.push({start:o,key:a,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(a):(Object.assign(i,{key:a,sep:[]}),this.onKeyLine=!0);return}default:{let a=this.startBlockValue(e);if(a){if(a.type==="block-seq"){if(!i.explicitKey&&i.sep&&!_e(i.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:o});this.stack.push(a);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Tr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=e.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;i.value||_e(i.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let i=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!i||i.value?e.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!i||i.value?e.items.push({start:[],key:n,sep:[]}):i.sep?this.stack.push(n):Object.assign(i,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=Ar(r),o=ht(n);xl(e);let a=e.end.splice(1,e.end.length);a.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:a}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let i=this.source.indexOf(`
|
|
141
141
|
`)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
|
|
142
|
-
`,i)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=kn(e),n=st(i);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=kn(e),n=st(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,i){return this.type!=="comment"||this.indent<=i?!1:e.every(n=>n.type==="newline"||n.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())}}};ml.Parser=Ho});var yl=v(Kt=>{"use strict";var pl=Ao(),Np=Bt(),Jt=Wt(),Sp=xr(),kp=C(),Ep=Wo(),gl=zo();function wl(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Ep.LineCounter||null,prettyErrors:e}}function Cp(t,e={}){let{lineCounter:i,prettyErrors:n}=wl(e),r=new gl.Parser(i?.addNewLine),o=new pl.Composer(e),a=Array.from(o.compose(r.parse(t)));if(n&&i)for(let s of a)s.errors.forEach(Jt.prettifyError(t,i)),s.warnings.forEach(Jt.prettifyError(t,i));return a.length>0?a:Object.assign([],{empty:!0},o.streamInfo())}function vl(t,e={}){let{lineCounter:i,prettyErrors:n}=wl(e),r=new gl.Parser(i?.addNewLine),o=new pl.Composer(e),a=null;for(let s of o.compose(r.parse(t),!0,t.length))if(!a)a=s;else if(a.options.logLevel!=="silent"){a.errors.push(new Jt.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&i&&(a.errors.forEach(Jt.prettifyError(t,i)),a.warnings.forEach(Jt.prettifyError(t,i))),a}function Pp(t,e,i){let n;typeof e=="function"?n=e:i===void 0&&e&&typeof e=="object"&&(i=e);let r=vl(t,i);if(!r)return null;if(r.warnings.forEach(o=>Sp.warn(r.options.logLevel,o)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:n},i))}function xp(t,e,i){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:i===void 0&&e&&(i=e),typeof i=="string"&&(i=i.length),typeof i=="number"){let r=Math.round(i);i=r<1?void 0:r>8?{indent:8}:{indent:r}}if(t===void 0){let{keepUndefined:r}=i??e??{};if(!r)return}return kp.isDocument(t)&&!n?t.toString(i):new Np.Document(t,n,i).toString(i)}Kt.parse=Pp;Kt.parseAllDocuments=Cp;Kt.parseDocument=vl;Kt.stringify=xp});var Ut=v(x=>{"use strict";var Rp=Ao(),_p=Bt(),Ap=lo(),Go=Wt(),Tp=kt(),ke=C(),Op=ve(),Ip=O(),jp=be(),Lp=Ne(),$p=Nn(),Dp=Fo(),Mp=Wo(),Bp=zo(),Cn=yl(),bl=yt();x.Composer=Rp.Composer;x.Document=_p.Document;x.Schema=Ap.Schema;x.YAMLError=Go.YAMLError;x.YAMLParseError=Go.YAMLParseError;x.YAMLWarning=Go.YAMLWarning;x.Alias=Tp.Alias;x.isAlias=ke.isAlias;x.isCollection=ke.isCollection;x.isDocument=ke.isDocument;x.isMap=ke.isMap;x.isNode=ke.isNode;x.isPair=ke.isPair;x.isScalar=ke.isScalar;x.isSeq=ke.isSeq;x.Pair=Op.Pair;x.Scalar=Ip.Scalar;x.YAMLMap=jp.YAMLMap;x.YAMLSeq=Lp.YAMLSeq;x.CST=$p;x.Lexer=Dp.Lexer;x.LineCounter=Mp.LineCounter;x.Parser=Bp.Parser;x.parse=Cn.parse;x.parseAllDocuments=Cn.parseAllDocuments;x.parseDocument=Cn.parseDocument;x.stringify=Cn.stringify;x.visit=bl.visit;x.visitAsync=bl.visitAsync});import Pn from"path";function qp(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim();if(i.length===0||Pn.posix.isAbsolute(i)||Pn.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be a project-relative path`);if(i===".")return[];let n=i.replaceAll("\\","/").split("/");if(n.some(r=>r===".."))throw new Error(`${e} must stay inside the project root`);if(n.some(r=>r===""||r==="."))throw new Error(`${e} must not contain empty or dot path segments`);return n}function ct(t){let e=qp(t,"native.artifact_root");return e.length===0?".":e.join("/")}function kl(t,e="docs"){let i=t??e;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function Xt(t,e,i=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim().replaceAll("\\","/");if(n.length===0||Pn.posix.isAbsolute(n)||Pn.win32.isAbsolute(n)||/^(?:~|[\\/])/u.test(n))throw new Error(`${e} must be relative to its declared path base`);let r=n.split("/");if(r.some(o=>o===".."))throw new Error(`${e} must stay inside its declared path base`);if(r.some(o=>o===""||o==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!i&&/[*?]/u.test(n))throw new Error(`${e} cannot contain wildcards`);return r.join("/")}function Yt(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function El(t,e,i){let n=t??e;if(n!=="en"&&n!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return n}function An(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>xn)throw new Error(`${e} exceeds ${xn} characters`);let i=0;for(let n=0;n<t.length;n+=1)t[n]==="?"?i+=1:t[n]==="*"&&(i+=1,t[n+1]==="*"&&(n+=1));if(i>Rn)throw new Error(`${e} contains more than ${Rn} wildcard tokens`);return t}function Nl(t,e,i){if(t===void 0)return[...i];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(n=>An(n,e)))].sort((n,r)=>n.localeCompare(r,"en"))}function Vo(t,e,i){let n=t??e;if(!Number.isSafeInteger(n)||n<1)throw new Error(`${i} must be a positive integer`);return n}function Wp(t){if(t===void 0)return{...re,include:[...re.include],exclude:[...re.exclude]};let e=Yt(t,"native.snapshot");return{include:Nl(e.include,"native.snapshot.include",re.include),exclude:Nl(e.exclude,"native.snapshot.exclude",re.exclude),max_files:Vo(e.max_files,re.max_files,"native.snapshot.max_files"),max_total_bytes:Vo(e.max_total_bytes,re.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Vo(e.max_duration_ms,re.max_duration_ms,"native.snapshot.max_duration_ms")}}function Hp(t){if(t===void 0)return;let e=Yt(t,"native.pending_root_move"),i=e.id,n=e.from_artifact_root,r=e.to_artifact_root,o=e.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof n!="string"||typeof r!="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 a;if(e.cleanup!==void 0){let s=Yt(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,f=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof f!="string"||!/^[a-f0-9]{64}$/u.test(f))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");a={kind:c,state:l,manifestHash:f}}return{id:i,fromArtifactRoot:ct(n),toArtifactRoot:ct(r),stage:o,...a?{cleanup:a}:{}}}function zp(t,e={}){let i=Yt(t,"native"),n=i.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof n!="string")throw new Error("native.artifact_root must be a string");let r=i.clarification_mode??"sequential";if(r!=="sequential"&&r!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let o=i.archive_confirmation??"automatic";if(o!=="automatic"&&o!=="required")throw new Error("native.archive_confirmation must be automatic or required");let a=i.max_verify_failures??Sl;if(!Number.isSafeInteger(a)||a<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Hp(i.pending_root_move);return{artifact_root:ct(n),language:El(i.language,"en","native.language"),clarification_mode:r,archive_confirmation:o,max_verify_failures:a,snapshot:Wp(i.snapshot),...s?{pending_root_move:s}:{}}}function Gp(t){let e=Yt(t,"classic"),i=e.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let n=e.review_mode??"standard";if(n!=="off"&&n!=="standard"&&n!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let r=e.auto_transition??!0;if(typeof r!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:kl(e.artifact_layout),language:El(e.language,"zh-CN","classic.language"),context_compression:i,review_mode:n,auto_transition:r}}function Vp(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function Jp(t,e,i,n,r){let o=t.schema!==void 0;if(!(o||t.default_workflow!==void 0||t.workflows!==void 0||!r.allowPartialProject&&t.native!==void 0)||r.allowPartialProject&&!o)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let s=t.workflows??[t.default_workflow];if(!Array.isArray(s)||s.length===0||s.some(l=>l!=="native"&&l!=="classic"))throw new Error("workflows must contain native and/or classic");let c=[...new Set(s)];if(!c.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(c.includes("native")&&!e)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:c,ambient_resume:n,...e?{native:e}:{},...i?{classic:i}:{}}}function Qt(t,e={}){let i=(0,Jo.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let n=i.toJS();if(n==null)return{value:{},config:null,ambient_resume:!0};if(typeof n!="object"||Array.isArray(n))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let r=n,o=Vp(r.ambient_resume),a=r.native===void 0?void 0:zp(r.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),s=r.classic===void 0?void 0:Gp(r.classic),c=Jp(r,a,s,o,{allowPartialProject:e.allowPartialProject??!1});return{value:r,config:c,ambient_resume:o,...a?{native:a}:{},...s?{classic:s}:{}}}var Jo,_n,xn,Rn,Sl,Fp,re,fe=B(()=>{"use strict";Jo=Pi(Ut(),1),_n=64*1024,xn=1024,Rn=64,Sl=5,Fp=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],re={include:["**/*"],exclude:[...Fp],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4}});function Ee(t){return t!==0&&t!==0n&&t!=="0"}function oe(t,e){return Ee(t.dev)&&Ee(e.dev)&&Ee(t.ino)&&Ee(e.ino)}function T(t,e){let i=Ee(t.dev)&&Ee(e.dev);if(i&&t.dev!==e.dev)return!1;let n=Ee(t.ino)&&Ee(e.ino);return n&&t.ino!==e.ino?!1:i&&n?!0:t.birthtime===e.birthtime}var ni=B(()=>{"use strict"});import{constants as Tn,promises as De}from"fs";function Qo(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Pl(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function ri(t){return{dev:t.dev,ino:t.ino,birthtime:Qo(t)}}function On(t,e){let i=ri(t),n=ri(e);return oe(i,n)?T(i,n):T(i,n)&&Qo(t)===Qo(e)&&Pl(t)===Pl(e)&&t.size===e.size}async function oi(t,e,i={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let n=i.label??"file",r=i.bigint===!0,o=await De.lstat(t,{bigint:r});if(!o.isFile()||o.isSymbolicLink())throw new he("not-regular-file",`${n} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new he("too-large",`${n} exceeds ${e} bytes`);let a=await De.realpath(t);await i.verify?.("pre-open",{realPath:a,identity:ri(o)});let s=process.platform==="win32"?Tn.O_RDONLY:Tn.O_RDONLY|Tn.O_NOFOLLOW|Tn.O_NONBLOCK,c;try{c=await De.open(t,s)}catch(l){throw l.code==="ELOOP"?new he("not-regular-file",`${n} must be a regular file`,{cause:l}):l}try{let[l,f,u]=await Promise.all([c.stat({bigint:r}),De.lstat(t,{bigint:r}),De.realpath(t)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||u!==a||!On(o,l)||!On(o,f))throw new he("changed",`${n} changed while opening`);await i.verify?.("post-open",{realPath:u,identity:ri(l)}),await i.hooks?.afterOpen?.();let d=[],p=0,w=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let b=e+1-p,{bytesRead:S}=await c.read(w,0,Math.min(w.length,b),null);if(S===0)break;if(p+=S,p>e)throw new he("too-large",`${n} exceeds ${e} bytes`);d.push(Buffer.from(w.subarray(0,S)))}await i.hooks?.beforeFinalCheck?.();let[h,m,y]=await Promise.all([c.stat({bigint:r}),De.lstat(t,{bigint:r}),De.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||y!==a||!On(o,h)||!On(o,m))throw new he("changed",`${n} changed while reading`);return await i.verify?.("post-read",{realPath:y,identity:ri(h)}),{bytes:Buffer.concat(d,p),stat:h,realPath:y}}finally{await c.close()}}var he,In=B(()=>{"use strict";ni();he=class extends Error{reason;constructor(e,i,n){super(i,n),this.name="RaceSafeReadError",this.reason=e}}});import{promises as jn}from"fs";import Ce from"path";function Zp(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Zo(t,e){let i=Ce.relative(t,e);return i===""||!Ce.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Ce.sep}`)}async function xl(t,e){let i=Ce.resolve(t),n=await jn.lstat(i);if(!n.isDirectory()||n.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return jn.realpath(i)}async function Rl(t,e,i,n){let r=t;for(let o=0;o<i.length;o++){r=Ce.join(r,i[o]);let a;try{a=await jn.lstat(r)}catch(f){if(Zp(f))return{exists:!1,kind:"missing"};throw f}let s=Ce.relative(t,r).replaceAll("\\","/");if(a.isSymbolicLink())throw new Error(`${n.label} crosses a symbolic link or junction at ${s}`);let c=o===i.length-1;if(!c&&!a.isDirectory())throw new Error(`${n.label} ancestor ${s} must be a real directory`);if(c&&(n.expected==="file"&&!a.isFile()||n.expected==="directory"&&!a.isDirectory()||n.expected==="any"&&!a.isFile()&&!a.isDirectory()))throw new Error(`${n.label} must be a real ${n.expected}`);let l=await jn.realpath(r);if(!Zo(e,l))throw new Error(`${n.label} resolves outside the project root`);if(c)return{exists:!0,kind:a.isFile()?"file":a.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function H(t,e,i){let n=Xt(e,i.label),r=Ce.resolve(t),o=await xl(r,i.label),a=n.split("/"),s=Ce.resolve(r,...a);if(!Zo(r,s))throw new Error(`${i.label} must stay inside the project root`);let c=await Rl(r,o,a,i);return{projectRoot:r,target:s,relative:n,exists:c.exists,kind:c.kind}}async function ae(t,e,i,n){let r=await H(t,e,{label:n.label,expected:"file"});if(!r.exists){let a=new Error(`${n.label} does not exist`);throw a.code="ENOENT",a}let o=await xl(r.projectRoot,n.label);return oi(r.target,i,{...n,verify:async(a,s)=>{if(!Zo(o,s.realPath))throw new Error(`${n.label} resolves outside the project root`);await Rl(r.projectRoot,o,r.relative.split("/"),{label:n.label,expected:"file"})}})}var Pe=B(()=>{"use strict";In();fe()});import{createHash as eg}from"crypto";function tg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Me(t,e={}){return(await si(t,e)).document}async function ig(t){try{return(await ae(t,ai,_n,{label:ai})).bytes}catch(e){if(tg(e))return null;throw e}}function ng(t){return t?{exists:!0,sha256:eg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function si(t,e={}){let i=await ig(t);return{document:i?Qt(i.toString("utf8"),e):null,identity:ng(i)}}async function ea(t){return(await Me(t))?.config??null}var ai,Be=B(()=>{"use strict";fe();Pe();ai=".comet/config.yaml"});import{randomUUID as rg}from"crypto";import{constants as og,promises as I}from"fs";import D from"path";async function ta(t,e){try{return await I.link(t,e),{linked:!0}}catch(i){let n=i.code;if(n!=="ENOTSUP"&&n!=="EOPNOTSUPP")throw i}return await I.copyFile(t,e,og.COPYFILE_EXCL),{linked:!1}}function ft(t,e){let i=D.relative(t,e);return i===""||!D.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${D.sep}`)}function $n(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function ag(t,e){return T(t,$n(e))}function Ln(t,e){let i=$n(t),n=$n(e);return oe(i,n)?T(i,n):T(i,n)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Dn(t){let e=await I.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 I.realpath(t),...$n(e)}}async function xe(t){for(let e of t){let i=await I.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!ag(e,i)||await I.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function sg(t,e){let i=D.resolve(t),n=D.resolve(e);if(!ft(i,n))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let r=[await Dn(i)],o=D.relative(i,n).split(D.sep).filter(Boolean),a=i;for(let s of o){await xe(r),a=D.join(a,s);try{await I.mkdir(a)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Dn(a);if(!ft(r[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${a}`);r.push(c)}return await xe(r),r}async function cg(t,e){let i=D.resolve(t),n=D.resolve(e);if(!ft(i,n))throw new Error(`Contained file parent is outside its managed root: ${e}`);let r=[await Dn(i)],o=D.relative(i,n).split(D.sep).filter(Boolean),a=i;for(let s of o){a=D.join(a,s);try{let c=await Dn(a);if(!ft(r[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${a}`);r.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await xe(r),r}async function _l(t){let e;try{e=await I.open(t,"r"),await e.sync()}catch(i){let n=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(n??""))throw i}finally{await e?.close()}}async function lg(t,e,i){let n=D.dirname(t),r=await sg(i.containedRoot,n),o=D.join(n,`.${D.basename(t)}.${rg()}.tmp`),a,s;try{await i.beforeTemporaryOpen?.(),a=await I.open(o,"wx"),s=await a.stat();let[c,l]=await Promise.all([I.lstat(o),I.realpath(o)]);if(await xe(r),!c.isFile()||c.isSymbolicLink()||!Ln(s,c)||!ft(r[0].realPath,l))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await a.writeFile(e,"utf8"):await a.writeFile(e),await a.sync(),!Ln(s,await a.stat()))throw new Error("Contained atomic write temporary file changed while writing");await a.close(),a=void 0,await i.beforeCommit?.(),await xe(r);let f=await I.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!Ln(f,s))throw new Error("Contained atomic write temporary file changed before commit");i.exclusive?(await ta(o,t),await I.unlink(o)):await I.rename(o,t),await _l(n)}catch(c){await a?.close();try{await xe(r),await I.rm(o,{force:!0})}catch{}throw c}}async function Re(t,e,i){await lg(t,e,i)}async function ia(t,e){let i=D.dirname(t),n=await cg(e.containedRoot,i);if(!n)return!1;let r,o;try{r=await I.lstat(t),o=await I.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!r.isFile()||r.isSymbolicLink()||!ft(n[0].realPath,o))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await xe(n);let[a,s]=await Promise.all([I.lstat(t),I.realpath(t)]);if(!a.isFile()||a.isSymbolicLink()||!Ln(r,a)||s!==o)throw new Error("Contained file removal target changed before removal");return await I.unlink(t),await xe(n),await _l(i),!0}var dt=B(()=>{"use strict";ni()});var bN,na=B(()=>{"use strict";dt();Be();Pe();bN=16*1024});var Mn=B(()=>{"use strict";dt();fe();Be();Pe();na()});var Hn=B(()=>{"use strict"});var Ul=B(()=>{"use strict"});var pa=B(()=>{"use strict";Hn()});var Yl=B(()=>{"use strict";Hn();pa()});var Xl=B(()=>{"use strict";Hn();dt();Ul();Yl();fe();Pe();Be();Mn();na();pa()});import{TextDecoder as Qg}from"util";function Ql(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Zg(t,e){try{return new Qg("utf-8",{fatal:!0}).decode(t.bytes)}catch(i){throw new Error(`${e} is not valid UTF-8`,{cause:i})}}async function ga(t,e,i,n,r={}){try{let o=await ae(t,e,i,{label:n,hooks:r.hooks});return{result:o,text:Zg(o,n)}}catch(o){let a=o.code;if(a==="ENOENT"||a==="ENOTDIR")return null;throw o}}async function Zl(t,e,i,n,r={}){return(await ga(t,e,i,n,r))?.text??null}async function eu(t,e,i,n,r,o={}){if(Buffer.byteLength(i,"utf8")>n)throw new Error(`${r} exceeds ${n} bytes`);let a=await ga(t,e,n,r),s=await H(t,e,{label:r,expected:"file"});await Re(s.target,i,{containedRoot:s.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await ga(t,e,n,r);if(!(!a&&!c)){if(!a||!c)throw new Error(`${r} changed before commit`);if(a.result.realPath!==c.result.realPath||!T(Ql(a.result.stat),Ql(c.result.stat))||a.text!==c.text)throw new Error(`${r} changed before commit`)}}})}async function tu(t,e,i,n={}){let r=await H(t,e,{label:i,expected:"file"});return r.exists?ia(r.target,{containedRoot:r.projectRoot,beforeRemove:n.beforeRemove}):!1}var iu=B(()=>{"use strict";Xl();ni()});var su={};ff(su,{RUN_STATE_FILE:()=>zn,applyRunStateToDocument:()=>ru,readRunState:()=>wa,removeRunState:()=>au,runStateFromDocument:()=>wi,writeRunState:()=>va});import ew from"path";function gi(t,e){let i=t[e];if(typeof i!="string"||i.length===0)throw new Error(`Invalid Run state: ${e} must be a non-empty string`);return i}function pi(t,e){let i=gi(t,e);if(ew.isAbsolute(i)||/^(?:[A-Za-z]:|[\\/]|~)/u.test(i)||i.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Run state: ${e} must stay inside the change directory`);return i}function tw(t){let e=t.run_retries??"{}",i;try{i=typeof e=="string"?JSON.parse(e):e}catch(n){throw new Error("Invalid Run state: run_retries must be a JSON object",{cause:n})}if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid Run state: run_retries must be a JSON object");for(let n of Object.values(i))if(!Number.isInteger(n)||Number(n)<0)throw new Error("Invalid Run state: retry counts must be non-negative integers");return i}function wi(t){if(!t.run_id)return null;let e=gi(t,"run_id"),i=gi(t,"skill"),n=gi(t,"skill_version"),r=gi(t,"skill_hash"),o=pi(t,"pending_ref"),a=pi(t,"trajectory_ref"),s=pi(t,"context_ref"),c=pi(t,"artifacts_ref"),l=pi(t,"checkpoint_ref"),f=Number(t.iteration);if(!Number.isInteger(f)||f<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:i,skillVersion:n,skillHash:r,orchestration:t.orchestration,currentStep:nu(t,"current_step"),iteration:f,pending:nu(t,"pending"),pendingRef:o,trajectoryRef:a,contextRef:s,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:tw(t)}}function ru(t,e){e?t.run_id=e.runId:delete t.run_id}function iw(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 nw(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 wi(e)}async function wa(t,e={}){let i=await Zl(t,zn,ou,"Run state",e);if(i===null)return null;let n=JSON.parse(i);return nw(n)}async function va(t,e,i={}){await eu(t,zn,JSON.stringify(iw(e),null,2),ou,"Run state",i)}async function au(t,e={}){await tu(t,zn,"Run state",e)}var nu,zn,ou,vi=B(()=>{"use strict";iu();nu=(t,e)=>{let i=t[e];return i==null?null:String(i)};zn=".comet/run-state.json",ou=256*1024});import of from"path";import{promises as rf}from"fs";fe();import{promises as lt}from"fs";import R from"path";import Kp from"os";var Uo=".comet/config.yaml";async function Ko(t){try{return await lt.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Up(t){try{let e=await lt.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Zt(t,e){let i=R.relative(t,e);return i===""||!R.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${R.sep}`)}async function ei(t){let e=[],i=t;for(;!await Ko(i);){let r=R.dirname(i);if(r===i)break;e.push(R.basename(i)),i=r}let n=await lt.realpath(i);return R.resolve(n,...e.reverse())}async function Cl(t){try{return(await lt.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function ti(t){let e=R.resolve(t);try{(await lt.stat(e)).isDirectory()||(e=R.dirname(e))}catch(r){if(r.code!=="ENOENT")throw r}let i=e,n=R.resolve(Kp.homedir());for(;;){if(!(e===n&&i!==n)){let a=R.join(e,...Uo.split("/")),s=e===i||await Up(a);if(await Ko(a)&&s)return e}if(await Ko(R.join(e,".git")))return e;let o=R.dirname(e);if(o===e)return i;e=o}}function Yo(t){return ct(t)}async function Yp(t,e){let i=Yo(e),n=R.resolve(t,...i.split("/")),r=await lt.realpath(t),o=await ei(n);if(!Zt(r,o))throw new Error("native.artifact_root resolves outside the project root");return n}async function Xo(t,e){let i=Yo(e),n=await Yp(t,i),r=R.join(n,"comet");if(await Cl(r))throw new Error("The configured Native comet root must not be a symbolic link");let[o,a]=await Promise.all([ei(n),ei(r)]);if(!Zt(o,a))throw new Error("The configured Native comet root resolves outside its artifact root");return{projectRoot:R.resolve(t),configFile:R.join(t,...Uo.split("/")),artifactRoot:n,artifactRootRef:i,nativeRoot:r,specsDir:R.join(r,"specs"),changesDir:R.join(r,"changes"),archiveDir:R.join(r,"archive"),runtimeDir:R.join(r,"runtime"),locksDir:R.join(r,"runtime","locks"),transactionsDir:R.join(r,"runtime","transactions")}}function ut(t,e){return Zt(R.resolve(t),R.resolve(e))}async function de(t,e){let i=R.resolve(t),n=R.resolve(e);if(!Zt(i,n))throw new Error(`Path is outside the Native root: ${e}`);if(await Cl(i))throw new Error(`Native root must not be a symbolic link: ${t}`);let[r,o]=await Promise.all([ei(i),ei(n)]);if(!Zt(r,o))throw new Error(`Path resolves outside the Native root: ${e}`);return n}import{promises as mg}from"fs";import A from"path";import{promises as Xp}from"fs";async function ii(t){try{return await Xp.access(t),!0}catch(e){if(Qp(e))return!1;throw e}}function Qp(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}fe();Be();Mn();Pe();var ci=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},oa=class extends Error{constructor(i,n,r){let o=M(r,i),a=M(r,n);super(`Classic layout conflict: both ${o}/ and ${a}/ exist; run comet doctor and resolve the conflict before writing`);this.configuredRoot=i;this.alternateRoot=n;this.name="ClassicLayoutConflictError"}configuredRoot;alternateRoot;code="classic-layout-conflict"},Ol=".comet/config.yaml";function pg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Il(t){await H(t,Ol,{label:Ol,expected:"file"})}function jl(t,e){let i=A.resolve(t),n=e==="docs"?A.join(i,"docs"):i,r=A.join(n,"openspec"),o=A.join(i,"docs","superpowers");return{projectRoot:i,artifactLayout:e,openSpecBase:n,openSpecRoot:r,changesDir:A.join(r,"changes"),archiveDir:A.join(r,"changes","archive"),specsDir:A.join(r,"specs"),superpowersRoot:o,superpowersSpecsDir:A.join(o,"specs"),superpowersPlansDir:A.join(o,"plans"),superpowersReportsDir:A.join(o,"reports")}}async function gg(t){await Il(t);let e=await Me(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new ci;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new ci("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function wg(t,e){return jl(t,e??await gg(t))}async function vg(t,e){let i=await wg(t,e),n=i.artifactLayout==="legacy"?"docs":"legacy",r=jl(t,n).openSpecRoot,[o,a]=await Promise.all([H(i.projectRoot,M(i.projectRoot,i.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),H(i.projectRoot,M(i.projectRoot,r),{label:"Alternate Classic OpenSpec root",expected:"directory"})]),s=o.exists,c=a.exists;return{paths:i,configuredRootExists:s,alternateRoot:r,alternateRootExists:c,dualRoots:s&&c}}async function yg(t,e){let i=[t.openSpecRoot,t.changesDir,t.archiveDir,t.specsDir,e,t.superpowersRoot,t.superpowersSpecsDir,t.superpowersPlansDir,t.superpowersReportsDir];for(let n of i){let r=M(t.projectRoot,n);await H(t.projectRoot,r,{label:`Classic managed physical path ${r}`,expected:"directory"})}}async function Fe(t,e,i={}){let n=await vg(t,e);if(await yg(n.paths,n.alternateRoot),n.dualRoots&&!i.allowAlternateRoot)throw new oa(n.paths.openSpecRoot,n.alternateRoot,n.paths.projectRoot);if(!n.configuredRootExists){let r=M(n.paths.projectRoot,n.paths.openSpecRoot),o=M(n.paths.projectRoot,n.alternateRoot);throw new ci(`Configured Classic OpenSpec root is missing: ${r} (alternate ${o} is ${n.alternateRootExists?"present":"missing"})`)}return n.paths}async function Bn(t,e,i={}){let n=A.join(A.resolve(t),".comet","classic-root-move.json");if(await ii(n))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let r=await Fe(t,e,i);if(!await ii(r.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${M(r.projectRoot,r.openSpecRoot)}`);return r}async function Ll(t){let e=A.resolve(t),i=null;try{(await mg.lstat(e)).isDirectory()||(e=A.dirname(e))}catch(n){if(!pg(n))throw n}for(;;){A.basename(e)==="openspec"&&(i=A.dirname(e));let n=A.join(e,".comet","config.yaml"),r=!1;if(await ii(n))try{await Il(e);let a=(await Me(e))?.value;r=!!a&&typeof a=="object"&&!Array.isArray(a)&&(a.schema==="comet.project.v1"||a.default_workflow!==void 0||a.native!==void 0)}catch{}if(r||await ii(A.join(e,".git")))return e;let o=A.dirname(e);if(o===e)return i??A.resolve(t);e=o}}function M(t,e){return A.relative(A.resolve(t),e).replaceAll("\\","/")}import{readFileSync as bg}from"fs";var Ng=new Set(["applypatch","create","createfile","deletefile","edit","editfile","patch","strreplaceeditor","write","writefile","writefiletool"]),Sg=new Set(["glob","grep","listfiles","read","readfile","search","view"]),Ml=["file_path","filePath","path","target_file","targetFile"],Bl=["file_paths","filePaths","paths","files","targets"],Fl=["operations","edits"],kg=["patch","diff","patchText","patch_text","changes"],aa=new Set(["claude","codex","windsurf","github-copilot","gemini","amazon-q","qwen","kiro","codebuddy","qoder"]);function sa(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function $l(t){return t.toLowerCase().replace(/[^a-z0-9]+/gu,"")}function Eg(t){for(let e of["tool_name","toolName","tool","name"]){let i=t[e];if(typeof i=="string"&&i.trim())return i.trim()}return null}function Cg(t){if(typeof t!="string")return t;let e=t.trim();if(!e.startsWith("{")&&!e.startsWith("["))return t;try{return JSON.parse(e)}catch{return t}}function Pg(t){for(let e of["tool_input","toolInput","toolArgs","tool_args","arguments"])if(t[e]!==void 0)return Cg(t[e]);return t}function Dl(t){let e=[],i=[/^\*\*\* (?:Add|Update|Delete) File:\s+(.+?)\s*$/gmu,/^\+\+\+\s+(?:b\/)?(.+?)\s*$/gmu];for(let n of i)for(let r of t.matchAll(n)){let o=r[1]?.trim();o&&o!=="/dev/null"&&e.push(o)}return e}function qe(t,e){if(typeof e=="string"){let i=e.trim();i&&t.push(i);return}if(Array.isArray(e)){for(let i of e)qe(t,i);return}if(sa(e)){for(let i of Ml)qe(t,e[i]);for(let i of Bl)qe(t,e[i]);for(let i of Fl)qe(t,e[i])}}function xg(t,e){let i=[],n=[e,t].filter(sa);for(let r of n){for(let o of Ml)qe(i,r[o]);for(let o of Bl)qe(i,r[o]);for(let o of Fl)qe(i,r[o]);for(let o of kg){let a=r[o];typeof a=="string"&&i.push(...Dl(a))}}return typeof e=="string"&&i.push(...Dl(e)),[...new Set(i)]}function li(t,e){if(e?.trim())return{intent:"write",targets:[e.trim()],toolName:null};if(!t.trim())return{intent:"unknown",targets:[],toolName:null};let i;try{i=JSON.parse(t)}catch{return{intent:"unknown",targets:[],toolName:null}}if(!sa(i))return{intent:"unknown",targets:[],toolName:null};let n=Eg(i),r=xg(i,Pg(i));return n&&Ng.has($l(n))?{intent:r.length>0?"write":"unknown",targets:r,toolName:n}:n&&Sg.has($l(n))?{intent:"non-write",targets:[],toolName:n}:n?{intent:"unknown",targets:r,toolName:n}:{intent:r.length>0?"write":"unknown",targets:r,toolName:null}}function ca(){let t=process.env.FILE_PATH;if(t?.trim()||process.stdin.isTTY)return li("",t);try{return li(bg(0,"utf8"),t)}catch{return li("",t)}}function ql(t,e){return aa.has(t)?t==="github-copilot"?{exitCode:0,stdout:e.allowed?`{}
|
|
142
|
+
`,i)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=Ar(e),r=ht(i);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=Ar(e),r=ht(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,i){return this.type!=="comment"||this.indent<=i?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};_l.Parser=ta});var jl=v(ri=>{"use strict";var Al=qo(),rg=Jt(),ii=Xt(),ng=Mn(),og=C(),ag=ea(),Tl=ia();function Ol(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new ag.LineCounter||null,prettyErrors:e}}function sg(t,e={}){let{lineCounter:i,prettyErrors:r}=Ol(e),n=new Tl.Parser(i?.addNewLine),o=new Al.Composer(e),a=Array.from(o.compose(n.parse(t)));if(r&&i)for(let s of a)s.errors.forEach(ii.prettifyError(t,i)),s.warnings.forEach(ii.prettifyError(t,i));return a.length>0?a:Object.assign([],{empty:!0},o.streamInfo())}function Il(t,e={}){let{lineCounter:i,prettyErrors:r}=Ol(e),n=new Tl.Parser(i?.addNewLine),o=new Al.Composer(e),a=null;for(let s of o.compose(n.parse(t),!0,t.length))if(!a)a=s;else if(a.options.logLevel!=="silent"){a.errors.push(new ii.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(a.errors.forEach(ii.prettifyError(t,i)),a.warnings.forEach(ii.prettifyError(t,i))),a}function cg(t,e,i){let r;typeof e=="function"?r=e:i===void 0&&e&&typeof e=="object"&&(i=e);let n=Il(t,i);if(!n)return null;if(n.warnings.forEach(o=>ng.warn(n.options.logLevel,o)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:r},i))}function lg(t,e,i){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:i===void 0&&e&&(i=e),typeof i=="string"&&(i=i.length),typeof i=="number"){let n=Math.round(i);i=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=i??e??{};if(!n)return}return og.isDocument(t)&&!r?t.toString(i):new rg.Document(t,r,i).toString(i)}ri.parse=cg;ri.parseAllDocuments=sg;ri.parseDocument=Il;ri.stringify=lg});var mt=v(x=>{"use strict";var ug=qo(),fg=Jt(),dg=ko(),ra=Xt(),hg=Ot(),Ae=C(),mg=Ce(),pg=O(),gg=xe(),wg=Re(),vg=Rr(),yg=Qo(),bg=ea(),Ng=ia(),Or=jl(),Ll=Rt();x.Composer=ug.Composer;x.Document=fg.Document;x.Schema=dg.Schema;x.YAMLError=ra.YAMLError;x.YAMLParseError=ra.YAMLParseError;x.YAMLWarning=ra.YAMLWarning;x.Alias=hg.Alias;x.isAlias=Ae.isAlias;x.isCollection=Ae.isCollection;x.isDocument=Ae.isDocument;x.isMap=Ae.isMap;x.isNode=Ae.isNode;x.isPair=Ae.isPair;x.isScalar=Ae.isScalar;x.isSeq=Ae.isSeq;x.Pair=mg.Pair;x.Scalar=pg.Scalar;x.YAMLMap=gg.YAMLMap;x.YAMLSeq=wg.YAMLSeq;x.CST=vg;x.Lexer=yg.Lexer;x.LineCounter=bg.LineCounter;x.Parser=Ng.Parser;x.parse=Or.parse;x.parseAllDocuments=Or.parseAllDocuments;x.parseDocument=Or.parseDocument;x.stringify=Or.stringify;x.visit=Ll.visit;x.visitAsync=Ll.visitAsync});import Ir from"path";function Sg(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim();if(i.length===0||Ir.posix.isAbsolute(i)||Ir.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function pt(t){let e=Sg(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Bl(t,e="docs"){let i=t??e;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function ai(t,e,i=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim().replaceAll("\\","/");if(r.length===0||Ir.posix.isAbsolute(r)||Ir.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let n=r.split("/");if(n.some(o=>o===".."))throw new Error(`${e} must stay inside its declared path base`);if(n.some(o=>o===""||o==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!i&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function ni(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ml(t,e,i){let r=t??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function $r(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>jr)throw new Error(`${e} exceeds ${jr} characters`);let i=0;for(let r=0;r<t.length;r+=1)t[r]==="?"?i+=1:t[r]==="*"&&(i+=1,t[r+1]==="*"&&(r+=1));if(i>Lr)throw new Error(`${e} contains more than ${Lr} wildcard tokens`);return t}function $l(t,e,i){if(t===void 0)return[...i];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(r=>$r(r,e)))].sort((r,n)=>r.localeCompare(n,"en"))}function na(t,e,i){let r=t??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function Eg(t){if(t===void 0)return{...le,include:[...le.include],exclude:[...le.exclude]};let e=ni(t,"native.snapshot");return{include:$l(e.include,"native.snapshot.include",le.include),exclude:$l(e.exclude,"native.snapshot.exclude",le.exclude),max_files:na(e.max_files,le.max_files,"native.snapshot.max_files"),max_total_bytes:na(e.max_total_bytes,le.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:na(e.max_duration_ms,le.max_duration_ms,"native.snapshot.max_duration_ms")}}function Cg(t){if(t===void 0)return;let e=ni(t,"native.pending_root_move"),i=e.id,r=e.from_artifact_root,n=e.to_artifact_root,o=e.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(o!=="copying"&&o!=="ready"&&o!=="switched")throw new Error("native.pending_root_move.stage is invalid");let a;if(e.cleanup!==void 0){let s=ni(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,f=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof f!="string"||!/^[a-f0-9]{64}$/u.test(f))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");a={kind:c,state:l,manifestHash:f}}return{id:i,fromArtifactRoot:pt(r),toArtifactRoot:pt(n),stage:o,...a?{cleanup:a}:{}}}function Pg(t,e={}){let i=ni(t,"native"),r=i.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let n=i.clarification_mode??"sequential";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let o=i.archive_confirmation??"automatic";if(o!=="automatic"&&o!=="required")throw new Error("native.archive_confirmation must be automatic or required");let a=i.max_verify_failures??Dl;if(!Number.isSafeInteger(a)||a<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Cg(i.pending_root_move);return{artifact_root:pt(r),language:Ml(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:o,max_verify_failures:a,snapshot:Eg(i.snapshot),...s?{pending_root_move:s}:{}}}function xg(t){let e=ni(t,"classic"),i=e.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=e.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:Bl(e.artifact_layout),language:Ml(e.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function Rg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function _g(t,e,i,r,n){let o=t.schema!==void 0;if(!(o||t.default_workflow!==void 0||t.workflows!==void 0||!n.allowPartialProject&&t.native!==void 0)||n.allowPartialProject&&!o)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let s=t.workflows??[t.default_workflow];if(!Array.isArray(s)||s.length===0||s.some(l=>l!=="native"&&l!=="classic"))throw new Error("workflows must contain native and/or classic");let c=[...new Set(s)];if(!c.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(c.includes("native")&&!e)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:c,ambient_resume:r,...e?{native:e}:{},...i?{classic:i}:{}}}function gt(t,e={}){let i=(0,oa.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let r=i.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=r,o=Rg(n.ambient_resume),a=n.native===void 0?void 0:Pg(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),s=n.classic===void 0?void 0:xg(n.classic),c=_g(n,a,s,o,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:c,ambient_resume:o,...a?{native:a}:{},...s?{classic:s}:{}}}var oa,oi,jr,Lr,Dl,kg,le,ue=B(()=>{"use strict";oa=xt(mt(),1),oi=64*1024,jr=1024,Lr=64,Dl=5,kg=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],le={include:["**/*"],exclude:[...kg],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4}});function Te(t){return t!==0&&t!==0n&&t!=="0"}function fe(t,e){return Te(t.dev)&&Te(e.dev)&&Te(t.ino)&&Te(e.ino)}function T(t,e){let i=Te(t.dev)&&Te(e.dev);if(i&&t.dev!==e.dev)return!1;let r=Te(t.ino)&&Te(e.ino);return r&&t.ino!==e.ino?!1:i&&r?!0:t.birthtime===e.birthtime}var fi=B(()=>{"use strict"});import{constants as Dr,promises as We}from"fs";function ua(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Wl(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function di(t){return{dev:t.dev,ino:t.ino,birthtime:ua(t)}}function Br(t,e){let i=di(t),r=di(e);return fe(i,r)?T(i,r):T(i,r)&&ua(t)===ua(e)&&Wl(t)===Wl(e)&&t.size===e.size}async function hi(t,e,i={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=i.label??"file",n=i.bigint===!0,o=await We.lstat(t,{bigint:n});if(!o.isFile()||o.isSymbolicLink())throw new ge("not-regular-file",`${r} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new ge("too-large",`${r} exceeds ${e} bytes`);let a=await We.realpath(t);await i.verify?.("pre-open",{realPath:a,identity:di(o)});let s=process.platform==="win32"?Dr.O_RDONLY:Dr.O_RDONLY|Dr.O_NOFOLLOW|Dr.O_NONBLOCK,c;try{c=await We.open(t,s)}catch(l){throw l.code==="ELOOP"?new ge("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,f,u]=await Promise.all([c.stat({bigint:n}),We.lstat(t,{bigint:n}),We.realpath(t)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||u!==a||!Br(o,l)||!Br(o,f))throw new ge("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:u,identity:di(l)}),await i.hooks?.afterOpen?.();let d=[],m=0,w=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let b=e+1-m,{bytesRead:k}=await c.read(w,0,Math.min(w.length,b),null);if(k===0)break;if(m+=k,m>e)throw new ge("too-large",`${r} exceeds ${e} bytes`);d.push(Buffer.from(w.subarray(0,k)))}await i.hooks?.beforeFinalCheck?.();let[h,p,y]=await Promise.all([c.stat({bigint:n}),We.lstat(t,{bigint:n}),We.realpath(t)]);if(!p.isFile()||p.isSymbolicLink()||y!==a||!Br(o,h)||!Br(o,p))throw new ge("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:y,identity:di(h)}),{bytes:Buffer.concat(d,m),stat:h,realPath:y}}finally{await c.close()}}var ge,Mr=B(()=>{"use strict";fi();ge=class extends Error{reason;constructor(e,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Fr}from"fs";import Oe from"path";function Lg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function fa(t,e){let i=Oe.relative(t,e);return i===""||!Oe.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Oe.sep}`)}async function ql(t,e){let i=Oe.resolve(t),r=await Fr.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Fr.realpath(i)}async function Hl(t,e,i,r){let n=t;for(let o=0;o<i.length;o++){n=Oe.join(n,i[o]);let a;try{a=await Fr.lstat(n)}catch(f){if(Lg(f))return{exists:!1,kind:"missing"};throw f}let s=Oe.relative(t,n).replaceAll("\\","/");if(a.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${s}`);let c=o===i.length-1;if(!c&&!a.isDirectory())throw new Error(`${r.label} ancestor ${s} must be a real directory`);if(c&&(r.expected==="file"&&!a.isFile()||r.expected==="directory"&&!a.isDirectory()||r.expected==="any"&&!a.isFile()&&!a.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await Fr.realpath(n);if(!fa(e,l))throw new Error(`${r.label} resolves outside the project root`);if(c)return{exists:!0,kind:a.isFile()?"file":a.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function G(t,e,i){let r=ai(e,i.label),n=Oe.resolve(t),o=await ql(n,i.label),a=r.split("/"),s=Oe.resolve(n,...a);if(!fa(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await Hl(n,o,a,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function te(t,e,i,r){let n=await G(t,e,{label:r.label,expected:"file"});if(!n.exists){let a=new Error(`${r.label} does not exist`);throw a.code="ENOENT",a}let o=await ql(n.projectRoot,r.label);return hi(n.target,i,{...r,verify:async(a,s)=>{if(!fa(o,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await Hl(n.projectRoot,o,n.relative.split("/"),{label:r.label,expected:"file"})}})}var we=B(()=>{"use strict";Mr();ue()});import{createHash as $g}from"crypto";function Dg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function qe(t,e={}){return(await pi(t,e)).document}async function Bg(t){try{return(await te(t,mi,oi,{label:mi})).bytes}catch(e){if(Dg(e))return null;throw e}}function Mg(t){return t?{exists:!0,sha256:$g("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function pi(t,e={}){let i=await Bg(t);return{document:i?gt(i.toString("utf8"),e):null,identity:Mg(i)}}async function da(t){return(await qe(t))?.config??null}var mi,He=B(()=>{"use strict";ue();we();mi=".comet/config.yaml"});import{randomUUID as Fg}from"crypto";import{constants as Wg,promises as I}from"fs";import D from"path";async function ha(t,e){try{return await I.link(t,e),{linked:!0}}catch(i){let r=i.code;if(r!=="ENOTSUP"&&r!=="EOPNOTSUPP")throw i}return await I.copyFile(t,e,Wg.COPYFILE_EXCL),{linked:!1}}function yt(t,e){let i=D.relative(t,e);return i===""||!D.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${D.sep}`)}function qr(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function qg(t,e){return T(t,qr(e))}function Wr(t,e){let i=qr(t),r=qr(e);return fe(i,r)?T(i,r):T(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Hr(t){let e=await I.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 I.realpath(t),...qr(e)}}async function Ie(t){for(let e of t){let i=await I.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!qg(e,i)||await I.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function Hg(t,e){let i=D.resolve(t),r=D.resolve(e);if(!yt(i,r))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let n=[await Hr(i)],o=D.relative(i,r).split(D.sep).filter(Boolean),a=i;for(let s of o){await Ie(n),a=D.join(a,s);try{await I.mkdir(a)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Hr(a);if(!yt(n[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${a}`);n.push(c)}return await Ie(n),n}async function Gg(t,e){let i=D.resolve(t),r=D.resolve(e);if(!yt(i,r))throw new Error(`Contained file parent is outside its managed root: ${e}`);let n=[await Hr(i)],o=D.relative(i,r).split(D.sep).filter(Boolean),a=i;for(let s of o){a=D.join(a,s);try{let c=await Hr(a);if(!yt(n[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${a}`);n.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await Ie(n),n}async function Gl(t){let e;try{e=await I.open(t,"r"),await e.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await e?.close()}}async function zg(t,e,i){let r=D.dirname(t),n=await Hg(i.containedRoot,r),o=D.join(r,`.${D.basename(t)}.${Fg()}.tmp`),a,s;try{await i.beforeTemporaryOpen?.(),a=await I.open(o,"wx"),s=await a.stat();let[c,l]=await Promise.all([I.lstat(o),I.realpath(o)]);if(await Ie(n),!c.isFile()||c.isSymbolicLink()||!Wr(s,c)||!yt(n[0].realPath,l))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await a.writeFile(e,"utf8"):await a.writeFile(e),await a.sync(),!Wr(s,await a.stat()))throw new Error("Contained atomic write temporary file changed while writing");await a.close(),a=void 0,await i.beforeCommit?.(),await Ie(n);let f=await I.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!Wr(f,s))throw new Error("Contained atomic write temporary file changed before commit");i.exclusive?(await ha(o,t),await I.unlink(o)):await I.rename(o,t),await Gl(r)}catch(c){await a?.close();try{await Ie(n),await I.rm(o,{force:!0})}catch{}throw c}}async function ve(t,e,i){await zg(t,e,i)}async function ma(t,e){let i=D.dirname(t),r=await Gg(e.containedRoot,i);if(!r)return!1;let n,o;try{n=await I.lstat(t),o=await I.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!n.isFile()||n.isSymbolicLink()||!yt(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[a,s]=await Promise.all([I.lstat(t),I.realpath(t)]);if(!a.isFile()||a.isSymbolicLink()||!Wr(n,a)||s!==o)throw new Error("Contained file removal target changed before removal");return await I.unlink(t),await Ie(r),await Gl(i),!0}var Ge=B(()=>{"use strict";fi()});var vk,pa=B(()=>{"use strict";Ge();He();we();vk=16*1024});var zr=B(()=>{"use strict";Ge();ue();He();we();pa()});var Xr=B(()=>{"use strict"});var hu=B(()=>{"use strict"});var Ra=B(()=>{"use strict";Xr()});var mu=B(()=>{"use strict";Xr();Ra()});var Iw,gu=B(()=>{"use strict";Iw=xt(mt(),1);Ge();ue();we()});var wu=B(()=>{"use strict";Xr();Ge();hu();mu();ue();gu();we();He();zr();pa();Ra()});import{TextDecoder as Lw}from"util";function vu(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function $w(t,e){try{return new Lw("utf-8",{fatal:!0}).decode(t.bytes)}catch(i){throw new Error(`${e} is not valid UTF-8`,{cause:i})}}async function _a(t,e,i,r,n={}){try{let o=await te(t,e,i,{label:r,hooks:n.hooks});return{result:o,text:$w(o,r)}}catch(o){let a=o.code;if(a==="ENOENT"||a==="ENOTDIR")return null;throw o}}async function yu(t,e,i,r,n={}){return(await _a(t,e,i,r,n))?.text??null}async function bu(t,e,i,r,n,o={}){if(Buffer.byteLength(i,"utf8")>r)throw new Error(`${n} exceeds ${r} bytes`);let a=await _a(t,e,r,n),s=await G(t,e,{label:n,expected:"file"});await ve(s.target,i,{containedRoot:s.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await _a(t,e,r,n);if(!(!a&&!c)){if(!a||!c)throw new Error(`${n} changed before commit`);if(a.result.realPath!==c.result.realPath||!T(vu(a.result.stat),vu(c.result.stat))||a.text!==c.text)throw new Error(`${n} changed before commit`)}}})}async function Nu(t,e,i,r={}){let n=await G(t,e,{label:i,expected:"file"});return n.exists?ma(n.target,{containedRoot:n.projectRoot,beforeRemove:r.beforeRemove}):!1}var ku=B(()=>{"use strict";wu();fi()});var xu={};Kf(xu,{RUN_STATE_FILE:()=>Qr,applyRunStateToDocument:()=>Eu,readRunState:()=>Aa,removeRunState:()=>Pu,runStateFromDocument:()=>Si,writeRunState:()=>Ta});import Dw from"path";function ki(t,e){let i=t[e];if(typeof i!="string"||i.length===0)throw new Error(`Invalid Run state: ${e} must be a non-empty string`);return i}function Ni(t,e){let i=ki(t,e);if(Dw.isAbsolute(i)||/^(?:[A-Za-z]:|[\\/]|~)/u.test(i)||i.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Run state: ${e} must stay inside the change directory`);return i}function Bw(t){let e=t.run_retries??"{}",i;try{i=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(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid Run state: run_retries must be a JSON object");for(let r of Object.values(i))if(!Number.isInteger(r)||Number(r)<0)throw new Error("Invalid Run state: retry counts must be non-negative integers");return i}function Si(t){if(!t.run_id)return null;let e=ki(t,"run_id"),i=ki(t,"skill"),r=ki(t,"skill_version"),n=ki(t,"skill_hash"),o=Ni(t,"pending_ref"),a=Ni(t,"trajectory_ref"),s=Ni(t,"context_ref"),c=Ni(t,"artifacts_ref"),l=Ni(t,"checkpoint_ref"),f=Number(t.iteration);if(!Number.isInteger(f)||f<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:i,skillVersion:r,skillHash:n,orchestration:t.orchestration,currentStep:Su(t,"current_step"),iteration:f,pending:Su(t,"pending"),pendingRef:o,trajectoryRef:a,contextRef:s,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:Bw(t)}}function Eu(t,e){e?t.run_id=e.runId:delete t.run_id}function Mw(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 Fw(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 Si(e)}async function Aa(t,e={}){let i=await yu(t,Qr,Cu,"Run state",e);if(i===null)return null;let r=JSON.parse(i);return Fw(r)}async function Ta(t,e,i={}){await bu(t,Qr,JSON.stringify(Mw(e),null,2),Cu,"Run state",i)}async function Pu(t,e={}){await Nu(t,Qr,"Run state",e)}var Su,Qr,Cu,Ei=B(()=>{"use strict";ku();Su=(t,e)=>{let i=t[e];return i==null?null:String(i)};Qr=".comet/run-state.json",Cu=256*1024});import Wf from"path";import{promises as Ff}from"fs";ue();import{promises as wt}from"fs";import R from"path";import Ag from"os";var sa=".comet/config.yaml";async function aa(t){try{return await wt.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Tg(t){try{let e=await wt.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function si(t,e){let i=R.relative(t,e);return i===""||!R.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${R.sep}`)}async function ci(t){let e=[],i=t;for(;!await aa(i);){let n=R.dirname(i);if(n===i)break;e.push(R.basename(i)),i=n}let r=await wt.realpath(i);return R.resolve(r,...e.reverse())}async function Fl(t){try{return(await wt.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function li(t){let e=R.resolve(t);try{(await wt.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let i=e,r=R.resolve(Ag.homedir());for(;;){if(!(e===r&&i!==r)){let a=R.join(e,...sa.split("/")),s=e===i||await Tg(a);if(await aa(a)&&s)return e}if(await aa(R.join(e,".git")))return e;let o=R.dirname(e);if(o===e)return i;e=o}}function ca(t){return pt(t)}async function Og(t,e){let i=ca(e),r=R.resolve(t,...i.split("/")),n=await wt.realpath(t),o=await ci(r);if(!si(n,o))throw new Error("native.artifact_root resolves outside the project root");return r}async function la(t,e){let i=ca(e),r=await Og(t,i),n=R.join(r,"comet");if(await Fl(n))throw new Error("The configured Native comet root must not be a symbolic link");let[o,a]=await Promise.all([ci(r),ci(n)]);if(!si(o,a))throw new Error("The configured Native comet root resolves outside its artifact root");return{projectRoot:R.resolve(t),configFile:R.join(t,...sa.split("/")),artifactRoot:r,artifactRootRef:i,nativeRoot:n,specsDir:R.join(n,"specs"),changesDir:R.join(n,"changes"),archiveDir:R.join(n,"archive"),runtimeDir:R.join(n,"runtime"),locksDir:R.join(n,"runtime","locks"),transactionsDir:R.join(n,"runtime","transactions")}}function vt(t,e){return si(R.resolve(t),R.resolve(e))}async function pe(t,e){let i=R.resolve(t),r=R.resolve(e);if(!si(i,r))throw new Error(`Path is outside the Native root: ${e}`);if(await Fl(i))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,o]=await Promise.all([ci(i),ci(r)]);if(!si(n,o))throw new Error(`Path resolves outside the Native root: ${e}`);return r}import{promises as Kl}from"fs";import A from"path";import{promises as Ig}from"fs";async function ui(t){try{return await Ig.access(t),!0}catch(e){if(jg(e))return!1;throw e}}function jg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}ue();He();zr();we();var ze=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Vl=".comet/config.yaml";function Jl(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Ul(t){await G(t,Vl,{label:Vl,expected:"file"})}function Yl(t,e){let i=A.resolve(t),r=e==="docs"?A.join(i,"docs"):i,n=A.join(r,"openspec"),o=A.join(i,"docs","superpowers");return{projectRoot:i,artifactLayout:e,openSpecBase:r,openSpecRoot:n,changesDir:A.join(n,"changes"),archiveDir:A.join(n,"changes","archive"),specsDir:A.join(n,"specs"),superpowersRoot:o,superpowersSpecsDir:A.join(o,"specs"),superpowersPlansDir:A.join(o,"plans"),superpowersReportsDir:A.join(o,"reports")}}async function Yg(t){await Ul(t);let e=await qe(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new ze;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new ze("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function Xg(t,e){return Yl(t,e??await Yg(t))}async function Qg(t){try{return await Kl.lstat(t),!0}catch(e){if(Jl(e))return!1;throw e}}async function Zg(t,e){let i=await Xg(t,e),r=i.artifactLayout==="legacy"?"docs":"legacy",n=Yl(t,r).openSpecRoot,[o,a]=await Promise.all([G(i.projectRoot,M(i.projectRoot,i.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),Qg(n)]),s=o.exists;return{paths:i,configuredRootExists:s,alternateRoot:n,alternateRootExists:a,dualRoots:s&&a}}async function ew(t){let e=[t.openSpecRoot,t.changesDir,t.archiveDir,t.specsDir,t.superpowersRoot,t.superpowersSpecsDir,t.superpowersPlansDir,t.superpowersReportsDir];for(let i of e){let r=M(t.projectRoot,i);await G(t.projectRoot,r,{label:`Classic managed physical path ${r}`,expected:"directory"})}}async function ye(t,e){let i=await Zg(t,e);if(await ew(i.paths),!i.configuredRootExists){let r=M(i.paths.projectRoot,i.paths.openSpecRoot),n=M(i.paths.projectRoot,i.alternateRoot);throw new ze(`Configured Classic OpenSpec root is missing: ${r} (alternate ${n} is ${i.alternateRootExists?"present":"missing"})`)}return i.paths}async function Vr(t,e){let i=A.join(A.resolve(t),".comet","classic-root-move.json");if(await ui(i))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let r=await ye(t,e);if(!await ui(r.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${M(r.projectRoot,r.openSpecRoot)}`);return r}async function Xl(t){let e=A.resolve(t),i=null;try{(await Kl.lstat(e)).isDirectory()||(e=A.dirname(e))}catch(r){if(!Jl(r))throw r}for(;;){A.basename(e)==="openspec"&&(i=A.dirname(e));let r=A.join(e,".comet","config.yaml"),n=!1;if(await ui(r))try{await Ul(e);let a=(await qe(e))?.value;n=!!a&&typeof a=="object"&&!Array.isArray(a)&&(a.schema==="comet.project.v1"||a.default_workflow!==void 0||a.native!==void 0)}catch{}if(n||await ui(A.join(e,".git")))return e;let o=A.dirname(e);if(o===e)return i??A.resolve(t);e=o}}function M(t,e){return A.relative(A.resolve(t),e).replaceAll("\\","/")}import{readFileSync as tw}from"fs";import Ql from"path";var iw=new Set(["applypatch","create","createfile","deletefile","edit","editfile","patch","strreplaceeditor","write","writefile","writefiletool"]),rw=new Set(["glob","grep","listfiles","read","readfile","search","view"]),eu=["file_path","filePath","path","target_file","targetFile"],tu=["file_paths","filePaths","paths","files","targets"],iu=["operations","edits"],nw=["patch","diff","patchText","patch_text","changes"],va=new Set(["claude","codex","windsurf","github-copilot","gemini","amazon-q","qwen","kiro","codebuddy","qoder"]);function ya(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Zl(t){return t.toLowerCase().replace(/[^a-z0-9]+/gu,"")}function ow(t){for(let e of["tool_name","toolName","tool","name"]){let i=t[e];if(typeof i=="string"&&i.trim())return i.trim()}return null}function aw(t){for(let e of["cwd","working_directory","workspaceRoot"]){let i=t[e];if(!(typeof i!="string"||!i.trim()||!Ql.isAbsolute(i.trim())))return Ql.resolve(i.trim())}}function sw(t){if(typeof t!="string")return t;let e=t.trim();if(!e.startsWith("{")&&!e.startsWith("["))return t;try{return JSON.parse(e)}catch{return t}}function cw(t){for(let e of["tool_input","toolInput","toolArgs","tool_args","arguments"])if(t[e]!==void 0)return sw(t[e]);return t}function wa(t){let e=[],i=[/^\*\*\* (?:Add|Update|Delete) File:\s+(.+?)\s*$/gmu,/^\+\+\+\s+(?:b\/)?(.+?)\s*$/gmu];for(let r of i)for(let n of t.matchAll(r)){let o=n[1]?.trim();o&&o!=="/dev/null"&&e.push(o)}return e}function Ve(t,e){if(typeof e=="string"){let i=e.trim();i&&t.push(i);return}if(Array.isArray(e)){for(let i of e)Ve(t,i);return}if(ya(e)){for(let i of eu)Ve(t,e[i]);for(let i of tu)Ve(t,e[i]);for(let i of iu)Ve(t,e[i])}}function lw(t,e){let i=[],r=[e,t].filter(ya);for(let n of r){for(let o of eu)Ve(i,n[o]);for(let o of tu)Ve(i,n[o]);for(let o of iu)Ve(i,n[o]);for(let o of nw){let a=n[o];typeof a=="string"&&i.push(...wa(a))}}return typeof e=="string"&&i.push(...wa(e)),[...new Set(i)]}function gi(t,e){if(e?.trim())return{intent:"write",targets:[e.trim()],toolName:null};if(!t.trim())return{intent:"unknown",targets:[],toolName:null};let i;try{i=JSON.parse(t)}catch{let a=wa(t);return a.length>0?{intent:"write",targets:[...new Set(a)],toolName:"apply_patch"}:{intent:"unknown",targets:[],toolName:null}}if(!ya(i))return{intent:"unknown",targets:[],toolName:null};let r=ow(i),n=lw(i,cw(i)),o=aw(i);return r&&iw.has(Zl(r))?{intent:n.length>0?"write":"unknown",targets:n,toolName:r,...o?{cwd:o}:{}}:r&&rw.has(Zl(r))?{intent:"non-write",targets:[],toolName:r,...o?{cwd:o}:{}}:r?{intent:"unknown",targets:n,toolName:r,...o?{cwd:o}:{}}:{intent:n.length>0?"write":"unknown",targets:n,toolName:null,...o?{cwd:o}:{}}}function ba(){let t=process.env.FILE_PATH;if(t?.trim()||process.stdin.isTTY)return gi("",t);try{return gi(tw(0,"utf8"),t)}catch{return gi("",t)}}function ru(t,e){return va.has(t)?t==="github-copilot"?{exitCode:0,stdout:e.allowed?`{}
|
|
143
143
|
`:`${JSON.stringify({permissionDecision:"deny",permissionDecisionReason:e.reason})}
|
|
144
144
|
`,stderr:""}:e.allowed?{exitCode:0,stdout:"",stderr:""}:{exitCode:2,stdout:"",stderr:`${e.reason}
|
|
145
145
|
`}:{exitCode:64,stdout:"",stderr:`Unsupported Comet Hook platform: ${t}
|
|
146
|
-
`}}var
|
|
147
|
-
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function fa(t){let e=ua(t);if(e)throw new Error(e)}function Ag(t,e){return{label:M(t,e),directory:e}}async function Tg(t,e,i){let n=Ag(t,e);if(!(await di(t,e,{label:i,expected:"directory"})).exists)return{change:n,exists:!1,stateExists:!1};let o=await di(t,zl.join(e,".comet.yaml"),{label:`${i} state`,expected:"file"});return{change:n,exists:!0,stateExists:o.exists}}async function hi(t,e=process.cwd()){fa(t);let i=await Fe(e),n=await Tg(i.projectRoot,zl.join(i.changesDir,t),`Classic active change ${t}`);return{...n.change,exists:n.exists,stateExists:n.stateExists}}var da=Pi(Ut(),1);import{execFileSync as Gl}from"child_process";import{randomUUID as Og}from"crypto";import{promises as mi}from"fs";import Vl from"path";function Ig(t){try{let e=Gl("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return e&&e!=="HEAD"?e:null}catch{return null}}var jg=la("liveGitBranch",t=>Ig(t));function Lg(t){try{return Gl("git",["rev-parse","--is-inside-work-tree"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()==="true"}catch{return!1}}var $g=la("isGitWorkTree",t=>Lg(t)),Dg=["current","branch","worktree"];function Jl(t){return Dg.includes(t)}function Mg(t){return Jl(t.isolation)?t.boundBranch===null&&t.currentBranch===null&&t.gitWorkTree===!1?{status:"not-applicable"}:t.boundBranch===null?t.currentBranch===null?{status:"unbound-detached"}:{status:"needs-heal",branch:t.currentBranch}:t.currentBranch===t.boundBranch?{status:"ok"}:{status:"drift",boundBranch:t.boundBranch,currentBranch:t.currentBranch}:{status:"not-applicable"}}async function Fn(t,e){let i=Vl.join(t,".comet.yaml"),n=(0,da.parseDocument)(await mi.readFile(i,"utf8"),{uniqueKeys:!1});if(n.errors.length>0)throw new Error(`Invalid .comet.yaml: ${n.errors[0].message}`);let r=n.toJS()??{},o=typeof r.isolation=="string"?r.isolation:null,a=typeof r.bound_branch=="string"&&r.bound_branch!==""?r.bound_branch:null,s=Jl(o),c=jg(e.cwd),l=s&&a===null&&c===null?$g(e.cwd):!0,f=Mg({isolation:o,boundBranch:a,currentBranch:c,gitWorkTree:l});return f.status==="needs-heal"&&e.heal?(await Bg(t,f.branch),{status:"healed",branch:f.branch,bindingRequired:s,currentBranch:c}):{...f,bindingRequired:s,currentBranch:c}}async function Bg(t,e){let i=Vl.join(t,".comet.yaml"),n=(0,da.parseDocument)(await mi.readFile(i,"utf8"),{uniqueKeys:!1});n.set("bound_branch",e);let r=`${i}.${Og()}.tmp`;try{await mi.writeFile(r,n.toString(),"utf8"),await mi.rename(r,i)}catch(o){throw await mi.rm(r,{force:!0}),o}}function Fg(t){return t??"detached HEAD"}function qn(t,e,i){return`change '${t}' is bound to branch '${e}', but current branch is '${Fg(i)}'`}function Wn(t){return`change '${t}' uses a branch-bound workspace mode but has no bound branch and HEAD is detached; checkout a branch first before continuing.`}In();import qg from"path";var ha="comet.selection.v2",Wg=16*1024;function ma(t){return qg.join(t,".comet","current-change.json")}function Hg(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Kl(t){return t===null||typeof t=="string"}function zg(t){let e;try{e=JSON.parse(t)}catch(i){throw new Error(`current change selection contains invalid JSON: ${i instanceof Error?i.message:String(i)}`,{cause:i})}if(!Hg(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!Kl(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:ha,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==ha)throw new Error(`current change selection schema must be ${ha}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!Kl(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function ht(t){let e;try{let n=ma(t),{bytes:r}=await oi(n,Wg,{label:"current change selection"});e=r.toString("utf8")}catch(n){if(n.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${n instanceof Error?n.message:String(n)}`,{cause:n})}return{status:"selected",...zg(e)}}var Jn=Pi(Ut(),1);dt();Pe();import Vn from"path";vi();var ba=["full","hotfix","tweak"],cu=1,uu=["open","design","build","verify","archive"],rw=["en","zh-CN"],ow=["off","beta"],aw=["subagent-driven-development","executing-plans","direct"],sw=["plan-ready"],cw=["confirmed"],lw=["tdd","direct"],uw=["off","standard","thorough"],fw=["current","branch","worktree"],dw=["light","full"],hw=["pending","pass","fail"],mw=["pending","handled"],pw=["pending","confirmed"],Na=["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","verification_report","branch_status","created_at","verified_at","archive_confirmation","archived","direct_override","handoff_context","handoff_hash","classic_profile","classic_migration"],gw=["run_id"],fu=new Set([...Na,...gw]),ww=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function lu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function mt(t,e){let i=t[e];if(i==null||i==="")return null;if(typeof i!="string")throw new Error(`Invalid Classic state: ${e} must be a string or null`);return i}function F(t,e,i,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!="string"||!i.includes(r))throw new Error(`Invalid Classic state: ${e} must be one of ${i.join(", ")}${n?" or null":""}`);return r}function ya(t,e,i=!0){let n=t[e];if(n==null||n===""){if(i)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof n!="boolean")throw new Error(`Invalid Classic state: ${e} must be true or false`);return n}function vw(t,e,i=0){let n=t[e];if(n==null||n==="")return i;if(typeof n!="number"||!Number.isInteger(n)||n<0)throw new Error(`Invalid Classic state: ${e} must be a non-negative integer`);return n}function Gn(t,e){let i=mt(t,e);if(i===null)return null;if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(i)||i.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Classic state: ${e} must be a relative repository path`);return i}function yw(t,e){let i=mt(t,e);if(i!==null&&!/^[a-f0-9]{64}$/u.test(i))throw new Error(`Invalid Classic state: ${e} must be a sha256 hex digest`);return i}function bw(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==cu)throw new Error(`Invalid Classic state: classic_migration must be ${cu}`);return e}function Nw(t){if(!Na.some(i=>lu(t,i)))return null;for(let i of ww)if(!lu(t,i))return null;return{workflow:F(t,"workflow",ba,!1),language:F(t,"language",rw),phase:F(t,"phase",uu,!1),contextCompression:F(t,"context_compression",ow),buildMode:F(t,"build_mode",aw),buildPause:F(t,"build_pause",sw),subagentDispatch:F(t,"subagent_dispatch",cw),tddMode:F(t,"tdd_mode",lw),reviewMode:F(t,"review_mode",uw),isolation:F(t,"isolation",fw),boundBranch:mt(t,"bound_branch"),verifyMode:F(t,"verify_mode",dw),autoTransition:ya(t,"auto_transition"),baseRef:mt(t,"base_ref"),designDoc:Gn(t,"design_doc"),plan:Gn(t,"plan"),verifyResult:F(t,"verify_result",hw,!1),verifyFailures:vw(t,"verify_failures"),verificationReport:Gn(t,"verification_report"),branchStatus:F(t,"branch_status",mw),createdAt:mt(t,"created_at"),verifiedAt:mt(t,"verified_at"),archiveConfirmation:F(t,"archive_confirmation",pw),archived:ya(t,"archived",!1),directOverride:ya(t,"direct_override"),handoffContext:Gn(t,"handoff_context"),handoffHash:yw(t,"handoff_hash"),classicProfile:F(t,"classic_profile",ba),classicMigration:bw(t)}}function du(t,e){let i=e??null;if(i===null&&e===void 0&&t.run_id&&t.skill)try{i=wi(t)}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(r.replace(/^Invalid Run state:/u,"Invalid Classic state:"),{cause:n})}return{classic:Nw(t),run:i,unknownKeys:Object.keys(t).filter(n=>!fu.has(n))}}function hu(t){let e=t.workflow,i=t.phase,n=t.archived,r=t.design_doc;return{workflow:typeof e=="string"&&ba.includes(e)?e:null,phase:typeof i=="string"&&uu.includes(i)?i:null,archived:n===!0,designDoc:typeof r=="string"&&r!==""?r:null,unknownKeys:Object.keys(t).filter(o=>!fu.has(o))}}vi();var Sw=2*1024*1024;function yi(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 kw(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 i of e)t.delete(i)}function Ew(t){let e=!1;for(let i of["build_command","verify_command"])t.has(i)&&(t.delete(i),e=!0);return e}async function mu(t){let e;try{e=(await ae(Vn.dirname(t),Vn.basename(t),Sw,{label:"Classic state document"})).bytes.toString("utf8")}catch(n){if(n.code!=="ENOENT")throw n;return new Jn.Document({})}let i=(0,Jn.parseDocument)(e);if(i.errors.length>0)throw new Error(`Invalid Classic state document: ${i.errors[0].message}`);return yi(i),i}async function Kn(t,e={}){let i=e.migrate!==!1,n=Vn.join(t,".comet.yaml"),r=await mu(n),o=yi(r),a=Ew(r);a&&(o=yi(r));let s=await wa(t);if(!s&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(vi(),su));s=c(o),s&&i&&(await va(t,s),kw(r),a=!0)}return a&&i&&await Re(n,r.toString(),{containedRoot:t}),du(yi(r),s)}async function pu(t){let e=await mu(Vn.join(t,".comet.yaml"));return hu(yi(e))}var Rw=Q("readCometCurrentSelection",t=>ht(t));async function _w(t,e){fa(e);let i=await hi(e,t);if(!i.stateExists)throw new Error(`Cannot select current change '${e}': active change state not found`);let n=await Kn(i.directory,{migrate:!1});if(!n.classic)throw new Error(`Cannot select current change '${e}': Classic state is incomplete`);if(n.classic.archived)throw new Error(`Cannot select current change '${e}': change is archived`);return i.directory}async function Un(t){let e;try{e=await Rw(t)}catch(o){return{status:"stale",reason:o instanceof Error?o.message:String(o)}}if(e.status==="missing")return{status:"missing"};if(e.selection.workflow!=="classic")return{status:"stale",reason:`current change '${e.selection.change}' belongs to Native, not Classic`};let i=e.selection,n;try{n=await _w(t,i.change)}catch(o){return{status:"stale",reason:o instanceof Error?o.message:String(o)}}let r=await Fn(n,{heal:!1,cwd:t});return r.status==="drift"?{status:"stale",reason:qn(i.change,r.boundBranch,r.currentBranch)}:r.status==="unbound-detached"?{status:"stale",reason:Wn(i.change)}:r.status==="ok"?{status:"selected",selection:i}:i.branch!==null&&r.currentBranch!==i.branch?{status:"stale",reason:`current change '${i.change}' was selected on branch '${i.branch}', current branch is '${r.currentBranch??"detached HEAD"}'`}:{status:"selected",selection:i}}function Ae(t,e){return{exitCode:t,stderr:e+`
|
|
148
|
-
`}}function
|
|
149
|
-
`))}function
|
|
150
|
-
`))}function
|
|
151
|
-
`))}function
|
|
152
|
-
`))}function
|
|
153
|
-
`))}async function Kw(t,e,i){let n=await Tw(e,t),r;try{r=await Bn(t)}catch(c){return Ae(2,`[COMET-HOOK] blocked: ${c instanceof Error?c.message:String(c)}`)}if(qw(n))return _e(`${n} (whitelist: comet config)`);if(Ww(n))return _e(`${n} (whitelist: superpowers workspace)`);if(n==="CLAUDE.md"||n==="CHANGELOG.md"||n==="README.md"||Fw(n))return _e(`${n} (whitelist: root markdown)`);let o;try{o=await Bw(n,t,r,i)}catch(c){return Ae(2,`[COMET-HOOK] blocked: ${c instanceof Error?c.message:String(c)}`)}if(!o)return _e("no active comet change");if("blockedResult"in o)return o.blockedResult;if(o.archived)return _e(`${n} (own change archived)`);let a=o.phase,s=Hw(n,a,`${M(t,r.openSpecRoot)}/`);if(s)return _e(s);if(ku(n,Su(t,r))){if(o.superpowersArtifact==="matched"&&Cu(o))return _e(`${n} (phase: ${a}, superpowers)`);if(o.superpowersArtifact==="unmatched")return Vw(n,o)}return a==="build"&&o.classic?.workflow==="full"&&!o.classic.designDoc?Gw(n):a==="build"||a==="verify"?_e(`${n} (phase: ${a})`):zw(n,a)}async function Pu(t,e,i){if(i.intent!=="non-write")try{await Bn(t)}catch(o){return{allowed:!1,reason:o instanceof Error?o.message:String(o),workflow:"classic",change:e}}let n;try{n=await Si(t)}catch(o){return{allowed:!1,reason:o instanceof Error?o.message:String(o),workflow:"classic",change:e}}let r=n.find(o=>se(o)===e);if(!r)return{allowed:!1,reason:`Selected Classic change ${e} is missing or archived; resume /comet-classic before retrying`,workflow:"classic",change:e};if(i.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(i.intent==="unknown"||i.targets.length===0)return r.phase==="verify"||r.phase==="build"&&!(r.classic?.workflow==="full"&&!r.classic.designDoc)?{allowed:!0,reason:`Classic change is in ${r.phase}`,workflow:"classic",change:e,phase:r.phase}:{allowed:!1,reason:`Hook write target could not be determined while Classic change ${e} is in ${r.phase}; resume /comet-classic before retrying`,workflow:"classic",change:e,phase:r.phase};for(let o of i.targets){let a=await Kw(t,o,e);if(a.exitCode!==0)return{allowed:!1,reason:a.stderr?.trim()||"Classic phase guard blocked the write",workflow:"classic",change:e,phase:r.phase}}return{allowed:!0,reason:`Classic write allowed in ${r.phase}`,workflow:"classic",change:e,phase:r.phase}}import{promises as py}from"fs";import vt from"path";var Aa=Pi(Ut(),1);import{promises as Kv}from"fs";import Ke from"path";import{createHash as Qw}from"node:crypto";import{promises as Z}from"node:fs";import J from"node:path";import{TextDecoder as Zw}from"node:util";var Uw=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Yw=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Xw(t){return t.toLowerCase().startsWith(".env")}function Sa(t){let i=t.replaceAll("\\","/").split("/").filter(Boolean).map(n=>n.toLowerCase());return i.some(n=>Xw(n))?"environment-file":i.some(n=>Yw.has(n))?"credential-config":i.includes(".git")?"git-metadata":i.some(n=>Uw.has(n))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}ni();var ev=1024*1024;function ka(t,e){let i=J.relative(t,e);return i===""||!J.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${J.sep}`)}function tv(t){let e=J.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(r=>{let o=r.codePointAt(0)??0;return o<=31||o===127})||J.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let i=t.toLowerCase(),n=Sa(t);if(n||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${n??"native-runtime"}): ${t}`);return t}function iv(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function nv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Xn(t,e){let i={...t,birthtime:t.birthtimeMs},n={...e,birthtime:e.birthtimeMs};return oe(i,n)?T(i,n):T(i,n)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function xu(t){let e=await Z.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await Z.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function rv(t,e){let i=J.resolve(t),n=J.resolve(e);if(!ka(i,n))throw new Error("Native artifact path is outside its root");let r=[await xu(i)],o=i;for(let a of J.relative(i,n).split(J.sep).filter(Boolean)){o=J.join(o,a);let s=await xu(o);if(!ka(r[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${o}`);r.push(s)}return r}async function Ru(t){for(let e of t){let i=await Z.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!nv(e,i)||await Z.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function Ea(t){let e=tv(t.ref),i=iv(t.maxBytes??ev),n=J.resolve(t.root,...e.split("/")),r=await rv(t.root,J.dirname(n));await t.hooks?.afterParentChainCaptured?.();let o=await Z.lstat(n);if(!o.isFile()||o.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(o.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);let a=await Z.realpath(n);if(!ka(r[0].realPath,a))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await Z.open(n,"r");try{let[c,l,f]=await Promise.all([s.stat(),Z.lstat(n),Z.realpath(n)]);if(await Ru(r),!c.isFile()||!l.isFile()||l.isSymbolicLink()||f!==a||!Xn(o,c)||!Xn(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let u=[],d=0,p=Buffer.allocUnsafe(Math.min(64*1024,i+1));for(;;){let S=i+1-d,k=await s.read(p,0,Math.min(p.length,S),null);if(k.bytesRead===0)break;if(d+=k.bytesRead,d>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);u.push(Buffer.from(p.subarray(0,k.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[w,h,m]=await Promise.all([s.stat(),Z.lstat(n),Z.realpath(n)]);if(await Ru(r),!h.isFile()||h.isSymbolicLink()||m!==a||!Xn(c,w)||!Xn(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let y=Buffer.concat(u,d),b;try{b=new Zw("utf-8",{fatal:!0}).decode(y)}catch(S){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:S})}return{ref:e,size:d,hash:Qw("sha256").update(y).digest("hex"),text:b}}finally{await s.close()}}fe();Be();Mn();var Qn=An;async function Zn(t){let e=(await Me(t))?.config??null;return e?.native?e:null}import{AsyncLocalStorage as ov}from"async_hooks";In();var Bk=16*1024;var Fk=new ov;import{TextDecoder as mv}from"util";import{createHash as av}from"node:crypto";import{constants as er,promises as ee}from"node:fs";import te from"node:path";import{TextDecoder as sv}from"node:util";function ir(t,e){let i=te.relative(t,e);return i===""||!te.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${te.sep}`)}function cv(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function lv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function uv(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function tr(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Pa(t,e){let i=await ee.lstat(t);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await ee.realpath(t),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function fv(t,e,i){let n=te.resolve(t),r=te.resolve(e);if(!ir(n,r))throw new Error(`${i} is outside its managed root`);let o=[await Pa(n,i)],a=n;for(let s of te.relative(n,r).split(te.sep).filter(Boolean)){await He(o,i),a=te.join(a,s);let c=await Pa(a,i);if(!ir(o[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${a}`);o.push(c)}return await He(o,i),o}async function He(t,e){for(let i of t){let n=await ee.lstat(i.path);if(!n.isDirectory()||n.isSymbolicLink()||!lv(i,n)||await ee.realpath(i.path)!==i.realPath)throw new Error(`${e} parent changed during I/O: ${i.path}`)}}async function dv(t,e,i){let n=[],r=0,o=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let a=e+1-r,{bytesRead:s}=await t.read(o,0,Math.min(o.length,a),null);if(s===0)break;if(r+=s,r>e)throw new Error(`${i} exceeds ${e} bytes`);n.push(Buffer.from(o.subarray(0,s)))}return Buffer.concat(n,r)}async function _u(t){let e=cv(t.maxBytes),i=te.resolve(t.file),n=await fv(t.root,te.dirname(i),t.label),r=await Promise.all((t.forbiddenRoots??[]).map(f=>Pa(te.resolve(f),t.label)));await t.hooks?.afterParentChainCaptured?.(),await He(n,t.label);let o=await ee.lstat(i);if(!o.isFile()||o.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(o.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let a=uv(o),s=await ee.realpath(i);if(!ir(n[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(r.some(f=>ir(f.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?er.O_RDONLY:er.O_RDONLY|er.O_NOFOLLOW|er.O_NONBLOCK,l=await ee.open(i,c);try{let f=await l.stat();await t.hooks?.afterOpen?.();let[u,d]=await Promise.all([ee.lstat(i),ee.realpath(i)]);if(await He(n,t.label),await He(r,t.label),!f.isFile()||!u.isFile()||u.isSymbolicLink()||d!==s||!tr(a,f)||!tr(a,u))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let p=await dv(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[w,h,m]=await Promise.all([l.stat(),ee.lstat(i),ee.realpath(i)]);if(await He(n,t.label),await He(r,t.label),!h.isFile()||h.isSymbolicLink()||m!==s||!tr(a,w)||!tr(a,h))throw new Error(`${t.label} changed while reading`);return{bytes:p,hash:av("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}async function Au(t){let e=await _u(t),i;try{i=new sv("utf-8",{fatal:!0}).decode(e.bytes)}catch(n){throw new Error(`${t.label} is not valid UTF-8`,{cause:n})}return{...e,text:i}}var rE=256*1024,oE=1024*1024,aE=16*1024;var sE=64*1024*1024;var cE=new mv("utf-8",{fatal:!0});import rr from"path";import{createHash as pv}from"crypto";function Iu(t){return pv("sha256").update(t).digest("hex")}var _E={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},wv=1e3,vv=8*1024*1024,yv=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,bv=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),Nv=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),Sv=new Set(["schema","include","exclude","hash"]),kv=new Set(["provider","gitSelection","physicalSelection","projection"]),Ev=new Set(["provider","selection"]),Cv=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),Pv=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),xv=new Set(["schema","status","before","after"]),Rv=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),_v=new Set(["path","hash","size","type","gitObjectId"]),Av=new Set(["path","size","type","reason"]),Tv=new Set(["ref","hash","count"]),Ov=new Set(["change-created","legacy-migration","explicit"]),Iv=new Set(["file","directory","other"]),jv=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),or=/^[a-f0-9]{64}$/u,Lv=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var AE=64*1024,TE=64*1024;var OE={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},IE={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function nr(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var jE=(1n<<256n)-1n;function $v(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function Dv(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
|
|
154
|
-
`)}function
|
|
155
|
-
${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function xa(t,e,i){let n=new Set(e),r=[...e];for(;r.length>0;){if(i&&!i())return null;let o=r.pop(),a=t[o];a&&(a.kind==="star"||a.kind==="globstar"||a.kind==="globstar-slash")&&!n.has(o+1)&&(n.add(o+1),r.push(o+1))}return n}function Bv(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function ju(t){let e=Qn(t,"Native snapshot pattern"),i=[];for(let n=0;n<e.length;n+=1){let r=e[n];r==="*"&&e[n+1]==="*"?(n+=1,e[n+1]==="/"?(n+=1,i.push({kind:"globstar-slash"})):i.push({kind:"globstar"})):r==="*"?i.push({kind:"star"}):r==="?"?i.push({kind:"question"}):i.push({kind:"literal",value:r})}return(n,r)=>{let o=r?Bv(r):void 0;if(o&&!o())return!1;let a=xa(i,new Set([0]),o);if(a===null)return!1;for(let s of n){if(o&&!o())return!1;let c=new Set;for(let l of a){if(o&&!o())return!1;let f=i[l];f&&(f.kind==="literal"&&f.value===s||f.kind==="question"&&s!=="/"?c.add(l+1):f.kind==="star"&&s!=="/"||f.kind==="globstar"?c.add(l):f.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(a=xa(i,c,o),a===null||a.size===0)return!1}return xa(i,a,o)?.has(i.length)??!1}}function Fv(t){if(t===void 0)return;let e=[...new Set(t.include.map(r=>Qn(r,"include")))].sort((r,o)=>r.localeCompare(o,"en")),i=[...new Set(t.exclude.map(r=>Qn(r,"exclude")))].sort((r,o)=>r.localeCompare(o,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let n=Mv(e,i);if("hash"in t&&t.hash!==n)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:i,hash:n},includeMatchers:e.map(ju),excludeMatchers:i.map(ju),excludedDirectoryPrefixes:i.flatMap(r=>{if(!r.endsWith("/**"))return[];let o=r.slice(0,-3);return/[*?]/u.test(o)?[]:[o]}).sort((r,o)=>r.localeCompare(o,"en"))}}function K(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function U(t,e,i){let n=Object.keys(t).find(r=>!e.has(r));if(n)throw new Error(`${i} contains unknown field: ${n}`)}function gt(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function ce(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function Du(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let i=rr.posix.normalize(t);if(i!==t||rr.posix.isAbsolute(t)||i===".."||i.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function qv(t,e){let i=K(t,`Native snapshot entry ${e}`);U(i,_v,`Native snapshot entry ${e}`);let n=Du(i.path,`Native snapshot entry ${e} path`);if(typeof i.hash!="string"||!or.test(i.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(i.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let r={path:n,hash:i.hash,size:ce(i.size,`Native snapshot entry ${e} size`),type:"file"};if(i.gitObjectId!==void 0){if(typeof i.gitObjectId!="string"||!Lv.test(i.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);r.gitObjectId=i.gitObjectId}return r}function Wv(t,e){let i=K(t,`Native snapshot omission ${e}`);if(U(i,Av,`Native snapshot omission ${e}`),!Iv.has(i.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!jv.has(i.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:Du(i.path,`Native snapshot omission ${e} path`),size:i.size===null?null:ce(i.size,`Native snapshot omission ${e} size`),type:i.type,reason:i.reason}}function Hv(t){let e=K(t,"Native snapshot omission overflow");if(U(e,Tv,"Native snapshot omission overflow"),typeof e.hash!="string"||!or.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let i=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==i)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:i,hash:e.hash,count:gt(e.count,"Native snapshot omission overflow count")}}function pt(t,e){let i=K(t,e);if(U(i,Pv,e),typeof i.hash!="string"||!or.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let n=ce(i.recordCount,`${e} recordCount`),r=ce(i.storedRecordCount,`${e} storedRecordCount`),o=ce(i.stdoutBytes,`${e} stdoutBytes`);if(r>n||!i.overflow&&r!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,recordCount:n,storedRecordCount:r,stdoutBytes:o,overflow:i.overflow}}function Lu(t){let e=K(t,"Native Git selection evidence");if(U(e,Cv,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let i=pt(e.stageBefore,"Native Git selection stageBefore"),n=pt(e.combined,"Native Git selection combined"),r=pt(e.stageAfter,"Native Git selection stageAfter"),o=pt(e.finalStageBefore,"Native Git selection finalStageBefore"),a=pt(e.finalCombined,"Native Git selection finalCombined"),s=pt(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[i,n,r,o,a,s].some(u=>u.overflow),l=!nr(i,r)||!nr(r,o)||!nr(n,a)||!nr(o,s),f=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==f)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:f,stageBefore:i,combined:n,stageAfter:r,finalStageBefore:o,finalCombined:a,finalStageAfter:s}}function $u(t,e){let i=K(t,e);if(U(i,Rv,e),typeof i.hash!="string"||!or.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean"||typeof i.unstable!="boolean")throw new Error(`${e} flags are invalid`);let n=ce(i.visitedNodeCount,`${e} visitedNodeCount`),r=ce(i.recordCount,`${e} recordCount`),o=ce(i.storedRecordCount,`${e} storedRecordCount`),a=ce(i.encodedBytes,`${e} encodedBytes`);if(o>r||!i.overflow&&o!==r)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,visitedNodeCount:n,recordCount:r,storedRecordCount:o,encodedBytes:a,overflow:i.overflow,unstable:i.unstable}}function zv(t){let e=K(t,"Native physical selection evidence");if(U(e,xv,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let i=$u(e.before,"Native physical selection before"),n=$u(e.after,"Native physical selection after"),r=i.overflow||n.overflow,o=i.unstable||n.unstable||!$v(i,n);if(!r&&!o)throw new Error("Native physical selection evidence must describe an exceptional selection");let a=r&&o?"overflow-and-changed":r?"overflow":"changed";if(e.status!==a)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:a,before:i,after:n}}function Gv(t){let e=K(t,"Native content snapshot manifest");if(U(e,bv,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!Ov.has(e.origin))throw new Error("Native content snapshot origin is invalid");let i;if(e.capture!==void 0){let g=K(e.capture,"Native content snapshot capture");if(U(g,kv,"Native content snapshot capture"),g.provider!=="git"&&g.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let P=g.gitSelection===void 0?void 0:Lu(g.gitSelection),N=g.physicalSelection===void 0?void 0:zv(g.physicalSelection),_=null;if(g.projection!==void 0){let z=K(g.projection,"Native content snapshot projection");if(U(z,Ev,"Native content snapshot projection"),z.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");_={provider:"git",...z.selection===void 0?{}:{selection:Lu(z.selection)}}}if(g.provider==="git"){if(N||_)throw new Error("Native Git capture cannot include physical or projection evidence");i={provider:"git",...P?{gitSelection:P}:{}}}else{if(P)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(N&&_)throw new Error("Native physical-tree capture cannot combine selection and projection");i=_?{provider:"physical-tree",projection:_}:{provider:"physical-tree",...N?{physicalSelection:N}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let n=K(e.limits,"Native content snapshot limits");U(n,Nv,"Native content snapshot limits");let r={maxFiles:gt(n.maxFiles,"Native snapshot maxFiles"),maxFileBytes:gt(n.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:gt(n.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:gt(n.maxManifestBytes,"Native snapshot maxManifestBytes"),...n.maxDurationMs===void 0?{}:{maxDurationMs:gt(n.maxDurationMs,"Native snapshot maxDurationMs")}},o;if(e.policy!==void 0){let g=K(e.policy,"Native snapshot policy");if(U(g,Sv,"Native snapshot policy"),g.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(g.include)||!Array.isArray(g.exclude))throw new Error("Native snapshot policy patterns must be arrays");o=Fv({include:g.include,exclude:g.exclude,hash:g.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let a=e.entries.map(qv),s=e.omitted.map(Wv),c=ce(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:Hv(e.omissionOverflow);if(a.length>r.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(a.some(g=>g.size>r.maxFileBytes)||a.reduce((g,P)=>g+P.size,0)>r.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(a.map(g=>g.path)).size!==a.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>wv||c<s.length)throw new Error("Native content snapshot omission count is invalid");let f=c-s.length;if(f===0&&l||f>0&&l?.count!==f)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let u=s.filter(g=>g.reason==="git-enumeration-limit"),d=s.filter(g=>g.reason==="git-selection-changed");for(let g of[...u,...d])if(g.path!=="."||g.size!==null||g.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(u.length>1||d.length>1)throw new Error("Native Git selection omissions must not be duplicated");let p=i?.provider==="git"?i.gitSelection:i?.projection?.selection,w=p?.status==="overflow"||p?.status==="overflow-and-changed",h=p?.status==="changed"||p?.status==="overflow-and-changed";if(w!==(u.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(h!==(d.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let m=s.filter(g=>g.reason==="physical-enumeration-limit"),y=s.filter(g=>g.reason==="physical-selection-changed");for(let g of[...m,...y])if(g.path!=="."||g.size!==null||g.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(m.length>1||y.length>1)throw new Error("Native physical selection omissions must not be duplicated");let b=i?.physicalSelection,S=b?.status==="overflow"||b?.status==="overflow-and-changed",k=b?.status==="changed"||b?.status==="overflow-and-changed";if(S!==(m.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(k!==(y.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");let E={schema:"comet.native.content-snapshot.v1",origin:e.origin,...i?{capture:i}:{},createdAt:e.createdAt,complete:e.complete,limits:r,...o?{policy:o}:{},entries:a,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}};if(Dv(E)>r.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function Vv(t,e){if(!yv.test(e))throw new Error(`Invalid Native change name: ${e}`);let i=rr.join(t.changesDir,e);if(!ut(t.changesDir,i))throw new Error("Native change path escaped");return rr.join(i,"runtime","baseline-manifest.json")}async function Mu(t,e){let i=Vv(t,e);await de(t.nativeRoot,i);try{let n=await Au({root:t.nativeRoot,file:i,maxBytes:vv,label:"Native baseline snapshot manifest"});return Gv(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}vi();var JE={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};var oC=16*1024;var ze="comet.native.v3",Ge="comet.native.v2",Ve="comet.native.v1";var Fu=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],Uv=new Set(Fu),qu=new Set([...Fu,"minimum_runtime_version","revision"]),Yv=new Set([...qu,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),Xv=new Set(["capability","operation","source","base_hash"]),Qv=new Set(["shape","build","verify","archive"]),Zv=new Set(["implicit","confirmed"]),ey=new Set(["pending","pass","fail"]),wt="comet-state.yaml",_a=/^[a-f0-9]{64}$/u,Wu=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,ty=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,ar=class extends Error{constructor(i,n){super(`Native change ${i} uses ${n}; run comet native doctor ${i} --repair before mutating it`);this.change=i;this.schema=n;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},Ue=class extends Error{constructor(i,n){super(i!==ze||n===null?`Unsupported Native change schema ${i} for runtime protocol ${3}`:`Native change ${i} requires runtime protocol ${n}; current protocol is ${3}`);this.schema=i;this.minimumRuntimeVersion=n;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"};var xC=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
|
|
156
|
-
`);function Ei(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Hu(t,e,i){let n=Object.keys(t).filter(r=>!e.has(r));if(n.length>0)throw new Error(`${i} has unknown field(s): ${n.join(", ")}`)}function sr(t){if(!Wu.test(t))throw new Error(`Invalid Native change name: ${t}`)}function iy(t){if(!Wu.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function zu(t,e){if(t.length===0||Ke.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function ny(t,e){let i=Ei(t,`spec_changes[${e}]`);if(Hu(i,Xv,`spec_changes[${e}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(iy(i.capability),i.operation!=="create"&&i.operation!=="replace"&&i.operation!=="remove")throw new Error(`Invalid spec operation for ${i.capability}`);let n=i.source,r=i.base_hash;if(n!==void 0&&typeof n!="string")throw new Error(`Spec source for ${i.capability} must be a string`);if(typeof n=="string"&&zu(n,`Spec source for ${i.capability}`),i.operation==="create"){if(!n)throw new Error(`Create spec ${i.capability} requires source`);if(r!==null)throw new Error(`Create spec ${i.capability} requires null base_hash`)}else if(i.operation==="replace"){if(!n)throw new Error(`Replace spec ${i.capability} requires source`);if(typeof r!="string"||!_a.test(r))throw new Error(`Replace spec ${i.capability} requires a SHA-256 base_hash`)}else{if(n!==void 0)throw new Error(`Remove spec ${i.capability} forbids source`);if(typeof r!="string"||!_a.test(r))throw new Error(`Remove spec ${i.capability} requires a SHA-256 base_hash`)}return{capability:i.capability,operation:i.operation,...typeof n=="string"?{source:n}:{},base_hash:r}}function ry(t){return/^\d{4}-\d{2}-\d{2}$/u.test(t)?new Date(`${t}T00:00:00.000Z`).toISOString().slice(0,10)===t:!1}function Ta(t,e){if(Hu(t,e,wt),typeof t.name!="string")throw new Error("Native change name is required");if(sr(t.name),t.language!=="en"&&t.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof t.phase!="string"||!Qv.has(t.phase))throw new Error("Native change phase is invalid");if(t.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(t.approval!==null&&!Zv.has(t.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native spec_changes must be an array");let i=t.spec_changes.map(ny),n=i.map(r=>r.capability).filter((r,o,a)=>a.indexOf(r)!==o);if(n.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(n)].join(", ")}`);if(typeof t.verification_result!="string"||!ey.has(t.verification_result))throw new Error("Native verification_result is invalid");if(t.verification_report!==null&&typeof t.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof t.verification_report=="string"&&zu(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!ry(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:i,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function Gu(t){let e=Ei(t,wt);if(e.schema!==Ve)throw new Error(`Expected ${Ve}`);return{schema:Ve,...Ta(e,Uv)}}function ki(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Ra(t,e,i){if(t===null)return null;let n=typeof t=="string"?ty.exec(t):null;if(!n||n[1]!==i)throw new Error(`${e} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return t}function oy(t){if(t==null)return null;if(typeof t!="string"||!_a.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function ay(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function Vu(t){let e=Ei(t,wt);if(e.schema!==Ge)throw new Error(`Expected ${Ge}`);if(ki(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Ge} minimum_runtime_version must be 2`);return{schema:Ge,minimum_runtime_version:2,revision:ki(e.revision,"Native v2 revision"),...Ta(e,qu)}}function sy(t){let e=Ei(t,wt);if(e.schema!==ze){if(e.schema===Ve||e.schema===Ge){let a=e.schema===Ve?Gu(e):Vu(e);throw new ar(a.name,a.schema)}throw new Ue(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let i=ki(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new Ue(e.schema,i);if(i!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let n=ki(e.revision,"Native revision"),r=Ta(e,Yv),o=oy(e.approved_contract_hash);if(r.approval===null&&o!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:ze,minimum_runtime_version:3,revision:n,verification_protocol:ay(e.verification_protocol),...r,approved_contract_hash:o,implementation_scope:Ra(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Ra(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Ra(e.partial_allowance,"Native partial_allowance","allowances")}}function cy(t){let e=Ei(t,wt);if(e.schema===Ve){let r=Gu(e);return{status:"migration-required",schema:r.schema,minimumRuntimeVersion:1,state:r,message:`Native change ${r.name} requires migration to ${ze}`}}if(e.schema===Ge){let r=Vu(e);return{status:"migration-required",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r,message:`Native change ${r.name} requires migration to ${ze}`}}if(e.schema!==ze){let r=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:r,state:null,message:new Ue(typeof e.schema=="string"?e.schema:"(missing)",r).message}}let i=ki(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:i,state:null,message:new Ue(e.schema,i).message};let n=sy(e);return{status:"current",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n}}function Ju(t,e){sr(e);let i=Ke.join(t.changesDir,e);if(!ut(t.changesDir,i))throw new Error("Native change path escaped");return i}async function ly(t,e){let i=Ke.join(Ju(t,e),"runtime","schema-migration.json");await de(t.nativeRoot,i);try{return await Kv.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}var uy=256*1024;async function fy(t,e=Ke.dirname(t)){let i=Ke.relative(e,t).split(Ke.sep).join("/"),n=await Ea({root:e,ref:i,maxBytes:uy}),r=(0,Aa.parseDocument)(n.text,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Invalid Native change file ${t}: ${r.errors[0].message}`);return r.toJS()}async function dy(t,e){let i=Ke.join(Ju(t,e),wt);await de(t.nativeRoot,i);let n=cy(await fy(i,t.nativeRoot));if(n.state&&n.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await ly(t,e)?{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimumRuntimeVersion,state:n.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(n.status==="current"&&n.state&&await hy(t,n.state),n)}async function hy(t,e){if(await Mu(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function cr(t,e){let i=await dy(t,e);if(i.status==="migration-required")throw new ar(e,i.schema);if(i.status==="runtime-incompatible"||!i.state)throw new Ue(i.schema,i.minimumRuntimeVersion);return i.state}var IC=16*1024;async function my(t){let e=await ht(t.projectRoot);return e.status==="missing"||e.selection.workflow!=="native"?null:(sr(e.selection.change),e.selection)}async function Ku(t){let e=await my(t);return e?(await cr(t,e.change),e.change):null}function lr(t,e){let i=vt.relative(t,e);return i===""||!i.startsWith("..")&&!vt.isAbsolute(i)}function gy(t,e,i){return i.targets.length>0&&i.targets.every(n=>{let r=vt.resolve(t,n);return lr(t,r)?vt.relative(t,r).replaceAll("\\","/")===".comet/config.yaml"||lr(e,r):!0})}async function wy(t){let e=await Zn(t);if(!e||!(e.workflows??[e.default_workflow]).includes("native"))return null;let i=await Xo(t,e.native.artifact_root),n;try{n=await py.readdir(i.changesDir,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return{paths:i,changes:[]};throw o}let r=[];for(let o of n.sort((a,s)=>a.name.localeCompare(s.name))){if(!o.isDirectory()||o.isSymbolicLink())continue;let a=await cr(i,o.name);a.archived||r.push(a)}return{paths:i,changes:r}}var Uu=Q("nativeActiveContext",t=>wy(t));async function Yu(t){return((await Uu(t))?.changes??[]).map(i=>({workflow:"native",name:i.name,phase:i.phase}))}async function Xu(t,e,i){let n=await Uu(t);if(!n)return{allowed:!0,reason:"Native workflow is not enabled"};if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(n.changes.length===0)return{allowed:!0,reason:gy(t,n.paths.nativeRoot,e)?"Native control artifact write":"No Native changes exist"};let r;if(i){if(r=n.changes.find(s=>s.name===i),!r)return{allowed:!1,reason:`Selected Native change ${i} is missing or archived; resume /comet-native before retrying`,workflow:"native",change:i}}else if(n.changes.length===1)r=n.changes[0];else{let s=await Ku(n.paths);if(r=n.changes.find(c=>c.name===s),!r)return{allowed:!1,reason:"Multiple Native changes are active; select the change to resume before writing code",workflow:"native"}}if(r.phase==="build")return{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:r.phase,change:r.name};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!1,reason:`Hook write target could not be determined while Native change ${r.name} is in ${r.phase}; resume /comet-native before retrying`,workflow:"native",phase:r.phase,change:r.name};let o=!1,a=!1;for(let s of e.targets){let c=vt.resolve(t,s);if(!lr(t,c)){a=!0;continue}if(vt.relative(t,c).replaceAll("\\","/")===".comet/config.yaml"||lr(n.paths.nativeRoot,c)){o=!0;continue}return{allowed:!1,reason:`Native change ${r.name} is in ${r.phase}; implementation writes are only allowed in build. Resume /comet-native to continue safely`,workflow:"native",phase:r.phase,change:r.name}}return{allowed:!0,reason:o?"Native control artifact write":a?"Write target is outside the guarded project":"No guarded write target was provided",workflow:"native",phase:r.phase,change:r.name}}Be();var Qu=Q("readWorkflowProjectConfig",t=>ea(t)),JC=Q("discoverNativeProject",t=>ti(t));var vy=Q("readCometCurrentSelection",t=>ht(t)),tf={listNative:Yu,listClassic:Nu,inspectNative:Xu,inspectClassic:Pu};function yy(t){return t?t.workflows??[t.default_workflow]:["classic"]}async function Zu(t,e,i,n){let[r,o]=await Promise.all([e.includes("native")?n?.workflow==="native"?n.candidates:i.listNative(t):[],e.includes("classic")?n?.workflow==="classic"?n.candidates:i.listClassic(t):[]]);return[...r,...o]}function ef(t,e){return t.length===0?{status:"none",staleSelection:e}:t.length===1?{status:"inferred",owner:t[0],staleSelection:e}:{status:"ambiguous",candidates:t,staleSelection:e}}async function by(t,e=tf){let i=await Qu(t),n=yy(i),r;try{r=await vy(t)}catch(o){return{status:"stale",code:"selection-unreadable",reason:o instanceof Error?o.message:String(o)}}if(r.status==="selected"){let o=r.selection;if(!n.includes(o.workflow))return{status:"stale",code:"workflow-disabled",reason:`selected workflow '${o.workflow}' is not enabled for this project`};let a;try{a=o.workflow==="native"?await e.listNative(t):await e.listClassic(t)}catch(c){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${c instanceof Error?c.message:String(c)}`}}let s=a.find(c=>c.name===o.change);if(!s){let c={code:"target-missing",reason:`selected ${o.workflow} change '${o.change}' is missing or archived`};try{let l=await Zu(t,n,e,{workflow:o.workflow,candidates:a});return ef(l,c)}catch(l){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${l instanceof Error?l.message:String(l)}`}}}if(o.workflow==="classic"){let c=await Un(t);if(c.status!=="selected")return{status:"stale",code:"classic-selection-invalid",reason:c.status==="stale"?c.reason:`selected Classic change '${o.change}' is no longer active`}}return{status:"owned",owner:s}}try{let o=await Zu(t,n,e);return ef(o)}catch(o){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${o instanceof Error?o.message:String(o)}`}}}async function nf(t,e,i=tf){if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};try{let n=await by(t,i);if(n.status==="none")return{allowed:!0,reason:"No active Comet change"};if(n.status==="stale")return{allowed:!1,reason:`${n.reason}. Resume /comet-native or /comet-classic and select the current change before retrying`};if(n.status==="ambiguous")return{allowed:!1,reason:`Multiple active Comet changes require one current selection: ${n.candidates.map(o=>`${o.workflow}:${o.name}`).join(", ")}`};let r=n.owner;return r.workflow==="native"?i.inspectNative(t,e,r.name):i.inspectClassic(t,r.name,e)}catch(n){return{allowed:!1,reason:`Comet Hook Router failed closed: ${n instanceof Error?n.message:String(n)}`}}}var Ny="Usage: comet-hook-router --platform <platform-id> [--project-root <project-root>]";function Sy(t){let e,i;for(let n=0;n<t.length;n++){let r=t[n];if(r==="--platform"){e=t[++n];continue}if(r==="--project-root"){i=t[++n];continue}throw new Error(`Unknown argument: ${r}`)}if(!e||e.startsWith("--"))throw new Error("--platform is required");if(!aa.has(e))throw new Error(`unsupported Hook platform: ${e}`);if(i?.startsWith("--"))throw new Error("--project-root requires a value");return{platformId:e,...i?{projectRoot:of.resolve(i)}:{}}}async function ky(t){if(t.projectRoot)return t.projectRoot;let e=await ti(process.cwd());for(let r of[[".comet","config.yaml"],[".git"]])try{return await rf.lstat(of.join(e,...r)),e}catch(o){if(o.code!=="ENOENT")throw o}let i=await Ll(process.cwd()),n=await Fe(i);try{return await rf.lstat(n.changesDir),i}catch(r){if(r.code!=="ENOENT")throw r}return null}async function Ey(t){let e;try{e=Sy(t)}catch(r){return process.stderr.write(`${r instanceof Error?r.message:String(r)}
|
|
157
|
-
${Ny}
|
|
158
|
-
`)
|
|
146
|
+
`}}var wi=null;async function nu(t){if(wi!==null)return t();wi={entries:new Map};try{return await t()}finally{wi=null}}function ou(t,e){let i=t;for(let r of e)i+="\0"+(typeof r=="string"?r:JSON.stringify(r));return i}function K(t,e){return(...i)=>{let r=wi;if(r===null)return e(...i);let n=ou(`async:${t}`,i),o=r.entries.get(n);if(o)return o.value;let a=e(...i).catch(s=>{throw r.entries.delete(n),s});return r.entries.set(n,{value:a}),a}}function Na(t,e){return(...i)=>{let r=wi;if(r===null)return e(...i);let n=ou(`sync:${t}`,i),o=r.entries.get(n);if(o)return o.value;let a=e(...i);return r.entries.set(n,{value:a}),a}}import{promises as on,readFileSync as EE}from"fs";import J from"path";import su from"path";Ge();ue();we();import vi from"path";var Hk=2*1024*1024;function fw(t,e,i){let r=vi.resolve(t),n=vi.isAbsolute(e)?vi.resolve(e):vi.resolve(r,e),o=vi.relative(r,n).replaceAll("\\","/");return{root:r,relative:ai(o,i),target:n}}async function bt(t,e,i){let r=fw(t,e,i.label);return G(r.root,r.relative,i)}async function au(t,e,i){return(await bt(t,e,{label:i.label,expected:i.expected??"any"})).exists}function ka(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}'
|
|
147
|
+
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function Sa(t){let e=ka(t);if(e)throw new Error(e)}function dw(t,e){return{label:M(t,e),directory:e}}async function hw(t,e,i){let r=dw(t,e);if(!(await bt(t,e,{label:i,expected:"directory"})).exists)return{change:r,exists:!1,stateExists:!1};let o=await bt(t,su.join(e,".comet.yaml"),{label:`${i} state`,expected:"file"});return{change:r,exists:!0,stateExists:o.exists}}async function yi(t,e=process.cwd()){Sa(t);let i=await ye(e),r=await hw(i.projectRoot,su.join(i.changesDir,t),`Classic active change ${t}`);return{...r.change,exists:r.exists,stateExists:r.stateExists}}import{promises as Ea}from"fs";import z from"path";function cu(t,e){let i=z.relative(t,e);return i===""||i!==".."&&!i.startsWith(`..${z.sep}`)&&!z.isAbsolute(i)}async function mw(t){let e=z.resolve(t),i=z.parse(e).root,r=[],n=e;for(;n&&n!==i;)try{let o=await Ea.realpath(n);return z.join(o,...r.reverse())}catch(o){let a=o.code;if(a!=="ENOENT"&&a!=="ENOTDIR")throw o;r.push(z.basename(n)),n=z.dirname(n)}try{let o=await Ea.realpath(i);return z.join(o,...r.reverse())}catch{return null}}async function Kr(t,e){let i=z.resolve(t),r=await Ea.realpath(i),n=[],o=[];for(let a of e){let s=z.isAbsolute(a)?z.resolve(a):z.resolve(i,a),c=await mw(s);((c?cu(r,c):cu(i,s))?n:o).push(a)}return{projectTargets:n,externalTargets:o}}var Ca=xt(mt(),1);import{execFileSync as lu}from"child_process";import{randomUUID as pw}from"crypto";import{promises as bi}from"fs";import uu from"path";function gw(t){try{let e=lu("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return e&&e!=="HEAD"?e:null}catch{return null}}var ww=Na("liveGitBranch",t=>gw(t));function vw(t){try{return lu("git",["rev-parse","--is-inside-work-tree"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()==="true"}catch{return!1}}var yw=Na("isGitWorkTree",t=>vw(t)),bw=["current","branch","worktree"];function fu(t){return bw.includes(t)}function Nw(t){return fu(t.isolation)?t.boundBranch===null&&t.currentBranch===null&&t.gitWorkTree===!1?{status:"not-applicable"}:t.boundBranch===null?t.currentBranch===null?{status:"unbound-detached"}:{status:"needs-heal",branch:t.currentBranch}:t.currentBranch===t.boundBranch?{status:"ok"}:{status:"drift",boundBranch:t.boundBranch,currentBranch:t.currentBranch}:{status:"not-applicable"}}async function Jr(t,e){let i=uu.join(t,".comet.yaml"),r=(0,Ca.parseDocument)(await bi.readFile(i,"utf8"),{uniqueKeys:!1});if(r.errors.length>0)throw new Error(`Invalid .comet.yaml: ${r.errors[0].message}`);let n=r.toJS()??{},o=typeof n.isolation=="string"?n.isolation:null,a=typeof n.bound_branch=="string"&&n.bound_branch!==""?n.bound_branch:null,s=fu(o),c=ww(e.cwd),l=s&&a===null&&c===null?yw(e.cwd):!0,f=Nw({isolation:o,boundBranch:a,currentBranch:c,gitWorkTree:l});return f.status==="needs-heal"&&e.heal?(await kw(t,f.branch),{status:"healed",branch:f.branch,bindingRequired:s,currentBranch:c}):{...f,bindingRequired:s,currentBranch:c}}async function kw(t,e){let i=uu.join(t,".comet.yaml"),r=(0,Ca.parseDocument)(await bi.readFile(i,"utf8"),{uniqueKeys:!1});r.set("bound_branch",e);let n=`${i}.${pw()}.tmp`;try{await bi.writeFile(n,r.toString(),"utf8"),await bi.rename(n,i)}catch(o){throw await bi.rm(n,{force:!0}),o}}function Sw(t){return t??"detached HEAD"}function Ur(t,e,i){return`change '${t}' is bound to branch '${e}', but current branch is '${Sw(i)}'`}function Yr(t){return`change '${t}' uses a branch-bound workspace mode but has no bound branch and HEAD is detached; checkout a branch first before continuing.`}Mr();import Ew from"path";var Pa="comet.selection.v2",Cw=16*1024;function xa(t){return Ew.join(t,".comet","current-change.json")}function Pw(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function du(t){return t===null||typeof t=="string"}function xw(t){let e;try{e=JSON.parse(t)}catch(i){throw new Error(`current change selection contains invalid JSON: ${i instanceof Error?i.message:String(i)}`,{cause:i})}if(!Pw(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!du(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:Pa,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==Pa)throw new Error(`current change selection schema must be ${Pa}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!du(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function Nt(t){let e;try{let r=xa(t),{bytes:n}=await hi(r,Cw,{label:"current change selection"});e=n.toString("utf8")}catch(r){if(r.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${r instanceof Error?r.message:String(r)}`,{cause:r})}return{status:"selected",...xw(e)}}var tn=xt(mt(),1);Ge();we();import en from"path";Ei();var Ia=["full","hotfix","tweak"],Ru=1,Au=["open","design","build","verify","archive"],Ww=["en","zh-CN"],qw=["off","beta"],Hw=["subagent-driven-development","executing-plans","direct"],Gw=["plan-ready"],zw=["confirmed"],Vw=["tdd","direct"],Kw=["off","standard","thorough"],Jw=["current","branch","worktree"],Uw=["light","full"],Yw=["pending","pass","fail"],Xw=["pending","handled"],Qw=["pending","confirmed"],ja=["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","verification_report","branch_status","created_at","verified_at","archive_confirmation","archived","direct_override","handoff_context","handoff_hash","classic_profile","classic_migration"],Zw=["run_id"],Tu=new Set([...ja,...Zw]),ev=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function _u(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function kt(t,e){let i=t[e];if(i==null||i==="")return null;if(typeof i!="string")throw new Error(`Invalid Classic state: ${e} must be a string or null`);return i}function F(t,e,i,r=!0){let n=t[e];if(n==null||n===""){if(r)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof n!="string"||!i.includes(n))throw new Error(`Invalid Classic state: ${e} must be one of ${i.join(", ")}${r?" or null":""}`);return n}function Oa(t,e,i=!0){let r=t[e];if(r==null||r===""){if(i)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 tv(t,e,i=0){let r=t[e];if(r==null||r==="")return i;if(typeof r!="number"||!Number.isInteger(r)||r<0)throw new Error(`Invalid Classic state: ${e} must be a non-negative integer`);return r}function Zr(t,e){let i=kt(t,e);if(i===null)return null;if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(i)||i.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Classic state: ${e} must be a relative repository path`);return i}function iv(t,e){let i=kt(t,e);if(i!==null&&!/^[a-f0-9]{64}$/u.test(i))throw new Error(`Invalid Classic state: ${e} must be a sha256 hex digest`);return i}function rv(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==Ru)throw new Error(`Invalid Classic state: classic_migration must be ${Ru}`);return e}function nv(t){if(!ja.some(i=>_u(t,i)))return null;for(let i of ev)if(!_u(t,i))return null;return{workflow:F(t,"workflow",Ia,!1),language:F(t,"language",Ww),phase:F(t,"phase",Au,!1),contextCompression:F(t,"context_compression",qw),buildMode:F(t,"build_mode",Hw),buildPause:F(t,"build_pause",Gw),subagentDispatch:F(t,"subagent_dispatch",zw),tddMode:F(t,"tdd_mode",Vw),reviewMode:F(t,"review_mode",Kw),isolation:F(t,"isolation",Jw),boundBranch:kt(t,"bound_branch"),verifyMode:F(t,"verify_mode",Uw),autoTransition:Oa(t,"auto_transition"),baseRef:kt(t,"base_ref"),designDoc:Zr(t,"design_doc"),plan:Zr(t,"plan"),verifyResult:F(t,"verify_result",Yw,!1),verifyFailures:tv(t,"verify_failures"),verificationReport:Zr(t,"verification_report"),branchStatus:F(t,"branch_status",Xw),createdAt:kt(t,"created_at"),verifiedAt:kt(t,"verified_at"),archiveConfirmation:F(t,"archive_confirmation",Qw),archived:Oa(t,"archived",!1),directOverride:Oa(t,"direct_override"),handoffContext:Zr(t,"handoff_context"),handoffHash:iv(t,"handoff_hash"),classicProfile:F(t,"classic_profile",Ia),classicMigration:rv(t)}}function Ou(t,e){let i=e??null;if(i===null&&e===void 0&&t.run_id&&t.skill)try{i=Si(t)}catch(r){let n=r instanceof Error?r.message:String(r);throw new Error(n.replace(/^Invalid Run state:/u,"Invalid Classic state:"),{cause:r})}return{classic:nv(t),run:i,unknownKeys:Object.keys(t).filter(r=>!Tu.has(r))}}function Iu(t){let e=t.workflow,i=t.phase,r=t.archived,n=t.design_doc;return{workflow:typeof e=="string"&&Ia.includes(e)?e:null,phase:typeof i=="string"&&Au.includes(i)?i:null,archived:r===!0,designDoc:typeof n=="string"&&n!==""?n:null,unknownKeys:Object.keys(t).filter(o=>!Tu.has(o))}}Ei();var ov=2*1024*1024;function Ci(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 av(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 i of e)t.delete(i)}function sv(t){let e=!1;for(let i of["build_command","verify_command"])t.has(i)&&(t.delete(i),e=!0);return e}async function ju(t){let e;try{e=(await te(en.dirname(t),en.basename(t),ov,{label:"Classic state document"})).bytes.toString("utf8")}catch(r){if(r.code!=="ENOENT")throw r;return new tn.Document({})}let i=(0,tn.parseDocument)(e);if(i.errors.length>0)throw new Error(`Invalid Classic state document: ${i.errors[0].message}`);return Ci(i),i}async function rn(t,e={}){let i=e.migrate!==!1,r=en.join(t,".comet.yaml"),n=await ju(r),o=Ci(n),a=sv(n);a&&(o=Ci(n));let s=await Aa(t);if(!s&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(Ei(),xu));s=c(o),s&&i&&(await Ta(t,s),av(n),a=!0)}return a&&i&&await ve(r,n.toString(),{containedRoot:t}),Ou(Ci(n),s)}async function Lu(t){let e=await ju(en.join(t,".comet.yaml"));return Iu(Ci(e))}var fv=K("readCometCurrentSelection",t=>Nt(t));async function dv(t,e){Sa(e);let i=await yi(e,t);if(!i.stateExists)throw new Error(`Cannot select current change '${e}': active change state not found`);let r=await rn(i.directory,{migrate:!1});if(!r.classic)throw new Error(`Cannot select current change '${e}': Classic state is incomplete`);if(r.classic.archived)throw new Error(`Cannot select current change '${e}': change is archived`);return i.directory}async function nn(t){let e;try{e=await fv(t)}catch(o){return{status:"stale",reason:o instanceof Error?o.message:String(o)}}if(e.status==="missing")return{status:"missing"};if(e.selection.workflow!=="classic")return{status:"stale",reason:`current change '${e.selection.change}' belongs to Native, not Classic`};let i=e.selection,r;try{r=await dv(t,i.change)}catch(o){return{status:"stale",reason:o instanceof Error?o.message:String(o)}}let n=await Jr(r,{heal:!1,cwd:t});return n.status==="drift"?{status:"stale",reason:Ur(i.change,n.boundBranch,n.currentBranch)}:n.status==="unbound-detached"?{status:"stale",reason:Yr(i.change)}:n.status==="ok"?{status:"selected",selection:i}:i.branch!==null&&n.currentBranch!==i.branch?{status:"stale",reason:`current change '${i.change}' was selected on branch '${i.branch}', current branch is '${n.currentBranch??"detached HEAD"}'`}:{status:"selected",selection:i}}import Ke from"node:path";async function $u(t,e){if(!e||e==="null")return{status:"missing",recordedPath:null};let i=await ye(t),r=Ke.resolve(t,e),n=Ke.relative(i.superpowersPlansDir,r);return Ke.isAbsolute(e)||!n||n.startsWith(`..${Ke.sep}`)||Ke.isAbsolute(n)||n.includes(Ke.sep)||Ke.extname(n).toLowerCase()!==".md"?{status:"broken",recordedPath:e}:await au(t,e,{label:`Classic build plan ${e}`,expected:"file"})?{status:"ready",recordedPath:e}:{status:"broken",recordedPath:e}}function ie(t,e){return{exitCode:t,stderr:e+`
|
|
148
|
+
`}}function be(t){return ie(0,`[COMET-HOOK] allowed: ${t}`)}function xi(t){return t.replaceAll("\\","/").replace(/\/+/gu,"/")}function Je(t){let e=xi(t);return process.platform==="win32"?e.toLowerCase():e}function Du(t,e){let i=xi(J.relative(e,t));return i===""?"":i.startsWith("../")||i===".."||J.isAbsolute(i)?null:i}async function hv(t){let e=J.resolve(t),i=J.parse(e).root,r=[],n=e;for(;n&&n!==i;)try{let o=await on.realpath(n);return J.join(o,...r.reverse())}catch(o){let a=o.code;if(a!=="ENOENT"&&a!=="ENOTDIR")throw o;r.push(J.basename(n)),n=J.dirname(n)}try{let o=await on.realpath(i);return J.join(o,...r.reverse())}catch{return null}}async function mv(t,e){let i=J.isAbsolute(t)?t:J.resolve(e,t),r=xi(i),n=Du(i,e);if(n!==null)return n;try{let o=await hv(i),a=await on.realpath(e);if(o){let s=Du(o,a);if(s!==null)return s;r=xi(o)}}catch{if(!J.isAbsolute(t))return xi(t).replace(/^\.\//u,"")}return r.replace(/^\.\//u,"")}async function Wu(t){try{let e=await rn(t,{migrate:!1}),i=Array.from(new Set(e.unknownKeys)).sort();if(i.length>0)throw new Error(`Invalid Classic state: unknown field(s): ${i.join(", ")}`);if(!e.classic)throw new Error("Classic state projection is unavailable");return{changeDir:t,phase:e.classic.phase,classic:e.classic,archived:e.classic.archived}}catch(e){let i=await Lu(t);return i.phase?{changeDir:t,phase:i.phase,classic:null,archived:i.archived,invalidState:e instanceof Error&&e.message.includes("unknown field")}:null}}async function pv(t){let e=(await ye(t)).changesDir,i=[];if(!(await bt(t,e,{label:"Classic changes directory",expected:"directory"})).exists)return i;for(let n of(await on.readdir(e,{withFileTypes:!0})).sort((o,a)=>o.name.localeCompare(a.name))){if(n.name==="archive"||ka(n.name))continue;let o=await yi(n.name,t);if(!o.exists||!o.stateExists)continue;let a=await Wu(o.directory);!a||a.archived||i.push(a)}return i}var Ri=K("classicActiveChanges",t=>pv(t)),qu=K("classicPlanReadiness",$u);async function Hu(t){return(await Ri(t)).map(e=>({workflow:"classic",name:re(e),phase:e.phase}))}function Gu(t,e){return`${M(t,e.superpowersRoot)}/`}function zu(t,e){return Je(t).startsWith(Je(e))}function gv(t,e){return[{prefix:`${M(t,e.superpowersSpecsDir)}/`,field:"designDoc",wireField:"design_doc",phase:"design"},{prefix:`${M(t,e.superpowersPlansDir)}/`,field:"plan",wireField:"plan",phase:"build"},{prefix:`${M(t,e.superpowersReportsDir)}/`,field:"verificationReport",wireField:"verification_report",phase:"verify"}]}function wv(t,e){let i=Je(t),r=e.find(o=>i.startsWith(Je(o.prefix)));if(!r)return null;let n=i.slice(Je(r.prefix).length);return!n||n.includes("/")||!n.endsWith(".md")?null:r}function Vu(t,e){return t.classic?.[e.field]??null}function vv(t,e){return t.classic!==null&&t.phase===e.phase&&!Vu(t,e)}async function Bu(t,e,i){return vv(e,i)?!0:i.field!=="plan"||e.phase!=="build"?!1:(await qu(t,e.classic?.plan??null)).status==="broken"}function Ku(t){return t.phase==="design"||t.phase==="build"||t.phase==="verify"}function re(t){return t.changeDir?J.basename(t.changeDir):null}var yv=new Set(["design","plan","verify","verification","verification-report","report"]);function Mu(t){return t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}function bv(t,e){return[e.classic?.designDoc,e.classic?.plan,e.classic?.verificationReport].some(r=>r&&Je(r)===Je(t))}function Nv(t,e){let r=(t.split("/").at(-1)??t).replace(/\.[^.]+$/u,"");if(r===e)return!0;let n=[...yv].map(Mu).join("|");return new RegExp(`(^|[-_.])${Mu(e)}[-_.](${n})$`,"u").test(r)}async function kv(t,e){let i=await Ri(e),r=i.find(a=>bv(t,a));if(r)return{governing:r,match:"recorded"};let o=i.filter(Ku).filter(a=>{let s=re(a);return s!==null&&Nv(t,s)}).sort((a,s)=>(re(s)?.length??0)-(re(a)?.length??0))[0];return o?{governing:o,match:"named"}:null}async function Fu(t,e,i){let r=await Ri(t);if(r.length===0)return null;if(i)return r.find(a=>re(a)===i)??{blockedResult:Pi(e,`selected change '${i}' is no longer active`)};let n=await nn(t);if(n.status==="stale")return{blockedResult:Pi(e,n.reason)};if(n.status==="selected"){let o=r.find(a=>re(a)===n.selection.change);return o||{blockedResult:Pi(e,`selected change '${n.selection.change}' is no longer active`)}}if(r.length===1){let o=r[0];if(o.changeDir!==null){let a=await Jr(o.changeDir,{heal:!1,cwd:t}),s=re(o)??"unknown";if(a.status==="drift")return{blockedResult:Pi(e,Ur(s,a.boundBranch,a.currentBranch))};if(a.status==="unbound-detached")return{blockedResult:Pi(e,Yr(s))}}return o}return{blockedResult:Ov(e,r.map(o=>re(o)).filter(Boolean))}}async function Sv(t,e,i,r){let n=`${M(e,i.changesDir)}/`;if(t.startsWith(n)){let o=t.slice(n.length),[a]=o.split("/");if(a&&a!=="archive"){let s=await yi(a,e);if(s.stateExists){let c=await Wu(s.directory);return c||{changeDir:s.directory,phase:"open",classic:null,archived:!1}}return{changeDir:s.directory,phase:"open",classic:null,archived:!1}}}if(zu(t,Gu(e,i))){let o=await kv(t,e);if(o?.match==="recorded")return{...o.governing,superpowersArtifact:"matched"};let a=wv(t,gv(e,i));if(o)return a?{...o.governing,superpowersArtifact:await Bu(e,o.governing,a)?"matched":"unmatched",superpowersSlot:a}:{...o.governing,superpowersArtifact:"matched"};if(a){let l=await Fu(e,t,r);return!l||"blockedResult"in l?l:{...l,superpowersArtifact:await Bu(e,l,a)?"matched":"unmatched",superpowersSlot:a}}let s=await Ri(e),c=r?s.find(l=>re(l)===r)??null:s[0]??null;return c?{...c,superpowersArtifact:"unmatched"}:null}return Fu(e,t,r)}function Ev(t){return!t.includes("/")&&t.endsWith(".md")}function Cv(t){return t.startsWith(".comet/")||t.includes("/.comet/")}function Pv(t){return t===".superpowers"||t.startsWith(".superpowers/")}function xv(t,e,i){if(!t.startsWith(i))return null;let r=t.endsWith("/.comet.yaml")||t.endsWith("/.openspec.yaml"),n=t.endsWith("/proposal.md")||t.endsWith("/design.md")||t.endsWith("/tasks.md"),o=t.includes("/.comet/"),a=t.includes("/specs/");return e==="open"&&(n||r||o||a)?`${t} (phase: open, openspec artifacts)`:e==="design"&&(n||r||o||a)?`${t} (phase: design, handoff/spec)`:e==="build"&&(t.endsWith("/tasks.md")||r||a)?`${t} (phase: build, spec/tasks)`:e==="verify"&&(t.endsWith("/tasks.md")||r)?`${t} (phase: verify, tasks/state)`:e==="archive"&&r?`${t} (phase: archive, state)`:null}function Rv(t,e){let i=e==="open"?[" BLOCKED: source writes are not allowed during open"," This phase does not allow source writes"," ALLOWED: create proposal/design/tasks artifacts and run guard"," NEXT: finish clarification and artifacts, then run guard --apply"]:e==="design"?[" BLOCKED: source writes are not allowed during design"," This phase does not allow source writes"," ALLOWED: run brainstorming, create the Design Doc, and run guard"," NEXT: finish the Design Doc, then run comet guard <change-name> design --apply to enter build"]:[" BLOCKED: source writes are not allowed during archive"," This phase does not allow source writes"," ALLOWED: confirm archive state and run the archive script"];return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝","",` Current phase: ${e}`,` Target file: ${t}`,"",...i,""].join(`
|
|
149
|
+
`))}function _v(t){return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝",""," Current phase: build (workflow: full), but design_doc is empty",` Target file: ${t}`,""," BLOCKED: full workflow source writes require a recorded Design Doc"," This phase does not allow source writes until design_doc is recorded"," NEXT: return to design, create/link the Design Doc, then run guard again",""].join(`
|
|
150
|
+
`))}function Av(t,e,i,r,n){let o=re(e)??"<change-name>",a=i.status==="missing",s=a?"classic-build-plan-missing":"classic-build-plan-broken",c=a?"plan is not recorded":"the recorded plan path does not resolve to a file",l=a?[]:[`RECORDED_PLAN: ${i.recordedPath}`],f=e.changeDir?M(r,e.changeDir):"<classic-change-dir>",u=M(r,n.superpowersPlansDir),d=a?`comet state set ${o} plan <repository-relative-plan-path>`:`comet state set ${o} plan <new-repository-relative-plan-path>`,m=a?["2. Load the Superpowers writing-plans Skill.",`3. Read the Design Doc path from "comet state get ${o} design_doc" and read ${f}/tasks.md.`,`4. Create the implementation plan under ${u}/.`,"5. Record the plan path:",` ${d}`]:[`2. Restore the plan file at ${i.recordedPath}, or load the Superpowers writing-plans Skill and create a replacement under ${u}/.`,"3. When creating a replacement, record its path:",` ${d}`];return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝","",`ERROR_CODE: ${s}`,`CHANGE: ${o}`,"WORKFLOW: full","PHASE: build",`TARGET: ${t}`,`STATE: ${c}`,...l,"","BLOCKED: project source writes require a ready Superpowers implementation plan.","","ALLOWED_RECOVERY_WRITES:",`- ${u}/<plan-file>.md`,"- Comet state updates performed by the comet CLI",`- ${f} artifacts allowed by the build phase`,"","RECOVERY:",`1. Invoke /comet-build for ${o} and resume Step 1.`,...m,`${a?"6":"4"}. Verify recovery:`,` comet state check ${o} build --recover`,"","SUCCESS: plan is reported as DONE and recovery advances beyond plan creation.",`RETRY: retry the original Write/Edit for ${t} only after SUCCESS.`,"PROHIBITED: do not treat tasks.md as the implementation plan or write project source before SUCCESS.","If writing-plans is unavailable, stop and report the missing Skill instead of bypassing this check.",""].join(`
|
|
151
|
+
`))}function Tv(t,e){let i=e.superpowersSlot,r=i?Vu(e,i):null,n=i?e.phase!==i.phase?[` BLOCKED: ${i.wireField} cannot be first-written in phase ${e.phase}`,` Expected phase: ${i.phase}`," NEXT: resume the matching Comet phase or use an already recorded artifact path"]:r?[` BLOCKED: ${i.wireField} is already recorded for this change`,` Recorded path: ${r}`," NEXT: write the recorded artifact or explicitly correct the state path"]:[" BLOCKED: standard Superpowers artifact state is incomplete"," NEXT: validate the active change state, then retry the matching phase"]:[" BLOCKED: unmatched Superpowers artifact"," This docs/superpowers/ path does not match any active change artifact"," NEXT: use a recorded artifact path or a standard phase artifact directory"];return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝","",` Current phase: ${e.phase}`,` Target file: ${t}`,"",...n,""].join(`
|
|
152
|
+
`))}function Ov(t,e){return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝",""," BLOCKED: multiple active changes require a current change",` Target file: ${t}`,` Active changes: ${e.join(", ")}`,""," NEXT: run comet state select <change-name>, then retry the source write",""].join(`
|
|
153
|
+
`))}function Pi(t,e){return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝",""," BLOCKED: current change selection is stale or invalid",` Target file: ${t}`,` Reason: ${e}`,""," NEXT: run comet state select <change-name>, then retry the source write",""].join(`
|
|
154
|
+
`))}async function Iv(t,e,i,r=Kr){try{if((await r(t,[e])).projectTargets.length===0)return be(`${e} (outside guarded project)`)}catch(l){return ie(2,[`[COMET-HOOK] blocked: scope could not be determined safely for ${e}.`,`REASON: ${l instanceof Error?l.message:String(l)}`,"NEXT: verify that the project root is accessible, then retry the write."].join(`
|
|
155
|
+
`))}let n=await mv(e,t),o;try{o=await Vr(t)}catch(l){return ie(2,`[COMET-HOOK] blocked: ${l instanceof Error?l.message:String(l)}`)}if(Cv(n))return be(`${n} (whitelist: comet config)`);if(Pv(n))return be(`${n} (whitelist: superpowers workspace)`);if(n==="CLAUDE.md"||n==="CHANGELOG.md"||n==="README.md"||Ev(n))return be(`${n} (whitelist: root markdown)`);let a;try{a=await Sv(n,t,o,i)}catch(l){return ie(2,`[COMET-HOOK] blocked: ${l instanceof Error?l.message:String(l)}`)}if(!a)return be("no active comet change");if("blockedResult"in a)return a.blockedResult;if(a.archived)return be(`${n} (own change archived)`);let s=a.phase,c=xv(n,s,`${M(t,o.openSpecRoot)}/`);if(c)return be(c);if(zu(n,Gu(t,o))){if(a.superpowersArtifact==="matched"&&Ku(a))return be(`${n} (phase: ${s}, superpowers)`);if(a.superpowersArtifact==="unmatched")return Tv(n,a)}if(a.invalidState)return ie(2,`[COMET-HOOK] blocked: active Classic state is invalid; repair .comet.yaml before writing ${n}`);if(s==="build"&&a.classic?.workflow==="full"&&!a.classic.designDoc)return _v(n);if(s==="build"&&a.classic?.workflow==="full"){let l=await qu(t,a.classic.plan);if(l.status!=="ready")return Av(n,a,l,t,o)}return s==="build"||s==="verify"?be(`${n} (phase: ${s})`):Rv(n,s)}async function Ju(t,e,i,r={}){if(i.intent!=="non-write")try{await Vr(t)}catch(a){return{allowed:!1,reason:a instanceof Error?a.message:String(a),workflow:"classic",change:e}}let n;try{n=await Ri(t)}catch(a){return{allowed:!1,reason:a instanceof Error?a.message:String(a),workflow:"classic",change:e}}let o=n.find(a=>re(a)===e);if(!o)return{allowed:!1,reason:`Selected Classic change ${e} is missing or archived; resume /comet-classic before retrying`,workflow:"classic",change:e};if(i.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(i.intent==="unknown"||i.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"classic",change:e,phase:o.phase};for(let a of i.targets){let s=await Iv(t,a,e,r.scopeTargets);if(s.exitCode!==0)return{allowed:!1,reason:s.stderr?.trim()||"Classic phase guard blocked the write",workflow:"classic",change:e,phase:o.phase}}return{allowed:!0,reason:`Classic write allowed in ${o.phase}`,workflow:"classic",change:e,phase:o.phase}}import{promises as lb}from"fs";import Pt from"path";var za=xt(mt(),1);import{promises as qy}from"fs";import et from"path";import{createHash as Dv}from"node:crypto";import{promises as ne}from"node:fs";import U from"node:path";import{TextDecoder as Bv}from"node:util";var jv=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Lv=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function $v(t){return t.toLowerCase().startsWith(".env")}function La(t){let i=t.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>$v(r))?"environment-file":i.some(r=>Lv.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>jv.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}fi();var Mv=1024*1024;function $a(t,e){let i=U.relative(t,e);return i===""||!U.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${U.sep}`)}function Fv(t){let e=U.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(n=>{let o=n.codePointAt(0)??0;return o<=31||o===127})||U.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let i=t.toLowerCase(),r=La(t);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${t}`);return t}function Wv(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function qv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function an(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return fe(i,r)?T(i,r):T(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Uu(t){let e=await ne.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await ne.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Hv(t,e){let i=U.resolve(t),r=U.resolve(e);if(!$a(i,r))throw new Error("Native artifact path is outside its root");let n=[await Uu(i)],o=i;for(let a of U.relative(i,r).split(U.sep).filter(Boolean)){o=U.join(o,a);let s=await Uu(o);if(!$a(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${o}`);n.push(s)}return n}async function Yu(t){for(let e of t){let i=await ne.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!qv(e,i)||await ne.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function sn(t){let e=Fv(t.ref),i=Wv(t.maxBytes??Mv),r=U.resolve(t.root,...e.split("/")),n=await Hv(t.root,U.dirname(r));await t.hooks?.afterParentChainCaptured?.();let o=await ne.lstat(r);if(!o.isFile()||o.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(o.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);let a=await ne.realpath(r);if(!$a(n[0].realPath,a))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await ne.open(r,"r");try{let[c,l,f]=await Promise.all([s.stat(),ne.lstat(r),ne.realpath(r)]);if(await Yu(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||f!==a||!an(o,c)||!an(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let u=[],d=0,m=Buffer.allocUnsafe(Math.min(64*1024,i+1));for(;;){let k=i+1-d,S=await s.read(m,0,Math.min(m.length,k),null);if(S.bytesRead===0)break;if(d+=S.bytesRead,d>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);u.push(Buffer.from(m.subarray(0,S.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[w,h,p]=await Promise.all([s.stat(),ne.lstat(r),ne.realpath(r)]);if(await Yu(n),!h.isFile()||h.isSymbolicLink()||p!==a||!an(c,w)||!an(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let y=Buffer.concat(u,d),b;try{b=new Bv("utf-8",{fatal:!0}).decode(y)}catch(k){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:k})}return{ref:e,size:d,hash:Dv("sha256").update(y).digest("hex"),text:b}}finally{await s.close()}}ue();He();zr();var cn=$r;async function ln(t){let e=(await qe(t))?.config??null;return e?.native?e:null}import{AsyncLocalStorage as Gv}from"async_hooks";Mr();var nC=16*1024;var oC=new Gv;import{TextDecoder as Zv}from"util";import{createHash as zv}from"node:crypto";import{constants as un,promises as oe}from"node:fs";import ae from"node:path";import{TextDecoder as Vv}from"node:util";function dn(t,e){let i=ae.relative(t,e);return i===""||!ae.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ae.sep}`)}function Kv(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function Jv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Uv(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function fn(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Ba(t,e){let i=await oe.lstat(t);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await oe.realpath(t),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function Yv(t,e,i){let r=ae.resolve(t),n=ae.resolve(e);if(!dn(r,n))throw new Error(`${i} is outside its managed root`);let o=[await Ba(r,i)],a=r;for(let s of ae.relative(r,n).split(ae.sep).filter(Boolean)){await Ue(o,i),a=ae.join(a,s);let c=await Ba(a,i);if(!dn(o[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${a}`);o.push(c)}return await Ue(o,i),o}async function Ue(t,e){for(let i of t){let r=await oe.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!Jv(i,r)||await oe.realpath(i.path)!==i.realPath)throw new Error(`${e} parent changed during I/O: ${i.path}`)}}async function Xv(t,e,i){let r=[],n=0,o=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let a=e+1-n,{bytesRead:s}=await t.read(o,0,Math.min(o.length,a),null);if(s===0)break;if(n+=s,n>e)throw new Error(`${i} exceeds ${e} bytes`);r.push(Buffer.from(o.subarray(0,s)))}return Buffer.concat(r,n)}async function Xu(t){let e=Kv(t.maxBytes),i=ae.resolve(t.file),r=await Yv(t.root,ae.dirname(i),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(f=>Ba(ae.resolve(f),t.label)));await t.hooks?.afterParentChainCaptured?.(),await Ue(r,t.label);let o=await oe.lstat(i);if(!o.isFile()||o.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(o.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let a=Uv(o),s=await oe.realpath(i);if(!dn(r[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(f=>dn(f.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?un.O_RDONLY:un.O_RDONLY|un.O_NOFOLLOW|un.O_NONBLOCK,l=await oe.open(i,c);try{let f=await l.stat();await t.hooks?.afterOpen?.();let[u,d]=await Promise.all([oe.lstat(i),oe.realpath(i)]);if(await Ue(r,t.label),await Ue(n,t.label),!f.isFile()||!u.isFile()||u.isSymbolicLink()||d!==s||!fn(a,f)||!fn(a,u))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let m=await Xv(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[w,h,p]=await Promise.all([l.stat(),oe.lstat(i),oe.realpath(i)]);if(await Ue(r,t.label),await Ue(n,t.label),!h.isFile()||h.isSymbolicLink()||p!==s||!fn(a,w)||!fn(a,h))throw new Error(`${t.label} changed while reading`);return{bytes:m,hash:zv("sha256").update(m).digest("hex"),size:m.length}}finally{await l.close()}}async function Qu(t){let e=await Xu(t),i;try{i=new Vv("utf-8",{fatal:!0}).decode(e.bytes)}catch(r){throw new Error(`${t.label} is not valid UTF-8`,{cause:r})}return{...e,text:i}}var SC=256*1024,EC=1024*1024,CC=16*1024;var PC=64*1024*1024;var xC=new Zv("utf-8",{fatal:!0});import mn from"path";import{createHash as ey}from"crypto";function tf(t){return ey("sha256").update(t).digest("hex")}var JC={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},iy=1e3,ry=8*1024*1024,ny=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,oy=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),ay=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),sy=new Set(["schema","include","exclude","hash"]),cy=new Set(["provider","gitSelection","physicalSelection","projection"]),ly=new Set(["provider","selection"]),uy=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),fy=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),dy=new Set(["schema","status","before","after"]),hy=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),my=new Set(["path","hash","size","type","gitObjectId"]),py=new Set(["path","size","type","reason"]),gy=new Set(["ref","hash","count"]),wy=new Set(["change-created","legacy-migration","explicit"]),vy=new Set(["file","directory","other"]),yy=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),pn=/^[a-f0-9]{64}$/u,by=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var UC=64*1024,YC=64*1024;var XC={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},QC={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function hn(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var ZC=(1n<<256n)-1n;function Ny(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function ky(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
|
|
156
|
+
`)}function Sy(t,e){return tf(`comet.native.snapshot-policy.v1
|
|
157
|
+
${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function Ma(t,e,i){let r=new Set(e),n=[...e];for(;n.length>0;){if(i&&!i())return null;let o=n.pop(),a=t[o];a&&(a.kind==="star"||a.kind==="globstar"||a.kind==="globstar-slash")&&!r.has(o+1)&&(r.add(o+1),n.push(o+1))}return r}function Ey(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function rf(t){let e=cn(t,"Native snapshot pattern"),i=[];for(let r=0;r<e.length;r+=1){let n=e[r];n==="*"&&e[r+1]==="*"?(r+=1,e[r+1]==="/"?(r+=1,i.push({kind:"globstar-slash"})):i.push({kind:"globstar"})):n==="*"?i.push({kind:"star"}):n==="?"?i.push({kind:"question"}):i.push({kind:"literal",value:n})}return(r,n)=>{let o=n?Ey(n):void 0;if(o&&!o())return!1;let a=Ma(i,new Set([0]),o);if(a===null)return!1;for(let s of r){if(o&&!o())return!1;let c=new Set;for(let l of a){if(o&&!o())return!1;let f=i[l];f&&(f.kind==="literal"&&f.value===s||f.kind==="question"&&s!=="/"?c.add(l+1):f.kind==="star"&&s!=="/"||f.kind==="globstar"?c.add(l):f.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(a=Ma(i,c,o),a===null||a.size===0)return!1}return Ma(i,a,o)?.has(i.length)??!1}}function Cy(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>cn(n,"include")))].sort((n,o)=>n.localeCompare(o,"en")),i=[...new Set(t.exclude.map(n=>cn(n,"exclude")))].sort((n,o)=>n.localeCompare(o,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let r=Sy(e,i);if("hash"in t&&t.hash!==r)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:i,hash:r},includeMatchers:e.map(rf),excludeMatchers:i.map(rf),excludedDirectoryPrefixes:i.flatMap(n=>{if(!n.endsWith("/**"))return[];let o=n.slice(0,-3);return/[*?]/u.test(o)?[]:[o]}).sort((n,o)=>n.localeCompare(o,"en"))}}function Y(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function X(t,e,i){let r=Object.keys(t).find(n=>!e.has(n));if(r)throw new Error(`${i} contains unknown field: ${r}`)}function Et(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function de(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function af(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let i=mn.posix.normalize(t);if(i!==t||mn.posix.isAbsolute(t)||i===".."||i.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function Py(t,e){let i=Y(t,`Native snapshot entry ${e}`);X(i,my,`Native snapshot entry ${e}`);let r=af(i.path,`Native snapshot entry ${e} path`);if(typeof i.hash!="string"||!pn.test(i.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(i.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:r,hash:i.hash,size:de(i.size,`Native snapshot entry ${e} size`),type:"file"};if(i.gitObjectId!==void 0){if(typeof i.gitObjectId!="string"||!by.test(i.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=i.gitObjectId}return n}function xy(t,e){let i=Y(t,`Native snapshot omission ${e}`);if(X(i,py,`Native snapshot omission ${e}`),!vy.has(i.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!yy.has(i.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:af(i.path,`Native snapshot omission ${e} path`),size:i.size===null?null:de(i.size,`Native snapshot omission ${e} size`),type:i.type,reason:i.reason}}function Ry(t){let e=Y(t,"Native snapshot omission overflow");if(X(e,gy,"Native snapshot omission overflow"),typeof e.hash!="string"||!pn.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let i=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==i)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:i,hash:e.hash,count:Et(e.count,"Native snapshot omission overflow count")}}function St(t,e){let i=Y(t,e);if(X(i,fy,e),typeof i.hash!="string"||!pn.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let r=de(i.recordCount,`${e} recordCount`),n=de(i.storedRecordCount,`${e} storedRecordCount`),o=de(i.stdoutBytes,`${e} stdoutBytes`);if(n>r||!i.overflow&&n!==r)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,recordCount:r,storedRecordCount:n,stdoutBytes:o,overflow:i.overflow}}function nf(t){let e=Y(t,"Native Git selection evidence");if(X(e,uy,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let i=St(e.stageBefore,"Native Git selection stageBefore"),r=St(e.combined,"Native Git selection combined"),n=St(e.stageAfter,"Native Git selection stageAfter"),o=St(e.finalStageBefore,"Native Git selection finalStageBefore"),a=St(e.finalCombined,"Native Git selection finalCombined"),s=St(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[i,r,n,o,a,s].some(u=>u.overflow),l=!hn(i,n)||!hn(n,o)||!hn(r,a)||!hn(o,s),f=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==f)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:f,stageBefore:i,combined:r,stageAfter:n,finalStageBefore:o,finalCombined:a,finalStageAfter:s}}function of(t,e){let i=Y(t,e);if(X(i,hy,e),typeof i.hash!="string"||!pn.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean"||typeof i.unstable!="boolean")throw new Error(`${e} flags are invalid`);let r=de(i.visitedNodeCount,`${e} visitedNodeCount`),n=de(i.recordCount,`${e} recordCount`),o=de(i.storedRecordCount,`${e} storedRecordCount`),a=de(i.encodedBytes,`${e} encodedBytes`);if(o>n||!i.overflow&&o!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,visitedNodeCount:r,recordCount:n,storedRecordCount:o,encodedBytes:a,overflow:i.overflow,unstable:i.unstable}}function _y(t){let e=Y(t,"Native physical selection evidence");if(X(e,dy,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let i=of(e.before,"Native physical selection before"),r=of(e.after,"Native physical selection after"),n=i.overflow||r.overflow,o=i.unstable||r.unstable||!Ny(i,r);if(!n&&!o)throw new Error("Native physical selection evidence must describe an exceptional selection");let a=n&&o?"overflow-and-changed":n?"overflow":"changed";if(e.status!==a)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:a,before:i,after:r}}function Ay(t){let e=Y(t,"Native content snapshot manifest");if(X(e,oy,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!wy.has(e.origin))throw new Error("Native content snapshot origin is invalid");let i;if(e.capture!==void 0){let g=Y(e.capture,"Native content snapshot capture");if(X(g,cy,"Native content snapshot capture"),g.provider!=="git"&&g.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let P=g.gitSelection===void 0?void 0:nf(g.gitSelection),N=g.physicalSelection===void 0?void 0:_y(g.physicalSelection),_=null;if(g.projection!==void 0){let H=Y(g.projection,"Native content snapshot projection");if(X(H,ly,"Native content snapshot projection"),H.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");_={provider:"git",...H.selection===void 0?{}:{selection:nf(H.selection)}}}if(g.provider==="git"){if(N||_)throw new Error("Native Git capture cannot include physical or projection evidence");i={provider:"git",...P?{gitSelection:P}:{}}}else{if(P)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(N&&_)throw new Error("Native physical-tree capture cannot combine selection and projection");i=_?{provider:"physical-tree",projection:_}:{provider:"physical-tree",...N?{physicalSelection:N}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let r=Y(e.limits,"Native content snapshot limits");X(r,ay,"Native content snapshot limits");let n={maxFiles:Et(r.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Et(r.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Et(r.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Et(r.maxManifestBytes,"Native snapshot maxManifestBytes"),...r.maxDurationMs===void 0?{}:{maxDurationMs:Et(r.maxDurationMs,"Native snapshot maxDurationMs")}},o;if(e.policy!==void 0){let g=Y(e.policy,"Native snapshot policy");if(X(g,sy,"Native snapshot policy"),g.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(g.include)||!Array.isArray(g.exclude))throw new Error("Native snapshot policy patterns must be arrays");o=Cy({include:g.include,exclude:g.exclude,hash:g.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let a=e.entries.map(Py),s=e.omitted.map(xy),c=de(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:Ry(e.omissionOverflow);if(a.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(a.some(g=>g.size>n.maxFileBytes)||a.reduce((g,P)=>g+P.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(a.map(g=>g.path)).size!==a.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>iy||c<s.length)throw new Error("Native content snapshot omission count is invalid");let f=c-s.length;if(f===0&&l||f>0&&l?.count!==f)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let u=s.filter(g=>g.reason==="git-enumeration-limit"),d=s.filter(g=>g.reason==="git-selection-changed");for(let g of[...u,...d])if(g.path!=="."||g.size!==null||g.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(u.length>1||d.length>1)throw new Error("Native Git selection omissions must not be duplicated");let m=i?.provider==="git"?i.gitSelection:i?.projection?.selection,w=m?.status==="overflow"||m?.status==="overflow-and-changed",h=m?.status==="changed"||m?.status==="overflow-and-changed";if(w!==(u.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(h!==(d.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let p=s.filter(g=>g.reason==="physical-enumeration-limit"),y=s.filter(g=>g.reason==="physical-selection-changed");for(let g of[...p,...y])if(g.path!=="."||g.size!==null||g.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(p.length>1||y.length>1)throw new Error("Native physical selection omissions must not be duplicated");let b=i?.physicalSelection,k=b?.status==="overflow"||b?.status==="overflow-and-changed",S=b?.status==="changed"||b?.status==="overflow-and-changed";if(k!==(p.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(S!==(y.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");let E={schema:"comet.native.content-snapshot.v1",origin:e.origin,...i?{capture:i}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...o?{policy:o}:{},entries:a,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}};if(ky(E)>n.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function Ty(t,e){if(!ny.test(e))throw new Error(`Invalid Native change name: ${e}`);let i=mn.join(t.changesDir,e);if(!vt(t.changesDir,i))throw new Error("Native change path escaped");return mn.join(i,"runtime","baseline-manifest.json")}async function sf(t,e){let i=Ty(t,e);await pe(t.nativeRoot,i);try{let r=await Qu({root:t.nativeRoot,file:i,maxBytes:ry,label:"Native baseline snapshot manifest"});return Ay(JSON.parse(r.text))}catch(r){if(r.code==="ENOENT")return null;throw r}}Ei();var dP={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};import{createHash as Ly}from"node:crypto";import{promises as gn}from"node:fs";import je from"node:path";import{execFileSync as Iy}from"child_process";import Ai from"path";function _i(t,e){return Iy("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function jy(t,e){let i=Ai.normalize(t),r=Ai.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function cf(t){try{let e=Ai.resolve(_i(t,["rev-parse","--show-toplevel"])),r=_i(t,["worktree","list","--porcelain","-z"]).split("\0").find(a=>a.startsWith("worktree ")),n=r?Ai.resolve(r.slice(9)):e,o=null;try{o=_i(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!jy(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:o}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function lf(t){try{_i(t,["rev-parse","--is-inside-work-tree"])}catch{return[]}return _i(t,["worktree","list","--porcelain","-z"]).split("\0").filter(i=>i.startsWith("worktree ")).map(i=>Ai.resolve(i.slice(9)))}var Ti=/^[a-f0-9]{64}$/u,$y=16*1024,Wa=process.platform;function hf(t,e){let i=je.relative(t,e);return je.isAbsolute(i)||i===".."||i.startsWith(`..${je.sep}`)?null:i.replaceAll("\\","/")||"."}function mf(t){return Array.from(t).some(e=>{let i=e.codePointAt(0)??0;return i<=31||i===127})}function pf(t,e){if(t.length===0||mf(t)||t.includes("\\")||je.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let i=je.posix.normalize(t);if(i!==t||i===".."||i.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return i}function qa(t,e){return Ly("sha256").update(`${t}
|
|
158
|
+
${e}`).digest("hex")}async function uf(t,e){let i=await gn.realpath(e),r=await gn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=Wa==="win32"?je.normalize(i).toLowerCase():i;return qa(t,`${n}
|
|
159
|
+
${r.dev}
|
|
160
|
+
${r.ino}
|
|
161
|
+
${r.birthtimeMs}`)}async function ff(t,e){let i=await gn.realpath(e),r=await gn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=Wa==="win32"?je.normalize(i).toLowerCase():i;return qa(t,n)}function Dy(t){if(typeof t!="string")throw new Error("Native workspace capturedAt is invalid");let e=new Date(t);if(!Number.isFinite(e.getTime())||e.toISOString()!==t)throw new Error("Native workspace capturedAt is invalid");return t}function df(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||mf(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function gf(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(df(t.changeBranch,"Native workspace change branch"),df(t.targetBranch,"Native workspace target branch"),(t.isolation==="branch"||t.isolation==="worktree")&&(t.changeBranch===null||t.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function wn(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(e).filter(a=>!i.has(a));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.join(", ")}`);if(e.schema!=="comet.native.workspace.v2"&&e.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(e.capturedRevision)||e.capturedRevision<1||typeof e.nativeRootRef!="string"||!Ti.test(String(e.projectRootId))||!Ti.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");Dy(e.capturedAt),pf(e.nativeRootRef,"Native workspace root ref");let n=e.projectRootPathId!==void 0,o=e.nativeRootPathId!==void 0;if(n!==o)throw new Error("Native workspace path identities must be provided together");if(n&&!Ti.test(String(e.projectRootPathId))||o&&!Ti.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!Ti.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.schema==="comet.native.workspace.v2"){if(e.isolation!==void 0||e.changeBranch!==void 0||e.targetBranch!==void 0||e.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof e.isolation!="string"||e.changeBranch===void 0||e.targetBranch===void 0||e.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(gf(e),e.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(e.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function By(t,e){return je.join(t.changesDir,e,"runtime","workspace.json")}function My(t,e){let i=hf(t.nativeRoot,By(t,e));if(!i||i===".")throw new Error("Native workspace file escaped its root");return pf(i,"Native workspace file ref")}async function Fy(t,e){try{let i=await sn({root:t.nativeRoot,ref:My(t,e),maxBytes:$y});return JSON.parse(i.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Wy(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=hf(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let[i,r,n,o]=await Promise.all([uf("comet.native.workspace-project-root.v2",t.paths.projectRoot),uf("comet.native.workspace-native-root.v2",t.paths.nativeRoot),ff("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),ff("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),a=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&gf(t.binding);let s={capturedAt:a,capturedRevision:t.revision,nativeRootRef:e,projectRootId:i,nativeRootId:r,projectRootPathId:n,nativeRootPathId:o,...t.sessionId?{sessionHash:qa("comet.native.workspace-session.v2",`${i}
|
|
162
|
+
${r}
|
|
163
|
+
${t.sessionId}`)}:{}},c=t.binding?{schema:"comet.native.workspace.v3",...s,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...s};return wn(c),c}async function wf(t,e){let i=await Fy(t,e);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(wn(i),i)}async function vf(t){wn(t.identity);let e=await Wy({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),i=[],r=[];return e.nativeRootRef!==t.identity.nativeRootRef&&i.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&i.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&i.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&i.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&i.push("native-root-legacy-identity")),Wa==="win32"&&i.length>0&&i.every(o=>o==="project-root-legacy-identity"||o==="native-root-legacy-identity")?r.push("workspace-inspection-unavailable"):i.length>0&&r.push("workspace-root-changed"),{state:r.length===0?"aligned":r.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:r,driftComponents:i}}async function yf(t){if(wn(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await vf(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let i=cf(t.paths.projectRoot);return t.identity.changeBranch===null?i.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:i.isGitWorktree?i.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${i.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!i.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}async function bf(t,e){let i=await wf(t,e);if(i===null)return null;let r=await yf({paths:t,identity:i});if(r.state==="drifted")throw new Error(`${r.code}: ${r.message}`);return i}var Ye="comet.native.v3",Xe="comet.native.v2",Qe="comet.native.v1";var Nf=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],Hy=new Set(Nf),kf=new Set([...Nf,"minimum_runtime_version","revision"]),Gy=new Set([...kf,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),zy=new Set(["capability","operation","source","base_hash"]),Vy=new Set(["shape","build","verify","archive"]),Ky=new Set(["implicit","confirmed"]),Jy=new Set(["pending","pass","fail"]),Ct="comet-state.yaml",Ga=/^[a-f0-9]{64}$/u,Sf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Uy=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,vn=class extends Error{constructor(i,r){super(`Native change ${i} uses ${r}; run comet native doctor ${i} --repair before mutating it`);this.change=i;this.schema=r;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},tt=class extends Error{constructor(i,r){super(i!==Ye||r===null?`Unsupported Native change schema ${i} for runtime protocol ${3}`:`Native change ${i} requires runtime protocol ${r}; current protocol is ${3}`);this.schema=i;this.minimumRuntimeVersion=r;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"};var ix=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
|
|
164
|
+
`);function Ii(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ef(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function yn(t){if(!Sf.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Yy(t){if(!Sf.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Cf(t,e){if(t.length===0||et.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function Xy(t,e){let i=Ii(t,`spec_changes[${e}]`);if(Ef(i,zy,`spec_changes[${e}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(Yy(i.capability),i.operation!=="create"&&i.operation!=="replace"&&i.operation!=="remove")throw new Error(`Invalid spec operation for ${i.capability}`);let r=i.source,n=i.base_hash;if(r!==void 0&&typeof r!="string")throw new Error(`Spec source for ${i.capability} must be a string`);if(typeof r=="string"&&Cf(r,`Spec source for ${i.capability}`),i.operation==="create"){if(!r)throw new Error(`Create spec ${i.capability} requires source`);if(n!==null)throw new Error(`Create spec ${i.capability} requires null base_hash`)}else if(i.operation==="replace"){if(!r)throw new Error(`Replace spec ${i.capability} requires source`);if(typeof n!="string"||!Ga.test(n))throw new Error(`Replace spec ${i.capability} requires a SHA-256 base_hash`)}else{if(r!==void 0)throw new Error(`Remove spec ${i.capability} forbids source`);if(typeof n!="string"||!Ga.test(n))throw new Error(`Remove spec ${i.capability} requires a SHA-256 base_hash`)}return{capability:i.capability,operation:i.operation,...typeof r=="string"?{source:r}:{},base_hash:n}}function Qy(t){return/^\d{4}-\d{2}-\d{2}$/u.test(t)?new Date(`${t}T00:00:00.000Z`).toISOString().slice(0,10)===t:!1}function Va(t,e){if(Ef(t,e,Ct),typeof t.name!="string")throw new Error("Native change name is required");if(yn(t.name),t.language!=="en"&&t.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof t.phase!="string"||!Vy.has(t.phase))throw new Error("Native change phase is invalid");if(t.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(t.approval!==null&&!Ky.has(t.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native spec_changes must be an array");let i=t.spec_changes.map(Xy),r=i.map(n=>n.capability).filter((n,o,a)=>a.indexOf(n)!==o);if(r.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(r)].join(", ")}`);if(typeof t.verification_result!="string"||!Jy.has(t.verification_result))throw new Error("Native verification_result is invalid");if(t.verification_report!==null&&typeof t.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof t.verification_report=="string"&&Cf(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!Qy(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:i,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function Pf(t){let e=Ii(t,Ct);if(e.schema!==Qe)throw new Error(`Expected ${Qe}`);return{schema:Qe,...Va(e,Hy)}}function Oi(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Ha(t,e,i){if(t===null)return null;let r=typeof t=="string"?Uy.exec(t):null;if(!r||r[1]!==i)throw new Error(`${e} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return t}function Zy(t){if(t==null)return null;if(typeof t!="string"||!Ga.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function eb(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function xf(t){let e=Ii(t,Ct);if(e.schema!==Xe)throw new Error(`Expected ${Xe}`);if(Oi(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Xe} minimum_runtime_version must be 2`);return{schema:Xe,minimum_runtime_version:2,revision:Oi(e.revision,"Native v2 revision"),...Va(e,kf)}}function tb(t){let e=Ii(t,Ct);if(e.schema!==Ye){if(e.schema===Qe||e.schema===Xe){let a=e.schema===Qe?Pf(e):xf(e);throw new vn(a.name,a.schema)}throw new tt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let i=Oi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new tt(e.schema,i);if(i!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let r=Oi(e.revision,"Native revision"),n=Va(e,Gy),o=Zy(e.approved_contract_hash);if(n.approval===null&&o!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Ye,minimum_runtime_version:3,revision:r,verification_protocol:eb(e.verification_protocol),...n,approved_contract_hash:o,implementation_scope:Ha(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Ha(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Ha(e.partial_allowance,"Native partial_allowance","allowances")}}function ib(t){let e=Ii(t,Ct);if(e.schema===Qe){let n=Pf(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Ye}`}}if(e.schema===Xe){let n=xf(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Ye}`}}if(e.schema!==Ye){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new tt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let i=Oi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:i,state:null,message:new tt(e.schema,i).message};let r=tb(e);return{status:"current",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r}}function Rf(t,e){yn(e);let i=et.join(t.changesDir,e);if(!vt(t.changesDir,i))throw new Error("Native change path escaped");return i}async function rb(t,e){let i=et.join(Rf(t,e),"runtime","schema-migration.json");await pe(t.nativeRoot,i);try{return await qy.lstat(i),!0}catch(r){if(r.code==="ENOENT")return!1;throw r}}var nb=256*1024;async function ob(t,e=et.dirname(t)){let i=et.relative(e,t).split(et.sep).join("/"),r=await sn({root:e,ref:i,maxBytes:nb}),n=(0,za.parseDocument)(r.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${t}: ${n.errors[0].message}`);return n.toJS()}async function ab(t,e){let i=et.join(Rf(t,e),Ct);await pe(t.nativeRoot,i);let r=ib(await ob(i,t.nativeRoot));if(r.state&&r.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await rb(t,e)?{status:"migration-required",schema:r.schema,minimumRuntimeVersion:r.minimumRuntimeVersion,state:r.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(r.status==="current"&&r.state&&await sb(t,r.state),r)}async function sb(t,e){if(await sf(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function bn(t,e){let i=await ab(t,e);if(i.status==="migration-required")throw new vn(e,i.schema);if(i.status==="runtime-incompatible"||!i.state)throw new tt(i.schema,i.minimumRuntimeVersion);return await bf(t,e),i.state}var cx=16*1024;async function cb(t){let e=await Nt(t.projectRoot);return e.status==="missing"||e.selection.workflow!=="native"?null:(yn(e.selection.change),e.selection)}async function _f(t){let e=await cb(t);return e?(await bn(t,e.change),e.change):null}function Nn(t,e){let i=Pt.relative(t,e);return i===""||!i.startsWith("..")&&!Pt.isAbsolute(i)}function ub(t,e,i){return i.targets.length>0&&i.targets.every(r=>{let n=Pt.resolve(t,r);return Nn(t,n)?Pt.relative(t,n).replaceAll("\\","/")===".comet/config.yaml"||Nn(e,n):!0})}async function fb(t){let e=await ln(t);if(!e||!(e.workflows??[e.default_workflow]).includes("native"))return null;let i=await la(t,e.native.artifact_root),r;try{r=await lb.readdir(i.changesDir,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return{paths:i,changes:[]};throw o}let n=[];for(let o of r.sort((a,s)=>a.name.localeCompare(s.name))){if(!o.isDirectory()||o.isSymbolicLink())continue;let a=await bn(i,o.name);a.archived||n.push(a)}return{paths:i,changes:n}}var Af=K("nativeActiveContext",t=>fb(t));async function Tf(t){return((await Af(t))?.changes??[]).map(i=>({workflow:"native",name:i.name,phase:i.phase}))}async function Of(t,e,i){let r=await Af(t);if(!r)return{allowed:!0,reason:"Native workflow is not enabled"};if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(r.changes.length===0)return{allowed:!0,reason:ub(t,r.paths.nativeRoot,e)?"Native control artifact write":"No Native changes exist"};let n;if(i){if(n=r.changes.find(s=>s.name===i),!n)return{allowed:!1,reason:`Selected Native change ${i} is missing or archived; resume /comet-native before retrying`,workflow:"native",change:i}}else if(r.changes.length===1)n=r.changes[0];else{let s=await _f(r.paths);if(n=r.changes.find(c=>c.name===s),!n)return{allowed:!1,reason:"Multiple Native changes are active; select the change to resume before writing code",workflow:"native"}}if(n.phase==="build")return{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:n.phase,change:n.name};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"native",phase:n.phase,change:n.name};let o=!1,a=!1;for(let s of e.targets){let c=Pt.resolve(t,s);if(!Nn(t,c)){a=!0;continue}if(Pt.relative(t,c).replaceAll("\\","/")===".comet/config.yaml"||Nn(r.paths.nativeRoot,c)){o=!0;continue}return{allowed:!1,reason:`Native change ${n.name} is in ${n.phase}; implementation writes are only allowed in build. Resume /comet-native to continue safely`,workflow:"native",phase:n.phase,change:n.name}}return{allowed:!0,reason:o?"Native control artifact write":a?"Write target is outside the guarded project":"No guarded write target was provided",workflow:"native",phase:n.phase,change:n.name}}He();var If=K("readWorkflowProjectConfig",t=>da(t)),kx=K("discoverNativeProject",t=>li(t));var db=K("readCometCurrentSelection",t=>Nt(t)),$f={listNative:Tf,listClassic:Hu,inspectNative:Of,inspectClassic:Ju};function hb(t){return t?t.workflows??[t.default_workflow]:["classic"]}async function jf(t,e,i,r,n={}){let o=async()=>{if(!e.includes("classic"))return[];if(r?.workflow==="classic")return r.candidates;try{return await i.listClassic(t)}catch(c){if(n.tolerateUnavailableClassic&&c instanceof ze)return[];throw c}},[a,s]=await Promise.all([e.includes("native")?r?.workflow==="native"?r.candidates:i.listNative(t):[],o()]);return[...a,...s]}function Lf(t,e){return t.length===0?{status:"none",staleSelection:e}:t.length===1?{status:"inferred",owner:t[0],staleSelection:e}:{status:"ambiguous",candidates:t,staleSelection:e}}async function mb(t,e=$f){let i=await If(t),r=hb(i),n;try{n=await db(t)}catch(o){return{status:"stale",code:"selection-unreadable",reason:o instanceof Error?o.message:String(o)}}if(n.status==="selected"){let o=n.selection;if(!r.includes(o.workflow))return{status:"stale",code:"workflow-disabled",reason:`selected workflow '${o.workflow}' is not enabled for this project`};let a;try{a=o.workflow==="native"?await e.listNative(t):await e.listClassic(t)}catch(c){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${c instanceof Error?c.message:String(c)}`}}let s=a.find(c=>c.name===o.change);if(!s){let c={code:"target-missing",reason:`selected ${o.workflow} change '${o.change}' is missing or archived`};try{let l=await jf(t,r,e,{workflow:o.workflow,candidates:a});return Lf(l,c)}catch(l){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${l instanceof Error?l.message:String(l)}`}}}if(o.workflow==="classic"){let c=await nn(t);if(c.status!=="selected")return{status:"stale",code:"classic-selection-invalid",reason:c.status==="stale"?c.reason:`selected Classic change '${o.change}' is no longer active`}}return{status:"owned",owner:s}}try{let o=await jf(t,r,e,void 0,{tolerateUnavailableClassic:!0});return Lf(o)}catch(o){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${o instanceof Error?o.message:String(o)}`}}}async function Df(t,e,i=$f){if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target is outside Comet attribution"};let r;try{let n=await(i.scopeTargets??Kr)(t,e.targets);if(n.projectTargets.length===0)return{allowed:!0,reason:"Write targets are outside the guarded project"};r={...e,targets:n.projectTargets}}catch(n){return{allowed:!1,reason:["Comet Hook Router scope could not be determined safely.",`Reason: ${n instanceof Error?n.message:String(n)}`,"Next: verify that the project root is accessible, then retry the write."].join(" ")}}try{let n=await mb(t,i);if(n.status==="none")return{allowed:!0,reason:"No active Comet change"};if(n.status==="stale")return{allowed:!1,reason:`${n.reason}. Resume /comet-native or /comet-classic and select the current change before retrying`};if(n.status==="ambiguous")return{allowed:!1,reason:`Multiple active Comet changes require one current selection: ${n.candidates.map(a=>`${a.workflow}:${a.name}`).join(", ")}`};let o=n.owner;return o.workflow==="native"?i.inspectNative(t,r,o.name):i.inspectClassic(t,o.name,r)}catch(n){return{allowed:!1,reason:`Comet Hook Router failed closed: ${n instanceof Error?n.message:String(n)}`}}}import{promises as pb}from"fs";import Q from"path";function gb(t,e){let i=Q.resolve(t),r=Q.resolve(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function wb(t,e){let i=Q.relative(t,e);return i===""||i!==".."&&!i.startsWith(`..${Q.sep}`)&&!Q.isAbsolute(i)}function Bf(t,e){return[...e].sort((i,r)=>r.length-i.length).find(i=>wb(i,t))??null}async function vb(t){for(let e of[".git",Q.join(".comet","config.yaml")])try{await pb.lstat(Q.join(t,e))}catch(i){throw i.code!=="ENOENT"?i:new Error(`linked worktree ${t} is not initialized for Comet: missing ${e.replaceAll("\\","/")}`,{cause:i})}}async function Mf(t,e){let i=Q.resolve(t),r=lf(i);if(r.length<2||e.targets.length===0)return i;let o=(e.cwd?Bf(Q.resolve(e.cwd),r):null)??i,a=new Map;for(let c of e.targets){let l=Q.isAbsolute(c)?Q.resolve(c):Q.resolve(o,c),f=Bf(l,r);if(!f)continue;let u=process.platform==="win32"?f.toLowerCase():f;a.set(u,f)}if(a.size===0)return i;if(a.size>1)throw new Error("one Hook request cannot write across multiple Git worktrees");let[s]=a.values();return gb(s,i)||await vb(s),s}var yb="Usage: comet-hook-router --platform <platform-id> [--project-root <project-root>]";function bb(t){let e,i;for(let r=0;r<t.length;r++){let n=t[r];if(n==="--platform"){e=t[++r];continue}if(n==="--project-root"){i=t[++r];continue}throw new Error(`Unknown argument: ${n}`)}if(!e||e.startsWith("--"))throw new Error("--platform is required");if(!va.has(e))throw new Error(`unsupported Hook platform: ${e}`);if(i?.startsWith("--"))throw new Error("--project-root requires a value");return{platformId:e,...i?{projectRoot:Wf.resolve(i)}:{}}}async function Nb(t,e){if(t.projectRoot)return e?Mf(t.projectRoot,e):t.projectRoot;let i=await li(process.cwd());for(let o of[[".comet","config.yaml"],[".git"]])try{return await Ff.lstat(Wf.join(i,...o)),i}catch(a){if(a.code!=="ENOENT")throw a}let r=await Xl(process.cwd()),n=await ye(r);try{return await Ff.lstat(n.changesDir),r}catch(o){if(o.code!=="ENOENT")throw o}return null}async function kb(t){let e;try{e=bb(t)}catch(n){return process.stderr.write(`${n instanceof Error?n.message:String(n)}
|
|
165
|
+
${yb}
|
|
166
|
+
`),64}let i;try{let n=ba(),o=await Nb(e,n);i=o?await nu(()=>Df(o,n)):{allowed:!0,reason:"No Comet project discovered"}}catch(n){i={allowed:!1,reason:`Comet Hook Router failed closed during project discovery: ${n instanceof Error?n.message:String(n)}`}}let r=ru(e.platformId,i);return r.stdout&&process.stdout.write(r.stdout),r.stderr&&process.stderr.write(r.stderr),r.exitCode}process.exitCode=await kb(process.argv.slice(2));export{Nb as projectRootFrom,kb as runCometHookRouter};
|